Skip to content

Commit

Permalink
Update packages/website/blog/2024-05-27-announcing-typescript-eslint-…
Browse files Browse the repository at this point in the history
…v8-beta.mdx

Co-authored-by: auvred <[email protected]>
  • Loading branch information
JoshuaKGoldberg and auvred committed May 24, 2024
1 parent af8fa1f commit df2dcb0
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,44 @@ createRule({

See [feat(utils): allow specifying additional rule meta.docs in RuleCreator](https://github.com/typescript-eslint/typescript-eslint/pull/9025) for more details.

### Support for multi-pass fixes in `RuleTester`

The `RuleTester` provided by `@typescript-eslint/rule-tester` is a fork of ESLint's `RuleTester`.
One limitation of the original `RuleTester` is that it is not possible to verify that test cases requiring multiple fixes to be applied provide correct fixes.
[The original `RuleTester` applies only the first fix](https://eslint.org/docs/latest/integrate/nodejs-api#testing-fixes) when there is conflict between two fixes.

In typescript-eslint v8, `RuleTester` tries to apply all possible fixes for each test case.

If your rule tests had some test cases that required multi-pass fixes, you will see some test failures.
To fix these failures, provide an array of strings for `output` which specifies the output after each fix pass.

```ts
import { RuleTester } from '@typescript-eslint/rule-tester';
import rule from '../src/rules/my-rule.ts';

const ruleTester = new RuleTester();

ruleTester.run('my-rule', rule, {
valid: [
/* ... */
],
invalid: [
{
code: 'const a = 1;',
// Remove the line with string form of `output`
output: 'const b = 1;',
// Add the line with array form of `output`
output: ['const b = 1;', 'const c = 1;'],
errors: [
/* ... */
],
},
],
});
```

See [[rule-tester] support multipass fixes](https://github.com/typescript-eslint/typescript-eslint/issues/8554) for more details.

### Other Developer-Facing Breaking Changes

-[Repo: Rule [options] parameter should be non-nullable if defaultOptions exists](https://github.com/typescript-eslint/typescript-eslint/issues/5439)
Expand Down

0 comments on commit df2dcb0

Please sign in to comment.