Skip to content

Commit

Permalink
fix(linter): include actual span size in no-regex-spaces diagnostic (
Browse files Browse the repository at this point in the history
  • Loading branch information
camchenry committed Sep 22, 2024
1 parent a9a8e2a commit eed9ac7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 54 deletions.
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_regex_spaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
104 changes: 52 additions & 52 deletions crates/oxc_linter/src/snapshots/no_regex_spaces.snap
Original file line number Diff line number Diff line change
@@ -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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var 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]
1var foo = new RegExp('[[ ] ] ', 'v');
· ────
╰────
help: Use a quantifier, e.g. {2}
help: Use a quantifier: ` {4}`

0 comments on commit eed9ac7

Please sign in to comment.