-
Notifications
You must be signed in to change notification settings - Fork 18
Conversation
lib/rules/restrict-full-import.js
Outdated
|
||
function isRestrictedModule(mod) { | ||
return restricted.indexOf(mod) >= 0; | ||
} | ||
|
||
/* eslint-disable prettier/prettier*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint --fix
with the prettier/prettier config breaks this. It outputs invalid code. Create a reproducible issue in issue in eslint-plugin-prettier
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that this is a bug.
See prettier/eslint-config-prettier#31 & prettier/eslint-plugin-prettier#65
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of disabling prettier here, you can run eslint --fix
, manually correct the syntax error, and the eslint --fix
again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip.
I'd prefer leaving as is. I've commented a link to the issue for context.
} | ||
|
||
/* eslint-disable prettier/prettier*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, eslint --fix
with the prettier/prettier config breaks this. It outputs invalid code. Create a reproducible issue in issue in eslint-plugin-prettier
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space before the last *
69e3495
to
9308d0d
Compare
tests/.eslintrc.js
Outdated
@@ -2,5 +2,6 @@ module.exports = { | |||
extends: 'plugin:shopify/esnext', | |||
rules: { | |||
'import/no-extraneous-dependencies': 'off', | |||
'prettier/prettier': 'off', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we could extend the plugin:shopify/prettier
config and run prettier against the /tests
code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the alternative better
package.json
Outdated
@@ -18,6 +18,8 @@ | |||
"rules-status": "eslint-index lib/config/all.js --format table", | |||
"rules-omitted": "eslint-index lib/config/all.js --status omitted", | |||
"lint": "eslint . --max-warnings 0", | |||
"format": "prettier --write --single-quote --no-bracket-spacing --trailing-comma es5 './**/*.js'", | |||
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we update prettier
and/or eslint
hopefully, this can continue to list conflicting rules.
9308d0d
to
5c2baf3
Compare
package.json
Outdated
@@ -18,6 +18,7 @@ | |||
"rules-status": "eslint-index lib/config/all.js --format table", | |||
"rules-omitted": "eslint-index lib/config/all.js --status omitted", | |||
"lint": "eslint . --max-warnings 0", | |||
"prettier-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.eslintrc.js
should point to esnext
prettier
config instead.
@@ -3,9 +3,7 @@ module.exports = { | |||
jquery: true, | |||
}, | |||
|
|||
plugins: [ | |||
'shopify', | |||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes the result of running prettier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, it's within the 80 column size .
], | ||
|
||
// rules to disable to prefer prettier | ||
'shopify/binary-assignment-parens': 'off', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shopify/binary-assignment-parens
expects something like this:
const always = (config === 'always');
This will cause prettier to complain:
$ eslint . --max-warnings 0
/Users/ismailsyed/src/github.com/Shopify/eslint-plugin-shopify/lib/rules/class-property-semi.js
14:20 error Replace `(config·===·'always')` with `config·===·'always'` prettier/prettier
Unfortunately, we'll have to turn this rule off in favor of the 'prettier' experience.
No pun intended, lol.
'error', | ||
{ | ||
singleQuote: true, | ||
trailingComma: 'es5', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think we need to change this for the ESNext config — any way of making this dynamic based on other configs passed in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prettier config will disable the rule(s) regardless of the config passed in.
Extending this prettier config forces you to opt-in to the opinionated prettier experience. If a consumer wants, they can update the prettier/prettier
rules in their config.
'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: '<none|es5|all>',
bracketSpacing: false,
jsxBracketSameLine: false,
},
],
} | ||
|
||
/* eslint-disable prettier/prettier*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space before the last *
tests/.eslintrc.js
Outdated
@@ -2,5 +2,6 @@ module.exports = { | |||
extends: 'plugin:shopify/esnext', | |||
rules: { | |||
'import/no-extraneous-dependencies': 'off', | |||
'prettier/prettier': 'off', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the alternative better
'flowtype', | ||
'shopify', | ||
], | ||
plugins: ['flowtype', 'shopify'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also a config for prettier/flowtype
(in addition to one for React) — do we want those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. That work can be in a future PR. We'll have to manually find out which rules from those configs we'll need to turn off.
Comments addressed, ready for another 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a clever idea to show the effect of Prettier in this PR, but it's making it difficult to sift out what has really changed.
From my first sift through, two things that I'm not comfortable with:
- Arrays being translated to single lines based on line width
- This seems at odds with our "trailing comma makes it easier to track the originator of a change" philosophy
[{
being rewritten to have the opening brace on a new line
The second thing I'm sure I'll get over. The first seems like it should be up to the developer.
I kept all the automated |
5b14b27
to
1ed02b6
Compare
@@ -49,6 +51,7 @@ | |||
"isparta": "^4.0.0", | |||
"istanbul": "^0.4.5", | |||
"mocha": "^3.4.2", | |||
"prettier": "^1.7.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So consumers don't have to install prettier
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just worry about it needing to be aligned across repos, technically they would need to install it now in order to run the command alongside the linter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spoke offline with Chris. We're going to add prettier as an optional dependency since prettier is only required when extending the prettier config.
e5568ee
to
d0b3aa5
Compare
d0b3aa5
to
eca636a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels fine to me, I'm OK with the occasional non-ideal formatting.
plugin:shopify/prettier
.This PR also adds the following dependencies:
Ran this against core, here's a diff to get an idea of potential changes. Let me know if you see any concerns.