LoginSignup
3
4

More than 3 years have passed since last update.

Vue.jsでESLint

Last updated at Posted at 2019-05-16

VueでESLint

不要なのがあるかもしれない・・・
プロジェクト作成時にprettierは入れている

npm install --save-dev eslint-config-standard
npm install --save-dev eslint-plugin-import
npm install --save-dev eslint-plugin-node
npm install --save-dev eslint-plugin-promise
npm install --save-dev eslint-plugin-standard

設定ファイルの編集

プロジェクトルート直下の「.eslintrc.js」を編集する
細かい部分は調整が必要かもしれない

module.exports = {
  root: true,
  env: {
    node: true,
    mocha: true,
    browser: true,
  },
  extends: [
    'standard',
    'plugin:vue/recommended',
    'plugin:prettier/recommended',
  ],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'prettier/prettier': [
      'error',
      {
        semi: false,
        singleQuote: true,
        trailingComma: 'es5',
        indent: ['error', 2],
        'no-multiple-empty-lines': ['error', { max: 1 }],
      },
    ],
    // 'vue/html-closing-bracket-newline': 'off',
    'vue/max-attributes-per-line': 'off',
    'vue/html-self-closing': [
      'error',
      {
        html: {
          void: 'always',
          normal: 'always',
          component: 'always',
        },
        svg: 'always',
        math: 'always',
      },
    ],
    'vue/html-indent': [
      'error',
      2,
      {
        attribute: 1,
        baseIndent: 1,
        closeBracket: 0,
        alignAttributesVertically: true,
        ignores: [],
      },
    ],
  },
  parserOptions: {
    parser: 'babel-eslint',
  },
}

実行してみる

npm run lint
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4