-
Notifications
You must be signed in to change notification settings - Fork 19
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
using the local eslint and eslint config first #13
Conversation
|
||
@staticmethod | ||
def get_eslint_config(root, folders): | ||
cfs = ['.eslintrc.js', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json', '.eslintrc'] |
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 don't think we should be worrying about the configuration file. We call eslint from the command line passing the file path to be fixed. We pass a config file only if a project sets a specific one. Otherwise eslint calculates the configuration of that file based on the .eslintrc files up the tree to the root from that file.
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.
Any plugins or shareable configs that you use must also be installed globally to work with a globally-installed 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.
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 don't believe regular configuration files like .eslintrc
are considered shareable configs in eslint terminology.
From: http://eslint.org/docs/developer-guide/shareable-configs
Shareable configs are simply npm packages that export a configuration object.
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 the plugins have to be installed globally.
Does anyone from @eslint have additional thoughts on the ideal behavior of this plugin and the interaction with the eslint cli? |
I'm not 100% sure what's going on and I'm definitely not the best resource for this, but here's what I can try to offer:
You might find this article helpful (it's in Node but the concepts should be fairly easily translatable to Python). |
@xwartz Do you feel like you have a clear path forward on this PR based on @platinumazure's response? My thoughts are that it would be great to have this PR reduced to only try to find the local eslint if it exists. Following @platinumazure's step 3. |
Hi, @TheSavior |
# find package.json first | ||
if os.path.isfile(pkg): | ||
# get eslint from local node_modules | ||
return os.path.join(root, esl) |
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 believe that if you have a package.json, but do not have eslint installed locally, this would return the path as if you did have it installed, which then wouldn't be caught by the None check on 172.
I think there needs to be a check here to ensure that os.path.join(root, esl)
is a file
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.
findup is a pretty common pattern / function, looking at how it is typically implemented might help make sure we don't miss an edge case here.
@TheSavior |
@xwartz This looks great. I'm actually pretty new to python myself, most of the stuff I do these days in javascript. Thanks for the PR. |
Released as 2.1.0 |
using the local eslint and eslint config first, if not available, then using the settings config