fix(linter): include actual span size in no-regex-spaces diagnostic (#5957)

This commit is contained in:
camchenry 2024-09-22 04:45:40 +00:00
parent a9a8e2ad41
commit eed9ac7c46
2 changed files with 54 additions and 54 deletions

View file

@ -16,8 +16,8 @@ use oxc_span::Span;
use crate::{context::LintContext, rule::Rule, AstNode};
fn no_regex_spaces_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Spaces are hard to count.")
.with_help("Use a quantifier, e.g. {2}")
OxcDiagnostic::warn("Multiple consecutive spaces are hard to count.")
.with_help(format!("Use a quantifier: ` {{{size}}}`", size = span.size()))
.with_label(span)
}

View file

@ -1,184 +1,184 @@
---
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
1 │ var foo = new RegExp('[[ ] ] ', 'v');
· ────
╰────
help: Use a quantifier, e.g. {2}
help: Use a quantifier: ` {4}`