Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: migrate to FlatRuleTester v8 #204

Closed

Conversation

MikeMcC399
Copy link
Collaborator

Issue

Tests in the tests/lib/rules directory which run internally under ESLint 8.x are not compatible with ESLint 9.x.

The guide Migrate to 9.0 > FlatRuleTester is now RuleTester explain:

As announced in our blog post, the temporary FlatRuleTester class has been renamed to RuleTester, while the RuleTester class from v8.x has been removed. Additionally, the FlatRuleTester export from eslint/use-at-your-own-risk has been removed.

This is a breaking change for the tests.

Migration steps

The migration is done in two steps:

  1. Migrate to the temporary FlatRuleTester class in ESLint 8.x
  2. Migrate to the new RuleTester class in ESLint 9.x and at the same time migrate to using ESLint 9.x internally.

Changes

This PR deals with the first step of migrating to the temporary FlatRuleTester class in ESLint 8.x.

A follow-on PR will take care of the second step of migrating to ESLint 9.x

For all tests/lib/rules *.js test files

  1. Use const { FlatRuleTester } = require('eslint/use-at-your-own-risk') according to the blog post Testing rules with flat config and the RuleTester class.
  2. Change parserOptions to languageOptions.
  3. For tests/lib/rules/no-unnecessary-waiting.js remove the section which attempts to test disabling the rule. This is not compatible with the FlatRuleTester and it is attempting to test a function of ESLint rather than the rule itself.
  4. For tests/lib/rules/unsafe-to-chain-command.js modify an incompatible option syntax in one rule.

References

Verification

Ubuntu 22.04.4 LTS, Node.js v20.12.2 LTS

npm ci
npm run test

@cypress-app-bot
Copy link

@MikeMcC399
Copy link
Collaborator Author

It is not possible to have one set of tests which can be used on v7, v8 and v9, so the proposed migration strategy will not work.

Closing this PR as a different approach is needed here.

@MikeMcC399 MikeMcC399 closed this May 6, 2024
@MikeMcC399 MikeMcC399 deleted the migrate/flatruletester-v8 branch May 7, 2024 07:17
@MikeMcC399
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants