From 56a42551449de24c8bf4698fbb33e683608c4279 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 19 Jul 2023 16:56:07 +0300 Subject: [PATCH] configs: use rules in relevant configs --- auto.js | 1 + core.js | 127 ++++++++++++++++++++++++++++++++++++++++++ index.js | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++- package.json | 9 ++- react.js | 11 ++++ rules.js | 141 ----------------------------------------------- zod.js | 3 + 7 files changed, 299 insertions(+), 146 deletions(-) create mode 100644 auto.js delete mode 100644 rules.js diff --git a/auto.js b/auto.js new file mode 100644 index 0000000..e6e13eb --- /dev/null +++ b/auto.js @@ -0,0 +1 @@ +module.exports = require('./index'); diff --git a/core.js b/core.js index 8e7b395..ba3f8cc 100644 --- a/core.js +++ b/core.js @@ -21,4 +21,131 @@ module.exports = { }, ], plugins: ['canonical', 'sonarjs', '@typescript-eslint', 'prettier'], + rules: { + // Disabled + 'brace-style': 'off', + '@typescript-eslint/brace-style': 'off', + 'comma-dangle': 'off', + '@typescript-eslint/comma-dangle': 'off', + 'comma-spacing': 'off', + '@typescript-eslint/comma-spacing': 'off', + 'func-call-spacing': 'off', + '@typescript-eslint/func-call-spacing': 'off', + indent: 'off', + '@typescript-eslint/indent': 'off', + 'keyword-spacing': 'off', + '@typescript-eslint/keyword-spacing': 'off', + 'lines-between-class-members': 'off', + '@typescript-eslint/lines-between-class-members': 'off', + '@typescript-eslint/member-delimiter-style': 'off', + 'no-extra-parens': 'off', + '@typescript-eslint/no-extra-parens': 'off', + 'object-curly-spacing': 'off', + '@typescript-eslint/object-curly-spacing': 'off', + 'padding-line-between-statements': 'off', + '@typescript-eslint/padding-line-between-statements': 'off', + quotes: 'off', + '@typescript-eslint/quotes': 'off', + semi: 'off', + '@typescript-eslint/semi': 'off', + 'space-before-blocks': 'off', + '@typescript-eslint/space-before-blocks': 'off', + 'space-before-function-paren': 'off', + '@typescript-eslint/space-before-function-paren': 'off', + 'space-infix-ops': 'off', + '@typescript-eslint/space-infix-ops': 'off', + '@typescript-eslint/type-annotation-spacing': 'off', + + // Config + 'linebreak-style': ['error', 'windows'], + 'import/extensions': 'off', + 'newline-before-return': 'warn', + '@typescript-eslint/consistent-type-imports': 'error', + 'function-paren-newline': 'off', + 'promise/prefer-await-to-then': 'off', + '@typescript-eslint/explicit-member-accessibility': [ + 'warn', + { + accessibility: 'explicit', + overrides: { + constructors: 'off', + }, + }, + ], + 'id-length': 'warn', + 'import/no-unassigned-import': 'off', + 'import/no-named-as-default-member': 'warn', + '@typescript-eslint/naming-convention': 'warn', + + // Unicorn + 'unicorn/no-array-for-each': 'off', + 'unicorn/prevent-abbreviations': 'off', + 'unicorn/prefer-node-protocol': 'off', + 'unicorn/no-array-reduce': 'off', + 'unicorn/prefer-module': 'off', + 'unicorn/text-encoding-identifier-case': 'off', + 'unicorn/filename-case': [ + 'error', + { + case: 'kebabCase', + ignore: ['^.*.(jsx|tsx)$'], + }, + ], + 'unicorn/numeric-separators-style': [ + 'warn', + { + onlyIfContainsSeparator: false, + hexadecimal: { + minimumDigits: 0, + groupLength: 2, + }, + binary: { + minimumDigits: 0, + groupLength: 4, + }, + octal: { + minimumDigits: 0, + groupLength: 4, + }, + number: { + minimumDigits: 5, + groupLength: 3, + }, + }, + ], + + // Canonical + 'canonical/prefer-inline-type-import': 'off', + '@babel/object-curly-spacing': ['off'], + 'canonical/filename-match-exported': ['off'], + 'canonical/import-specifier-newline': ['off'], + 'canonical/destructuring-property-newline': ['off'], + 'canonical/export-specifier-newline': 'off', + 'canonical/sort-keys': [ + 'warn', + 'asc', + { + natural: true, + }, + ], + 'canonical/id-match': ['off'], + 'import/order': [ + 'error', + { + groups: [], + 'newlines-between': 'always', + }, + ], + 'func-style': ['warn', 'declaration', { allowArrowFunctions: true }], + 'arrow-body-style': [ + 'error', + 'as-needed', + { + requireReturnForObjectLiteral: false, + }, + ], + + // Sonar + 'sonarjs/no-duplicate-string': 'warn', + }, }; diff --git a/index.js b/index.js index d241d3e..0938938 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,11 @@ module.exports = { files: '*.ts', }, { - extends: ['canonical/react', 'canonical/jsx-a11y', 'canonical/typescript'], + extends: [ + 'canonical/react', + 'canonical/jsx-a11y', + 'canonical/typescript', + ], files: '*.tsx', }, { @@ -41,5 +45,150 @@ module.exports = { extends: ['plugin:testing-library/react', 'canonical/jest'], }, ], - plugins: ['canonical', 'sonarjs', '@typescript-eslint', 'prettier', 'testing-library'], + plugins: [ + 'canonical', + 'sonarjs', + '@typescript-eslint', + 'prettier', + 'testing-library', + ], + rules: { + // Disabled + 'brace-style': 'off', + '@typescript-eslint/brace-style': 'off', + 'comma-dangle': 'off', + '@typescript-eslint/comma-dangle': 'off', + 'comma-spacing': 'off', + '@typescript-eslint/comma-spacing': 'off', + 'func-call-spacing': 'off', + '@typescript-eslint/func-call-spacing': 'off', + indent: 'off', + '@typescript-eslint/indent': 'off', + 'keyword-spacing': 'off', + '@typescript-eslint/keyword-spacing': 'off', + 'lines-between-class-members': 'off', + '@typescript-eslint/lines-between-class-members': 'off', + '@typescript-eslint/member-delimiter-style': 'off', + 'no-extra-parens': 'off', + '@typescript-eslint/no-extra-parens': 'off', + 'object-curly-spacing': 'off', + '@typescript-eslint/object-curly-spacing': 'off', + 'padding-line-between-statements': 'off', + '@typescript-eslint/padding-line-between-statements': 'off', + quotes: 'off', + '@typescript-eslint/quotes': 'off', + semi: 'off', + '@typescript-eslint/semi': 'off', + 'space-before-blocks': 'off', + '@typescript-eslint/space-before-blocks': 'off', + 'space-before-function-paren': 'off', + '@typescript-eslint/space-before-function-paren': 'off', + 'space-infix-ops': 'off', + '@typescript-eslint/space-infix-ops': 'off', + '@typescript-eslint/type-annotation-spacing': 'off', + + // Config + 'linebreak-style': ['error', 'windows'], + 'import/extensions': 'off', + 'react/prop-types': 'off', + 'newline-before-return': 'warn', + '@typescript-eslint/consistent-type-imports': 'error', + 'function-paren-newline': 'off', + 'promise/prefer-await-to-then': 'off', + '@typescript-eslint/explicit-member-accessibility': [ + 'warn', + { + accessibility: 'explicit', + overrides: { + constructors: 'off', + }, + }, + ], + 'id-length': 'warn', + 'import/no-unassigned-import': 'off', + 'import/no-named-as-default-member': 'warn', + 'react/jsx-sort-props': 'off', + '@typescript-eslint/naming-convention': 'warn', + + // Unicorn + 'unicorn/no-array-for-each': 'off', + 'unicorn/prevent-abbreviations': 'off', + 'unicorn/prefer-node-protocol': 'off', + 'unicorn/no-array-reduce': 'off', + 'unicorn/prefer-module': 'off', + 'unicorn/text-encoding-identifier-case': 'off', + 'unicorn/filename-case': [ + 'error', + { + case: 'kebabCase', + ignore: ['^.*.(jsx|tsx)$'], + }, + ], + 'unicorn/numeric-separators-style': [ + 'warn', + { + onlyIfContainsSeparator: false, + hexadecimal: { + minimumDigits: 0, + groupLength: 2, + }, + binary: { + minimumDigits: 0, + groupLength: 4, + }, + octal: { + minimumDigits: 0, + groupLength: 4, + }, + number: { + minimumDigits: 5, + groupLength: 3, + }, + }, + ], + + // Canonical + 'canonical/prefer-inline-type-import': 'off', + '@babel/object-curly-spacing': ['off'], + 'canonical/filename-match-exported': ['off'], + 'canonical/import-specifier-newline': ['off'], + 'canonical/destructuring-property-newline': ['off'], + 'canonical/export-specifier-newline': 'off', + 'canonical/sort-keys': [ + 'warn', + 'asc', + { + natural: true, + }, + ], + 'canonical/id-match': ['off'], + 'import/order': [ + 'error', + { + groups: [], + 'newlines-between': 'always', + }, + ], + 'func-style': ['warn', 'declaration', { allowArrowFunctions: true }], + 'react/function-component-definition': [ + 'error', + { + namedComponents: 'function-declaration', + unnamedComponents: 'arrow-function', + }, + ], + 'arrow-body-style': [ + 'error', + 'as-needed', + { + requireReturnForObjectLiteral: false, + }, + ], + + // Sonar + 'sonarjs/no-duplicate-string': 'warn', + + // Zod + 'zod/require-strict': 'off', + }, }; diff --git a/package.json b/package.json index e048aa0..322a043 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vchikalkin/eslint-config-awesome", - "version": "1.0.4", + "version": "1.0.5", "license": "MIT", "main": "index.js", "devDependencies": { @@ -23,9 +23,12 @@ "repository": "https://github.com/vchikalkin/eslint-config-awesome", "author": "vchikalkin", "keywords": [ - "eslint", "config", + "eslint", + "json", "nextjs", - "prettier" + "prettier", + "react", + "zod" ] } diff --git a/react.js b/react.js index 0b71421..5a8ee40 100644 --- a/react.js +++ b/react.js @@ -18,4 +18,15 @@ module.exports = { files: '*.jsx', }, ], + rules: { + 'react/prop-types': 'off', + 'react/jsx-sort-props': 'off', + 'react/function-component-definition': [ + 'error', + { + namedComponents: 'function-declaration', + unnamedComponents: 'arrow-function', + }, + ], + }, }; diff --git a/rules.js b/rules.js deleted file mode 100644 index 2c53cdf..0000000 --- a/rules.js +++ /dev/null @@ -1,141 +0,0 @@ -module.exports = { - rules: { - // Disabled - 'brace-style': 'off', - '@typescript-eslint/brace-style': 'off', - 'comma-dangle': 'off', - '@typescript-eslint/comma-dangle': 'off', - 'comma-spacing': 'off', - '@typescript-eslint/comma-spacing': 'off', - 'func-call-spacing': 'off', - '@typescript-eslint/func-call-spacing': 'off', - indent: 'off', - '@typescript-eslint/indent': 'off', - 'keyword-spacing': 'off', - '@typescript-eslint/keyword-spacing': 'off', - 'lines-between-class-members': 'off', - '@typescript-eslint/lines-between-class-members': 'off', - '@typescript-eslint/member-delimiter-style': 'off', - 'no-extra-parens': 'off', - '@typescript-eslint/no-extra-parens': 'off', - 'object-curly-spacing': 'off', - '@typescript-eslint/object-curly-spacing': 'off', - 'padding-line-between-statements': 'off', - '@typescript-eslint/padding-line-between-statements': 'off', - quotes: 'off', - '@typescript-eslint/quotes': 'off', - semi: 'off', - '@typescript-eslint/semi': 'off', - 'space-before-blocks': 'off', - '@typescript-eslint/space-before-blocks': 'off', - 'space-before-function-paren': 'off', - '@typescript-eslint/space-before-function-paren': 'off', - 'space-infix-ops': 'off', - '@typescript-eslint/space-infix-ops': 'off', - '@typescript-eslint/type-annotation-spacing': 'off', - - // Config - 'linebreak-style': ['error', 'windows'], - 'import/extensions': 'off', - 'react/prop-types': 'off', - 'newline-before-return': 'warn', - '@typescript-eslint/consistent-type-imports': 'error', - 'function-paren-newline': 'off', - 'promise/prefer-await-to-then': 'off', - '@typescript-eslint/explicit-member-accessibility': [ - 'warn', - { - accessibility: 'explicit', - overrides: { - constructors: 'off', - }, - }, - ], - 'id-length': 'warn', - 'import/no-unassigned-import': 'off', - 'import/no-named-as-default-member': 'warn', - 'react/jsx-sort-props': 'off', - '@typescript-eslint/naming-convention': 'warn', - - // Unicorn - 'unicorn/no-array-for-each': 'off', - 'unicorn/prevent-abbreviations': 'off', - 'unicorn/prefer-node-protocol': 'off', - 'unicorn/no-array-reduce': 'off', - 'unicorn/prefer-module': 'off', - 'unicorn/text-encoding-identifier-case': 'off', - 'unicorn/filename-case': [ - 'error', - { - case: 'kebabCase', - ignore: ['^.*.(jsx|tsx)$'], - }, - ], - 'unicorn/numeric-separators-style': [ - 'warn', - { - onlyIfContainsSeparator: false, - hexadecimal: { - minimumDigits: 0, - groupLength: 2, - }, - binary: { - minimumDigits: 0, - groupLength: 4, - }, - octal: { - minimumDigits: 0, - groupLength: 4, - }, - number: { - minimumDigits: 5, - groupLength: 3, - }, - }, - ], - - // Canonical - 'canonical/prefer-inline-type-import': 'off', - '@babel/object-curly-spacing': ['off'], - 'canonical/filename-match-exported': ['off'], - 'canonical/import-specifier-newline': ['off'], - 'canonical/destructuring-property-newline': ['off'], - 'canonical/export-specifier-newline': 'off', - 'canonical/sort-keys': [ - 'warn', - 'asc', - { - natural: true, - }, - ], - 'canonical/id-match': ['off'], - 'import/order': [ - 'error', - { - groups: [], - 'newlines-between': 'always', - }, - ], - 'func-style': ['warn', 'declaration', { allowArrowFunctions: true }], - 'react/function-component-definition': [ - 'error', - { - namedComponents: 'function-declaration', - unnamedComponents: 'arrow-function', - }, - ], - 'arrow-body-style': [ - 'error', - 'as-needed', - { - requireReturnForObjectLiteral: false, - }, - ], - - // Sonar - 'sonarjs/no-duplicate-string': 'warn', - - // Zod - 'zod/require-strict': 'off', - }, -}; diff --git a/zod.js b/zod.js index 3dd5515..85db74e 100644 --- a/zod.js +++ b/zod.js @@ -14,4 +14,7 @@ module.exports = { files: '*.ts', }, ], + rules: { + 'zod/require-strict': 'off', + }, };