configs: use rules in relevant configs

This commit is contained in:
vchikalkin 2023-07-19 16:56:07 +03:00
parent 86ab43aeb4
commit 56a4255144
7 changed files with 299 additions and 146 deletions

1
auto.js Normal file
View File

@ -0,0 +1 @@
module.exports = require('./index');

127
core.js
View File

@ -21,4 +21,131 @@ module.exports = {
}, },
], ],
plugins: ['canonical', 'sonarjs', '@typescript-eslint', 'prettier'], 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',
},
}; };

153
index.js
View File

@ -21,7 +21,11 @@ module.exports = {
files: '*.ts', files: '*.ts',
}, },
{ {
extends: ['canonical/react', 'canonical/jsx-a11y', 'canonical/typescript'], extends: [
'canonical/react',
'canonical/jsx-a11y',
'canonical/typescript',
],
files: '*.tsx', files: '*.tsx',
}, },
{ {
@ -41,5 +45,150 @@ module.exports = {
extends: ['plugin:testing-library/react', 'canonical/jest'], 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',
},
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "@vchikalkin/eslint-config-awesome", "name": "@vchikalkin/eslint-config-awesome",
"version": "1.0.4", "version": "1.0.5",
"license": "MIT", "license": "MIT",
"main": "index.js", "main": "index.js",
"devDependencies": { "devDependencies": {
@ -23,9 +23,12 @@
"repository": "https://github.com/vchikalkin/eslint-config-awesome", "repository": "https://github.com/vchikalkin/eslint-config-awesome",
"author": "vchikalkin", "author": "vchikalkin",
"keywords": [ "keywords": [
"eslint",
"config", "config",
"eslint",
"json",
"nextjs", "nextjs",
"prettier" "prettier",
"react",
"zod"
] ]
} }

11
react.js vendored
View File

@ -18,4 +18,15 @@ module.exports = {
files: '*.jsx', files: '*.jsx',
}, },
], ],
rules: {
'react/prop-types': 'off',
'react/jsx-sort-props': 'off',
'react/function-component-definition': [
'error',
{
namedComponents: 'function-declaration',
unnamedComponents: 'arrow-function',
},
],
},
}; };

141
rules.js
View File

@ -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',
},
};

3
zod.js
View File

@ -14,4 +14,7 @@ module.exports = {
files: '*.ts', files: '*.ts',
}, },
], ],
rules: {
'zod/require-strict': 'off',
},
}; };