Background
In WebUI, we used closure_linter in the past, which was removed at [1] for good
reasons. Since then, clang-format is gradually being used across the JS codebase
to enforce consistent formatting of the code. While clang-format is very useful,
it does not perform any checks for issues that can't be auto-formatted.
Proposal
I am proposing using ESLint in a complementary way to clang-format, to perform
additional checks on the code (see attached screenshot for example error report).
Expected benefits
- Consistency across JS cobebase in Chromium.
- Increase automatic enforcement of JS styleguide as much as possible.
- PRESUBMIT integration will save a lot of code reviewers and reviewees time.
Why ESLint?
ESlint seems to be the best open source available tool for JS linting.
- Active development.
- Used by many popular projects (among others Node.js [2] and Chromium's DevTools [3]).
- Highly customizable (200+ rules, see http://eslint.org/docs/rules/)
- Understands latest ES6 syntax.
- Flexible rule enforcement (can override rules when necessary, either at a
folder level or even for a few lines in the code).
- Rules/features are being considered with popular JS style-guides in mind
(namely Google's and AirBnB's style guides, which is very convenient).
[1] https://bugs.chromium.org/p/chromium/issues/detail?id=567770#c28
[2] https://github.com/nodejs/node/blob/master/.eslintrc.yaml
[3] https://cs.chromium.org/chromium/src/third_party/WebKit/Source/devtools/.eslintrc.js
Comment 1 by dpa...@chromium.org
, May 9 2017