Skip to content

Commit

Permalink
chore: brought in typescript-eslint@v8 with stylistic preset (#10911)
Browse files Browse the repository at this point in the history
This applies two internal tooling updates:

* Bumps typescript-eslint to its beta v8:
https://typescript-eslint.io/blog/announcing-typescript-eslint-v8-beta
* Enables typescript-eslint's [shared `stylistic`
config](https://typescript-eslint.io/users/configs#stylistic) for
internal code (not `eslint-config`)

Any changes (will be) commented inline. This also doesn't tackle three
good followups:

* Rules with many existing reports I kept disabled under a `TODO:`
comment in `.eslintrc.js`
* A reasonable next step for the project would be to look through those
and decide which should be fixed up.
* This doesn't enable [typed
linting](https://typescript-eslint.io/getting-started/typed-linting)
internally
  * Would definitely recommend next!
* Onboarding to ESLint's flat config
  * Blocked on #10897 

**There should be no user-facing functional changes**. It should just be
cleanups.

⚠️ This isn't ready for merge, as it uses `rc-v8` versions of
`typescript-eslint`. Just posting as a reference prior to v8 going
stable.
* Once v8 is stable, I can update this to use the released version.
* Alternately, if you'd like these changes sooner, I can make a version
of this that doesn't update to `rc-v8` - it'll just have slightly fewer
changes...

This PR came out of a casual conversation with @Tobbe. I'm happy to file
an issue / make a more formal internal tooling request if you'd prefer.
❤️

---------

Co-authored-by: Tobbe Lundberg <[email protected]>
Co-authored-by: Josh GM Walker <[email protected]>
  • Loading branch information
3 people committed Aug 13, 2024
1 parent 8d2c049 commit 25630e9
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 128 deletions.
36 changes: 36 additions & 0 deletions .changesets/10911.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
- chore: brought in typescript-eslint@v8 with stylistic preset (#10911) by @JoshuaKGoldberg

This change updates Redwood linting config and introduces some changes to the linting rules that are applied to your project.

Specifically:

1. `jsx-a11y/no-noninteractive-element-to-interactive-role` has it's default config updated.
3. `@typescript-eslint/explicit-function-return-type` used to be turned off, now it's no longer applied.
4. `@typescript-eslint/no-empty-interface` - used to be turned off, now it's no longer applied.
5. `@typescript-eslint/explicit-module-boundary-types` - used be turned off, now it's no longer applied.
6. `@typescript-eslint/ban-types` - used to be 'warn', now it's no longer applied. This has been replaces with a set of smaller more specific rules.
7. `no-empty-function` - used be turned off, now it's no longer applied. The ts-eslint flavour is still there and turned off still.
8. `camelcase` - used to be turned off, now it's 'warn'.
9. `@typescript-eslint/camelcase` - used to be turned off, now it's no longer applied.
10. `no-use-before-define` - used to be turned off, now it's no longer applied.
11. `@typescript-eslint/no-use-before-define` - used to be turned off, now it's no longer applied.
12. `@typescript-eslint/prefer-namespace-keyword` - used to be turned off, now it's 'error'
13. `unicode-bom` - used to be turned off, now it's no longer applied.
14. `@typescript-eslint/adjacent-overload-signatures` - used to be 'error', now it's no longer applied.
15. `@typescript-eslint/no-explicit-any` - used be 'warn', now 'error'
16. `@typescript-eslint/no-inferrable-types` - used to be 'error', now it's no longer applied.
17. `no-loss-of-precision` - used be 'off', now 'error'
18. `@typescript-eslint/no-loss-of-precision` - used be 'error', now it's no longer applied.
19. `@typescript-eslint/no-non-null-assertion` - used be 'warn', now it's no longer applied.
20. `valid-typeof` - used be either 'error' or 'off', now always 'error'
21. `no-unused-expressions` - used be always 'error', now either 'error' or 'off'
22. `@typescript-eslint/prefer-function-type` - newly added as 'off'
23. `@typescript-eslint/no-require-imports` - newly added as 'off'
24. `@typescript-eslint/no-empty-object-type` - newly added as 'off'
25. `unicorn/template-indent` - newly added as 'off'
26. `@typescript-eslint/no-duplicate-enum-values` - newly added as 'error'
27. `@typescript-eslint/no-unsafe-declaration-merging` - newly added as 'error'
28. `@typescript-eslint/no-unsafe-function-type` - newly added as 'error'
29. `@typescript-eslint/no-unused-expressions` - newly added as 'error'
30. `@typescript-eslint/no-wrapper-object-types` - newly added as 'error'
31. `no-new-native-nonconstructor` - newly added as 'off'
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,25 @@ module.exports = {
},
overrides: [
{
extends: ['plugin:@typescript-eslint/stylistic'],
files: ['*.ts', '*.tsx'],
rules: {
// TODO: Look into enabling these eventually
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/consistent-generic-constructors': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/prefer-for-of': 'off',
'@typescript-eslint/prefer-function-type': 'off',
'@typescript-eslint/consistent-type-imports': 'error',

// Specific 'stylistic' rules we alter
camelcase: 'off',
curly: 'error',
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/codemods/src/codemods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import yargs from 'yargs'

// eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
yargs
.scriptName('codemods')
.example([['$0 add-directives', 'Run the add-directives codemod']])
Expand Down
20 changes: 6 additions & 14 deletions packages/eslint-config/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module.exports = {
// Uses https://github.com/isaacs/minimatch under the hood
// See https://github.com/isaacs/node-glob#glob-primer for syntax
// eslint-disable-next-line prettier/prettier
pattern: 'src/*/**/\*.?(sdl.){js,ts}',
pattern: 'src/*/**/*.?(sdl.){js,ts}',
patternOptions: {
nobrace: true,
noglobstar: true,
Expand Down Expand Up @@ -151,26 +151,18 @@ module.exports = {
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
rules: {
// 'recommended' rules we alter
'@typescript-eslint/no-explicit-any': 'warn',
// TODO: look into enabling these eventually
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/prefer-function-type': 'off',

// Specific 'recommended' rules we alter
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
],
// Specific 'stylistic' rules we enable
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
// Other non-grouped rules we alter
'valid-typeof': 'off',
camelcase: 'off',
'@typescript-eslint/camelcase': 'off',
'no-empty-function': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'off',
},
},
{
Expand Down
Loading

0 comments on commit 25630e9

Please sign in to comment.