Skip to content

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

Merged
merged 3 commits into from
Dec 19, 2016
Merged

Build: ESLint setup improvements #3385

merged 3 commits into from
Dec 19, 2016

Conversation

mgol
Copy link
Member

@mgol mgol commented Nov 2, 2016

Summary

Checklist

Mark an [x] for completed items, if you're not sure leave them unchecked and we can assist.

Thanks! Bots and humans will be around shortly to check it out.

  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).

I found these when working on jquery/jquery-migrate#238.

cc @markelog

@mgol mgol added the Build label Nov 2, 2016
@mgol mgol self-assigned this Nov 2, 2016
@mention-bot
Copy link

@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.

@markelog
Copy link
Member

markelog commented Nov 3, 2016

You might as well rephrase

// See https://github.com/sindresorhus/grunt-eslint/issues/119
it seems @sindresorhus didn't restore those issues – https://twitter.com/arkel/status/760518498699411457

Also might be a good idea to remove this too

@mgol
Copy link
Member Author

mgol commented Nov 3, 2016

Yeah. Maybe a little description could be useful since you can't view the ticket.

@mgol
Copy link
Member Author

mgol commented Nov 3, 2016

And good catch about the JSCS mention!

@sindresorhus
Copy link
Contributor

You might as well rephrase

// See https://github.com/sindresorhus/grunt-eslint/issues/119
it seems @sindresorhus didn't restore those issues – https://twitter.com/arkel/status/760518498699411457

I forgot. Done now.

@markelog
Copy link
Member

markelog commented Nov 3, 2016

@sindresorhus cool, thank you

@mgol
Copy link
Member Author

mgol commented Nov 7, 2016

@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" )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member

@markelog markelog Nov 14, 2016

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

Copy link
Member Author

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,
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

@markelog
Copy link
Member

markelog commented Nov 9, 2016

@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?

I find you approach marvellous :)

@mgol
Copy link
Member Author

mgol commented Nov 16, 2016

@markelog PR updated, PTAL.

@@ -1,4 +1,6 @@
{
"extends": "../src/.eslintrc.json",
"root": true,
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member

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...

@mgol
Copy link
Member Author

mgol commented Nov 30, 2016

@markelog PR updated, PTAL.

"env": {
"node": true
}
"extends": "./.eslintrc-node.json"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about root: true?

Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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)

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markelog PR updated

@timmywil timmywil modified the milestone: 3.2.0 Dec 12, 2016
mgol added 3 commits December 19, 2016 02:07
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
@mgol mgol merged commit 1754e31 into jquery:master Dec 19, 2016
@mgol mgol deleted the eslint branch December 19, 2016 01:16
gibson042 added a commit to gibson042/jquery that referenced this pull request Dec 19, 2016
Fixes Node smoke tests

Ref jquerygh-3385
gibson042 added a commit that referenced this pull request Dec 19, 2016
Fixes Node smoke tests

Ref gh-3385
Closes gh-3460
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

7 participants