Skip to content

Commit 7a596bf

Browse files
authored
Replace deprecated rules and remove fix cycles (#478)
1 parent 85fea9f commit 7a596bf

2 files changed

Lines changed: 28 additions & 68 deletions

File tree

src/configs/javascript.ts

Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const baseRules: Linter.RulesRecord = {
6868
'no-fallthrough': 'error',
6969
'@stylistic/no-floating-decimal': 'error',
7070
'no-global-assign': ['error', {exceptions: []}],
71-
'no-native-reassign': 'off',
7271
'no-implicit-coercion': ['off', {
7372
boolean: false,
7473
number: true,
@@ -156,7 +155,6 @@ const baseRules: Linter.RulesRecord = {
156155
message: 'Use the exponentiation operator (**) instead.',
157156
}],
158157
'no-return-assign': ['error', 'always'],
159-
'no-return-await': 'error',
160158
'no-script-url': 'error',
161159
'no-self-assign': ['error', {
162160
props: true,
@@ -238,10 +236,8 @@ const baseRules: Linter.RulesRecord = {
238236
'no-unsafe-optional-chaining': ['error', {disallowArithmeticOperators: true}],
239237
'no-unused-private-class-members': 'off',
240238
'no-useless-backreference': 'error',
241-
'no-negated-in-lhs': 'off',
242239
'require-atomic-updates': 'off',
243240
'use-isnan': 'error',
244-
'valid-jsdoc': 'off',
245241
'valid-typeof': ['error', {requireStringLiterals: true}],
246242

247243
// Style (from airbnb-base, with customizations)
@@ -263,13 +259,7 @@ const baseRules: Linter.RulesRecord = {
263259
ignoreConsecutiveComments: true,
264260
},
265261
}],
266-
'@stylistic/comma-dangle': ['error', {
267-
arrays: 'always-multiline',
268-
objects: 'always-multiline',
269-
imports: 'always-multiline',
270-
exports: 'always-multiline',
271-
functions: 'always-multiline',
272-
}],
262+
'@stylistic/comma-dangle': ['error', 'always-multiline'],
273263
'@stylistic/comma-spacing': ['error', {before: false, after: true}],
274264
'@stylistic/comma-style': ['error', 'last', {
275265
exceptions: {
@@ -290,7 +280,7 @@ const baseRules: Linter.RulesRecord = {
290280
'consistent-this': 'off',
291281
'@stylistic/eol-last': ['error', 'always'],
292282
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
293-
'func-call-spacing': ['error', 'never'],
283+
'@stylistic/function-call-spacing': ['error', 'never'],
294284
'func-name-matching': ['off', 'always', {
295285
includeCommonJSModuleExports: false,
296286
considerPropertyDescriptor: true,
@@ -345,7 +335,7 @@ const baseRules: Linter.RulesRecord = {
345335
ignoreComments: false,
346336
},
347337
],
348-
'jsx-quotes': ['error', 'prefer-double'],
338+
'@stylistic/jsx-quotes': ['error', 'prefer-double'],
349339
'@stylistic/key-spacing': ['error', {beforeColon: false, afterColon: true}],
350340
'@stylistic/keyword-spacing': ['error', {
351341
before: true,
@@ -364,12 +354,8 @@ const baseRules: Linter.RulesRecord = {
364354
'@stylistic/linebreak-style': ['error', 'unix'],
365355
'@stylistic/lines-between-class-members': ['error', 'always', {exceptAfterSingleLine: false}],
366356
'@stylistic/lines-around-comment': 'off',
367-
'lines-around-directive': ['error', {
368-
before: 'always',
369-
after: 'always',
370-
}],
371357
'max-depth': ['off', 4],
372-
'max-len': [
358+
'@stylistic/max-len': [
373359
'error',
374360
{
375361
code: 120,
@@ -394,7 +380,7 @@ const baseRules: Linter.RulesRecord = {
394380
'max-nested-callbacks': 'off',
395381
'max-params': ['off', 3],
396382
'max-statements': ['off', 10],
397-
'max-statements-per-line': ['off', {max: 1}],
383+
'@stylistic/max-statements-per-line': ['off', {max: 1}],
398384
'@stylistic/multiline-comment-style': ['off', 'starred-block'],
399385
'@stylistic/multiline-ternary': ['error', 'always-multiline'],
400386
'new-cap': ['error', {
@@ -404,15 +390,13 @@ const baseRules: Linter.RulesRecord = {
404390
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
405391
}],
406392
'@stylistic/new-parens': 'error',
407-
'newline-after-var': 'off',
408-
'newline-before-return': 'off',
409393
'@stylistic/newline-per-chained-call': 'off',
410394
'no-array-constructor': 'error',
411395
'no-bitwise': 'off',
412396
'no-continue': 'off',
413397
'no-inline-comments': 'off',
414398
'no-lonely-if': 'error',
415-
'no-mixed-operators': ['error', {
399+
'@stylistic/no-mixed-operators': ['error', {
416400
groups: [
417401
['%', '**'],
418402
['%', '+'],
@@ -426,7 +410,7 @@ const baseRules: Linter.RulesRecord = {
426410
],
427411
allowSamePrecedence: false,
428412
}],
429-
'no-mixed-spaces-and-tabs': 'error',
413+
'@stylistic/no-mixed-spaces-and-tabs': 'error',
430414
'no-multi-assign': ['error'],
431415
'@stylistic/no-multiple-empty-lines': [
432416
'error',
@@ -438,16 +422,14 @@ const baseRules: Linter.RulesRecord = {
438422
],
439423
'no-negated-condition': 'off',
440424
'no-nested-ternary': 'error',
441-
'no-new-object': 'error',
442425
'no-plusplus': 'off',
443426
'no-restricted-syntax': [
444427
'error',
445428
'ForInStatement',
446429
'LabeledStatement',
447430
'WithStatement',
448431
],
449-
'no-spaced-func': 'error',
450-
'no-tabs': 'error',
432+
'@stylistic/no-tabs': 'error',
451433
'no-ternary': 'off',
452434
'@stylistic/no-trailing-spaces': ['error', {
453435
skipBlankLines: false,
@@ -471,7 +453,7 @@ const baseRules: Linter.RulesRecord = {
471453
'one-var': ['error', 'never'],
472454
'@stylistic/one-var-declaration-per-line': ['error', 'always'],
473455
'operator-assignment': ['error', 'always'],
474-
'@stylistic/operator-linebreak': ['error', 'before', {overrides: {'=': 'none'}}],
456+
'@stylistic/operator-linebreak': ['error', 'before', {overrides: {'=': 'ignore'}}],
475457
'@stylistic/padded-blocks': ['error', {
476458
blocks: 'never',
477459
classes: 'never',
@@ -546,9 +528,8 @@ const baseRules: Linter.RulesRecord = {
546528
],
547529
'prefer-exponentiation-operator': 'error',
548530
'prefer-object-spread': 'error',
549-
'@stylistic/quote-props': ['error', 'as-needed', {keywords: false, unnecessary: true, numbers: false}],
531+
'@stylistic/quote-props': ['error', 'as-needed', {keywords: false, unnecessary: true, numbers: true}],
550532
'@stylistic/quotes': ['error', 'single', {avoidEscape: true}],
551-
'require-jsdoc': 'off',
552533
'@stylistic/semi': ['error', 'always'],
553534
'@stylistic/semi-spacing': ['error', {before: false, after: true}],
554535
'@stylistic/semi-style': ['error', 'last'],
@@ -640,7 +621,6 @@ const baseRules: Linter.RulesRecord = {
640621
enforceForRenamedProperties: false,
641622
}],
642623
'prefer-numeric-literals': 'error',
643-
'prefer-reflect': 'off',
644624
'prefer-rest-params': 'error',
645625
'prefer-spread': 'error',
646626
'prefer-template': 'error',
@@ -658,7 +638,6 @@ const baseRules: Linter.RulesRecord = {
658638

659639
// Variables (from airbnb-base)
660640
'init-declarations': 'off',
661-
'no-catch-shadow': 'off',
662641
'no-delete-var': 'error',
663642
'no-label-var': 'error',
664643
'no-restricted-globals': [
@@ -752,22 +731,8 @@ const baseRules: Linter.RulesRecord = {
752731
// Strict (from airbnb-base)
753732
strict: ['error', 'never'],
754733

755-
// Node (from airbnb-base)
756-
'callback-return': 'off',
757-
'global-require': 'error',
758-
'handle-callback-err': 'off',
759-
'no-buffer-constructor': 'error',
760-
'no-mixed-requires': ['off', false],
761-
'no-new-require': 'error',
762-
'no-path-concat': 'error',
763-
'no-process-env': 'off',
764-
'no-process-exit': 'off',
765-
'no-restricted-modules': 'off',
766-
'no-sync': 'off',
767-
768734
// Import rules (from airbnb-base)
769735
'import-x/no-unresolved': 'off',
770-
'import-x/named': 'error',
771736
'import-x/default': 'off',
772737
'import-x/namespace': 'off',
773738
'import-x/export': 'error',
@@ -780,7 +745,6 @@ const baseRules: Linter.RulesRecord = {
780745
'import-x/no-amd': 'error',
781746
'import-x/no-nodejs-modules': 'off',
782747
'import-x/first': 'error',
783-
'import-x/imports-first': 'off',
784748
'import-x/no-duplicates': 'error',
785749
'import-x/no-namespace': 'off',
786750
'import-x/extensions': [
@@ -906,15 +870,5 @@ export function createJavaScriptConfig(plugin: ESLint.Plugin): Linter.Config[] {
906870
...baseRules,
907871
},
908872
},
909-
{
910-
name: '@croct/javascript/tests',
911-
files: [
912-
'src/**/*.test.js',
913-
'test/**/*.js',
914-
],
915-
rules: {
916-
'no-new-object': 'off',
917-
},
918-
},
919873
];
920874
}

src/configs/typescript.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ const baseRules: Linter.RulesRecord = {
2525
ignoreTypeValueShadow: true,
2626
ignoreFunctionTypeParameterNameValueShadow: true,
2727
}],
28-
'@typescript-eslint/no-empty-interface': 'off',
2928
'@typescript-eslint/explicit-member-accessibility': [
3029
'error',
3130
],
3231
'@typescript-eslint/explicit-module-boundary-types': 'off',
33-
'@typescript-eslint/explicit-function-return-type': ['error'],
32+
'@typescript-eslint/explicit-function-return-type': ['error', {allowExpressions: true}],
3433
'@typescript-eslint/no-explicit-any': 'off',
3534
'no-use-before-define': 'off',
3635
'@typescript-eslint/no-use-before-define': 'off',
@@ -71,6 +70,23 @@ const baseRules: Linter.RulesRecord = {
7170
}],
7271
'no-undef': 'off',
7372
'@typescript-eslint/no-namespace': 'off',
73+
'@typescript-eslint/restrict-template-expressions': 'off',
74+
75+
// Disable rules that turn `any` into `unknown`, places where `unknown` is the preferred type
76+
// have that type already.
77+
'@typescript-eslint/no-unsafe-argument': 'off',
78+
'@typescript-eslint/no-unsafe-assignment': 'off',
79+
'@typescript-eslint/no-unsafe-call': 'off',
80+
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
81+
'@typescript-eslint/no-unsafe-member-access': 'off',
82+
'@typescript-eslint/no-unsafe-return': 'off',
83+
'@typescript-eslint/no-unsafe-unary-minus': 'off',
84+
// Breaks with overloaded functions that implement both callback and Promise signatures
85+
'@typescript-eslint/no-misused-promises': 'off',
86+
// Doesn't detect classes that implement `toString` method
87+
'@typescript-eslint/no-base-to-string': 'off',
88+
// Conflict with TS promise ignore explicitly (void Promise)
89+
'no-void': 'off',
7490
};
7591

7692
// Factory function to create TypeScript config with the plugin reference
@@ -95,15 +111,5 @@ export function createTypescriptConfig(plugin: ESLint.Plugin, javascriptConfig:
95111
},
96112
rules: baseRules,
97113
},
98-
{
99-
name: '@croct/typescript/tests',
100-
files: [
101-
'src/**/*.test.ts',
102-
'test/**/*.ts',
103-
],
104-
rules: {
105-
'no-new-object': 'off',
106-
},
107-
},
108114
];
109115
}

0 commit comments

Comments
 (0)