mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(linter): change severity of no-sparse-arrays to warnings
This commit is contained in:
parent
f6047b6531
commit
66e95a5968
2 changed files with 16 additions and 14 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
use miette::{miette, LabeledSpan};
|
use miette::{miette, LabeledSpan};
|
||||||
use oxc_ast::{ast::ArrayExpressionElement, AstKind};
|
use oxc_ast::{ast::ArrayExpressionElement, AstKind};
|
||||||
use oxc_diagnostics::{
|
use oxc_diagnostics::{
|
||||||
miette::{self, Diagnostic},
|
miette::{self, Diagnostic, Severity},
|
||||||
thiserror::Error,
|
thiserror::Error,
|
||||||
};
|
};
|
||||||
use oxc_macros::declare_oxc_lint;
|
use oxc_macros::declare_oxc_lint;
|
||||||
|
|
@ -56,6 +56,7 @@ impl Rule for NoSparseArrays {
|
||||||
if !violations.is_empty() {
|
if !violations.is_empty() {
|
||||||
if violations.len() < 10 {
|
if violations.len() < 10 {
|
||||||
ctx.diagnostic(miette!(
|
ctx.diagnostic(miette!(
|
||||||
|
severity = Severity::Warning,
|
||||||
labels = violations,
|
labels = violations,
|
||||||
help = "remove the comma or insert `undefined`",
|
help = "remove the comma or insert `undefined`",
|
||||||
"eslint(no-sparse-arrays): Unexpected comma in middle of array"
|
"eslint(no-sparse-arrays): Unexpected comma in middle of array"
|
||||||
|
|
@ -71,6 +72,7 @@ impl Rule for NoSparseArrays {
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.diagnostic(miette!(
|
ctx.diagnostic(miette!(
|
||||||
|
severity = Severity::Warning,
|
||||||
labels = vec![span],
|
labels = vec![span],
|
||||||
help = "remove the comma or insert `undefined`",
|
help = "remove the comma or insert `undefined`",
|
||||||
"eslint(no-sparse-arrays): {} unexpected commas in middle of array",
|
"eslint(no-sparse-arrays): {} unexpected commas in middle of array",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
source: crates/oxc_linter/src/tester.rs
|
source: crates/oxc_linter/src/tester.rs
|
||||||
expression: no_sparse_arrays
|
expression: no_sparse_arrays
|
||||||
---
|
---
|
||||||
× eslint(no-sparse-arrays): Unexpected comma in middle of array
|
⚠ eslint(no-sparse-arrays): Unexpected comma in middle of array
|
||||||
╭─[no_sparse_arrays.tsx:1:1]
|
╭─[no_sparse_arrays.tsx:1:1]
|
||||||
1 │ var a = [,];
|
1 │ var a = [,];
|
||||||
· ▲
|
· ▲
|
||||||
|
|
@ -10,7 +10,7 @@ expression: no_sparse_arrays
|
||||||
╰────
|
╰────
|
||||||
help: remove the comma or insert `undefined`
|
help: remove the comma or insert `undefined`
|
||||||
|
|
||||||
× eslint(no-sparse-arrays): Unexpected comma in middle of array
|
⚠ eslint(no-sparse-arrays): Unexpected comma in middle of array
|
||||||
╭─[no_sparse_arrays.tsx:1:1]
|
╭─[no_sparse_arrays.tsx:1:1]
|
||||||
1 │ var a = [ 1,, 2];
|
1 │ var a = [ 1,, 2];
|
||||||
· ▲
|
· ▲
|
||||||
|
|
@ -18,7 +18,7 @@ expression: no_sparse_arrays
|
||||||
╰────
|
╰────
|
||||||
help: remove the comma or insert `undefined`
|
help: remove the comma or insert `undefined`
|
||||||
|
|
||||||
× eslint(no-sparse-arrays): Unexpected comma in middle of array
|
⚠ eslint(no-sparse-arrays): Unexpected comma in middle of array
|
||||||
╭─[no_sparse_arrays.tsx:1:1]
|
╭─[no_sparse_arrays.tsx:1:1]
|
||||||
1 │ var a = [ 1,,,, 2];
|
1 │ var a = [ 1,,,, 2];
|
||||||
· ▲▲▲
|
· ▲▲▲
|
||||||
|
|
@ -28,7 +28,7 @@ expression: no_sparse_arrays
|
||||||
╰────
|
╰────
|
||||||
help: remove the comma or insert `undefined`
|
help: remove the comma or insert `undefined`
|
||||||
|
|
||||||
× eslint(no-sparse-arrays): 30 unexpected commas in middle of array
|
⚠ eslint(no-sparse-arrays): 30 unexpected commas in middle of array
|
||||||
╭─[no_sparse_arrays.tsx:1:1]
|
╭─[no_sparse_arrays.tsx:1:1]
|
||||||
1 │ var a = [ 1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2];
|
1 │ var a = [ 1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2];
|
||||||
· ──────────────────┬──────────────────
|
· ──────────────────┬──────────────────
|
||||||
|
|
@ -36,7 +36,7 @@ expression: no_sparse_arrays
|
||||||
╰────
|
╰────
|
||||||
help: remove the comma or insert `undefined`
|
help: remove the comma or insert `undefined`
|
||||||
|
|
||||||
× eslint(no-sparse-arrays): 83 unexpected commas in middle of array
|
⚠ eslint(no-sparse-arrays): 83 unexpected commas in middle of array
|
||||||
╭─[no_sparse_arrays.tsx:1:1]
|
╭─[no_sparse_arrays.tsx:1:1]
|
||||||
1 │ var a = [ 1, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 2];
|
1 │ var a = [ 1, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 2];
|
||||||
· ▲
|
· ▲
|
||||||
|
|
@ -44,7 +44,7 @@ expression: no_sparse_arrays
|
||||||
╰────
|
╰────
|
||||||
help: remove the comma or insert `undefined`
|
help: remove the comma or insert `undefined`
|
||||||
|
|
||||||
× eslint(no-sparse-arrays): 82 unexpected commas in middle of array
|
⚠ eslint(no-sparse-arrays): 82 unexpected commas in middle of array
|
||||||
╭─[no_sparse_arrays.tsx:1:1]
|
╭─[no_sparse_arrays.tsx:1:1]
|
||||||
1 │ var a = [ 1, , , , , , , , , , , , , , , , , , , , , , , , , , hello, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 2];
|
1 │ var a = [ 1, , , , , , , , , , , , , , , , , , , , , , , , , , hello, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 2];
|
||||||
· ▲
|
· ▲
|
||||||
|
|
@ -52,7 +52,7 @@ expression: no_sparse_arrays
|
||||||
╰────
|
╰────
|
||||||
help: remove the comma or insert `undefined`
|
help: remove the comma or insert `undefined`
|
||||||
|
|
||||||
× eslint(no-sparse-arrays): 81 unexpected commas in middle of array
|
⚠ eslint(no-sparse-arrays): 81 unexpected commas in middle of array
|
||||||
╭─[no_sparse_arrays.tsx:1:1]
|
╭─[no_sparse_arrays.tsx:1:1]
|
||||||
1 │ var a = [ 1, , , , , , , , , , , , , , , , , , , , , , , , , ,
|
1 │ var a = [ 1, , , , , , , , , , , , , , , , , , , , , , , , , ,
|
||||||
· ▲
|
· ▲
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue