LoginSignup
6
3

More than 5 years have passed since last update.

ESLintの導入手順まとめ

Last updated at Posted at 2018-06-13

ESLintの導入したときの手順をまとめる

yarn add

yarn add --dev eslint eslint-config-airbnb eslint-plugin-import babel-eslint`

設定ファイル

プロジェクト直下の内容のファイルを置く

.eslintrc.json
{
  "env": {
    "es6": true,
    "browser": true,
    "jquery": true // if use $
  },
   "plugins": [
    "import"
  ],
  "parser": "babel-eslint", // for async/await
  "extends": "airbnb-base"
}

ESLintの実行

Railsで app/frontend/javascriptにjsを配置するときの例
--fixオプションは可能なものは自動修正するオプション

以下の様にpackge.jsonscriptsに追加して
yarn run lint:javascriptで実行

package.json
...
  "scripts": {
    "lint:javascript": "eslint --fix app/frontend/javascripts/**/*"
  },
...
6
3
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
6
3