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

feat(rule-tester): switched to flat config #9603

Merged

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Jul 22, 2024

BREAKING CHANGE:
Switches RuleTester from legacy configs to flat configs.

PR Checklist

Overview

Switches the internals of our forked RuleTester to work with new Linter({ configType: 'flat' }); instead of configType: 'eslintrc'. This is a pretty substantial breaking change internally:

  • this.#linter is no longer able to defineRule() ad hoc; instead, the config: TesterConfigWithDefaults has to have plugins including the rule.
  • Because the @/ plugin can't be redefined, a @rule-tester/ prefix is added in front of rule names.
  • Per flat config, any parser, parserOptions, and other language-specific settings are moved to languageOptions.
    • This caused a lot of churn in our test files
  • Per flat config, parser has to be the actual parser, not a string descriptor.
    • As a convenience, I formally defaulted it to our parser
    • I went ahead and removed all the redundant parser: '@typescript-eslint/parser', parserOptions: { sourceType: 'module' }, and other seemingly unnecessary options from our test files
  • Marks the @typescript-eslint/utils RuleTester re-export as deprecated

I think we'll want to follow this up with added info in the v8 beta blog post. See our packages/eslint-plugin(-internal)/**/*.test.ts file changes. There's a fair amount users will have to do:

  • Nest lib, parser, parserOptions, sourceType, and any other parser options inside languageOptions
  • Switch parser from a string to the actual parser
  • The default ecmaVersion and sourceType are now 'latest' and 'module', respectively

💖

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Jul 22, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 11c5c78
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66a0e48cf8c5db000866436b
😎 Deploy Preview https://deploy-preview-9603--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 97 (🔴 down 2 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@bradzacher
Copy link
Member

Per flat config, any parser and parserOptions, and other language-specific settings are moved to languageOptions.

Thought: I wonder if we should have hoisted up our stuff / the common stuff to avoid churn. Cos this will mess with all the ecosystem as well. I know that was their intent but it is going to block plugins hard.

@JoshuaKGoldberg
Copy link
Member Author

JoshuaKGoldberg commented Jul 22, 2024

Per flat config, any parser and parserOptions, and other language-specific settings are moved to languageOptions.

Thought: I wonder if we should have hoisted up our stuff / the common stuff to avoid churn. Cos this will mess with all the ecosystem as well. I know that was their intent but it is going to block plugins hard.

Yeah I don't think we're in a good place to do anything here. +1 that this will be work for plugins, but:

  • Switching our RuleTester from a rough drop-in to something noticeably different from the core config system would be a big step away from core
  • Most plugins will just need to wrap some stuff in languageOptions

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review July 22, 2024 12:05
@JoshuaKGoldberg JoshuaKGoldberg requested review from bradzacher and a team July 22, 2024 12:05
packages/rule-tester/src/RuleTester.ts Outdated Show resolved Hide resolved
packages/rule-tester/src/RuleTester.ts Outdated Show resolved Hide resolved
@bradzacher bradzacher added the breaking change This change will require a new major version to be released label Jul 22, 2024
JoshuaKGoldberg and others added 2 commits July 24, 2024 07:22
Copy link

codecov bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.01%. Comparing base (ae980e3) to head (11c5c78).
Report is 8 commits behind head on v8.

Additional details and impacted files
@@            Coverage Diff             @@
##               v8    #9603      +/-   ##
==========================================
+ Coverage   88.00%   88.01%   +0.01%     
==========================================
  Files         401      401              
  Lines       13647    13637      -10     
  Branches     3965     3960       -5     
==========================================
- Hits        12010    12003       -7     
  Misses       1325     1325              
+ Partials      312      309       -3     
Flag Coverage Δ
unittest 88.01% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/utils/src/eslint-utils/deepMerge.ts 89.47% <ø> (ø)
packages/utils/src/ts-eslint/Linter.ts 50.00% <ø> (ø)
packages/utils/src/ts-eslint/RuleTester.ts 50.00% <ø> (ø)
packages/utils/src/ts-eslint/SourceCode.ts 50.00% <ø> (ø)

... and 2 files with indirect coverage changes

@JoshuaKGoldberg JoshuaKGoldberg merged commit 32a7a70 into typescript-eslint:v8 Jul 24, 2024
63 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the rule-tester-flat-config branch July 24, 2024 12:24
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking change This change will require a new major version to be released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants