Skip to content

Commit

Permalink
docs: add unique dependencies rule
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlj95 committed Nov 12, 2024
1 parent 19b4c96 commit 301e2e4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
💡 Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).

| Name                       | Description | 💼 | 🔧 | 💡 |
| :--------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- | :- | :- | :- |
| [order-properties](docs/rules/order-properties.md) | Package properties must be declared in standard order || 🔧 | |
| [repository-shorthand](docs/rules/repository-shorthand.md) | Enforce either object or shorthand declaration for repository. || 🔧 | |
| [sort-collections](docs/rules/sort-collections.md) | Dependencies, scripts, and configuration values must be declared in alphabetical order. || 🔧 | |
| [unique-dependencies](docs/rules/unique-dependencies.md) | Enforce that if repository directory is specified, it matches the path to the package.json file || | 💡 |
| [valid-local-dependency](docs/rules/valid-local-dependency.md) | Checks existence of local dependencies in the package.json || | |
| [valid-name](docs/rules/valid-name.md) | Enforce that package names are valid npm package names || | |
| [valid-package-def](docs/rules/valid-package-def.md) | Enforce that package.json has all properties required by the npm spec || | |
| [valid-repository-directory](docs/rules/valid-repository-directory.md) | Enforce that if repository directory is specified, it matches the path to the package.json file || | 💡 |
| [valid-version](docs/rules/valid-version.md) | Enforce that package versions are valid semver specifiers || | |
| Name                       | Description | 💼 | 🔧 | 💡 |
| :--------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------ | :- | :- | :- |
| [order-properties](docs/rules/order-properties.md) | Package properties must be declared in standard order || 🔧 | |
| [repository-shorthand](docs/rules/repository-shorthand.md) | Enforce either object or shorthand declaration for repository. || 🔧 | |
| [sort-collections](docs/rules/sort-collections.md) | Dependencies, scripts, and configuration values must be declared in alphabetical order. || 🔧 | |
| [unique-dependencies](docs/rules/unique-dependencies.md) | Checks a dependency isn't specified more than once (i.e. in `dependencies` and `devDependencies`) || | 💡 |
| [valid-local-dependency](docs/rules/valid-local-dependency.md) | Checks existence of local dependencies in the package.json || | |
| [valid-name](docs/rules/valid-name.md) | Enforce that package names are valid npm package names || | |
| [valid-package-def](docs/rules/valid-package-def.md) | Enforce that package.json has all properties required by the npm spec || | |
| [valid-repository-directory](docs/rules/valid-repository-directory.md) | Enforce that if repository directory is specified, it matches the path to the package.json file || | 💡 |
| [valid-version](docs/rules/valid-version.md) | Enforce that package versions are valid semver specifiers || | |

<!-- end auto-generated rules list -->
<!-- prettier-ignore-end -->
Expand Down
25 changes: 25 additions & 0 deletions docs/rules/unique-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,28 @@
💡 This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).

<!-- end auto-generated rule header -->

This rule checks that every dependency is just added once to a [`package.json` key specifying dependencies](/~https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/main/src/rules/unique-dependencies.ts#L8-L16).

Example of **incorrect** code for this rule:

```json
{
"dependencies": {
"foo": "1.0.0"
},
"devDependencies": {
"foo": "1.0.0"
}
}
```

Example of **correct** code for this rule:

```json
{
"dependencies": {
"foo": "1.0.0"
}
}
```
2 changes: 1 addition & 1 deletion src/rules/unique-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const rule = createRule({
docs: {
category: "Best Practices",
description:
"Enforce that if repository directory is specified, it matches the path to the package.json file",
"Checks a dependency isn't specified more than once (i.e. in `dependencies` and `devDependencies`)",
recommended: true,
},
hasSuggestions: true,
Expand Down

0 comments on commit 301e2e4

Please sign in to comment.