---
# System prepended metadata

title: Eslint設定(for react project)
tags: [專案]

---

---
tags: 專案
---
# Eslint設定(for react project)

```javascript=
module.exports = {
  'env': {
    'browser': true,
    'node': true,
    'es2021': true,
  },
  'extends': [
    'eslint:recommended',
    'plugin:react/recommended',
  ],
  'parserOptions': {
    'ecmaFeatures': {
      'jsx': true,
    },
    sourceType: 'module',
    'ecmaVersion': 'latest',
  },
  'plugins': [
    'react',
  ],
  'rules': {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-unused-vars': 'warn',
    'no-extend-native': 'off',
    'no-duplicate-imports': 'error',
    'no-multiple-empty-lines': 'error',
    'no-trailing-spaces': 'error',
    'no-multi-spaces': 'error',
    'no-var': 'error',
    'prefer-promise-reject-errors': 'off',
    'standard/no-callback-literal': 'off',
    'react/react-in-jsx-scope': 'off',
    'generator-star-spacing': 'off',
    'comma-dangle': [
      'error',
      'always-multiline',
    ],
    'line-comment-position': [
      'error', {
        position: 'above',
      },
    ],
    'react/prop-types': 'off',
    'comma-spacing': 'error',
    'arrow-spacing': [
      'error',
      {
        'before': true,
        'after': true,
      },
    ],
    'indent': ['warn', 2, { SwitchCase: 1 }],
    'key-spacing': ['error', { 'beforeColon': false }],
    'quotes': ['error', 'single'],
    'space-infix-ops': ['error', { 'int32Hint': false }],
    semi: ['error', 'never'],
    'eol-last': ['error', 'always'],
    'object-curly-spacing': ['error', 'always'],
    'prefer-const': 'error',
  },
}

```