Eslint has had a few version since the last time I checked the config. They added new options, fixed a few that were broken and our codebase needs to get up to date. Some of the options are not "required" but enforce parts of our JS coding standards:
Here are the config changes:
"block-scoped-var": 2,
This help spot variable reuse, and make it explicit at which level the variable is used.
"no-undefined": 2,
This is to forbid if (somevar === undefined) because it should be written if (typeof somevar === 'undefined')
"brace-style": [2, "stroustrup", { "allowSingleLine": true }],
"comma-style": [2, "last"],
"semi": [2, "always"],
"space-after-keywords": [2, "always", {"checkFunctionKeyword": true}],
"spaced-line-comment": [2, "always"],
Just enforcing our coding standards.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | interdiff.txt | 304 bytes | nod_ |
| #17 | core-js-eslint-rules-2389515-17.patch | 69.55 KB | nod_ |
| #5 | interdiff.txt | 44.41 KB | nod_ |
Comments
Comment #1
wim leersThis helps improve the DX.
Comment #2
wim leers#2382533: Attach assets only via the asset library system landed, this will need a reroll now.
Comment #3
nod_Updated
Comment #4
nod_Added a couple of rules to prevent the code from being crazy.
Comment #5
nod_Some more coding standard rules.
for the space in brackets thing, I tried both ways. Requiring a space got me 1200 errors, requiring no space, 178 errors. I went with that.
I attached the interdiff, and the interdiff ignoring whitespace.
Comment #6
nod_Found some jshint related comment that needs to go away.
Comment #10
nod_Comment #12
webchickJust committed #2397681: field_ui.js fails eslint validation so this one will need a re-roll. Also tagging for manual testing (this shouldn't break anything but we should do a click-through of a few things to make sure).
Comment #13
nod_Comment #14
wim leersIf I run
eslint .in the Drupal 8 root, then I get thousands of errors. Mostly in 3rd party libraries, but also in core JS. Am I not using the right incantation?In any case: the patch looks great. I can't find anything to complain about!
Comment #15
nod_Version is important, latest is 0.11 what you got?
Comment #16
wim leersI installed it a few weeks ago, and I've got 0.9.2 apparently. Doesn't
.eslintrcallow you to specify a minimum version? That'd prevent this problem.After updating, only one problem remains.
Output of this command attached:
eslintis also linting JS in thelibrariesdirectory. This directory is indeed non-standard, but this also means it should not be checked byeslint.Comment #17
nod_Excluding libraries folder, from root, profile and sites directories.
Comment #18
wim leersLooks great now :)
All the affected JS still works fine.
Comment #19
alexpottCommitted a3efcb6 and pushed to 8.0.x. Thanks!