From a2e6c5de1afaefb8dc0f9dd0938fdf2f1575e31a Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 29 Dec 2023 16:22:50 -0500 Subject: [PATCH 1/2] doc: Add RuleTester changes to migrate to v9 guide --- docs/src/use/migrate-to-9.0.0.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/src/use/migrate-to-9.0.0.md b/docs/src/use/migrate-to-9.0.0.md index 1478bbabce4..d0c493a3985 100644 --- a/docs/src/use/migrate-to-9.0.0.md +++ b/docs/src/use/migrate-to-9.0.0.md @@ -29,6 +29,7 @@ The lists below are ordered roughly by the number of users each change is expect * [Function-style rules are no longer supported](#drop-function-style-rules) * [`meta.schema` is required for rules with options](#meta-schema-required) * [`FlatRuleTester` is now `RuleTester`](#flat-rule-tester) +* [Stricter `RuleTester` checks](#stricter-rule-tester) ### Breaking changes for integration developers @@ -209,6 +210,17 @@ As announced in our [blog post](/blog/2023/10/flat-config-rollout-plans/), the t **Related Issues(s):** [#13481](https://github.com/eslint/eslint/issues/13481) +## Stricter `RuleTester` checks + +In order to aid in the development of high-quality custom rules that are free from common bugs, ESLint v9.0.0 implements several changes to `RuleTester`: + +1. **Suggestion messages must be unique.** Because suggestions are typically displayed in an editor as a dropdown list, it's important that no two suggestions have the same message. Otherwise, it's impossible to know what any given suggestion will do. This additional check runs automatically. +1. **Suggestions must generate valid syntax.** In order for rule suggestions to be helpful, they need to be valid syntax. `RuleTester` now parses the output of suggestions using the same language options as the `code` value and throws an error if parsing fails. + +**To address:** Run your rule tests using `RuleTester` and fix any errors that occur. The changes you'll need to make to satisfy `RuleTester` are compatible with ESLint v8.x. + +**Related Issues(s):** [#15735](https://github.com/eslint/eslint/issues/15735), [#16908](https://github.com/eslint/eslint/issues/16908) + ## `FlatESLint` is now `ESLint` As announced in our [blog post](/blog/2023/10/flat-config-rollout-plans/), the temporary `FlatESLint` class has been renamed to `ESLint`, while the `ESLint` class from v8.x has been renamed to `LegacyESLint`. From f8474f8e95ebb70c82d235aeda8542224b4e4144 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 29 Dec 2023 17:05:05 -0500 Subject: [PATCH 2/2] Update docs/src/use/migrate-to-9.0.0.md Co-authored-by: Milos Djermanovic --- docs/src/use/migrate-to-9.0.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/use/migrate-to-9.0.0.md b/docs/src/use/migrate-to-9.0.0.md index d0c493a3985..9455c539a3b 100644 --- a/docs/src/use/migrate-to-9.0.0.md +++ b/docs/src/use/migrate-to-9.0.0.md @@ -214,7 +214,7 @@ As announced in our [blog post](/blog/2023/10/flat-config-rollout-plans/), the t In order to aid in the development of high-quality custom rules that are free from common bugs, ESLint v9.0.0 implements several changes to `RuleTester`: -1. **Suggestion messages must be unique.** Because suggestions are typically displayed in an editor as a dropdown list, it's important that no two suggestions have the same message. Otherwise, it's impossible to know what any given suggestion will do. This additional check runs automatically. +1. **Suggestion messages must be unique.** Because suggestions are typically displayed in an editor as a dropdown list, it's important that no two suggestions for the same lint problem have the same message. Otherwise, it's impossible to know what any given suggestion will do. This additional check runs automatically. 1. **Suggestions must generate valid syntax.** In order for rule suggestions to be helpful, they need to be valid syntax. `RuleTester` now parses the output of suggestions using the same language options as the `code` value and throws an error if parsing fails. **To address:** Run your rule tests using `RuleTester` and fix any errors that occur. The changes you'll need to make to satisfy `RuleTester` are compatible with ESLint v8.x.