Skip to content

Commit 53ff5ae

Browse files
Netailautofix-ci[bot]ematipico
authored
feat(analyse/json): add noDuplicateDependencies rule (#7142)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Emanuele Stoppa <[email protected]>
1 parent 0733558 commit 53ff5ae

File tree

28 files changed

+866
-56
lines changed

28 files changed

+866
-56
lines changed

.changeset/seven-bats-write.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Added the new nursery rule [`noDuplicateDependencies`](https://next.biomejs.dev/linter/rules/no-duplicate-dependencies/), which verifies that no dependencies are duplicated between the `bundledDependencies`, `bundleDependencies`, `dependencies`, `devDependencies`, `overrides`, `optionalDependencies`, and `peerDependencies` sections.
6+
7+
For example, the following snippets will trigger the rule:
8+
9+
```json
10+
{
11+
"dependencies": {
12+
"foo": ""
13+
},
14+
"devDependencies": {
15+
"foo": ""
16+
}
17+
}
18+
```
19+
20+
```json
21+
{
22+
"dependencies": {
23+
"foo": ""
24+
},
25+
"optionalDependencies": {
26+
"foo": ""
27+
}
28+
}
29+
```
30+
31+
```json
32+
{
33+
"dependencies": {
34+
"foo": ""
35+
},
36+
"peerDependencies": {
37+
"foo": ""
38+
}
39+
}
40+
```

crates/biome_analyze/src/rule.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ pub enum RuleSource {
157157
EslintVitest(&'static str),
158158
/// Rules from [Eslint Plugin Vue.js](https://eslint.vuejs.org/)
159159
EslintVueJs(&'static str),
160+
/// Rules from [Eslint Plugin Package.json](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json)
161+
EslintPackageJson(&'static str),
162+
/// Rules from [Eslint Plugin Package.json Dependencies](https://github.com/idan-at/eslint-plugin-package-json-dependencies)
163+
EslintPackageJsonDependencies(&'static str),
160164
}
161165

162166
impl PartialEq for RuleSource {
@@ -202,6 +206,10 @@ impl std::fmt::Display for RuleSource {
202206
Self::DenoLint(_) => write!(f, "deno-lint"),
203207
Self::EslintVitest(_) => write!(f, "@vitest/eslint-plugin"),
204208
Self::EslintVueJs(_) => write!(f, "eslint-plugin-vue"),
209+
Self::EslintPackageJson(_) => write!(f, "eslint-plugin-package-json"),
210+
Self::EslintPackageJsonDependencies(_) => {
211+
write!(f, "eslint-plugin-package-json-dependencies")
212+
}
205213
}
206214
}
207215
}
@@ -278,7 +286,9 @@ impl RuleSource {
278286
| Self::Stylelint(rule_name)
279287
| Self::DenoLint(rule_name)
280288
| Self::EslintVitest(rule_name)
281-
| Self::EslintVueJs(rule_name) => rule_name,
289+
| Self::EslintVueJs(rule_name)
290+
| Self::EslintPackageJson(rule_name)
291+
| Self::EslintPackageJsonDependencies(rule_name) => rule_name,
282292
}
283293
}
284294

@@ -317,6 +327,10 @@ impl RuleSource {
317327
Self::DenoLint(rule_name) => format!("deno-lint/{rule_name}"),
318328
Self::EslintVitest(rule_name) => format!("vitest/{rule_name}"),
319329
Self::EslintVueJs(rule_name) => format!("vue/{rule_name}"),
330+
Self::EslintPackageJson(rule_name) => format!("package-json/{rule_name}"),
331+
Self::EslintPackageJsonDependencies(rule_name) => {
332+
format!("package-json-dependencies/{rule_name}")
333+
}
320334
}
321335
}
322336

@@ -354,6 +368,8 @@ impl RuleSource {
354368
Self::DenoLint(rule_name) => format!("https://lint.deno.land/rules/{rule_name}"),
355369
Self::EslintVitest(rule_name) => format!("https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/{rule_name}.md"),
356370
Self::EslintVueJs(rule_name) => format!("https://eslint.vuejs.org/rules/{rule_name}"),
371+
Self::EslintPackageJson(rule_name) => format!("https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/main/docs/rules/{rule_name}.md"),
372+
Self::EslintPackageJsonDependencies(rule_name) => format!("https://github.com/idan-at/eslint-plugin-package-json-dependencies/blob/master/docs/rules/{rule_name}.md"),
357373
}
358374
}
359375

crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/biome_configuration/src/analyzer/linter/rules.rs

Lines changed: 75 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/biome_diagnostics_categories/src/categories.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ define_categories! {
311311
"lint/suspicious/noDuplicateCase": "https://biomejs.dev/linter/rules/no-duplicate-case",
312312
"lint/suspicious/noDuplicateClassMembers": "https://biomejs.dev/linter/rules/no-duplicate-class-members",
313313
"lint/suspicious/noDuplicateCustomProperties": "https://biomejs.dev/linter/rules/no-duplicate-custom-properties",
314+
"lint/nursery/noDuplicateDependencies": "https://biomejs.dev/linter/rules/no-duplicate-dependencies",
314315
"lint/suspicious/noDuplicateElseIf": "https://biomejs.dev/linter/rules/no-duplicate-else-if",
315316
"lint/suspicious/noDuplicateFields": "https://biomejs.dev/linter/rules/no-duplicate-fields",
316317
"lint/suspicious/noDuplicateFontNames": "https://biomejs.dev/linter/rules/no-font-family-duplicate-names",

crates/biome_json_analyze/src/lint.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
33
//! Generated file, do not edit by hand, see `xtask/codegen`
44
5+
pub mod nursery;
56
pub mod suspicious;
6-
::biome_analyze::declare_category! { pub Lint { kind : Lint , groups : [self :: suspicious :: Suspicious ,] } }
7+
::biome_analyze::declare_category! { pub Lint { kind : Lint , groups : [self :: nursery :: Nursery , self :: suspicious :: Suspicious ,] } }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! Generated file, do not edit by hand, see `xtask/codegen`
2+
3+
//! Generated file, do not edit by hand, see `xtask/codegen`
4+
5+
use biome_analyze::declare_lint_group;
6+
pub mod no_duplicate_dependencies;
7+
declare_lint_group! { pub Nursery { name : "nursery" , rules : [self :: no_duplicate_dependencies :: NoDuplicateDependencies ,] } }

0 commit comments

Comments
 (0)