mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(linter): include actual span size in no-regex-spaces diagnostic (#5957)
This commit is contained in:
parent
a9a8e2ad41
commit
eed9ac7c46
2 changed files with 54 additions and 54 deletions
|
|
@ -16,8 +16,8 @@ use oxc_span::Span;
|
||||||
use crate::{context::LintContext, rule::Rule, AstNode};
|
use crate::{context::LintContext, rule::Rule, AstNode};
|
||||||
|
|
||||||
fn no_regex_spaces_diagnostic(span: Span) -> OxcDiagnostic {
|
fn no_regex_spaces_diagnostic(span: Span) -> OxcDiagnostic {
|
||||||
OxcDiagnostic::warn("Spaces are hard to count.")
|
OxcDiagnostic::warn("Multiple consecutive spaces are hard to count.")
|
||||||
.with_help("Use a quantifier, e.g. {2}")
|
.with_help(format!("Use a quantifier: ` {{{size}}}`", size = span.size()))
|
||||||
.with_label(span)
|
.with_label(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,184 +1,184 @@
|
||||||
---
|
---
|
||||||
source: crates/oxc_linter/src/tester.rs
|
source: crates/oxc_linter/src/tester.rs
|
||||||
---
|
---
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:12]
|
╭─[no_regex_spaces.tsx:1:12]
|
||||||
1 │ var foo = / /;
|
1 │ var foo = / /;
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:15]
|
╭─[no_regex_spaces.tsx:1:15]
|
||||||
1 │ var foo = /bar baz/;
|
1 │ var foo = /bar baz/;
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:15]
|
╭─[no_regex_spaces.tsx:1:15]
|
||||||
1 │ var foo = /bar baz/;
|
1 │ var foo = /bar baz/;
|
||||||
· ────
|
· ────
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {4}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:16]
|
╭─[no_regex_spaces.tsx:1:16]
|
||||||
1 │ var foo = / a b c d /;
|
1 │ var foo = / a b c d /;
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:27]
|
╭─[no_regex_spaces.tsx:1:27]
|
||||||
1 │ var foo = RegExp(' a b c d ');
|
1 │ var foo = RegExp(' a b c d ');
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:22]
|
╭─[no_regex_spaces.tsx:1:22]
|
||||||
1 │ var foo = RegExp('bar baz');
|
1 │ var foo = RegExp('bar baz');
|
||||||
· ────
|
· ────
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {4}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:26]
|
╭─[no_regex_spaces.tsx:1:26]
|
||||||
1 │ var foo = new RegExp('bar baz');
|
1 │ var foo = new RegExp('bar baz');
|
||||||
· ────
|
· ────
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {4}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:15]
|
╭─[no_regex_spaces.tsx:1:15]
|
||||||
1 │ var foo = /bar {3}baz/;
|
1 │ var foo = /bar {3}baz/;
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:15]
|
╭─[no_regex_spaces.tsx:1:15]
|
||||||
1 │ var foo = /bar ?baz/;
|
1 │ var foo = /bar ?baz/;
|
||||||
· ───
|
· ───
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {3}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:26]
|
╭─[no_regex_spaces.tsx:1:26]
|
||||||
1 │ var foo = new RegExp('bar *baz')
|
1 │ var foo = new RegExp('bar *baz')
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:22]
|
╭─[no_regex_spaces.tsx:1:22]
|
||||||
1 │ var foo = RegExp('bar +baz')
|
1 │ var foo = RegExp('bar +baz')
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:26]
|
╭─[no_regex_spaces.tsx:1:26]
|
||||||
1 │ var foo = new RegExp('bar ');
|
1 │ var foo = new RegExp('bar ');
|
||||||
· ────
|
· ────
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {4}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:17]
|
╭─[no_regex_spaces.tsx:1:17]
|
||||||
1 │ var foo = /bar\\ baz/;
|
1 │ var foo = /bar\\ baz/;
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:15]
|
╭─[no_regex_spaces.tsx:1:15]
|
||||||
1 │ var foo = /(?: )/;
|
1 │ var foo = /(?: )/;
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:26]
|
╭─[no_regex_spaces.tsx:1:26]
|
||||||
1 │ var foo = RegExp('^foo(?= )');
|
1 │ var foo = RegExp('^foo(?= )');
|
||||||
· ───
|
· ───
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {3}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:14]
|
╭─[no_regex_spaces.tsx:1:14]
|
||||||
1 │ var foo = /\\ /
|
1 │ var foo = /\\ /
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:15]
|
╭─[no_regex_spaces.tsx:1:15]
|
||||||
1 │ var foo = / \\ /
|
1 │ var foo = / \\ /
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:12]
|
╭─[no_regex_spaces.tsx:1:12]
|
||||||
1 │ var foo = / foo /;
|
1 │ var foo = / foo /;
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:25]
|
╭─[no_regex_spaces.tsx:1:25]
|
||||||
1 │ var foo = new RegExp('\\d ')
|
1 │ var foo = new RegExp('\\d ')
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:25]
|
╭─[no_regex_spaces.tsx:1:25]
|
||||||
1 │ var foo = RegExp('\\u0041 ')
|
1 │ var foo = RegExp('\\u0041 ')
|
||||||
· ───
|
· ───
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {3}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:17]
|
╭─[no_regex_spaces.tsx:1:17]
|
||||||
1 │ var foo = /[ ] /;
|
1 │ var foo = /[ ] /;
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:12]
|
╭─[no_regex_spaces.tsx:1:12]
|
||||||
1 │ var foo = / [ ] /;
|
1 │ var foo = / [ ] /;
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:19]
|
╭─[no_regex_spaces.tsx:1:19]
|
||||||
1 │ var foo = RegExp(' [ ]');
|
1 │ var foo = RegExp(' [ ]');
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:24]
|
╭─[no_regex_spaces.tsx:1:24]
|
||||||
1 │ var foo = /[[ ] ] /v;
|
1 │ var foo = /[[ ] ] /v;
|
||||||
· ────
|
· ────
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {4}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:28]
|
╭─[no_regex_spaces.tsx:1:28]
|
||||||
1 │ var foo = new RegExp('[ ] ');
|
1 │ var foo = new RegExp('[ ] ');
|
||||||
· ──
|
· ──
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {2}`
|
||||||
|
|
||||||
⚠ eslint(no-regex-spaces): Spaces are hard to count.
|
⚠ eslint(no-regex-spaces): Multiple consecutive spaces are hard to count.
|
||||||
╭─[no_regex_spaces.tsx:1:30]
|
╭─[no_regex_spaces.tsx:1:30]
|
||||||
1 │ var foo = new RegExp('[[ ] ] ', 'v');
|
1 │ var foo = new RegExp('[[ ] ] ', 'v');
|
||||||
· ────
|
· ────
|
||||||
╰────
|
╰────
|
||||||
help: Use a quantifier, e.g. {2}
|
help: Use a quantifier: ` {4}`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue