[Tests] drop ESLint-10-incompatible 'type:' property from RuleTester error assertions#4006
Conversation
Wrap invalid test cases in `tests/helpers/ruleTester.js` to strip `type` when the running ESLint is >= 10. On older versions the function does nothing, keeping all `type:` assertions intact.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4006 +/- ##
==========================================
- Coverage 97.72% 97.57% -0.16%
==========================================
Files 134 137 +3
Lines 10170 10182 +12
Branches 3795 3795
==========================================
- Hits 9939 9935 -4
- Misses 231 247 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Alias-install failures on node 4/5: root cause and fix in
|
|
Where things stand on the latest tip: 521 pass / 1 fail / 1 skipping. The single red, This PR's actual content is the 19
Not planning further changes. Happy to revise if you'd rather see a different shape. |
ljharb
left a comment
There was a problem hiding this comment.
The solution here isn't to make eslint < 10 tests weaker - it's to make a helper that wraps all test cases and conditionally removes type when eslint is >= 10.
|
Additionally, please minimize use of LLMs in open source contributions; I'd rather read your prompt than read LLM prose output. |
Got it, we are on the same page now. I anticipate having the changes ready this weekend. |
c1033d9 to
73ef361
Compare
|
The weekend came early! |
73ef361 to
fa5e416
Compare
Summary
ESLint 10 removed
typefrom the list of valid properties on RuleTester errorobjects. The only allowed properties are now
message,messageId,data,line,column,endLine,endColumn,suggestions. Any test assertingerrors: [{ ..., type: '<AstNodeType>' }]now throwsInvalid error property name 'type'and the entire test file aborts beforeany other assertion runs — which is the load-bearing blocker keeping the
ESLint 10 matrix red on #3979.
This PR strips every error-block
type: '...'line/fragment from the rule-testsuite. No assertion strength is lost: every removed
type:co-existed withmessageIdormessage(or, inno-deprecated, lived in extras merged onto anerrorMessage(...)helper that already pre-fillsmessageIdanddata).Changes
1 infra commit, 19 test commits (reduce-only), 1 dep-pin commit.
tests/helpers/parsers.js— one-line guard so the deprecatedtypescript-eslint-parserpath is skipped under eslint 10 (it cannot parsea TS 5 tsconfig — the same path the eslint 10 matrix on Fix ESLint v10 RuleContext API removal (follow-up to #3972) #3979 uses).
tests/lib/rules/*.js(19 files) — removal of error-blocktype:only,one commit per file:
destructuring-assignment, forbid-component-props, forbid-dom-props,
forbid-foreign-prop-types, forbid-prop-types, jsx-curly-newline,
jsx-equals-spacing, jsx-no-duplicate-props, jsx-no-useless-fragment,
jsx-sort-default-props, jsx-sort-props, no-deprecated,
no-invalid-html-attribute, no-typos, no-unsafe, prop-types,
sort-default-props, sort-prop-types, style-prop-object.
package.json— pinjest-diffandoverrides.pretty-formatto30.3.0so the npm 5 install on node 4/5 doesn't trip on
npm:alias entriesintroduced in
pretty-format@30.4.0(May 7, 2026).Out of scope (intentionally not touched)
message:literals inforbid-dom-props/forbid-component-props—those rules support a user-supplied custom message via options
(
forbid: [{ propName, message: 'custom' }]), and the rule reports with thatliteral string and no messageId
(
report(context, customMessage, false, …)atlib/rules/forbid-component-props.jsandlib/rules/forbid-dom-props.js).Migrating them to
messageId:would require changing the rule's reportingbehavior — separate concern.
jsx-no-constructed-context-values,jsx-indent-props,jsx-indent—a broad grep for
type:matches them, but every match is insidedata: { ... type: 'X' ... }(rule-data templating, not error-objecttop-level). Their tests are unaffected by the eslint 10 schema change.
Verification
Run on Windows / Node 22.
eslint 9 (master CI config) —
npm install --no-save eslint@9 @typescript-eslint/parser@8.17 babel-eslint@10:Version > Detect version > works with virtual filenameand...recursive virtual filename) reproduce onorigin/masterand are notin any file this PR touches. No regressions.
eslint 10 + typescript@5 + @typescript-eslint/parser@canary
(
npm install --no-save --legacy-peer-deps eslint@10 @typescript-eslint/parser@canary typescript@5):Invalid error property name 'type'errors remain (down from~400 that were aborting test files before any other assertion).
rule-source / behavior issues that this PR is not trying to fix:
sourceCode.isSpaceBetweenTokens is not a function(deprecated ineslint 10) at
lib/rules/jsx-equals-spacing.jsValid test case must not have 'output' propertyShould have N error but had M(rule-behavior diffs under thecanary @typescript-eslint/parser)
'errors' on valid case,true == false)So this PR doesn't make the eslint 10 matrix on #3979 fully green, but it
unblocks every rule-test file that was previously aborting on the schema
violation, exposing the remaining work as actionable rule-source fixes.
Test plan
npm run unit-testunder eslint 9 — 17853 passing (= master)npm run unit-testunder eslint 10 + ts5 — zerotype:schema errorsgrep -nE "type:\s*['\"]\w+['\"]" tests/lib/rules/— remaining hitsare inside
data: {...}orcode: '...'strings only