8000 ESLint · uupaa/WebApp2 Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
uupaa edited this page Jun 10, 2017 · 5 revisions

Install

npm i を実行すると ESLint がインストールされます。

npm i

./node_modules/.bin/eslint --version --version

> v3.19.0

簡単な使い方

ESLint は JavaScript のエラーチェックを行うコマンドラインツールです。

npm run eslint [options] file.js [file.js...]
npm run eslit [options] dir とタイプすることで、JavaScript ファイルのチェックを行います。

npm run eslint app/lib
npm run eslint app/lib/modules/foo/bar.js

チェックしたくないファイルは .eslintignore に記述し、ルールの定義は .eslintrc に記述します。

初期設定

WebApp/2 を clone した直後の .eslintrc は以下のようになっており、 ES6 と ESModules を有効化しています。

{
  "parserOptions": {
    "ecmaVersion":      6,
    "sourceType":       "module"
  },
  "env": {
    "browser":          true,
    "node":             true,
    "es6":              true
  },
  "extends": [
    "eslint:recommended"
  ],
  "rules": {
    "strict":           [0],
    "no-new":           [0],
    "new-cap":          [0],
    "no-empty":         [0],
    "no-shadow":        [0],
    "camelcase":        [0],
    "key-spacing":      [0],
    "dot-notation":     [0],
    "comma-dangle":     [0],
    "no-console":       [0],
    "no-multi-str":     [0],
    "no-multi-spaces":  [0],
    "no-control-regex": [0],
    "no-unused-vars":   [1, { "vars": "all", "args": "after-used"} ],
    "no-underscore-dangle": [0],
    "no-use-before-define": [0],
    "no-inner-declarations": [0]
  },
  "globals": {
    "unescape":         false,
    "escape":           false
  }
}
0