Skip to content

Commit

Permalink
Merge pull request #3 from rambler-digital-solutions/new-rules
Browse files Browse the repository at this point in the history
feat: add code style rules
  • Loading branch information
andrepolischuk authored Jan 18, 2024
2 parents 30cadda + fb0be39 commit 7eb6985
Show file tree
Hide file tree
Showing 5 changed files with 518 additions and 303 deletions.
80 changes: 74 additions & 6 deletions packages/eslint-config/js.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-magic-numbers */

module.exports = {
parser: '@babel/eslint-parser',
env: {
Expand All @@ -8,19 +10,50 @@ module.exports = {
},
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:sonar/recommended',
'plugin:sonarjs/recommended',
'plugin:security/recommended'
'plugin:security/recommended-legacy'
],
rules: {
'no-multiple-empty-lines': ['error', {max: 1}],
'no-empty': ['error', {allowEmptyCatch: true}],
'prefer-const': ['error', {ignoreReadBeforeAssign: true}],
curly: ['error', 'all'],
semi: ['error', 'never'],
'comma-dangle': ['error', 'never'],
'eol-last': ['error', 'always'],
camelcase: ['error', {ignoreDestructuring: true}],
eqeqeq: ['error', 'always', {null: 'ignore'}],
'prefer-const': ['error', {ignoreReadBeforeAssign: true}],
'prefer-spread': 'error',
'prefer-template': 'error',
'prefer-rest-params': 'error',
'prefer-object-spread': 'error',
'prefer-destructuring': [
'error',
{array: true, object: true},
{enforceForRenamedProperties: true}
],
'prefer-arrow-callback': 'error',
'no-magic-numbers': [
'error',
{
ignore: [0, 1],
enforceConst: true,
ignoreDefaultValues: true,
ignoreClassFieldInitialValues: true
}
],
'dot-notation': 'error',
'max-depth': ['error', 2],
'max-nested-callbacks': ['error', 2],
'max-classes-per-file': 'error',
'max-params': ['error', 3],
'require-await': 'error',
'multiline-comment-style': ['error', 'starred-block'],
'no-prototype-builtins': 'off',
'no-global-assign': 'error',
'no-extend-native': 'error',
'padding-line-between-statements': [
'error',
{
Expand Down Expand Up @@ -55,9 +88,41 @@ module.exports = {
}
],
'no-duplicate-imports': 2,
'no-constant-condition': ['error', {
'checkLoops': false
}],
'no-constant-condition': [
'error',
{
checkLoops: false
}
],
'import/no-unresolved': ['error', {caseSensitiveStrict: true}],
'import/no-cycle': 'error',
'import/no-useless-path-segments': 'error',
'import/no-relative-parent-imports': 'error',
'import/no-default-export': 'error',
'import/no-unused-modules': [
'error',
{missingExports: false, unusedExports: true}
],
'import/no-anonymous-default-export': [
'error',
{allowCallExpression: false}
],
'import/newline-after-import': ['error', {considerComments: true}],
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'unknown',
'parent',
'index',
'sibling'
],
'newlines-between': 'ignore'
}
],
'sonar/anchor-precedence': 'error',
'sonar/bool-param-default': 'error',
'sonar/concise-regex': 'error',
Expand All @@ -71,7 +136,10 @@ module.exports = {
*/
'sonar/destructuring-assignment-syntax': 'off',
'sonar/empty-string-repetition': 'error',
'sonar/function-name': [2, {format: '^_?\\$?[a-zA-Z][a-zA-Z0-9]*\\$?$'}],
'sonar/function-name': [
'error',
{format: '^_?\\$?[a-zA-Z][a-zA-Z0-9]*\\$?$'}
],
'sonar/function-return-type': 'error',
'sonar/link-with-target-blank': 'error',
'sonar/max-union-size': 'off',
Expand Down
23 changes: 13 additions & 10 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
"access": "public"
},
"dependencies": {
"@babel/core": "^7.22.20",
"@babel/eslint-parser": "^7.22.15",
"@rushstack/eslint-patch": "^1.1.0",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"eslint-config-next": "^13.5.2",
"eslint-plugin-jsx-a11y": "^6.6.1",
"@babel/core": "^7.23.7",
"@babel/eslint-parser": "^7.23.3",
"@rushstack/eslint-patch": "^1.7.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"eslint-config-next": "^14.0.4",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-security": "^1.7.1",
"eslint-plugin-sonar": "^0.12.0",
"eslint-plugin-sonarjs": "^0.21.0"
"eslint-plugin-react-prefer-function-component": "^3.3.0",
"eslint-plugin-security": "^2.1.0",
"eslint-plugin-sonar": "^0.13.2",
"eslint-plugin-sonarjs": "^0.23.0",
"eslint-plugin-ssr-friendly": "^1.3.0"
}
}
16 changes: 13 additions & 3 deletions packages/eslint-config/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ module.exports = {
extends: [
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended'
'plugin:jsx-a11y/recommended',
'plugin:ssr-friendly/recommended',
'plugin:react-prefer-function-component/recommended'
],
rules: {
'react/prop-types': 0,
Expand All @@ -26,10 +28,18 @@ module.exports = {
}
],
'jsx-a11y/no-autofocus': [
2,
'error',
{
ignoreNonDOM: true
}
]
}
},
overrides: [
{
files: ['*.jsx', '*.tsx'],
rules: {
'import/no-default-export': 'off'
}
}
]
}
31 changes: 27 additions & 4 deletions packages/eslint-config/ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,42 @@ require('@rushstack/eslint-patch/modern-module-resolution')

module.exports = {
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{argsIgnorePattern: '^_', varsIgnorePattern: '^_'}
],
'@typescript-eslint/explicit-function-return-type': 'off'
]
},
overrides: [
{
files: ['*.ts', '*.mts', '*.cts', '*.tsx'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript'
],
rules: {
'prefer-destructuring': 'off',
'@typescript-eslint/prefer-destructuring': [
'error',
{array: true, object: true},
{
enforceForRenamedProperties: true,
enforceForDeclarationWithTypeAnnotation: true
}
],
'@typescript-eslint/no-magic-numbers': [
'error',
{
ignore: [0, 1],
enforceConst: true,
ignoreDefaultValues: true,
ignoreClassFieldInitialValues: true,
ignoreEnums: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
ignoreTypeIndexes: true
}
],
'@typescript-eslint/explicit-function-return-type': [
'error',
{allowExpressions: true}
Expand Down
Loading

0 comments on commit 7eb6985

Please sign in to comment.