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

Commit

Permalink
moving linter to support ts
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Aug 4, 2022
1 parent d1e5e20 commit ac87f6d
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 60 deletions.
1 change: 1 addition & 0 deletions crates/rome_js_analyze/src/registry.rs

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

2 changes: 2 additions & 0 deletions crates/rome_js_analyze/src/semantic_analyzers.rs

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

3 changes: 1 addition & 2 deletions crates/rome_js_analyze/src/semantic_analyzers/js.rs

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

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

3 changes: 2 additions & 1 deletion crates/rome_js_analyze/tests/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ fn run_test(input: &'static str, _: &str, _: &str, _: &str) {
let parsed = parse(&input_code, 0, source_type);
let root = parsed.tree();

let (group, rule) = parse_test_path(input_file);
let (group, rule) = dbg!(parse_test_path(input_file));

let rule_filter = RuleFilter::Rule(group, rule);
let filter = AnalysisFilter {
enabled_rules: Some(slice::from_ref(&rule_filter)),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ try {

# Diagnostics
```
warning[js/noUnusedVariables]: This variable is unused.
warning[no_unused_variables/noUnusedVariables]: This variable is unused.
┌─ noUnusedVariables.js:1:7
1 │ const a = 1;
Expand All @@ -68,7 +68,7 @@ Suggested fix: Remove this variable.
```

```
warning[js/noUnusedVariables]: This variable is unused.
warning[no_unused_variables/noUnusedVariables]: This variable is unused.
┌─ noUnusedVariables.js:2:7
2 │ const b = 2,
Expand All @@ -89,7 +89,7 @@ Suggested fix: Remove this variable.
```

```
warning[js/noUnusedVariables]: This function is unused.
warning[no_unused_variables/noUnusedVariables]: This function is unused.
┌─ noUnusedVariables.js:6:10
6 │ function f1() {}
Expand All @@ -112,7 +112,7 @@ Suggested fix: Remove this function.
```

```
warning[js/noUnusedVariables]: This function is unused.
warning[no_unused_variables/noUnusedVariables]: This function is unused.
┌─ noUnusedVariables.js:8:10
8 │ function f2() {
Expand All @@ -137,7 +137,7 @@ Suggested fix: Remove this function.
```
```
warning[js/noUnusedVariables]: This function is unused.
warning[no_unused_variables/noUnusedVariables]: This function is unused.
┌─ noUnusedVariables.js:12:10
12 │ function f3() {
Expand Down Expand Up @@ -165,7 +165,7 @@ Suggested fix: Remove this function.
```
```
warning[js/noUnusedVariables]: This parameter is unused.
warning[no_unused_variables/noUnusedVariables]: This parameter is unused.
┌─ noUnusedVariables.js:19:14
19function f41(a) {}
Expand All @@ -188,7 +188,7 @@ Suggested fix: Remove this parameter.
```
```
warning[js/noUnusedVariables]: This parameter is unused.
warning[no_unused_variables/noUnusedVariables]: This parameter is unused.
┌─ noUnusedVariables.js:22:17
22function f42(a, b) {
Expand All @@ -211,7 +211,7 @@ Suggested fix: Remove this parameter.
```
```
warning[js/noUnusedVariables]: This parameter is unused.
warning[no_unused_variables/noUnusedVariables]: This parameter is unused.
┌─ noUnusedVariables.js:27:17
27function f43(a, b) {
Expand All @@ -234,7 +234,7 @@ Suggested fix: Remove this parameter.
```
```
warning[js/noUnusedVariables]: This variable is unused.
warning[no_unused_variables/noUnusedVariables]: This variable is unused.
┌─ noUnusedVariables.js:32:7
32const f5 = () => {};
Expand All @@ -257,7 +257,7 @@ Suggested fix: Remove this variable.
```
```
warning[js/noUnusedVariables]: This variable is unused.
warning[no_unused_variables/noUnusedVariables]: This variable is unused.
┌─ noUnusedVariables.js:34:7
34const f6 = () => {
Expand All @@ -281,7 +281,7 @@ Suggested fix: Remove this variable.
```
```
warning[js/noUnusedVariables]: This variable is unused.
warning[no_unused_variables/noUnusedVariables]: This variable is unused.
┌─ noUnusedVariables.js:39:10
39 │ } catch (e) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
source: crates/rome_js_analyze/tests/spec_tests.rs
expression: noUnusedVariables.ts
---
# Input
```js
// Invalid
class D {
constructor(a: number) {}
f(a: number) {}
set a(a: number) {}
}
console.log(new D());
// Valid
interface A {
f(a: number);
set a(a: number);
[key: string]: string;
}
abstract class B {
constructor(a: number);
abstract f(a: number);
g(a: number);
abstract set a(a: number);
}
console.log(new B());
class C {
constructor(a: number);
f(a: number);
}
console.log(new C());
```

# Diagnostics
```
warning[no_unused_variables/noUnusedVariables]: This parameter is unused.
┌─ noUnusedVariables.ts:4:14
4 │ constructor(a: number) {}
│ -
Suggested fix: Remove this parameter.
| @@ -1,7 +1,7 @@
0 0 | // Invalid
1 1 |
2 2 | class D {
3 | - constructor(a: number) {}
3 | + constructor() {}
4 4 | f(a: number) {}
5 5 | set a(a: number) {}
6 6 | }
= note: Unused variables usually are result of incomplete refactoring, typos and other source of bugs.
```

```
warning[no_unused_variables/noUnusedVariables]: This parameter is unused.
┌─ noUnusedVariables.ts:5:4
5 │ f(a: number) {}
│ -
Suggested fix: Remove this parameter.
| @@ -2,7 +2,7 @@
1 1 |
2 2 | class D {
3 3 | constructor(a: number) {}
4 | - f(a: number) {}
4 | + f() {}
5 5 | set a(a: number) {}
6 6 | }
7 7 | console.log(new D());
= note: Unused variables usually are result of incomplete refactoring, typos and other source of bugs.
```

```
warning[no_unused_variables/noUnusedVariables]: This parameter is unused.
┌─ noUnusedVariables.ts:6:8
6 │ set a(a: number) {}
│ -
= note: Unused variables usually are result of incomplete refactoring, typos and other source of bugs.
```


Loading

0 comments on commit ac87f6d

Please sign in to comment.