Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
refactor(rome_js_analyze): rename noRedeclarations to noRedeclare (#4319
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Conaclos authored Mar 26, 2023
1 parent 763fd98 commit 1b08e34
Show file tree
Hide file tree
Showing 23 changed files with 137 additions and 135 deletions.
2 changes: 1 addition & 1 deletion crates/rome_diagnostics_categories/src/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ define_categories! {
"lint/nursery/noParameterAssign": "https://docs.rome.tools/lint/rules/noParameterAssign",
"lint/nursery/noNamespace": "https://docs.rome.tools/lint/rules/noNamespace",
// Insert new nursery rule here
"lint/nursery/noRedeclaration": "https://docs.rome.tools/lint/rules/noRedeclaration",
"lint/nursery/noRedeclare": "https://docs.rome.tools/lint/rules/noRedeclare",
"lint/nursery/useNamespaceKeyword": "https://docs.rome.tools/lint/rules/useNamespaceKeyword",

// performance
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ mod tests {

let mut error_ranges: Vec<TextRange> = Vec::new();
let options = AnalyzerOptions::default();
let rule_filter = RuleFilter::Rule("nursery", "noRedeclaration");
let rule_filter = RuleFilter::Rule("nursery", "noRedeclare");
analyze(
&parsed.tree(),
AnalysisFilter {
Expand Down
4 changes: 2 additions & 2 deletions crates/rome_js_analyze/src/semantic_analyzers/nursery.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use rome_rowan::AstNode;
use std::collections::HashMap;

declare_rule! {
/// Eliminate variables that have multiple declarations in the same scope.
/// Disallow variable, function, class, and type redeclarations in the same scope.
///
/// Source: https://typescript-eslint.io/rules/no-redeclare
///
/// ## Examples
///
Expand Down Expand Up @@ -58,9 +60,9 @@ declare_rule! {
/// bar(a: A, b: B) {}
/// }
/// ```
pub(crate) NoRedeclaration {
pub(crate) NoRedeclare {
version: "12.0.0",
name: "noRedeclaration",
name: "noRedeclare",
recommended: true,
}
}
Expand All @@ -72,7 +74,7 @@ pub(crate) struct Redeclaration {
redeclaration: TextRange,
}

impl Rule for NoRedeclaration {
impl Rule for NoRedeclare {
type Query = SemanticServices;
type State = Redeclaration;
type Signals = Vec<Redeclaration>;
Expand All @@ -96,13 +98,13 @@ impl Rule for NoRedeclaration {
rule_category!(),
redeclaration,
markup! {
"Shouldn't redeclare '"{ name }"'. Consider to delete it or rename it"
"Shouldn't redeclare '"{ name }"'. Consider to delete it or rename it."
},
)
.detail(
declaration,
markup! {
"'"{ name }"' is defined here."
"'"{ name }"' is defined here:"
},
);
Some(diag)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/rome_js_analyze/tests/spec_tests.rs
assertion_line: 91
expression: invalid-declaration-merging.ts
---
# Input
Expand All @@ -26,9 +25,9 @@ enum Order {

# Diagnostics
```
invalid-declaration-merging.ts:4:11 lint/nursery/noRedeclaration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalid-declaration-merging.ts:4:11 lint/nursery/noRedeclare ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Shouldn't redeclare 'Order'. Consider to delete it or rename it
! Shouldn't redeclare 'Order'. Consider to delete it or rename it.
2 │ export type Order = -1 | 0 | 1;
3 │
Expand All @@ -37,7 +36,7 @@ invalid-declaration-merging.ts:4:11 lint/nursery/noRedeclaration ━━━━━
5 │ f(): void;
6 │ }
i 'Order' is defined here.
i 'Order' is defined here:
1 │ // Type and value merging
> 2 │ export type Order = -1 | 0 | 1;
Expand All @@ -49,9 +48,9 @@ invalid-declaration-merging.ts:4:11 lint/nursery/noRedeclaration ━━━━━
```

```
invalid-declaration-merging.ts:8:7 lint/nursery/noRedeclaration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalid-declaration-merging.ts:8:7 lint/nursery/noRedeclare ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Shouldn't redeclare 'Order'. Consider to delete it or rename it
! Shouldn't redeclare 'Order'. Consider to delete it or rename it.
6 │ }
7 │
Expand All @@ -60,7 +59,7 @@ invalid-declaration-merging.ts:8:7 lint/nursery/noRedeclaration ━━━━━
9 │ prop: number;
10 │ }
i 'Order' is defined here.
i 'Order' is defined here:
1 │ // Type and value merging
> 2 │ export type Order = -1 | 0 | 1;
Expand All @@ -72,9 +71,9 @@ invalid-declaration-merging.ts:8:7 lint/nursery/noRedeclaration ━━━━━
```

```
invalid-declaration-merging.ts:12:6 lint/nursery/noRedeclaration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalid-declaration-merging.ts:12:6 lint/nursery/noRedeclare ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Shouldn't redeclare 'Order'. Consider to delete it or rename it
! Shouldn't redeclare 'Order'. Consider to delete it or rename it.
10 │ }
11 │
Expand All @@ -83,7 +82,7 @@ invalid-declaration-merging.ts:12:6 lint/nursery/noRedeclaration ━━━━━
13 │ Lower = -1,
14 │ Equal = 0,
i 'Order' is defined here.
i 'Order' is defined here:
1 │ // Type and value merging
> 2 │ export type Order = -1 | 0 | 1;
Expand Down
Loading

0 comments on commit 1b08e34

Please sign in to comment.