Repository navigation
Commit 177fb95
f0-1528
fix(config-eslint): flag an escaped dot or anchor in a bare abort assertion
The row on this pull request's own rule says a regex with an escaped dot slips past
abortSubstringSelector: /^Request was aborted\.$/ is not flagged while the same message
written as a string is. Measured against the rule as it stood, through the extension's
real config (calculateConfigForFile on core/task/__tests__/example.spec.ts, then
linter.verify):
toThrow(/^aborted$/) 1 (already flagged)
toThrow(/^Request was aborted\.$/) 0 <- the hole
toThrowError(/request aborted\.$/i) 0 <- the hole
toThrow(/^request aborted\$/) 0 <- same hole, escaped anchor
toThrow(/^Request was aborted because the peer …\.$/) 0 (a full message stays allowed)
The tail [.$]?$ cannot consume the backslash that an escaped dot or anchor leaves in the
pattern text, so the match dies one character short. The tail becomes [\\.$]*$ in both
branches of the selector (the string-value branch and the regex-pattern branch), which
consumes \\., \$, . or $ before the end and nothing else.
Red before, green after, in packages/config-eslint/api-provider-hygiene.test.js: the four
new rows fail with 'expected: 1' against the old tail (# tests 89, # fail 2 - the loop runs
for two lane paths) and pass against the new one (# tests 89, # pass 89, # fail 0). After
the change the probe reports 13 of 13 cases as wanted, including toThrow(/aborted\./) -> 1,
rejects.not.toThrow(/^Request was aborted\.$/) -> 0 and the long-message cases -> 0.
No spec in the repository is newly caught: eslint over src (with main merged at
a326612) still exits 0 with --max-warnings=0, root pnpm run lint is 12/12, and
pnpm lint in packages/config-eslint exits 0. No eslint-suppression entry changes
(pnpm exec eslint --prune-suppressions on both files leaves src/eslint-suppressions.json
byte-identical). Rule source and its test are the only files touched.1 parent a326612 commit 177fb95
2 files changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
300 | 306 | | |
| 307 | + | |
301 | 308 | | |
302 | 309 | | |
303 | 310 | | |
| |||
0 commit comments