diff --git a/README.md b/README.md index 1805c63..12089b6 100644 --- a/README.md +++ b/README.md @@ -96,9 +96,6 @@ for it. ### Things to know -- The default config uses `@babel/eslint-parser` to support stage features that - ESLint doesn't support and it opts to use the `@babel/eslint-plugin` rules - over the ESLint rules to support rules for these features as well. - All plugins needed for rules used by these configs are dependencies of this module so you don't have to install anything on your own. - The default config actually is composed of several configurations and you can @@ -109,7 +106,7 @@ for it. ```javascript module.exports = { - extends: ['kentcdodds/es6', 'kentcdodds/import', 'kentcdodds/jest'], + extends: ['kentcdodds/import', 'kentcdodds/jest'], rules: { /* custom rules */ }, diff --git a/es6.js b/es6.js deleted file mode 100644 index a77d617..0000000 --- a/es6.js +++ /dev/null @@ -1,92 +0,0 @@ -module.exports = { - env: { - es6: true, - }, - extends: ['prettier'], - parser: '@babel/eslint-parser', - parserOptions: { - babelOptions: { - presets: ['@babel/preset-react'], - }, - ecmaVersion: 2018, - requireConfigFile: false, - sourceType: 'module', - }, - plugins: ['@babel'], - rules: { - 'arrow-body-style': 'off', - 'constructor-super': 'error', - 'no-class-assign': 'error', - 'no-const-assign': 'error', - 'no-dupe-class-members': 'error', - 'no-duplicate-imports': 'error', - 'no-new-symbol': 'error', - 'no-restricted-exports': 'off', // not applicable for a config preset (should be configured only in projects) - 'no-restricted-imports': 'off', // not applicable for a config preset (should be configured only in projects) - 'no-this-before-super': 'error', - 'no-unsafe-optional-chaining': 'error', - 'no-useless-computed-key': 'error', - 'no-useless-constructor': 'error', - 'no-useless-rename': 'error', - 'no-var': 'error', - 'object-shorthand': ['error', 'properties'], // methods are optional so you can specify a name if you want - 'prefer-arrow-callback': [ - 'error', - {allowNamedFunctions: true, allowUnboundThis: true}, - ], - 'prefer-const': 'error', - 'prefer-destructuring': 'off', // nah, I like it, but not that much... - 'prefer-numeric-literals': 'error', - 'prefer-rest-params': 'error', - 'prefer-spread': 'error', - 'prefer-template': 'error', - 'require-yield': 'error', - 'sort-imports': 'off', - 'symbol-description': 'error', - - 'new-cap': 'off', - '@babel/new-cap': ['error', {capIsNew: true, newIsCap: true}], - - 'no-invalid-this': 'off', - '@babel/no-invalid-this': 'error', - - 'no-unused-expressions': 'off', - '@babel/no-unused-expressions': 'error', - }, - overrides: [ - { - files: ['**/*.ts?(x)'], - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - plugins: ['@typescript-eslint'], - rules: { - 'constructor-super': 'off', // ts(2335) & ts(2377) - 'no-const-assign': 'off', // ts(2588) - 'no-new-symbol': 'off', // ts(2588) - 'no-this-before-super': 'off', // ts(2376) - 'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more - 'prefer-const': 'error', // ts provides better types with const - 'prefer-rest-params': 'error', // ts provides better types with rest args over arguments - 'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply - - 'no-dupe-class-members': 'off', - '@typescript-eslint/no-dupe-class-members': 'off', // ts(2393) & ts(2300) - - 'no-duplicate-imports': 'off', - '@typescript-eslint/no-duplicate-imports': 'error', - - 'no-useless-constructor': 'off', - '@typescript-eslint/no-useless-constructor': 'error', - - '@babel/no-invalid-this': 'off', - '@typescript-eslint/no-invalid-this': 'error', - - '@babel/no-unused-expressions': 'off', - '@typescript-eslint/no-unused-expressions': 'error', - }, - }, - ], -} diff --git a/index.js b/index.js index 8e83c41..946fba3 100644 --- a/index.js +++ b/index.js @@ -10,12 +10,14 @@ const tsConfig = fs.existsSync('tsconfig.json') module.exports = { env: { browser: true, + es6: true, node: true, }, - extends: ['prettier', './import.js', './es6.js'], + extends: ['prettier', './import.js'], rules: { 'accessor-pairs': 'error', 'array-callback-return': 'error', + 'arrow-body-style': 'off', 'block-scoped-var': 'error', camelcase: 'off', // annoying to disable... 'capitalized-comments': 'off', // wHO CaRes? @@ -23,6 +25,7 @@ module.exports = { complexity: ['error', 20], 'consistent-return': 'error', 'consistent-this': 'off', // Too many use-cases for reassigning "this" to different values + 'constructor-super': 'error', curly: ['error', 'multi-line'], 'default-case': 'error', 'default-case-last': 'error', @@ -66,9 +69,11 @@ module.exports = { 'no-bitwise': 'error', 'no-caller': 'error', 'no-case-declarations': 'error', + 'no-class-assign': 'error', 'no-compare-neg-zero': 'error', 'no-cond-assign': 'error', 'no-console': 'off', + 'no-const-assign': 'error', 'no-constant-condition': 'error', 'no-constructor-return': 'error', 'no-continue': 'off', @@ -77,9 +82,11 @@ module.exports = { 'no-delete-var': 'error', 'no-div-regex': 'error', 'no-dupe-args': 'error', + 'no-dupe-class-members': 'error', 'no-dupe-else-if': 'error', 'no-dupe-keys': 'error', 'no-duplicate-case': 'error', + 'no-duplicate-imports': 'error', 'no-else-return': 'off', 'no-empty': 'error', 'no-empty-character-class': 'error', @@ -120,6 +127,7 @@ module.exports = { 'no-new': 'error', 'no-new-func': 'error', 'no-new-object': 'error', + 'no-new-symbol': 'error', 'no-new-wrappers': 'error', 'no-nonoctal-decimal-escape': 'error', 'no-obj-calls': 'error', @@ -132,7 +140,9 @@ module.exports = { 'no-prototype-builtins': 'off', 'no-redeclare': 'error', 'no-regex-spaces': 'error', + 'no-restricted-exports': 'off', // not applicable for a config preset (should be configured only in projects) 'no-restricted-globals': ['error', 'event', 'fdescribe'], + 'no-restricted-imports': 'off', // not applicable for a config preset (should be configured only in projects) 'no-restricted-properties': 'off', // no ideas of what to disallow right now... 'no-restricted-syntax': ['error', 'WithStatement'], 'no-return-assign': 'error', @@ -147,6 +157,7 @@ module.exports = { 'no-sparse-arrays': 'error', 'no-template-curly-in-string': 'error', 'no-ternary': 'off', + 'no-this-before-super': 'error', 'no-throw-literal': 'error', 'no-undef': 'error', 'no-undef-init': 'error', @@ -158,6 +169,7 @@ module.exports = { 'no-unreachable-loop': 'error', 'no-unsafe-finally': 'error', 'no-unsafe-negation': 'error', + 'no-unsafe-optional-chaining': 'error', 'no-unused-expressions': 'off', 'no-unused-labels': 'error', 'no-unused-vars': [ @@ -173,28 +185,46 @@ module.exports = { 'no-useless-backreference': 'error', 'no-useless-call': 'error', 'no-useless-catch': 'error', + 'no-useless-computed-key': 'error', 'no-useless-concat': 'error', + 'no-useless-constructor': 'error', 'no-useless-escape': 'error', + 'no-useless-rename': 'error', 'no-useless-return': 'error', + 'no-var': 'error', 'no-void': 'off', 'no-warning-comments': ['error', {location: 'anywhere', terms: ['fixme']}], 'no-with': 'off', + 'object-shorthand': ['error', 'properties'], // methods are optional so you can specify a name if you want 'one-var': ['error', {initialized: 'never', uninitialized: 'always'}], 'operator-assignment': 'off', // readability on a case-by-case basis 'padding-line-between-statements': 'off', // meh... + 'prefer-arrow-callback': [ + 'error', + {allowNamedFunctions: true, allowUnboundThis: true}, + ], + 'prefer-const': 'error', + 'prefer-destructuring': 'off', // nah, I like it, but not that much... 'prefer-exponentiation-operator': 'warn', 'prefer-named-capture-group': 'off', // maybe one day... But I'm not used to it yet. + 'prefer-numeric-literals': 'error', 'prefer-object-spread': 'warn', 'prefer-promise-reject-errors': 'off', // maybe one day... Not sure I'm in... 'prefer-regex-literals': 'off', + 'prefer-rest-params': 'error', + 'prefer-spread': 'error', + 'prefer-template': 'error', radix: 'error', 'require-atomic-updates': 'off', 'require-await': 'off', 'require-unicode-regexp': 'off', + 'require-yield': 'error', + 'sort-imports': 'off', 'sort-keys': 'off', 'sort-vars': 'off', 'spaced-comment': 'off', strict: 'error', + 'symbol-description': 'error', 'use-isnan': 'error', 'valid-typeof': 'error', 'vars-on-top': 'error', @@ -211,19 +241,27 @@ module.exports = { }, plugins: ['@typescript-eslint'], rules: { + 'constructor-super': 'off', // ts(2335) & ts(2377) 'getter-return': 'off', // ts(2378) + 'no-const-assign': 'off', // ts(2588) 'no-dupe-args': 'off', // ts(2300) 'no-dupe-keys': 'off', // ts(1117) 'no-func-assign': 'off', // ts(2539) 'no-import-assign': 'off', // ts(2539) & ts(2540) + 'no-new-symbol': 'off', // ts(2588) 'no-obj-calls': 'off', // ts(2349) 'no-setter-return': 'off', // ts(2408) + 'no-this-before-super': 'off', // ts(2376) 'no-undef': 'off', // ts(2304) 'no-unreachable': 'off', // ts(7027) 'no-unsafe-negation': 'off', // ts(2365) & ts(2360) & ts(2358) 'valid-typeof': 'off', // ts(2367) 'consistent-return': 'off', // in TS this is much less an issue + 'no-var': 'error', // TS transpiles let/const to var, so no need for vars any more + 'prefer-const': 'error', // TS provides better types with const + 'prefer-rest-params': 'error', // TS provides better types with rest args over arguments + 'prefer-spread': 'error', // TS transpiles spread to apply, so no need for manual apply 'default-param-last': 'off', '@typescript-eslint/default-param-last': 'off', @@ -240,6 +278,12 @@ module.exports = { 'no-array-constructor': 'off', '@typescript-eslint/no-array-constructor': 'error', + 'no-dupe-class-members': 'off', + '@typescript-eslint/no-dupe-class-members': 'off', // ts(2393) & ts(2300) + + 'no-duplicate-imports': 'off', + '@typescript-eslint/no-duplicate-imports': 'error', + 'no-empty-function': 'off', '@typescript-eslint/no-empty-function': 'off', @@ -287,6 +331,9 @@ module.exports = { }, ], + 'no-useless-constructor': 'off', + '@typescript-eslint/no-useless-constructor': 'error', + '@typescript-eslint/adjacent-overload-signatures': 'error', '@typescript-eslint/array-type': 'off', '@typescript-eslint/await-thenable': 'error', diff --git a/package.json b/package.json index 865faef..6fa1e8d 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,6 @@ }, "homepage": "https://github.com/kentcdodds/eslint-config-kentcdodds#readme", "dependencies": { - "@babel/core": "^7.16.5", - "@babel/eslint-parser": "^7.16.5", - "@babel/eslint-plugin": "^7.16.5", - "@babel/preset-react": "^7.16.5", "@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/parser": "^4.33.0", "eslint-config-prettier": "^8.3.0",