Skip to content

Commit

Permalink
feat(eslint-config): add some new js/ts rules
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepolischuk committed Jan 19, 2024
1 parent e7d712d commit 622ed63
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 13 deletions.
49 changes: 43 additions & 6 deletions packages/eslint-config/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ require('@rushstack/eslint-patch/modern-module-resolution')

module.exports = {
parser: '@babel/eslint-parser',
parserOptions: {
requireConfigFile: false
},
env: {
es6: true,
browser: true,
Expand Down Expand Up @@ -41,6 +44,8 @@ module.exports = {
{enforceForRenamedProperties: true}
],
'prefer-arrow-callback': 'error',
'prefer-promise-reject-errors': 'error',
'object-shorthand': 'error',
'no-magic-numbers': [
'error',
{
Expand All @@ -51,15 +56,25 @@ module.exports = {
}
],
'dot-notation': 'error',
'max-depth': ['error', 2],
'max-nested-callbacks': ['error', 2],
'max-classes-per-file': 'error',
// eslint-disable-next-line no-magic-numbers
/* eslint-disable no-magic-numbers */
'max-depth': ['error', 3],
'max-nested-callbacks': ['error', 3],
'max-params': ['error', 3],
/* eslint-enable no-magic-numbers */
'max-classes-per-file': 'error',
'require-await': 'error',
'new-cap': 'error',
'no-prototype-builtins': 'off',
'no-global-assign': 'error',
'no-extend-native': 'error',
'no-alert': 'error',
'no-unsafe-optional-chaining': [
'error',
{disallowArithmeticOperators: true}
],
'no-unused-expressions': ['error', {enforceForJSX: true}],
'no-sequences': ['error', {allowInParentheses: false}],
'no-implicit-coercion': ['error', {disallowTemplateShorthand: true}],
'padding-line-between-statements': [
'error',
{
Expand Down Expand Up @@ -94,6 +109,9 @@ module.exports = {
}
],
'no-duplicate-imports': 'error',
'no-nested-ternary': 'error',
'no-unneeded-ternary': 'error',
'no-param-reassign': 'error',
'no-constant-condition': [
'error',
{
Expand All @@ -102,7 +120,6 @@ module.exports = {
],
'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': 'off',
'import/no-unresolved': 'off',
Expand Down Expand Up @@ -170,5 +187,25 @@ module.exports = {
'security/detect-pseudoRandomBytes': 'error',
'security/detect-unsafe-regex': 'off',
'security/detect-bidi-characters': 'error'
}
},
overrides: [
{
files: [
'**/test/**',
'**/tests/**',
'**/spec/**',
'**/__tests__/**',
'*.test.*',
'*.spec.*',
'*.e2e.*',
'*.e2e-spec.*'
],
rules: {
'no-magic-numbers': 'off',
'max-classes-per-file': 'off',
'sonarjs/no-duplicate-string': 'off',
'sonarjs/no-identical-functions': 'off'
}
}
]
}
29 changes: 22 additions & 7 deletions packages/eslint-config/ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
require('@rushstack/eslint-patch/modern-module-resolution')

module.exports = {
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{argsIgnorePattern: '^_', varsIgnorePattern: '^_'}
]
},
overrides: [
{
files: ['*.ts', '*.mts', '*.cts', '*.tsx'],
Expand All @@ -25,6 +19,11 @@ module.exports = {
'plugin:import/typescript'
],
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{argsIgnorePattern: '^_', varsIgnorePattern: '^_'}
],
'prefer-destructuring': 'off',
'@typescript-eslint/prefer-destructuring': [
'error',
Expand Down Expand Up @@ -54,6 +53,22 @@ module.exports = {
{allowExpressions: true}
]
}
},
{
files: [
'**/test/**',
'**/tests/**',
'**/spec/**',
'**/__tests__/**',
'*.test.*',
'*.spec.*',
'*.e2e.*',
'*.e2e-spec.*'
],
rules: {
'@typescript-eslint/no-magic-numbers': 'off'
}
}
]
],
ignorePatterns: ['*.d.ts']
}

0 comments on commit 622ed63

Please sign in to comment.