Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/helpers/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ const parsers = {
|| features.has('jsx namespace')
|| features.has('bind operator')
|| features.has('do expressions');
const tsOld = !skipTS && !features.has('no-ts-old');
// typescript-eslint-parser (deprecated) cannot parse a TS 5 tsconfig, used by the eslint 10 matrix.
const tsOld = !skipTS && !features.has('no-ts-old') && !semver.satisfies(version, '>= 10');
const tsNew = !skipTS && !features.has('no-ts-new');

return [].concat(
Expand Down
22 changes: 21 additions & 1 deletion tests/helpers/ruleTester.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ function convertToFlat(item, plugins) {
return newItem;
}

const eslintMajor = semver.major(eslintPkg.version);

function stripTypeOnEslint10(test) {
if (eslintMajor < 10 || !test || typeof test !== 'object' || !Array.isArray(test.errors)) {
return test;
}
return Object.assign({}, test, {
errors: test.errors.map((err) => {
if (!err || typeof err !== 'object' || !('type' in err)) {
return err;
}
const next = Object.assign({}, err);
delete next.type;
return next;
}),
});
}

let RuleTester = ESLintRuleTester;

if (semver.major(eslintPkg.version) >= 9) {
Expand Down Expand Up @@ -98,7 +116,9 @@ if (semver.major(eslintPkg.version) >= 9) {
run(ruleName, rule, tests) {
const newTests = {
valid: tests.valid.map((test) => convertToFlat(test, this[PLUGINS])),
invalid: tests.invalid.map((test) => convertToFlat(test, this[PLUGINS])),
invalid: tests.invalid
.map(stripTypeOnEslint10)
.map((test) => convertToFlat(test, this[PLUGINS])),
};

super.run(ruleName, rule, newTests);
Expand Down
Loading