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

Use import/no-extraneous-dependencies #329

Open
novemberborn opened this issue Jun 1, 2018 · 8 comments
Open

Use import/no-extraneous-dependencies #329

novemberborn opened this issue Jun 1, 2018 · 8 comments

Comments

@novemberborn
Copy link

https://github.com/benmosher/eslint-plugin-import/blob/HEAD/docs/rules/no-extraneous-dependencies.md would help prevent issues like avajs/ava#1823.

The globs would have to be configurable though.

@sindresorhus
Copy link
Member

Weird, we already have it included:

'import/no-extraneous-dependencies': 'error',

@novemberborn
Copy link
Author

I think that needs to be ['error', {devDependencies: false}], or rather a (configurable) glob with files that are typically used during development.

@pvdlg
Copy link
Contributor

pvdlg commented Sep 13, 2018

What would be the list of path typically used in development?
Do we have a way to determine that in a way reliable enough to not be configurable?

@novemberborn
Copy link
Author

What would be the list of path typically used in development?

script / scripts, test / tests / __tests__… not sure what else.

Do we have a way to determine that in a way reliable enough to not be configurable?

Ultimately there'll be too many edge cases to not have it be configurable.

@pvdlg
Copy link
Contributor

pvdlg commented Sep 17, 2018

Ultimately there'll be too many edge cases to not have it be configurable.

Yes indeed. @sindresorhus do you think we should add a dedicated variable for this case?
I wonder if that could be beneficial for other rules.

@pvdlg
Copy link
Contributor

pvdlg commented Sep 18, 2018

See import-js/eslint-plugin-import#1171 for a possible solution. That would avoid the need for a dedicated option in XO.

If it doesn't get implemented there we could implement it in XO, but I think this a feature that belongs to the plugin rather than XO.

@pvdlg
Copy link
Contributor

pvdlg commented Sep 19, 2018

We could also use eslint-plugin-node/no-extraneous-require and eslint-plugin-node/no-extraneous-import that doesn't have this problem. However it seems those rules do not distinguish dependencies and devDependencies.

Also eslint-plugin-node/no-unpublished-require verifies that all the required/imported files and module are published (modules are in dependencies and files are in files and not .npmignore).
It was disabled because of mysticatea/eslint-plugin-node#105.
@sindresorhus to workaround the problem you reported, maybe we could enable the rule when either a files property is defined in the package.json or an .npmignore file exist. So for app project where you don't set files nor create an .npmignore the rule would be disabled.

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

No branches or pull requests

5 participants
@novemberborn @sindresorhus @fregante @pvdlg and others