Skip to content
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

Merged

Conversation

fredrikekelund
Copy link
Contributor

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.

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

@kentcdodds kentcdodds left a 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}`)
Copy link
Member

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 👍

@fredrikekelund
Copy link
Contributor Author

Looks like I missed to run nps validate before pushing, I just ran nps test. Should be fixed now in any case!

@codecov-io
Copy link

codecov-io commented Aug 20, 2017

Codecov Report

Merging #93 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #93   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      3           
  Lines         107    107           
=====================================
  Hits          107    107

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 87c0cf1...15a3fcb. Read the comment docs.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Thanks!

@kentcdodds kentcdodds merged commit 8ffe4ad into prettier:master Aug 20, 2017
@kentcdodds
Copy link
Member

Would you like to add yourself to the contributors table?

@fredrikekelund
Copy link
Contributor Author

No thanks, that's not necessary!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants