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

test: use Linter and ESLint directly from eslint in tests #1177

Merged
merged 3 commits into from
Mar 31, 2025

Conversation

43081j
Copy link
Contributor

@43081j 43081j commented Mar 31, 2025

This drops a few of the compat exports in tests and imports directly from eslint instead.

Linter already seems to work in our tests for 8.x and 9.x directly.

ESLint is the flat class in 9.x, but the legacy one in 8.x. Luckily, it provides loadESLint which can retrieve the flat ESLint for us in both versions, so we should no longer need the compat helper.

We can't quite get rid of the RuleTester compat layer as 8.x doesn't export the flat rule tester from the index (it is only available through the unsupported-api entrypoint).

43081j added 3 commits March 31, 2025 15:49
Uses eslint's own `Linter` rather than the compat layer.
Uses the `loadESLint` helper directly from eslint instead.
Copy link

changeset-bot bot commented Mar 31, 2025

🦋 Changeset detected

Latest commit: d10536e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Try the Instant Preview in Online Playground

ESLint Online Playground

Install the Instant Preview to Your Local

npm i https://pkg.pr.new/eslint-plugin-svelte@1177

Published Instant Preview Packages:

View Commit

import plugin from '../../../src/index.js';
import { ESLint } from '../../utils/eslint-compat.js';
import { loadESLint, type ESLint as ESLintClass } from 'eslint';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as i understand, ESLint here is the flat ESLint already. but when we force install 8.x in CI, it will be the legacy one at runtime. which is why we can't just import {ESLint} from 'eslint'

Copy link
Member

@baseballyama baseballyama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works both ESLint v9 and 8.57.1.

@baseballyama baseballyama merged commit ec22fb4 into sveltejs:main Mar 31, 2025
17 checks passed
@43081j 43081j deleted the no-compat-linter branch March 31, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants