From f0f1ee1b0de3b94eac2d21d893270a567b39ffa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michell=20Oca=C3=B1a?= Date: Wed, 3 Jul 2024 18:37:54 -0300 Subject: [PATCH] feat(lint/noIrregularWhitespace): improve whitespace validation --- .../lint/nursery/no_irregular_whitespace.rs | 55 ++--- .../nursery/noIrregularWhitespace/invalid.js | 2 - .../noIrregularWhitespace/invalid.js.snap | 214 ++++++++---------- .../nursery/noIrregularWhitespace/valid.js | 2 - .../noIrregularWhitespace/valid.js.snap | 2 - 5 files changed, 113 insertions(+), 162 deletions(-) diff --git a/crates/biome_js_analyze/src/lint/nursery/no_irregular_whitespace.rs b/crates/biome_js_analyze/src/lint/nursery/no_irregular_whitespace.rs index 61eeed98a5e1..7ac0adfa25f5 100644 --- a/crates/biome_js_analyze/src/lint/nursery/no_irregular_whitespace.rs +++ b/crates/biome_js_analyze/src/lint/nursery/no_irregular_whitespace.rs @@ -1,7 +1,7 @@ use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic}; use biome_console::markup; use biome_js_syntax::AnyJsStatement; -use biome_rowan::{AstNode, TextRange, TextSize}; +use biome_rowan::{AstNode, Direction}; const IRREGULAR_WHITESPACES: &[char; 22] = &[ '\u{c}', '\u{b}', '\u{85}', '\u{feff}', '\u{a0}', '\u{1680}', '\u{180e}', '\u{2000}', @@ -52,6 +52,12 @@ impl Rule for NoIrregularWhitespace { fn run(ctx: &RuleContext) -> Self::Signals { let node = ctx.query(); + // let syntax = node.syntax(); + + // for tree in syntax.descendants_tokens(Direction::Next) { + // dbg!(tree.leading_trivia(), tree.trailing_trivia()); + // } + get_irregular_whitespace(node) } @@ -75,36 +81,23 @@ impl Rule for NoIrregularWhitespace { fn get_irregular_whitespace(node: &AnyJsStatement) -> Option<()> { let syntax = node.syntax(); - let node_text = syntax.text_trimmed(); - let range_start: u32 = node.range().start().into(); - - IRREGULAR_WHITESPACES - .iter() - .find_map(|whitespace_character| { - let text_size = node_text - .find_char(*whitespace_character)? - .checked_add(TextSize::from(range_start))?; - let text_range = TextRange::new(text_size, text_size); + let has_irregular_whitespace = syntax.descendants_tokens(Direction::Next).any(|token| { + let pieces = token + .leading_trivia() + .pieces() + .chain(token.trailing_trivia().pieces()); - let element_at_index = node - .range() - .contains(text_size) - .then(|| syntax.covering_element(text_range))?; - - let is_string_literal = matches!( - element_at_index.kind(), - biome_js_syntax::JsSyntaxKind::JS_STRING_LITERAL - | biome_js_syntax::JsSyntaxKind::JSX_TEXT_LITERAL - | biome_js_syntax::JsSyntaxKind::TEMPLATE_CHUNK - ); - - if is_string_literal { - return None; - } + pieces.filter(|trivia| trivia.is_whitespace()).any( + |trivia: biome_rowan::SyntaxTriviaPiece| { + IRREGULAR_WHITESPACES.iter().any(|irregular_whitespace| { + trivia + .text() + .chars() + .any(|char| &char == irregular_whitespace) + }) + }, + ) + }); - node_text - .chars() - .find(|char| whitespace_character.eq(char)) - .and(Some(())) - }) + has_irregular_whitespace.then_some(()) } diff --git a/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/invalid.js b/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/invalid.js index 81c77093a29e..1447546409bf 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/invalid.js +++ b/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/invalid.js @@ -1,10 +1,8 @@ /* \u{b} */ const foo = 'thing'; /* \u{c} */ const foo = 'thing'; -/* \u{85} */ const…foo…=…'thing'; /* \u{feff} */ constfoo='thing'; /* \u{a0} */ const foo = 'thing'; /* \u{1680} */ const foo = 'thing'; -/* \u{180e} */ const᠎foo᠎=᠎'thing'; /* \u{2000} */ const foo = 'thing'; /* \u{2001} */ const foo = 'thing'; /* \u{2002} */ const foo = 'thing'; diff --git a/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/invalid.js.snap b/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/invalid.js.snap index 39f6a9c48ea9..9e38a3a11268 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/invalid.js.snap +++ b/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/invalid.js.snap @@ -6,11 +6,9 @@ expression: invalid.js ```jsx /* \u{b} */ const foo = 'thing'; /* \u{c} */ const foo = 'thing'; -/* \u{85} */ const…foo…=…'thing'; /* \u{feff} */ constfoo='thing'; /* \u{a0} */ const foo = 'thing'; /* \u{1680} */ const foo = 'thing'; -/* \u{180e} */ const᠎foo᠎=᠎'thing'; /* \u{2000} */ const foo = 'thing'; /* \u{2001} */ const foo = 'thing'; /* \u{2002} */ const foo = 'thing'; @@ -38,7 +36,7 @@ invalid.js:1:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ > 1 │ /* \u{b} */ const␋foo␋=␋'thing'; │ ^^^^^^^^^^^^^^^^^^^^ 2 │ /* \u{c} */ const↡foo↡=↡'thing'; - 3 │ /* \u{85} */ const␠foo␠=␠'thing'; + 3 │ /* \u{feff} */ const�foo�=�'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -53,8 +51,8 @@ invalid.js:2:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ 1 │ /* \u{b} */ const␋foo␋=␋'thing'; > 2 │ /* \u{c} */ const↡foo↡=↡'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 3 │ /* \u{85} */ const␠foo␠=␠'thing'; - 4 │ /* \u{feff} */ const�foo�=�'thing'; + 3 │ /* \u{feff} */ const�foo�=�'thing'; + 4 │ /* \u{a0} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -68,10 +66,10 @@ invalid.js:3:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ 1 │ /* \u{b} */ const␋foo␋=␋'thing'; 2 │ /* \u{c} */ const↡foo↡=↡'thing'; - > 3 │ /* \u{85} */ const␠foo␠=␠'thing'; + > 3 │ /* \u{feff} */ const�foo�=�'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 4 │ /* \u{feff} */ const�foo�=�'thing'; - 5 │ /* \u{a0} */ const␠foo␠=␠'thing'; + 4 │ /* \u{a0} */ const␠foo␠=␠'thing'; + 5 │ /* \u{1680} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -84,11 +82,11 @@ invalid.js:4:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. 2 │ /* \u{c} */ const↡foo↡=↡'thing'; - 3 │ /* \u{85} */ const␠foo␠=␠'thing'; - > 4 │ /* \u{feff} */ const�foo�=�'thing'; + 3 │ /* \u{feff} */ const�foo�=�'thing'; + > 4 │ /* \u{a0} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 5 │ /* \u{a0} */ const␠foo␠=␠'thing'; - 6 │ /* \u{1680} */ const␠foo␠=␠'thing'; + 5 │ /* \u{1680} */ const␠foo␠=␠'thing'; + 6 │ /* \u{2000} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -100,12 +98,12 @@ invalid.js:5:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 3 │ /* \u{85} */ const␠foo␠=␠'thing'; - 4 │ /* \u{feff} */ const�foo�=�'thing'; - > 5 │ /* \u{a0} */ const␠foo␠=␠'thing'; + 3 │ /* \u{feff} */ const�foo�=�'thing'; + 4 │ /* \u{a0} */ const␠foo␠=␠'thing'; + > 5 │ /* \u{1680} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 6 │ /* \u{1680} */ const␠foo␠=␠'thing'; - 7 │ /* \u{180e} */ const�foo�=�'thing'; + 6 │ /* \u{2000} */ const␠foo␠=␠'thing'; + 7 │ /* \u{2001} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -117,12 +115,12 @@ invalid.js:6:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 4 │ /* \u{feff} */ const�foo�=�'thing'; - 5 │ /* \u{a0} */ const␠foo␠=␠'thing'; - > 6 │ /* \u{1680} */ const␠foo␠=␠'thing'; + 4 │ /* \u{a0} */ const␠foo␠=␠'thing'; + 5 │ /* \u{1680} */ const␠foo␠=␠'thing'; + > 6 │ /* \u{2000} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 7 │ /* \u{180e} */ const�foo�=�'thing'; - 8 │ /* \u{2000} */ const␠foo␠=␠'thing'; + 7 │ /* \u{2001} */ const␠foo␠=␠'thing'; + 8 │ /* \u{2002} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -134,12 +132,12 @@ invalid.js:7:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 5 │ /* \u{a0} */ const␠foo␠=␠'thing'; - 6 │ /* \u{1680} */ const␠foo␠=␠'thing'; - > 7 │ /* \u{180e} */ const�foo�=�'thing'; + 5 │ /* \u{1680} */ const␠foo␠=␠'thing'; + 6 │ /* \u{2000} */ const␠foo␠=␠'thing'; + > 7 │ /* \u{2001} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 8 │ /* \u{2000} */ const␠foo␠=␠'thing'; - 9 │ /* \u{2001} */ const␠foo␠=␠'thing'; + 8 │ /* \u{2002} */ const␠foo␠=␠'thing'; + 9 │ /* \u{2003} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -151,12 +149,12 @@ invalid.js:8:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 6 │ /* \u{1680} */ const␠foo␠=␠'thing'; - 7 │ /* \u{180e} */ const�foo�=�'thing'; - > 8 │ /* \u{2000} */ const␠foo␠=␠'thing'; + 6 │ /* \u{2000} */ const␠foo␠=␠'thing'; + 7 │ /* \u{2001} */ const␠foo␠=␠'thing'; + > 8 │ /* \u{2002} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 9 │ /* \u{2001} */ const␠foo␠=␠'thing'; - 10 │ /* \u{2002} */ const␠foo␠=␠'thing'; + 9 │ /* \u{2003} */ const␠foo␠=␠'thing'; + 10 │ /* \u{2004} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -168,12 +166,12 @@ invalid.js:9:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 7 │ /* \u{180e} */ const�foo�=�'thing'; - 8 │ /* \u{2000} */ const␠foo␠=␠'thing'; - > 9 │ /* \u{2001} */ const␠foo␠=␠'thing'; + 7 │ /* \u{2001} */ const␠foo␠=␠'thing'; + 8 │ /* \u{2002} */ const␠foo␠=␠'thing'; + > 9 │ /* \u{2003} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 10 │ /* \u{2002} */ const␠foo␠=␠'thing'; - 11 │ /* \u{2003} */ const␠foo␠=␠'thing'; + 10 │ /* \u{2004} */ const␠foo␠=␠'thing'; + 11 │ /* \u{2005} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -185,12 +183,12 @@ invalid.js:10:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 8 │ /* \u{2000} */ const␠foo␠=␠'thing'; - 9 │ /* \u{2001} */ const␠foo␠=␠'thing'; - > 10 │ /* \u{2002} */ const␠foo␠=␠'thing'; + 8 │ /* \u{2002} */ const␠foo␠=␠'thing'; + 9 │ /* \u{2003} */ const␠foo␠=␠'thing'; + > 10 │ /* \u{2004} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 11 │ /* \u{2003} */ const␠foo␠=␠'thing'; - 12 │ /* \u{2004} */ const␠foo␠=␠'thing'; + 11 │ /* \u{2005} */ const␠foo␠=␠'thing'; + 12 │ /* \u{2006} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -202,12 +200,12 @@ invalid.js:11:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 9 │ /* \u{2001} */ const␠foo␠=␠'thing'; - 10 │ /* \u{2002} */ const␠foo␠=␠'thing'; - > 11 │ /* \u{2003} */ const␠foo␠=␠'thing'; + 9 │ /* \u{2003} */ const␠foo␠=␠'thing'; + 10 │ /* \u{2004} */ const␠foo␠=␠'thing'; + > 11 │ /* \u{2005} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 12 │ /* \u{2004} */ const␠foo␠=␠'thing'; - 13 │ /* \u{2005} */ const␠foo␠=␠'thing'; + 12 │ /* \u{2006} */ const␠foo␠=␠'thing'; + 13 │ /* \u{2007} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -219,12 +217,12 @@ invalid.js:12:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 10 │ /* \u{2002} */ const␠foo␠=␠'thing'; - 11 │ /* \u{2003} */ const␠foo␠=␠'thing'; - > 12 │ /* \u{2004} */ const␠foo␠=␠'thing'; + 10 │ /* \u{2004} */ const␠foo␠=␠'thing'; + 11 │ /* \u{2005} */ const␠foo␠=␠'thing'; + > 12 │ /* \u{2006} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 13 │ /* \u{2005} */ const␠foo␠=␠'thing'; - 14 │ /* \u{2006} */ const␠foo␠=␠'thing'; + 13 │ /* \u{2007} */ const␠foo␠=␠'thing'; + 14 │ /* \u{2008} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -236,12 +234,12 @@ invalid.js:13:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 11 │ /* \u{2003} */ const␠foo␠=␠'thing'; - 12 │ /* \u{2004} */ const␠foo␠=␠'thing'; - > 13 │ /* \u{2005} */ const␠foo␠=␠'thing'; + 11 │ /* \u{2005} */ const␠foo␠=␠'thing'; + 12 │ /* \u{2006} */ const␠foo␠=␠'thing'; + > 13 │ /* \u{2007} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 14 │ /* \u{2006} */ const␠foo␠=␠'thing'; - 15 │ /* \u{2007} */ const␠foo␠=␠'thing'; + 14 │ /* \u{2008} */ const␠foo␠=␠'thing'; + 15 │ /* \u{2009} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -253,12 +251,12 @@ invalid.js:14:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 12 │ /* \u{2004} */ const␠foo␠=␠'thing'; - 13 │ /* \u{2005} */ const␠foo␠=␠'thing'; - > 14 │ /* \u{2006} */ const␠foo␠=␠'thing'; + 12 │ /* \u{2006} */ const␠foo␠=␠'thing'; + 13 │ /* \u{2007} */ const␠foo␠=␠'thing'; + > 14 │ /* \u{2008} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 15 │ /* \u{2007} */ const␠foo␠=␠'thing'; - 16 │ /* \u{2008} */ const␠foo␠=␠'thing'; + 15 │ /* \u{2009} */ const␠foo␠=␠'thing'; + 16 │ /* \u{200a} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -270,12 +268,12 @@ invalid.js:15:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 13 │ /* \u{2005} */ const␠foo␠=␠'thing'; - 14 │ /* \u{2006} */ const␠foo␠=␠'thing'; - > 15 │ /* \u{2007} */ const␠foo␠=␠'thing'; + 13 │ /* \u{2007} */ const␠foo␠=␠'thing'; + 14 │ /* \u{2008} */ const␠foo␠=␠'thing'; + > 15 │ /* \u{2009} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 16 │ /* \u{2008} */ const␠foo␠=␠'thing'; - 17 │ /* \u{2009} */ const␠foo␠=␠'thing'; + 16 │ /* \u{200a} */ const␠foo␠=␠'thing'; + 17 │ /* \u{200b} */ const�foo�=�'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -287,12 +285,12 @@ invalid.js:16:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 14 │ /* \u{2006} */ const␠foo␠=␠'thing'; - 15 │ /* \u{2007} */ const␠foo␠=␠'thing'; - > 16 │ /* \u{2008} */ const␠foo␠=␠'thing'; + 14 │ /* \u{2008} */ const␠foo␠=␠'thing'; + 15 │ /* \u{2009} */ const␠foo␠=␠'thing'; + > 16 │ /* \u{200a} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 17 │ /* \u{2009} */ const␠foo␠=␠'thing'; - 18 │ /* \u{200a} */ const␠foo␠=␠'thing'; + 17 │ /* \u{200b} */ const�foo�=�'thing'; + 18 │ /* \u{202f} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -304,12 +302,12 @@ invalid.js:17:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 15 │ /* \u{2007} */ const␠foo␠=␠'thing'; - 16 │ /* \u{2008} */ const␠foo␠=␠'thing'; - > 17 │ /* \u{2009} */ const␠foo␠=␠'thing'; + 15 │ /* \u{2009} */ const␠foo␠=␠'thing'; + 16 │ /* \u{200a} */ const␠foo␠=␠'thing'; + > 17 │ /* \u{200b} */ const�foo�=�'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 18 │ /* \u{200a} */ const␠foo␠=␠'thing'; - 19 │ /* \u{200b} */ const�foo�=�'thing'; + 18 │ /* \u{202f} */ const␠foo␠=␠'thing'; + 19 │ /* \u{205f} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -321,12 +319,12 @@ invalid.js:18:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 16 │ /* \u{2008} */ const␠foo␠=␠'thing'; - 17 │ /* \u{2009} */ const␠foo␠=␠'thing'; - > 18 │ /* \u{200a} */ const␠foo␠=␠'thing'; + 16 │ /* \u{200a} */ const␠foo␠=␠'thing'; + 17 │ /* \u{200b} */ const�foo�=�'thing'; + > 18 │ /* \u{202f} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 19 │ /* \u{200b} */ const�foo�=�'thing'; - 20 │ /* \u{202f} */ const␠foo␠=␠'thing'; + 19 │ /* \u{205f} */ const␠foo␠=␠'thing'; + 20 │ /* \u{3000} */ const␠foo␠=␠'thing'; i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -338,12 +336,12 @@ invalid.js:19:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 17 │ /* \u{2009} */ const␠foo␠=␠'thing'; - 18 │ /* \u{200a} */ const␠foo␠=␠'thing'; - > 19 │ /* \u{200b} */ const�foo�=�'thing'; + 17 │ /* \u{200b} */ const�foo�=�'thing'; + 18 │ /* \u{202f} */ const␠foo␠=␠'thing'; + > 19 │ /* \u{205f} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 20 │ /* \u{202f} */ const␠foo␠=␠'thing'; - 21 │ /* \u{205f} */ const␠foo␠=␠'thing'; + 20 │ /* \u{3000} */ const␠foo␠=␠'thing'; + 21 │ i Replace the irregular whitespaces with normal whitespaces or tabs. @@ -355,45 +353,11 @@ invalid.js:20:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━ ! Irregular whitespaces found. - 18 │ /* \u{200a} */ const␠foo␠=␠'thing'; - 19 │ /* \u{200b} */ const�foo�=�'thing'; - > 20 │ /* \u{202f} */ const␠foo␠=␠'thing'; + 18 │ /* \u{202f} */ const␠foo␠=␠'thing'; + 19 │ /* \u{205f} */ const␠foo␠=␠'thing'; + > 20 │ /* \u{3000} */ const␠foo␠=␠'thing'; │ ^^^^^^^^^^^^^^^^^^^^ - 21 │ /* \u{205f} */ const␠foo␠=␠'thing'; - 22 │ /* \u{3000} */ const␠foo␠=␠'thing'; - - i Replace the irregular whitespaces with normal whitespaces or tabs. - - -``` - -``` -invalid.js:21:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Irregular whitespaces found. - - 19 │ /* \u{200b} */ const�foo�=�'thing'; - 20 │ /* \u{202f} */ const␠foo␠=␠'thing'; - > 21 │ /* \u{205f} */ const␠foo␠=␠'thing'; - │ ^^^^^^^^^^^^^^^^^^^^ - 22 │ /* \u{3000} */ const␠foo␠=␠'thing'; - 23 │ - - i Replace the irregular whitespaces with normal whitespaces or tabs. - - -``` - -``` -invalid.js:22:16 lint/nursery/noIrregularWhitespace ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Irregular whitespaces found. - - 20 │ /* \u{202f} */ const␠foo␠=␠'thing'; - 21 │ /* \u{205f} */ const␠foo␠=␠'thing'; - > 22 │ /* \u{3000} */ const␠foo␠=␠'thing'; - │ ^^^^^^^^^^^^^^^^^^^^ - 23 │ + 21 │ i Replace the irregular whitespaces with normal whitespaces or tabs. diff --git a/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/valid.js b/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/valid.js index f9c1e387973f..316e1c11b9cd 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/valid.js +++ b/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/valid.js @@ -26,11 +26,9 @@ const foo = '\\\u2029'; /* \u{b} */ const foo = ' '; /* \u{c} */ const foo = ' '; /* \u{20} */ const foo = ' '; -/* \u{85} */ const foo = '…'; /* \u{feff} */ const foo = ''; /* \u{a0} */ const foo = ' '; /* \u{1680} */ const foo = ' '; -/* \u{180e} */ const foo = '᠎'; /* \u{2000} */ const foo = ' '; /* \u{2001} */ const foo = ' '; /* \u{2002} */ const foo = ' '; diff --git a/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/valid.js.snap b/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/valid.js.snap index aff53659f41e..08cb22fda1f3 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/valid.js.snap +++ b/crates/biome_js_analyze/tests/specs/nursery/noIrregularWhitespace/valid.js.snap @@ -32,11 +32,9 @@ const foo = '\\\u2029'; /* \u{b} */ const foo = ' '; /* \u{c} */ const foo = ' '; /* \u{20} */ const foo = ' '; -/* \u{85} */ const foo = '…'; /* \u{feff} */ const foo = ''; /* \u{a0} */ const foo = ' '; /* \u{1680} */ const foo = ' '; -/* \u{180e} */ const foo = '᠎'; /* \u{2000} */ const foo = ' '; /* \u{2001} */ const foo = ' '; /* \u{2002} */ const foo = ' ';