Closed
Bug 1432840
Opened 7 years ago
Closed 7 years ago
Switch Eslint to the AirBnb React preset (eslint-config-airbnb)
Categories
(Tree Management :: Treeherder, enhancement, P1)
Tree Management
Treeherder
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: emorley, Assigned: emorley)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Currently we're only using a small number of the eslint rules, since none are enabled by default (the `extends` config in our lint file is currently broken), so we're having to opt-in manually to each rule.
IMO opt-out rules makes much more sense than opt-in, as does using a popular style preset rather then inventing our own. As such IMO we should start using the AirBnb React preset (which Neutrino 8 now supports natively), and for now disable the parts that cause failures.
Later we can fix more of the issues and re-enable as many of the disabled rules as possible.
Splitting this out from the Neutrino 8 upgrade, to make the PRs easier to review. (Some earlier lint fixes already landed in bug 1364894 comment 11 too).
Comment 1•7 years ago
|
||
Assignee | ||
Updated•7 years ago
|
Attachment #8945150 -
Flags: review?(cdawson)
Updated•7 years ago
|
Attachment #8945150 -
Flags: review?(cdawson) → review+
Comment 2•7 years ago
|
||
Commits pushed to master at https://github.com/mozilla/treeherder
https://github.com/mozilla/treeherder/commit/13627f006b56200927b7fa027eced8a233187ca6
Bug 1432840 - Use the AirBnb React ESLint preset
Previously only 65 rules were enabled, since the `eslint:recommended`
and `plugin:react/recommended` entries in `extends` had no effect,
since when using ESLint's API rather than CLI, the options must be
passed inside the `baseConfig` property instead.
This commit corrects the usage of `extends` and switches us to AirBnb's
React ESLint preset rather than manually opting into rules:
https://github.com/airbnb/javascript
Even with the temporarily disabled rules (which can be gradually fixed
in the future), there are now over 200 ESLint rules enabled, giving
a significant increase in coverage.
Note: We're having to use v15 of `eslint-config-airbnb` rather than v16
until we update to newer Neutrino, since the latest preset has dropped
support for the ESLint v3 that comes with Neutrino 4.
https://github.com/mozilla/treeherder/commit/3ad926430866323ccb3dd72a5015fc885353435b
Bug 1432840 - Fix/enable eslint 'react/jsx-filename-extension'
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
https://github.com/mozilla/treeherder/commit/87a7f7373ff10d3c525aca5257bf83d287be6e01
Bug 1432840 - Fix/enable eslint 'jsx-quotes'
https://eslint.org/docs/rules/jsx-quotes
https://github.com/mozilla/treeherder/commit/704a84655f86661063906e86e1a9cb3f375ce37b
Bug 1432840 - Fix/enable eslint 'jsx-a11y/alt-text'
https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
https://github.com/mozilla/treeherder/commit/40c4ff5b298091ea67f0d4d365b59e63d32eed9c
Bug 1432840 - Fix/enable eslint 'react/jsx-boolean-value'
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
https://github.com/mozilla/treeherder/commit/c6fd3a6aa6b06faa3f8799de48a486218f441550
Bug 1432840 - Fix/enable eslint 'react/sort-comp'
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
https://github.com/mozilla/treeherder/commit/35ae7d6017cd6680de1c00fbbdf49695cf152cdc
Bug 1432840 - Fix/enable eslint 'react/jsx-curly-spacing'
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
https://github.com/mozilla/treeherder/commit/d85f5048398c3c7ad41b7238f4da262f6e6c6d05
Bug 1432840 - Fix/enable eslint 'react/jsx-wrap-multilines'
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
https://github.com/mozilla/treeherder/commit/50bca843a9cb1bf45e4813a94cd06baddb57a360
Bug 1432840 - Fix/enable eslint 'react/self-closing-comp'
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
https://github.com/mozilla/treeherder/commit/1ad475fdc84282131aebe0604b8c31190a87ea3a
Bug 1432840 - Fix/enable eslint 'react/jsx-tag-spacing'
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
https://github.com/mozilla/treeherder/commit/6f8d1bcf3fb63e444e0dd19354fc2167f33df045
Bug 1432840 - Fix/enable eslint 'react/jsx-closing-bracket-location'
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
https://github.com/mozilla/treeherder/commit/bc3b9579538a74024be0c4cc037a875db9539214
Bug 1432840 - Fix/enable eslint 'no-useless-return'
https://eslint.org/docs/rules/no-useless-return
https://github.com/mozilla/treeherder/commit/c58710501ee4923f0bf9e5e91546135bb1129169
Bug 1432840 - Fix/enable eslint 'no-useless-constructor'
https://eslint.org/docs/rules/no-useless-constructor
https://github.com/mozilla/treeherder/commit/0cbdc69c081924daea97cbea7d252d721630a8e0
Bug 1432840 - Fix/enable eslint 'no-restricted-properties'
https://eslint.org/docs/rules/no-restricted-properties
The AirBnB preset has configured `Math.pow` as restricted:
https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v15.1.0/README.md#es2016-properties--exponentiation-operator
Also rewrites the `ui/services/perf/math.js` to use arrow notation.
https://github.com/mozilla/treeherder/commit/6318a89b91cb65f7847c9a4a9685e3d3423746a8
Bug 1432840 - Fix/enable eslint 'import/no-named-as-default'
In `configureStore.js` the same object was being exported twice, once
as the default export and once as a named export. Since default exports
are preferred if there is only one export in a file, I've removed the
named import and left the default one.
In `Groups.jsx` the `Groups` class was exported but unused, so has
been adjusted to no longer be exported, so the `App.jsx` import
doesn't trigger the warning:
`import Groups from './Groups';`
See:
https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
https://github.com/mozilla/treeherder/commit/710b08b53aafa5540433a65f0e24895499f33a85
Bug 1432840 - Fix/enable eslint 'import/prefer-default-export'
The rule has been disabled in `constants.js`, since there will soon
be other exports in that file, so we don't want a default export.
https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
https://github.com/mozilla/treeherder/commit/2bd61a8da5846a467ed742383c5756d06feadd5b
Bug 1432840 - Fix/enable eslint 'import/first'
https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md
https://github.com/mozilla/treeherder/commit/0ebe066b173cd65ed9f6a328b791b39b62ebf796
Bug 1432840 - Fix/enable eslint 'prefer-spread'
https://eslint.org/docs/rules/prefer-spread
https://github.com/mozilla/treeherder/commit/820c6cf47cce71fd89758e173ce0ce79ffd86119
Bug 1432840 - Fix/enable eslint 'no-extra-semi'
https://eslint.org/docs/rules/no-extra-semi
https://github.com/mozilla/treeherder/commit/3327985173319b787f56670502d24005c90638a4
Bug 1432840 - Fix/enable eslint 'array-bracket-spacing'
https://eslint.org/docs/rules/array-bracket-spacing
Assignee | ||
Updated•7 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•7 years ago
|
Blocks: treeherder-react
Updated•3 years ago
|
Component: Treeherder: Docs & Development → TreeHerder
You need to log in
before you can comment on or make changes to this bug.
Description
•