Repository navigation
JS-1845 Create rule S9451: no-irregular-whitespace - #8211
Conversation
Ruling ReportNew issues flagged (5 issues)S9451> 1 | .menu .item { /* Noncompliant: no-break space before ".item" */
2 | padding: 8px 16px; /* Noncompliant: no-break space before "16px" */
3 | margin:0; /* Noncompliant: zero-width space */ 1 | .menu .item { /* Noncompliant: no-break space before ".item" */
> 2 | padding: 8px 16px; /* Noncompliant: no-break space before "16px" */
3 | margin:0; /* Noncompliant: zero-width space */
4 | grid-template-areas: "head head"; /* Noncompliant: grid area strings are checked */ 1 | .menu .item { /* Noncompliant: no-break space before ".item" */
2 | padding: 8px 16px; /* Noncompliant: no-break space before "16px" */
> 3 | margin:0; /* Noncompliant: zero-width space */
4 | grid-template-areas: "head head"; /* Noncompliant: grid area strings are checked */
5 | } 2 | padding: 8px 16px; /* Noncompliant: no-break space before "16px" */
3 | margin:0; /* Noncompliant: zero-width space */
> 4 | grid-template-areas: "head head"; /* Noncompliant: grid area strings are checked */
5 | }
6 | mootools-core/Tests/Fx/Fx.html:174 172 | width: 100px;
173 | height: 100px;
> 174 | }
175 | </style>
176 | |
Point the RSPEC refresh to SonarSource/rspec#8381 until it is merged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
718fabe to
0735eb8
Compare
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This comment has been minimized.
This comment has been minimized.
|
/pvf |
|
📊 Performance Validation complete |
Code Review ✅ Approved 2 closed / 2 findings🟡 Medium risk · Adding S9451 and retrying CSS parsing with invisible characters replaced could change diagnostics for affected stylesheets. Adds the ✅ 2 closed✅ Bug: Ruling expectation omits line 3 (zero-width space) of S9451.css
✅ Quality: Unsanitized U+200B now also triggers S9424, double-reporting S9451
Verification Rules 2/2 met Repos 4 inspected · PRs 3 inspectedFunctional validation No results Rules 2 passed 1 not applicable
Broader impact Repos 4 inspected PRs 3 inspectedCross-repo 4 repositories inspected 0 open impacts
Cross-PR 3 PRs inspected 0 open impactsAuto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
| const sanitizedCode = replaceInvisibleCharacters(code); | ||
| return { ...(await linter.lint(filePath, sanitizedCode, ruleFileType)), code: sanitizedCode }; |
There was a problem hiding this comment.
[P2] Preserve S9451 findings during parser recovery
When the first parse fails, the retry runs S9451 on text where all U+2000–U+200F characters have already been replaced with spaces. This loses findings throughout the file, including characters unrelated to the parse failure. For example, using JavaScript escape notation to construct the actual CSS:
const css = 'a\u200B { color: red; } b { color: red;\u200B }';analyzeCSS returns zero S9451 issues, whereas the first selector alone is reported. Please preserve the original source for S9451 during recovery, using the recovered AST for context and locations, and add an analyzer regression expecting both findings. Grid strings should likewise be inspected in the original text, while comments, ordinary strings, URLs, and escapes retain their exclusions.
| } | ||
| const value = decl.raws.value?.raw ?? decl.value; | ||
| // invisible characters such as U+200B are validated as spaces, leaving their report to S9451 | ||
| const value = replaceInvisibleCharacters(decl.raws.value?.raw ?? decl.value); |
There was a problem hiding this comment.
[P2] Complete S9424's delegation to S9451
replaceInvisibleCharacters only replaces U+2000–U+200F, but S9451 also owns characters such as U+00A0, U+1680, U+202F, and U+3000. With both rules enabled, the actual CSS constructed by 'a { color:\u00A0red; }' produces both S9451's whitespace issue and S9424's Unknown value issue at the same position. Replacing that one character with an ordinary space resolves both.
Please align this delegation with S9451's character policy so that the whitespace defect is reported once, while preserving S9424 findings for unrelated invalid parts of the value. Add a combined-rule regression for NBSP and representative characters outside U+2000–U+200F.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Code Review ✅ Approved 2 closed / 2 findings🟡 Medium risk · Changing CSS analysis to retry parsing with sanitized invisible characters could alter rule findings or source locations for malformed stylesheets. Adds the ✅ 2 closed✅ Bug: Ruling expectation omits line 3 (zero-width space) of S9451.css
✅ Quality: Unsanitized U+200B now also triggers S9424, double-reporting S9451
Verification Rules 2/2 met Repos 4 inspected · PRs 3 inspectedFunctional validation No results Rules 2 passed 1 not applicable
Broader impact Repos 4 inspected PRs 3 inspectedCross-repo 4 repositories inspected 0 open impacts
Cross-PR 3 PRs inspected 0 open impactsAuto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|





Summary by Gitar
gridAreaStringshelper shared with S9442 for grid area string parsingno-irregular-whitespacerule reporting irregular whitespace outside comments, URLs and stringsThis will update automatically on new commits.