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

refactor: make config rules static rather than based off rule metadata #1506

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Feb 16, 2024

Rule metadata is really typed for how @typescript-eslint use it and their recent majors have changed exports so we can't actually argument their interfaces anymore so this switches us to just using a static object.

I've not done anything fancy like having dedicated files in configs/ because I don't think there's a big advantage at this point and frankly I just want to push through to the ESLint v9 / @typescript-eslint v (I think 7..?) so will revisit restructuring later once the dust has settled.

I've also not removed the actual properties from the rules as I think that technically could be a breaking change? but I have at least tested without them locally to ensure all the scripts and workflow still work.

src/__tests__/rules.test.ts Outdated Show resolved Hide resolved
Comment on lines +67 to +94
const recommendedRules = {
'jest/expect-expect': 'warn',
'jest/no-alias-methods': 'error',
'jest/no-commented-out-tests': 'warn',
'jest/no-conditional-expect': 'error',
'jest/no-deprecated-functions': 'error',
'jest/no-disabled-tests': 'warn',
'jest/no-done-callback': 'error',
'jest/no-export': 'error',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/no-interpolation-in-snapshots': 'error',
'jest/no-jasmine-globals': 'error',
'jest/no-mocks-import': 'error',
'jest/no-standalone-expect': 'error',
'jest/no-test-prefixes': 'error',
'jest/valid-describe-callback': 'error',
'jest/valid-expect': 'error',
'jest/valid-expect-in-promise': 'error',
'jest/valid-title': 'error',
} satisfies Record<string, TSESLint.Linter.RuleLevel>;

const styleRules = {
'jest/no-alias-methods': 'warn',
'jest/prefer-to-be': 'error',
'jest/prefer-to-contain': 'error',
'jest/prefer-to-have-length': 'error',
} satisfies Record<string, TSESLint.Linter.RuleLevel>;
Copy link
Member

Choose a reason for hiding this comment

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

how can we ensure this is kept in sync with docs and the meta prop?

Copy link
Collaborator Author

@G-Rath G-Rath Feb 16, 2024

Choose a reason for hiding this comment

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

The docs are generated based on this (specifically, it builds the plugin and looks at the resulting configs object), and the meta props are going away - I've not removed them yet because the types currently still require them and that it might technically be breaking, though I could axe category in this PR if you like

@G-Rath G-Rath marked this pull request as ready for review February 16, 2024 18:45
@G-Rath G-Rath removed the bug label Feb 16, 2024
@G-Rath G-Rath requested a review from SimenB February 16, 2024 18:45
@G-Rath G-Rath merged commit ff16ef2 into main Mar 21, 2024
40 checks passed
@G-Rath G-Rath deleted the static-configs2 branch March 21, 2024 18:14
Copy link

🎉 This PR is included in version 28.0.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

github-actions bot commented Apr 6, 2024

🎉 This PR is included in version 28.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

2 participants