-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Explicitly specify ESLint config path for editor plugins in package.json #149
Conversation
Awesome! 👍 |
@@ -104,6 +104,11 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi | |||
}); | |||
delete hostPackage.scripts['eject']; | |||
|
|||
// explicitly specify ESLint config path for editor plugins | |||
hostPackage.eslintConfig = { | |||
extends: "./config/eslint.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.
I might be totally wrong, but is it safe to use /
since it's possible to be \
on windows? I think path.resolve
works cross platform.
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.
Thanks @eanplatter, I didn't notice that!
However, path.resolve
produces an absolute path which is probably not what we want here (what if the user moves or renames the project folder?).
How about changing it to path.normalize('./') + path.normalize('config/eslint.js')
? The first ./
(.\\
on windows) is required since Atom doesn't work without it.
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.
@insin could you help to confirm if this is an issue on windows? Thanks!
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 actually think it won't be, Node fs functions treat / in platform independent way. I wrote some unnecessary path.joins in the code before I learned this.
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, /
is fine in Node.js as an input path like this.
You only get problems if you're doing path stuff manually with /
and you might have a path which has been made "native" by converting it to absolute or relative with path
(which is why checking an absolute path with a RegExp
can be a gotcha - 🎵 Gotta [\\/]
'Em All, Pathémon 🎵)
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.
Awesome, thanks for clearing that up for me!
Sublime Text works as well with the |
Let’s remove unnecessary |
@gaearon haha i was just about to reply to you -- it doesn't work without |
Oh okay then. |
Thanks. |
FYI: I know this has already been merged but it only works when you install eslint and all the plugins globally. AFAIK it's a good rule of thumb to install all the dependencies locally per project. |
I'm trying to use this, and even when installing globally as @mareksuscak mentioned, I get an error in Atom:
|
If I symlink
then all is well. |
@mareksuscak sorry just saw this. Edit: sorry you're right! Please track #247. |
@weisjohn Are you using npm 3? The fix would only work with it. |
|
added migration steps to v2.5.0
Fixes #124. Notice that we need to change the path in
package.json
while ejecting since the config folder gets moved.Tested with Atom (Nuclide) and Visual Studio Code and it works both before and after ejection.
I'm not sure about Sublime Text -- seems likeSublimeLinter-eslint
only recognizes.eslintrc
config. However, it could be fixed by configuring the linter plugin itself. Or even better, could someone who uses Sublime Text send a PR to let it recognize theeslintConfig
field inpackage.json
? :)Edit: @kevinastone confirmed that Sublime Text works fine too.