-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Removed default values for eslintPath and prettierPath #93
Removed default values for eslintPath and prettierPath #93
Conversation
These values are not required by prettier-eslint-cli itself. They are only passed to prettier-eslint, and even then, they're optional. When using npm >3, passing the default value is optional, since the node_modules directory is flattened, but for npm 2.x, the default assumptions don't work. People should be running npm >3 today, but for CI scenarios, npm 2 or downwards can still be used in combination with node 4.x (which is going to be supported for a long time still). In any case, not passing a default value seems to align better with node's require algorithm - it will start where it needs to start (in this case wherever the prettier-eslint dependency has been installed), and then mimick find-up's logic.
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! I think I'm in favor of this change. Makes things simpler and improves support. How awesome is that!?
@@ -160,23 +158,6 @@ const parser = yargs | |||
|
|||
export default parser | |||
|
|||
function getPathInHostNodeModules(module) { | |||
logger.debug(`Looking for a local installation of the module "${module}"`) | |||
const modulePath = findUp.sync(`node_modules/${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.
Looks like you can remove thefindUp
and logger
imports from this file 👍
Looks like I missed to run |
Codecov Report
@@ Coverage Diff @@
## master #93 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 3 3
Lines 107 107
=====================================
Hits 107 107 Continue to review full report at Codecov.
|
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!
Would you like to add yourself to the contributors table? |
No thanks, that's not necessary! |
What:
Removed default values for eslintPath and prettierPath. This improves compatibility for scenarios where not all dependencies of a project reside in a completely flat node_modules folder (the most common cause for this would be that npm 2.x is still being used)
Why:
These values are not required by prettier-eslint-cli itself. They are only passed to prettier-eslint, and even then, they're optional. When using npm >3, whether we pass the value or not is all the same - the node_modules directory is flattened and both prettier and eslint will reside in the same node_modules folder no matter which other module depends on it. But for npm 2.x, the default assumptions don't work.
It's true that people should be running npm >3 today, but for CI scenarios, npm 2 or downwards can still be used in combination with node 4.x (which is going to be supported for a long time still).
In any case, not passing a default value seems to align better with node's
require
algorithm - it will start where it needs to start (in this case wherever the prettier-eslint dependency has been installed), and then mimick find-up's logic.How:
I simply removed the default values and the associated helper function.