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

added rule import/no-extraneous-dependencies to docs #2748

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,27 @@ Other Style Guides
import foo from './foo';
import bar from './bar';
import baz from './baz';

```

<a name="modules--import/no-extraneous-dependencies"></a><a name="10.11"></a>
Copy link
Collaborator

Choose a reason for hiding this comment

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

new sections don't get numbered links.

Suggested change
<a name="modules--import/no-extraneous-dependencies"></a><a name="10.11"></a>
<a name="modules--import/no-extraneous-dependencies"></a>


- [10.11](#modules--import/no-extraneous-dependencies) Forbid the use of extraneous packages.
eslint: [`import/no-extraneous-dependencies`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
eslint: [`import/no-extraneous-dependencies`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md)
eslint: [`import/no-extraneous-dependencies`](https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md)


> Why? You should only allow modules that are declared in the package.json's dependencies, devDependencies, optionalDependencies, peerDependencies, or bundledDependencies to be imported and used within the project.

```javascript
// bad
// Not declared in package.json - es6.js
import es6 from 'es6';
const es6 = require('es6');

// good
// Declared in package.json es6.js
import es6 from 'es6';
const es6 = require('es6');
Comment on lines +1483 to +1490
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's use a package name someone's actually likely to use here.

but also, i'm not sure how helpful this example is since it's not showing package.json. but maybe that'd be overkill?

Copy link

Choose a reason for hiding this comment

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

I added this lint rule in our project when someone tried to use "axios" without mentioning it in package.json. That can be used as an example.


```

**[⬆ back to top](#table-of-contents)**
Expand Down