Skip to content

Commit

Permalink
fix: resolve magic number warnings in eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitb35 committed Jul 30, 2024
1 parent 0208e9d commit c9ebff6
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const MAX_PARAMS = 4;
const JSX_INDENT_SIZE = 2;

module.exports = {
env: {
node: true,
Expand All @@ -10,7 +13,7 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:storybook/recommended',
'plugin:import/recommended' // Add this line to include recommended rules from eslint-plugin-import
'plugin:import/recommended', // Add this line to include recommended rules from eslint-plugin-import
],
parser: '@typescript-eslint/parser',
parserOptions: {
Expand All @@ -28,19 +31,25 @@ module.exports = {
'prefer-const': 'warn',
'no-var': 'error',
'consistent-return': 'warn',
'eqeqeq': ['error', 'always'],
eqeqeq: ['error', 'always'],
'@typescript-eslint/explicit-module-boundary-types': 'warn',
'@typescript-eslint/explicit-function-return-type': 'warn',

// React Best Practices
'react/jsx-key': 'error',
'react/no-array-index-key': 'warn',
'react/jsx-curly-brace-presence': ['warn', { props: 'never', children: 'never' }],
'react/jsx-curly-brace-presence': [
'warn',
{ props: 'never', children: 'never' },
],

// Code Quality
'complexity': ['warn', { max: 10 }],
'max-lines': ['warn', { max: 300, skipBlankLines: true, skipComments: true }],
'max-params': ['warn', 4],
complexity: ['warn', { max: 10 }],
'max-lines': [
'warn',
{ max: 300, skipBlankLines: true, skipComments: true },
],
'max-params': ['warn', MAX_PARAMS],
'no-magic-numbers': ['warn', { ignore: [0, 1] }],

// Security
Expand All @@ -55,7 +64,7 @@ module.exports = {
'no-empty-pattern': 'warn',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
Expand All @@ -65,28 +74,25 @@ module.exports = {
'react/react-in-jsx-scope': 'off',
'react/jsx-props-no-spreading': 'warn',
'react/jsx-filename-extension': [
'warn',
{ extensions: ['.js', '.jsx', '.tsx'] }
'warn',
{ extensions: ['.js', '.jsx', '.tsx'] },
],
'react/no-unknown-property': [
'error',
'error',
{
ignore: ['jsx', 'global'],
}
],
'react/jsx-indent': [
'warn',
2
},
],
'react/jsx-indent': ['warn', JSX_INDENT_SIZE],
'import/extensions': [
'warn',
'always',
'warn',
'always',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
}
},
],
'import/no-unresolved': 'warn', // should be error
'import/named': 'warn', // should be error
Expand Down

0 comments on commit c9ebff6

Please sign in to comment.