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
Use overrides
for a single .eslintrc.js
.
#7443
Conversation
I will follow up and make sure that |
blueprints/app/files/.eslintrc.js
Outdated
@@ -2,12 +2,39 @@ module.exports = { | |||
root: true, | |||
parserOptions: { | |||
ecmaVersion: 2017, | |||
sourceType: 'module' | |||
sourceType: 'module', |
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.
seems strange to only have trailing commas in this file. I vote for removal.
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.
😭 but ok 😄
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 agree, we should add them to all files...
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.
Ya, agreed. Though I’m happy to do this separately.
blueprints/app/files/.eslintrc.js
Outdated
files: [ | ||
'./ember-cli-build.js', | ||
'./testem.js', | ||
'./index.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.
should we use ./*.js
instead?
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.
Interesting. I hadn’t thought of that. Should work nicely.
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.
Sadly, this doesn't work. The main issue is that in the implementation (eslint/eslint#8081) when the files
and excludedFiles
are passed in to minimatch
(here) they also pass { matchBase: true }
as options.
From the minimatch
README about matchBase
:
If set, then patterns without slashes will be matched against the basename of the path if it contains slashes. For example, a?b would match the path /xyz/123/acb, but not /xyz/acb/123.
tl;dr Due to the usage of matchBase
it is not possible to use globs to match files in the project root. If we use *.js
it matches all files in the repo, if we use ./*.js
it matches no files, if we use /*.js
it throws an error....
😭 😭 😭
blueprints/app/files/.eslintrc.js
Outdated
ecmaVersion: 2015, | ||
}, | ||
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.
I think this has to be browser: null
or something like that. iirc true/false
only defines whether the global can be overwritten or something like 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.
Really!?!?! Weird! I’ll look it up. I have used this on a few other projects, will test and update as needed.
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 just realized I might be confusing this with the stuff in the globals
object, but we should verify just in case.
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.
Ya, I was looking through the docs on configuring and I think you are thinking of the globals stuff. For easy cross referencing:
- https://eslint.org/docs/user-guide/configuring#specifying-environments <- Docs on these
env
flags (no discussion of clobbering) - https://eslint.org/docs/user-guide/configuring#specifying-globals <- Docs on
globals
(includes discussion ontrue
/false
flag to allow clobbering)
blueprints/app/files/.eslintrc.js
Outdated
// test files | ||
{ | ||
files: ['tests/**/*.js'], | ||
env: { |
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.
indentation
blueprints/app/files/.eslintrc.js
Outdated
'./ember-cli-build.js', | ||
'./testem.js', | ||
'./index.js', | ||
'config/**/*.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.
what about tests/dummy/config/**/*.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.
👍 - good idea
|
||
// test files | ||
{ | ||
files: ['tests/**/*.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.
can we exclude tests/dummy/
?
it's okay if we can't since we haven't done it before either, but would be nice 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.
Yep, added and confirmed. Works nicely!
I would like to hold off merging until our meeting. I'm not 100% in favor of this. I like getting rid of the first line sprinkles of node files, but I'm not convinced that removing our tests/.eslintrc.js is a good idea. Everybody's documentation and blueprint injection touch that file (globals and test helpers), and it seems to me that it is in it's correct place. |
Seems good, happy to discuss...
This is where we disagree. The current system of having many
I think this is actually a separate concern from the others. We should choose the right set of defaults, and recommend them while also providing time and assistance to addons that may need to make modifications. Modifying a single file ( |
We decided in the core meeting that this is the way forward. With module unification, test files will be strewn about a project, so wildcard paths inside a single eslint config is the future (TM). |
29afbef
to
a367e98
Compare
Rebased and addressed all outstanding comments... |
Update the `.eslintrc.js` used by apps and addons, to avoid needing separate "sprinkles" of eslint configuration throughout the projects codebase. Compatible with `eslint@4.1.0`.
a367e98
to
6b5c068
Compare
@rwjblue this shouldn't block, but can you verify the behavior for in-repo-addons? |
@Turbo87 - Good point, I will do some testing. I believe that we might need to add |
Update the
.eslintrc.js
used by apps and addons, to avoid needing separate "sprinkles" of eslint configuration throughout the projects codebase.Compatible with
eslint@4.1.0
.Additional reading:
overrides
andfiles
configuration options (refs #3611) eslint/eslint#8081