Skip to content

Commit 0735b7c

Browse files
committed
Merge branch 'main' of github.com:taga3s/biome into add-noBeforeInteractiveScriptOutsideDocument
2 parents 0d45f0a + 2fce3df commit 0735b7c

32 files changed

+1134
-40
lines changed

.changeset/cold-ravens-show.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Added the nursery rule [`useUniqueInputFieldNames`](https://biomejs.dev/linter/rules/use-unique-input-field-names/). Require fields within an input object to be unique.
6+
7+
**Invalid:**
8+
9+
```graphql
10+
query A($x: Int, $x: Int) {
11+
field
12+
}
13+
```

.changeset/floppy-phones-create.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Added the nursery rule [`useUniqueFieldDefinitionNames`](https://biomejs.dev/linter/rules/use-unique-field-definition-names/). Require all fields of a type to be unique.

.changeset/nine-nights-know.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Added the nursery rule [`useUniqueArgumentNames`](https://biomejs.dev/linter/rules/use-unique-argument-names/). Enforce unique arguments for GraphQL fields & directives.
6+
7+
**Invalid:**
8+
9+
```graphql
10+
query {
11+
field(arg1: "value", arg1: "value")
12+
}
13+
```

.changeset/proud-ways-listen.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@biomejs/biome": patch
33
---
44

5-
Reduced the system calls when running the CLI. The performances might be noticable in big projects that have multiple libraries and enable project rules.
5+
Reduced the system calls when running the CLI. The performances might be noticeable in big projects that have multiple libraries and enable project rules.

.changeset/public-walls-buy.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@
33
---
44

55
Added the nursery rule [`useUniqueVariableNames`](https://biomejs.dev/linter/rules/use-unique-variable-names/). Enforce unique variable names for GraphQL operations.
6+
7+
**Invalid:**
8+
9+
```graphql
10+
query ($x: Int, $x: Int) {
11+
field
12+
}
13+
```

.gitattributes

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,46 @@
66
/crates/biome_configuration/src/analyzer/linter/rules.rs linguist-generated=true text=auto eol=lf
77
/crates/biome_configuration/src/analyzer/assist/actions.rs linguist-generated=true text=auto eol=lf
88
/crates/biome_configuration/src/analyzer/parse/rules.rs linguist-generated=true text=auto eol=lf
9+
/crates/biome_configuration/src/generated/domain_selector.rs linguist-generated=true text=auto eol=lf
910
# GraphQL
11+
/crates/biome_graphql_formatter/src/graphql/any/*.rs linguist-generated=true text=auto eol=lf
1012
/crates/biome_graphql_analyze/src/{lint,assist,syntax}.rs linguist-generated=true text=auto eol=lf
1113
/crates/biome_graphql_analyze/src/{lint,assist,syntax}/*.rs linguist-generated=true text=auto eol=lf
1214
/crates/biome_graphql_analyze/src/options.rs linguist-generated=true text=auto eol=lf
1315
/crates/biome_graphql_analyze/src/registry.rs linguist-generated=true text=auto eol=lf
1416
# CSS
17+
/crates/biome_css_formatter/src/{css,tailwind}/any/*.rs linguist-generated=true text=auto eol=lf
1518
/crates/biome_css_analyze/src/{lint,assist,syntax}.rs linguist-generated=true text=auto eol=lf
1619
/crates/biome_css_analyze/src/{lint,assist,syntax}/*.rs linguist-generated=true text=auto eol=lf
1720
/crates/biome_css_analyze/src/options.rs linguist-generated=true text=auto eol=lf
1821
/crates/biome_css_analyze/src/registry.rs linguist-generated=true text=auto eol=lf
1922
# JSON
23+
/crates/biome_json_formatter/src/json/any/*.rs linguist-generated=true text=auto eol=lf
2024
/crates/biome_json_analyze/src/{lint,assist,syntax}.rs linguist-generated=true text=auto eol=lf
2125
/crates/biome_json_analyze/src/{lint,assist,syntax}/*.rs linguist-generated=true text=auto eol=lf
22-
/crates/biome_js_analyze/src/options.rs linguist-generated=true text=auto eol=lf
23-
/crates/biome_js_analyze/src/registry.rs linguist-generated=true text=auto eol=lf
26+
/crates/biome_json_analyze/src/options.rs linguist-generated=true text=auto eol=lf
27+
/crates/biome_json_analyze/src/registry.rs linguist-generated=true text=auto eol=lf
2428
# JS
29+
/crates/biome_js_formatter/src/{js,jsx,ts}/any/*.rs linguist-generated=true text=auto eol=lf
2530
/crates/biome_js_analyze/src/{lint,assist,syntax}.rs linguist-generated=true text=auto eol=lf
2631
/crates/biome_js_analyze/src/{lint,assist,syntax}/*.rs linguist-generated=true text=auto eol=lf
2732
/crates/biome_js_analyze/src/options.rs linguist-generated=true text=auto eol=lf
2833
/crates/biome_js_analyze/src/registry.rs linguist-generated=true text=auto eol=lf
2934
# Grit
3035
/crates/biome_grit_patterns/src/grit_target_language/*/constants.rs linguist-generated=true text=auto eol=lf
36+
# HTML
37+
/crates/biome_html_formatter/src/{html,astro,vue,svelte}/any/*.rs linguist-generated=true text=auto eol=lf
38+
/crates/biome_html_analyze/src/{lint,assist,syntax}.rs linguist-generated=true text=auto eol=lf
39+
/crates/biome_html_analyze/src/{lint,assist,syntax}/*.rs linguist-generated=true text=auto eol=lf
40+
/crates/biome_html_analyze/src/options.rs linguist-generated=true text=auto eol=lf
41+
/crates/biome_html_analyze/src/registry.rs linguist-generated=true text=auto eol=lf
3142

3243
# Other
3344
/crates/biome_unicode_table/src/tables.rs linguist-generated=true text=auto eol=lf
3445
/packages/@biomejs/backend-jsonrpc/src/workspace.ts linguist-generated=true text=auto eol=lf
3546
/packages/@biomejs/biome/configuration_schema.json linguist-generated=true text=auto eol=lf
47+
/crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs linguist-generated=true text=auto eol=lf
48+
/crates/biome_diagnostics_categories/src/categories.rs linguist-generated=true text=auto eol=lf
3649
pnpm-lock.yaml linguist-generated=true text=auto eol=lf
3750

3851
# Files with the language manually specified, sorted alphabetically.

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

Lines changed: 90 additions & 27 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: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/biome_graphql_analyze/src/lint/nursery.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use biome_analyze::declare_lint_group;
66
pub mod no_empty_source;
77
pub mod use_consistent_graphql_descriptions;
88
pub mod use_deprecated_date;
9+
pub mod use_unique_argument_names;
10+
pub mod use_unique_field_definition_names;
911
pub mod use_unique_graphql_operation_name;
12+
pub mod use_unique_input_field_names;
1013
pub mod use_unique_variable_names;
11-
declare_lint_group! { pub Nursery { name : "nursery" , rules : [self :: no_empty_source :: NoEmptySource , self :: use_consistent_graphql_descriptions :: UseConsistentGraphqlDescriptions , self :: use_deprecated_date :: UseDeprecatedDate , self :: use_unique_graphql_operation_name :: UseUniqueGraphqlOperationName , self :: use_unique_variable_names :: UseUniqueVariableNames ,] } }
14+
declare_lint_group! { pub Nursery { name : "nursery" , rules : [self :: no_empty_source :: NoEmptySource , self :: use_consistent_graphql_descriptions :: UseConsistentGraphqlDescriptions , self :: use_deprecated_date :: UseDeprecatedDate , self :: use_unique_argument_names :: UseUniqueArgumentNames , self :: use_unique_field_definition_names :: UseUniqueFieldDefinitionNames , self :: use_unique_graphql_operation_name :: UseUniqueGraphqlOperationName , self :: use_unique_input_field_names :: UseUniqueInputFieldNames , self :: use_unique_variable_names :: UseUniqueVariableNames ,] } }
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
use std::collections::HashSet;
2+
3+
use biome_analyze::{
4+
Ast, Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule,
5+
};
6+
use biome_console::markup;
7+
use biome_graphql_syntax::GraphqlArguments;
8+
use biome_rowan::{AstNode, TokenText};
9+
use biome_rule_options::use_unique_argument_names::UseUniqueArgumentNamesOptions;
10+
11+
declare_lint_rule! {
12+
/// Require all argument names for fields & directives to be unique.
13+
///
14+
/// A GraphQL field or directive is only valid if all supplied arguments are uniquely named.
15+
///
16+
/// ## Examples
17+
///
18+
/// ### Invalid
19+
///
20+
/// ```graphql,expect_diagnostic
21+
/// query {
22+
/// field(arg1: "value", arg1: "value")
23+
/// }
24+
/// ```
25+
///
26+
/// ### Valid
27+
///
28+
/// ```graphql
29+
/// query {
30+
/// field(arg1: "value", arg2: "value")
31+
/// }
32+
/// ```
33+
///
34+
pub UseUniqueArgumentNames {
35+
version: "next",
36+
name: "useUniqueArgumentNames",
37+
language: "graphql",
38+
recommended: false,
39+
sources: &[RuleSource::EslintGraphql("unique-argument-names").same()],
40+
}
41+
}
42+
43+
impl Rule for UseUniqueArgumentNames {
44+
type Query = Ast<GraphqlArguments>;
45+
type State = ();
46+
type Signals = Option<Self::State>;
47+
type Options = UseUniqueArgumentNamesOptions;
48+
49+
fn run(ctx: &RuleContext<Self>) -> Self::Signals {
50+
let node = ctx.query();
51+
let mut found: HashSet<TokenText> = HashSet::new();
52+
53+
for element in node.arguments() {
54+
if let Some(name) = element.name().ok()
55+
&& let Some(value_token) = name.value_token().ok()
56+
{
57+
let string = value_token.token_text();
58+
if found.contains(&string) {
59+
return Some(());
60+
} else {
61+
found.insert(string);
62+
}
63+
}
64+
}
65+
66+
None
67+
}
68+
69+
fn diagnostic(ctx: &RuleContext<Self>, _state: &Self::State) -> Option<RuleDiagnostic> {
70+
let span = ctx.query().range();
71+
Some(
72+
RuleDiagnostic::new(
73+
rule_category!(),
74+
span,
75+
markup! {
76+
"Duplicate argument name."
77+
},
78+
)
79+
.note(markup! {
80+
"A GraphQL field or directive is only valid if all supplied arguments are uniquely named. Make sure to name every argument differently."
81+
}),
82+
)
83+
}
84+
}

0 commit comments

Comments
 (0)