.eslintrc.cjs 3.87 KB
Newer Older
minseok.park's avatar
minseok.park committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
module.exports = {
  root: true,
  env: { browser: true, es2020: true },
  extends: [
    'eslint:recommended',
    'plugin:react/recommended',
    'plugin:react/jsx-runtime',
    'plugin:react-hooks/recommended',
  ],
  ignorePatterns: ['dist', '.eslintrc.cjs'],
  parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
  settings: { react: { version: '18.2' } },
  plugins: ['react-refresh'],
  rules: {
    // react
    'react/prop-types': 0,

    // react-hooks
    'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
    'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies

    'react/display-name': 'off',
    'react/jsx-no-undef': ['error', {
      allowGlobals: true,
    }],

    // jsx-control-statements
    'jsx-control-statements/jsx-for-require-each': 'off',
    'jsx-control-statements/jsx-use-if-tag': 'off',

    // possible error
    'no-await-in-loop': 'error',
    'no-extra-parens': ['warn', 'functions'],
    'no-loss-of-precision': 'warn',
    'no-promise-executor-return': 'warn',
    'no-template-curly-in-string': 'warn',
    'no-unreachable-loop': 'warn',
    'no-useless-backreference': 'warn',
    'require-atomic-updates': 'error',

    // best practices
    'array-callback-return': 'error',
    // 'complexity': 'warn',
    'default-case-last': 'error',
    'eqeqeq': ['error', 'smart'],
    'grouped-accessor-pairs': 'warn',
    'no-constructor-return': 'error',
    'no-eval': 'error',
    'no-extend-native': 'warn',
    'no-extra-label': 'warn',
    'no-iterator': 'error',
    'no-lone-blocks': 'warn',
    'no-multi-spaces': ['warn', { ignoreEOLComments: true }],
    'no-new': 'warn',
    'no-new-func': 'warn',
    'no-new-wrappers': 'error',
    'no-param-reassign': 'error',
    'no-proto': 'error',
    'no-return-assign': 'error',
    'no-self-compare': 'warn',
    'no-unmodified-loop-condition': 'error',
    'no-useless-concat': 'error',
    'no-useless-return': 'error',
    'prefer-regex-literals': 'warn',
    'radix': 'error',

    // variables
    'no-unused-vars': ['warn', {
      args: 'after-used',
      argsIgnorePattern: '^_',
      ignoreRestSiblings: true,
      caughtErrors: 'none',
    }],

    // stylistic issues
    'array-bracket-spacing': ['warn'],
    'array-element-newline': ['warn', 'consistent'],
    'block-spacing': 'error',
    'comma-dangle': ['error', 'always-multiline'],
    'comma-spacing': 'warn',
    'comma-style': ['error', 'last'],
    'func-call-spacing': 'error',
    'eol-last': 'error',
    'indent': ['warn', 2, {
      VariableDeclarator: 'first',
      FunctionDeclaration: { parameters: 'first' },
      ignoreComments: true,
    }],
    'jsx-quotes': ['warn', 'prefer-single'],
    'keyword-spacing': 'error',
    'max-depth': 'error',
    'multiline-ternary': ['error', 'always-multiline'],
    'no-lonely-if': 'error',
    'no-multiple-empty-lines': ['warn', {
      max: 1,
      maxEOF: 0,
      maxBOF: 0,
    }],
    'no-trailing-spaces': 'error',
    'no-unneeded-ternary': 'error',
    'object-curly-spacing': ['warn', 'always'],
    'operator-linebreak': ['warn', 'before'],
    'quotes': ['warn', 'single', {
      avoidEscape: true,
      allowTemplateLiterals: true,
    }],
    'semi': ['warn', 'never'],
    'space-before-function-paren': 'warn',
    'space-in-parens': 'error',
    'space-infix-ops': ['error', { int32Hint: false }],

    // ecma6
    'arrow-body-style': 'warn',
    'arrow-spacing': 'error',
    'no-confusing-arrow': 'error',
    'no-restricted-exports': ['error', {
      restrictedNamedExports: ['defaults'],
    }],
    'no-useless-computed-key': 'warn',
    'no-useless-constructor': 'warn',
    'no-useless-rename': 'error',
    'no-var': 'error',
    // 'prefer-const': 'warn',
    'prefer-numeric-literals': 'warn',
    'prefer-rest-params': 'warn',
    'prefer-spread': 'warn',
    'prefer-template': 'warn',
    'rest-spread-spacing': 'warn',
    'yield-star-spacing': 'warn',
  },
}