From dfa78e1e09a9aaff3f20bb491c4c257c7c981dc0 Mon Sep 17 00:00:00 2001 From: roikoren755 <26850796+roikoren755@users.noreply.github.com> Date: Sun, 27 Jun 2021 20:11:54 +0300 Subject: [PATCH] fix: re-order rules (#32) * fix: re-order rules * Create quiet-ducks-complain.md --- .changeset/quiet-ducks-complain.md | 5 ++++ src/configs/base.ts | 29 +---------------------- src/configs/type-checking.ts | 38 ++++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 .changeset/quiet-ducks-complain.md diff --git a/.changeset/quiet-ducks-complain.md b/.changeset/quiet-ducks-complain.md new file mode 100644 index 0000000..ede4795 --- /dev/null +++ b/.changeset/quiet-ducks-complain.md @@ -0,0 +1,5 @@ +--- +"eslint-config-altnext": patch +--- + +fix: put rules in right configuration diff --git a/src/configs/base.ts b/src/configs/base.ts index e9d0dca..8ba4159 100644 --- a/src/configs/base.ts +++ b/src/configs/base.ts @@ -124,25 +124,11 @@ const base: Linter.Config = { '@typescript-eslint/consistent-type-definitions': ERROR, '@typescript-eslint/consistent-type-imports': ERROR, '@typescript-eslint/class-literal-property-style': ERROR, - '@typescript-eslint/dot-notation': ERROR, '@typescript-eslint/default-param-last': ERROR, '@typescript-eslint/explicit-function-return-type': [ERROR, { allowExpressions: true }], '@typescript-eslint/explicit-member-accessibility': [ERROR, { accessibility: 'no-public' }], '@typescript-eslint/interface-name-prefix': OFF, '@typescript-eslint/method-signature-style': [ERROR, 'method'], - '@typescript-eslint/naming-convention': [ - ERROR, - { - selector: 'property', - format: ['camelCase', 'UPPER_CASE', 'PascalCase'], - leadingUnderscore: 'allow', - filter: { regex: '^process\\.env\\.[A-Z][A-Z_]*$', match: false }, - }, - { selector: 'variable', format: ['camelCase', 'UPPER_CASE', 'PascalCase'], leadingUnderscore: 'allow' }, - { selector: 'typeLike', format: ['PascalCase'] }, - { selector: 'typeAlias', format: ['PascalCase'], custom: { regex: '^I[A-Z]', match: false } }, - { selector: 'interface', format: ['PascalCase'], prefix: ['I'] }, - ], '@typescript-eslint/no-empty-function': WARN, '@typescript-eslint/no-empty-interface': [WARN, { allowSingleExtends: true }], '@typescript-eslint/no-extra-non-null-assertion': ERROR, @@ -152,12 +138,6 @@ const base: Linter.Config = { '@typescript-eslint/no-parameter-properties': ERROR, '@typescript-eslint/no-unused-expressions': [ERROR, { allowTernary: true }], '@typescript-eslint/no-unused-vars': [ERROR, { ignoreRestSiblings: true }], - - '@typescript-eslint/no-unsafe-assignment': WARN, - '@typescript-eslint/no-unsafe-call': WARN, - '@typescript-eslint/no-unsafe-member-access': WARN, - '@typescript-eslint/no-unsafe-return': WARN, - '@typescript-eslint/no-use-before-define': WARN, '@typescript-eslint/no-useless-constructor': ERROR, '@typescript-eslint/no-var-requires': WARN, @@ -166,7 +146,6 @@ const base: Linter.Config = { '@typescript-eslint/prefer-function-type': ERROR, '@typescript-eslint/prefer-optional-chain': WARN, '@typescript-eslint/prefer-ts-expect-error': ERROR, - '@typescript-eslint/require-await': OFF, '@typescript-eslint/sort-type-union-intersection-members': ERROR, '@typescript-eslint/unified-signatures': ERROR, @@ -314,13 +293,7 @@ const base: Linter.Config = { { files: ['./**/*.story.tsx'], rules: { 'no-console': OFF } }, { files: ['./**/*.spec.ts'], - rules: { - '@typescript-eslint/no-unsafe-assignment': OFF, - '@typescript-eslint/no-unsafe-return': OFF, - '@typescript-eslint/no-var-requires': OFF, - '@typescript-eslint/unbound-method': OFF, - 'unicorn/no-useless-undefined': OFF, - }, + rules: { '@typescript-eslint/no-var-requires': OFF, 'unicorn/no-useless-undefined': OFF }, }, ], }; diff --git a/src/configs/type-checking.ts b/src/configs/type-checking.ts index 74108f9..d6df268 100644 --- a/src/configs/type-checking.ts +++ b/src/configs/type-checking.ts @@ -1,6 +1,6 @@ import type { Linter } from 'eslint'; -import { ERROR, WARN } from './consts'; +import { ERROR, OFF, WARN } from './consts'; const typeChecking: Linter.Config = { parserOptions: { ecmaFeatures: { impliedStrict: true, globalReturn: true }, ecmaVersion: 6 }, @@ -14,26 +14,54 @@ const typeChecking: Linter.Config = { 'import/resolver': { node: { extensions: ['.ts', '.jsx', '.js', '.tsx', '.json'] }, typescript: {} }, jest: { version: 27 }, }, - extends: ['./src/configs/base', 'plugin:@typescript-eslint/recommended-requiring-type-checking'], + extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking', './src/configs/base'], rules: { + '@typescript-eslint/dot-notation': ERROR, + '@typescript-eslint/naming-convention': [ + ERROR, + { + selector: 'property', + format: ['camelCase', 'UPPER_CASE', 'PascalCase'], + leadingUnderscore: 'allow', + filter: { regex: '^process\\.env\\.[A-Z][A-Z_]*$', match: false }, + }, + { selector: 'variable', format: ['camelCase', 'UPPER_CASE', 'PascalCase'], leadingUnderscore: 'allow' }, + { selector: 'typeLike', format: ['PascalCase'] }, + { selector: 'typeAlias', format: ['PascalCase'], custom: { regex: '^I[A-Z]', match: false } }, + { selector: 'interface', format: ['PascalCase'], prefix: ['I'] }, + ], '@typescript-eslint/no-base-to-string': ERROR, '@typescript-eslint/no-confusing-void-expression': ERROR, - '@typescript-eslint/no-floating-promises': 1, + '@typescript-eslint/no-floating-promises': WARN, '@typescript-eslint/no-implied-eval': ERROR, '@typescript-eslint/no-throw-literal': ERROR, '@typescript-eslint/no-unnecessary-boolean-literal-compare': ERROR, '@typescript-eslint/no-unnecessary-type-arguments': ERROR, + '@typescript-eslint/no-unsafe-assignment': WARN, + '@typescript-eslint/no-unsafe-call': WARN, + '@typescript-eslint/no-unsafe-member-access': WARN, + '@typescript-eslint/no-unsafe-return': WARN, '@typescript-eslint/prefer-nullish-coalescing': WARN, '@typescript-eslint/prefer-readonly': ERROR, '@typescript-eslint/prefer-reduce-type-parameter': ERROR, '@typescript-eslint/require-array-sort-compare': ERROR, + '@typescript-eslint/require-await': ERROR, '@typescript-eslint/restrict-template-expressions': WARN, '@typescript-eslint/return-await': [ERROR, 'in-try-catch'], '@typescript-eslint/switch-exhaustiveness-check': ERROR, '@typescript-eslint/unbound-method': WARN, - '@typescript-eslint/require-await': ERROR, }, - overrides: [{ files: ['./**/{__mocks__,__tests__}/*.ts{x,}'], rules: { '@typescript-eslint/require-await': 1 } }], + overrides: [ + { files: ['./**/{__mocks__,__tests__}/*.ts{x,}'], rules: { '@typescript-eslint/require-await': WARN } }, + { + files: ['./**/*.spec.ts'], + rules: { + '@typescript-eslint/no-unsafe-assignment': OFF, + '@typescript-eslint/no-unsafe-return': OFF, + '@typescript-eslint/unbound-method': OFF, + }, + }, + ], }; export = typeChecking;