
Highlights
This version of ESLint is not ready for production use and is provided to gather feedback from the community before releasing the final version. Please let us know if you have any problems or feedback by creating issues on our GitHub repo.
Note that this prerelease version of ESLint has a separate documentation section.
Enhancements to RuleTester
Since its earliest days, ESLint has provided the RuleTester API to help plugin authors test their rules against custom test cases and configurations. This release introduces several enhancements to RuleTester to enforce more robust test definitions and improve debugging.
requireData assertion option
A new assertion option, requireData, is now available. When set to true, RuleTester will require invalid test cases to include a data object whenever a messageId references a message with placeholders. This helps ensure that tests remain consistent with rule messages that rely on placeholder substitution.
For example, consider a hypothetical rule no-trivial-sum that reports on expressions such as 1 + 2 and defines a message with placeholders:
trivialSum: "Trivial sum found. Replace {{actualExpression}} with {{sum}}."
If an invalid test case includes messageId: "trivialSum" but omits data:
assertionOptions: { requireData: true },
invalid: [
{
code: "const a = 1 + 2;",
errors: [{ messageId: "trivialSum" }],
},
],
RuleTester will now throw an assertion error indicating that the data property is missing.
To resolve this, include the placeholder values in the error object:
{
code: "const a = 1 + 2;",
errors: [
{
messageId: "trivialSum",
data: { actualExpression: "1 + 2", sum: 3 },
},
],
},
Improved location reporting for failing tests
RuleTester now decorates stack traces with information that makes it easier to locate failing test cases in your source code. For example, if the no-trivial-sum rule fails to report an error for 1 + 2, the test case in the previous section will fail and the test output will include stack trace lines like:
roughly at RuleTester.run.invalid[0] (/my-project/test/no-trivial-sum.js:10)
roughly at RuleTester.run.invalid (/my-project/test/no-trivial-sum.js:7)
The first line indicates:
invalid[0]: the index of the failing test case in theinvalidarray/my-project/test/no-trivial-sum.js:10: the file and line number where that test case is defined. Many IDE terminals, including Visual Studio Code’s, recognize this format and allow you to click directly to the relevant line.
The second line points to the start of the entire invalid array.
Note that these line numbers may not always be included, depending on how your tests are structured. When the lines cannot be determined precisely, the failing test index (e.g., 0) and the printed code snippet are still available to locate the test case.
countThis option in max-params rule
The max-params rule now supports the new countThis option, which supersedes the deprecated countVoidThis. With the setting countThis: "never", the rule will now ignore any this annotation in a function’s argument list when counting the number of parameters in a TypeScript function. For example:
function doSomething(this: SomeType, first: string, second: number) {
// ...
}
will be considered a function taking only 2 parameters.
Installing
Since this is a pre-release version, you will not automatically be upgraded by npm. You must specify the next tag when installing:
npm i eslint@next --save-dev
You can also specify the version directly:
npm i eslint@10.0.0-rc.0 --save-dev
Migration Guide
As there are a lot of changes, we’ve created a migration guide describing the breaking changes in great detail along with the steps you should take to address them. We expect that most users should be able to upgrade without any build changes, but the migration guide should be a useful resource if you encounter problems.
Breaking Changes
Features
f0cafe5feat: rule tester add assertion optionrequireData(#20409) (fnx)f7ab693feat: output RuleTester test case failure index (#19976) (ST-DDT)7cbcbf9feat: addcountThisoption tomax-params(#20236) (Gerkin)
Bug Fixes
d186f8cfix: update eslint (#20427) (renovate[bot])2332262fix: error location should not modify error message in RuleTester (#20421) (Milos Djermanovic)ab99b21fix: ensurefilenameis passed as third argument toverifyAndFix()(#20405) (루밀LuMir)8a60f3bfix: removeecmaVersionandsourceTypefromParserOptionstype (#20415) (Pixel998)eafd727fix: removeTDZscope type (#20231) (jaymarvelz)39d1f51fix: correctScopetypings (#20404) (sethamus)2bd0f13fix: updateverifyandverifyAndFixtypes (#20384) (Francesco Trotta)
Documentation
65ed0c9docs: Update README (GitHub Actions Bot)b0e4717docs: [no-await-in-loop] Expand inapplicability (#20363) (Niklas Hambüchen)fca421fdocs: Update README (GitHub Actions Bot)d925c54docs: update config syntax inno-lone-blocks(#20413) (Pixel998)7d5c95fdocs: remove redundantsourceType: "module"from rule examples (#20412) (Pixel998)02e7e71docs: correct.mtsglob pattern in files with extensions example (#20403) (Ali Essalihi)
Chores
b4b3127chore: package.json update for @eslint/js release (Jenkins)f658419refactor: removerawparser option from JS language (#20416) (Pixel998)2c3efb7chore: removecategoryfrom type test fixtures (#20417) (Pixel998)36193fdchore: removecategoryfrom formatter test fixtures (#20418) (Pixel998)e8d203bchore: add JSX language tag validation tocheck-rule-examples(#20414) (Pixel998)bc465a1chore: pin dependencies (#20397) (renovate[bot])703f0f5test: replace deprecated rules inlintertests (#20406) (루밀LuMir)ba71baatest: enablestrictmode in type tests (#20398) (루밀LuMir)f9c4968refactor: removelib/linter/rules.js(#20399) (Francesco Trotta)6f1c48echore: updates for v9.39.2 release (Jenkins)
