-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lint: Disable errors for formatting handled by prettier #24635
Conversation
098f1cb
to
0da0540
Compare
// REST API objects include underscores | ||
camelcase: 0, | ||
|
||
// TODO: why did we turn this 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 think it errors because there are still chai
matchers which aren't compatible with Jest syntax. I bet the same story as with mocha
globals.
parser: 'babel-eslint', | ||
env: { | ||
browser: true, | ||
'jest/globals': true, | ||
// mocha is only still on because we have not finished porting all of our tests to jest's syntax | ||
mocha: true, |
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.
You can try to turn it off as we most likely migrated all globals to Jest.
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.
sure, different PR for that though.
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.
Excited to remove an annoyance with this 🙂
Added a comment about max-len
. If our goal here is "prettier
handles that, be silent eslint
" PR, then I'd like to remove max-len
as well.
Commented a few of the confusing parts of the diff so it's clear what rules aren't changed but have been formatted.
.eslintrc.js
Outdated
'jsx-a11y/anchor-has-content': 0, | ||
|
||
// error if any given line is over 140 characters long. | ||
// Ideally this would be even lower(120, 80?), but that's a big step. | ||
'max-len': [ 2, { code: 140 } ], |
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.
Shall we disable this as well? Prettier's functionality is based on breaking long lines.
A quick search will show lots of disabling for SVG paths or strings that aren't broken.
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.
Would remove 98 lint errors according to #24504 (comment) and allow for removal of ~69 {en,dis}able comments
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.
sounds good to me. I'll rename this PR.
} ], | ||
|
||
// Allows Chai `expect` expressions. Now that we're on jest, hopefully we can remove this one. | ||
'no-unused-expressions': 0, |
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.
No change, layout and comment.
{ | ||
rootFiles: [ 'index.js', 'index.jsx', 'main.js', 'main.jsx' ], | ||
}, | ||
], |
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.
No change, layout and comment.
.eslintrc.js
Outdated
} | ||
|
||
// turn off indenting rules since we let prettier handle it | ||
indent: 0, |
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.
New rule disabling eslint indent 🎉
.eslintrc.js
Outdated
'jsx-a11y/anchor-has-content': 0, // i18n-calypso translate triggers false failures | ||
|
||
// i18n-calypso translate triggers false failures | ||
'jsx-a11y/anchor-has-content': 0, |
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.
No change, layout.
I've pushed a commit that removes the now-redundant |
8a4baa6
to
0870b52
Compare
I've rebased. There was a new indent ignore that had been added, which is now removed 🙄 |
@sirreal taking a slightly different approach here. I'm going to pull in and use https://github.com/prettier/eslint-config-prettier |
Adding the prettier eslint config has the following effect: --- before 2018-05-11 10:28:38.000000000 -0400
+++ after 2018-05-11 10:28:50.000000000 -0400
@@ -1,11 +1,9 @@
-indent: 1790
wpcalypso/jsx-classname-namespace: 844
prefer-const: 647
react/no-string-refs: 249
valid-jsdoc: 247
jsx-a11y/click-events-have-key-events: 106
jsx-a11y/no-static-element-interactions: 98
-max-len: 98
jsx-a11y/anchor-is-valid: 69
jsx-a11y/alt-text: 62
jsx-a11y/label-has-for: 41
@@ -38,14 +36,12 @@
react/no-did-mount-set-state: 3
react/no-is-mounted: 3
jsx-a11y/media-has-caption: 2
-no-multi-spaces: 2
no-var: 2
eqeqeq: 1
jsx-a11y/html-has-lang: 1
jsx-a11y/role-has-required-aria-props: 1
no-nested-ternary: 1
no-use-before-define: 1
-operator-linebreak: 1
wpcalypso/i18n-no-variables: 1
-total: 4585
+total: 2694 |
This PR is doing a lot more than that right? |
@@ -21,21 +21,20 @@ class StatsFirstView extends React.PureComponent { | |||
<div> | |||
{ this.renderIcon() } | |||
<h1>{ this.props.translate( 'See How Your Site Is Performing' ) }</h1> | |||
{ /* eslint-disable max-len */ } | |||
{ } |
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.
you can delete this { }
@@ -163,7 +163,7 @@ class DeleteSite extends Component { | |||
<ActionPanel> | |||
<ActionPanelBody> | |||
<ActionPanelFigure> | |||
{ /* eslint-disable max-len */ } | |||
{ } |
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 one too
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.
Two small changes, but after fixing those feel free to 🚢
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 cleaned up the empty braces @samouri spotted.
Looked through code, seems correct.
Smoke tested, didn't spot any errors.
Let's 🚢 !
@@ -186,7 +186,7 @@ export const regexp = memoize( function( tag ) { | |||
return new RegExp( | |||
'\\[(\\[?)(' + | |||
tag + | |||
')(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)', // eslint-disable-line max-len | |||
')(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\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.
😮 🙈
const REGEXP_ATTR_STRING = /(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/g; // eslint-disable-line max-len | ||
const REGEXP_SHORTCODE = /\[(\[?)([^\[\]\/\s\u00a0\u200b]+)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*(?:\[(?!\/\2\])[^\[]*)*)(\[\/\2\]))?)(\]?)/; // eslint-disable-line max-len | ||
const REGEXP_ATTR_STRING = /(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/g; | ||
const REGEXP_SHORTCODE = /\[(\[?)([^\[\]\/\s\u00a0\u200b]+)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*(?:\[(?!\/\2\])[^\[]*)*)(\[\/\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.
😵
Since we now use prettier to format all of our code, we can turn eslint formatting errors covered by prettier (max-len, indent...). Prettier provides a config to do just that in
eslint-format-prettier
.The only real problem we have now is ternary expressions, so we could just ignore those nodes instead.See #24504, #24571