Skip to content

Commit c6f0c14

Browse files
committed
fix: migrate eslint config to typescript-eslint v8 + @Stylistic
- Rename .eslintrc.js to .eslintrc.cjs (ESM module compatibility) - Replace 17 removed formatting rules with @stylistic/eslint-plugin equivalents - Replace ban-types with no-restricted-types + no-unsafe-function-type + no-wrapper-object-types - Replace no-empty-interface with no-empty-object-type - Replace no-throw-literal with only-throw-error - Remove no-var-requires (covered by no-require-imports) - Remove prefer-ts-expect-error (covered by ban-ts-comment) - Replace no-loss-of-precision with base ESLint rule - Fix lint target to point at ui/ instead of nonexistent src/ - Point parserOptions.project at tsconfig.app.json
1 parent 56ae2ab commit c6f0c14

3 files changed

Lines changed: 96 additions & 34 deletions

File tree

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ module.exports = {
6565
parserOptions: {
6666
warnOnUnsupportedTypeScriptVersion: false,
6767
sourceType: 'module',
68-
project: 'tsconfig.json',
68+
project: 'tsconfig.app.json',
6969
ecmaFeatures: {
7070
jsx: true,
7171
},
7272
},
7373
plugins: [
7474
'@typescript-eslint',
75+
'@stylistic',
7576
'import',
7677
],
7778
settings: {
@@ -97,14 +98,16 @@ module.exports = {
9798
'error',
9899
{
99100
'ts-expect-error': 'allow-with-description',
101+
'ts-ignore': true,
100102
minimumDescriptionLength: 4,
101103
},
102104
],
103105
'@typescript-eslint/ban-tslint-comment': 'error',
104-
'@typescript-eslint/ban-types': [
106+
107+
// Replaces removed @typescript-eslint/ban-types (split in v8)
108+
'@typescript-eslint/no-restricted-types': [
105109
'error',
106110
{
107-
extendDefaults: false,
108111
types: {
109112
String: {
110113
message: 'Use `string` instead.',
@@ -141,12 +144,6 @@ module.exports = {
141144
'The `object` type is hard to use. Use `Record<string, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848',
142145
fixWith: 'Record<string, unknown>',
143146
},
144-
Function: 'Use a specific function type instead, like `() => void`.',
145-
// null: {
146-
// message:
147-
// 'Use `undefined` instead. See: https://github.com/sindresorhus/meta/issues/7',
148-
// fixWith: 'undefined',
149-
// },
150147
Buffer: {
151148
message:
152149
'Use Uint8Array instead. See: https://sindresorhus.com/blog/goodbye-nodejs-buffer',
@@ -161,24 +158,29 @@ module.exports = {
161158
},
162159
},
163160
],
161+
'@typescript-eslint/no-unsafe-function-type': 'error',
162+
'@typescript-eslint/no-wrapper-object-types': 'error',
163+
164164
'@typescript-eslint/class-literal-property-style': ['error', 'getters'],
165165
'@typescript-eslint/consistent-generic-constructors': [
166166
'error',
167167
'constructor',
168168
],
169169
'@typescript-eslint/consistent-indexed-object-style': 'error',
170+
171+
// Stylistic rules (moved from @typescript-eslint in v8)
170172
'brace-style': 'off',
171-
'@typescript-eslint/brace-style': [
173+
'@stylistic/brace-style': [
172174
'error',
173175
'1tbs',
174176
{
175177
allowSingleLine: false,
176178
},
177179
],
178180
'comma-dangle': 'off',
179-
'@typescript-eslint/comma-dangle': ['error', 'always-multiline'],
181+
'@stylistic/comma-dangle': ['error', 'always-multiline'],
180182
'comma-spacing': 'off',
181-
'@typescript-eslint/comma-spacing': [
183+
'@stylistic/comma-spacing': [
182184
'error',
183185
{
184186
before: false,
@@ -237,19 +239,19 @@ module.exports = {
237239
// ],
238240

239241
'func-call-spacing': 'off',
240-
'@typescript-eslint/func-call-spacing': ['error', 'never'],
242+
'@stylistic/function-call-spacing': ['error', 'never'],
241243
indent: 'off',
242-
'@typescript-eslint/indent': [
244+
'@stylistic/indent': [
243245
'error',
244246
2,
245247
{
246248
SwitchCase: 1,
247249
},
248250
],
249251
'keyword-spacing': 'off',
250-
'@typescript-eslint/keyword-spacing': 'error',
252+
'@stylistic/keyword-spacing': 'error',
251253
'lines-between-class-members': 'off',
252-
'@typescript-eslint/lines-between-class-members': [
254+
'@stylistic/lines-between-class-members': [
253255
'error',
254256
'always',
255257
{
@@ -258,7 +260,7 @@ module.exports = {
258260
exceptAfterSingleLine: true,
259261
},
260262
],
261-
'@typescript-eslint/member-delimiter-style': [
263+
'@stylistic/member-delimiter-style': [
262264
'error',
263265
{
264266
multiline: {
@@ -358,10 +360,12 @@ module.exports = {
358360
'@typescript-eslint/no-dynamic-delete': 'error',
359361
'no-empty-function': 'off',
360362
'@typescript-eslint/no-empty-function': 'error',
361-
'@typescript-eslint/no-empty-interface': [
363+
364+
// Replaces removed @typescript-eslint/no-empty-interface (v8)
365+
'@typescript-eslint/no-empty-object-type': [
362366
'error',
363367
{
364-
allowSingleExtends: true,
368+
allowInterfaces: 'with-single-extends',
365369
},
366370
],
367371

@@ -392,11 +396,11 @@ module.exports = {
392396
// ],
393397

394398
'no-extra-semi': 'off',
395-
'@typescript-eslint/no-extra-semi': 'error',
399+
'@stylistic/no-extra-semi': 'error',
396400
'no-loop-func': 'off',
397401
'@typescript-eslint/no-loop-func': 'error',
398-
'no-loss-of-precision': 'off',
399-
'@typescript-eslint/no-loss-of-precision': 'error',
402+
// Removed in @typescript-eslint v8 — base ESLint rule handles this now
403+
'no-loss-of-precision': 'error',
400404
'@typescript-eslint/no-extraneous-class': [
401405
'error',
402406
{
@@ -468,15 +472,17 @@ module.exports = {
468472
// The rule is buggy and keeps inferring `any` for types that are not `any`. Just a lot of false-positives.
469473
// '@typescript-eslint/no-redundant-type-constituents': 'error',
470474

475+
// no-require-imports subsumes the removed no-var-requires in v8
471476
'@typescript-eslint/no-require-imports': 'error',
472477
'@typescript-eslint/no-this-alias': [
473478
'error',
474479
{
475480
allowDestructuring: true,
476481
},
477482
],
483+
// Replaces removed @typescript-eslint/no-throw-literal (renamed in v8)
478484
'no-throw-literal': 'off',
479-
'@typescript-eslint/no-throw-literal': [
485+
'@typescript-eslint/only-throw-error': [
480486
'error',
481487
{
482488
// This should ideally be `false`, but it makes rethrowing errors inconvenient. There should be a separate `allowRethrowingUnknown` option.
@@ -534,17 +540,16 @@ module.exports = {
534540
'@typescript-eslint/no-useless-constructor': 'error',
535541
'object-curly-spacing': 'off',
536542
'curly': ['error', 'all'],
537-
'@typescript-eslint/object-curly-spacing': ['error', 'always'],
543+
'@stylistic/object-curly-spacing': ['error', 'always'],
538544
'padding-line-between-statements': 'off',
539-
'@typescript-eslint/padding-line-between-statements': [
545+
'@stylistic/padding-line-between-statements': [
540546
'error',
541547
{
542548
blankLine: 'always',
543549
prev: 'multiline-block-like',
544550
next: '*',
545551
},
546552
],
547-
'@typescript-eslint/no-var-requires': 'error',
548553
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
549554
'@typescript-eslint/parameter-properties': [
550555
'error',
@@ -584,10 +589,10 @@ module.exports = {
584589

585590
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
586591
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
587-
'@typescript-eslint/prefer-ts-expect-error': 'error',
592+
// Removed in v8 — covered by ban-ts-comment with ts-ignore: true
588593
'@typescript-eslint/promise-function-async': 'error',
589594
quotes: 'off',
590-
'@typescript-eslint/quotes': ['error', 'single'],
595+
'@stylistic/quotes': ['error', 'single'],
591596
'@typescript-eslint/restrict-plus-operands': [
592597
'error',
593598
{
@@ -613,7 +618,7 @@ module.exports = {
613618
// '@typescript-eslint/require-await': 'error',
614619

615620
'space-before-function-paren': 'off',
616-
'@typescript-eslint/space-before-function-paren': [
621+
'@stylistic/space-before-function-paren': [
617622
'error',
618623
{
619624
anonymous: 'always',
@@ -622,11 +627,11 @@ module.exports = {
622627
},
623628
],
624629
'space-infix-ops': 'off',
625-
'@typescript-eslint/space-infix-ops': 'error',
630+
'@stylistic/space-infix-ops': 'error',
626631
semi: 'off',
627-
'@typescript-eslint/semi': ['error', 'always'],
632+
'@stylistic/semi': ['error', 'always'],
628633
'space-before-blocks': 'off',
629-
'@typescript-eslint/space-before-blocks': ['error', 'always'],
634+
'@stylistic/space-before-blocks': ['error', 'always'],
630635

631636
// TODO: Reconsider enabling it again in 2023.
632637
// NOTE: The rule was complete redone in typescript-eslint v3, so this config needs to be changed before this is enabled.
@@ -656,7 +661,7 @@ module.exports = {
656661
lib: 'never',
657662
},
658663
],
659-
'@typescript-eslint/type-annotation-spacing': 'error',
664+
'@stylistic/type-annotation-spacing': 'error',
660665

661666
// Disabled as it crashes on most code.
662667
// https://github.com/typescript-eslint/typescript-eslint/search?q=%22unbound-method%22&state=open&type=Issues

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "pnpm run bundle:yaml-worker && tsc && vite build",
99
"bundle:yaml-worker": "esbuild node_modules/monaco-yaml/yaml.worker.js --bundle --format=esm --outfile=ui/providers/monaco/yaml.worker.bundle.js --platform=browser",
1010
"postinstall": "pnpm run bundle:yaml-worker",
11-
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
11+
"lint": "eslint ui --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1212
"preview": "nx preview",
1313
"test": "vitest run",
1414
"bench": "vitest bench --config vitest.bench.config.ts"
@@ -68,6 +68,7 @@
6868
"yaml": "^2.7.1"
6969
},
7070
"devDependencies": {
71+
"@stylistic/eslint-plugin": "^5.10.0",
7172
"@tanstack/react-query-devtools": "^5.76.1",
7273
"@testing-library/jest-dom": "^6.9.1",
7374
"@testing-library/react": "^14.2.1",

pnpm-lock.yaml

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)