-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Build: ESLint setup improvements #3385
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
Conversation
@mgol, thanks for your PR! By analyzing the history of the files in this pull request, we identified @markelog, @timmywil and @mikesherov to be potential reviewers. |
You might as well rephrase Line 113 in 5b4cb0d
Also might be a good idea to remove this too |
Yeah. Maybe a little description could be useful since you can't view the ticket. |
And good catch about the JSCS mention! |
I forgot. Done now. |
@sindresorhus cool, thank you |
@markelog I deleted the line but it seems to not exactly fit into the first commit, I added it as a separate one. What do you think? |
] ); | ||
|
||
grunt.registerTask( "lint:newer", [ | ||
"newer:jsonlint", | ||
runIfNewNode( "newer:eslint" ) |
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.
Same idea as in https://github.com/jquery/jquery-migrate/pull/238/files#diff-35b4a816e0441e6a375cd925af50752cR129 I suppose?
I wouldn't be oppose to comment about this in the code 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.
Yeah, commenting that makes sense, otherwise someone will remove it eventually. ;)
@@ -1,4 +1,8 @@ | |||
{ | |||
"env": { | |||
"browser": false, |
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.
To be more explicit? Why in these files only?
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.
What do you mean by "these files only"?
The configs cascade down in ESLint. If you don't specify browser: false
, you depend on the parent config to not specify browser: true
. Since we have to reset the node
env, I wanted to specify the browser one explicitly, it seems less fragile.
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.
Yeah, that's what I mean, you making only these configs explicit while others are still "less fragile", i'm wondering 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.
Ah, I get it now. I'll update the others as well. I'd only leave the ones that explicitly extend src/.eslintrc.json
as there we do want to replicate the same settings for source files.
I find you approach marvellous :) |
@markelog PR updated, PTAL. |
@@ -1,4 +1,6 @@ | |||
{ | |||
"extends": "../src/.eslintrc.json", | |||
"root": 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.
mmm, so this is root, so it wouldn't inherit upper configs, only extends one from src
and src
one doesn't have root
so it would inherit upper ones, which would be the same uppers since src
is sibling of test
dir, correct?
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.
Yeah, you're right. :D How about we create .eslintrc-(base|browser|node).json
files and extend whichever we need? Similarly to what I did for Angular; see https://github.com/angular/angular.js.
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.
Hm, how about we extend only eslint-jquery-config
with root: true
in every config? It will cause some repetition, but it could make it very clear. What do you think?
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.
We'd have to duplicate the globals in every src
-related .eslintrc.json
. What's the drawback of what I proposed?
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.
Yeah, I guess duplicating of globals would suck more.
What's the drawback of what I proposed?
Angular historically didn't shy away from those in their repo so it's seems fine for them, but for me personally that seems as a clutter
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.
Didn't shy from what exactly?
Is my proposal of the .eslintrc-(base|browser|node).json
files OK for you?
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.
From dot files
Is my proposal of the .eslintrc-(base|browser|node).json files OK for you?
If that's the best option we can come up with...
@markelog PR updated, PTAL. |
"env": { | ||
"node": true | ||
} | ||
"extends": "./.eslintrc-node.json" |
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.
What about root: 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.
Fixed.
"root": true, | ||
|
||
"extends": "../.eslintrc-browser.json", | ||
|
||
"env": { | ||
"browser": 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.
Should this be in .eslintrc-browser.json
only?
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'm not sure how to best play it out. The issue is that we don't want browser: true
to be specified in source as we take all the browser stuff from the window
variable and that's important for jsdom compatibility. On the other hand, it would be too much to fix in tests and that would only help us if we ever tried to run the test suite (or its parts) in jsdom which we don't have plans currently. So setup between src
& test
will differ.
What would you suggest?
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'm thinking set it in .eslintrc-browser.json
and disable it in src
seems more logical that way?
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.
@markelog I was thinking that generally our browser setup should be made work with all browser globals put on window
and not necessarily available a globals and that tests are the exception, not source.
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.
(Although it seems .eslintrc-browser.json
should have a comment explaining that)
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 we always want to reference global vars from window
object? Yeah I recall we talked about this before, sounds good to me then – a default disabled browser
option and additional comment
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 we always want to reference global vars from
window
object?
I'm sure you meant it :) but just to be precise - only the browser-only globals; the one from the ECMAScript specification are used directly.
I'll update the PR.
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.
@markelog PR updated
1. Use the short name of the preset in the config. 2. Run ESLint first on non-minified files. 3. Explicitly specify environments in every config file (those settings cascade which means we've been assuming a Node.js environment where we shouldn't have).
The file doesn't exist anymore.
This way `eslint .` run from the terminal will work regardless of ignored files present in the repository. Closes jquerygh-3385
Fixes Node smoke tests Ref jquerygh-3385
Summary
Checklist
Mark an
[x]
for completed items, if you're not sure leave them unchecked and we can assist.New tests have been added to show the fix or feature worksIf needed, a docs issue/PR was created at https://github.com/jquery/api.jquery.comThanks! Bots and humans will be around shortly to check it out.
which means we've been assuming a Node.js environment where we shouldn't have).
I found these when working on jquery/jquery-migrate#238.
cc @markelog