LoginSignup
42
49

More than 5 years have passed since last update.

新しくなった eslint --init を試す

Last updated at Posted at 2015-11-21

ESLint v1.10.0 がリリースされました。

このリリースでは、ESLint の初期設定の面倒臭さを軽減するために eslint --init コマンドが改善されています。
具体的には、人気の共有設定から選択してインストールし、.eslintrcpackage.json を自動的に更新するようになりました。

See Also: 共有設定でらくらく ESLint

さっそく試してみます。


shell
> npm install -g eslint-cli

その前に、簡単のために eslint-cli を入れておきます。
See Also: ESLint をグローバルにインストールせずに使う


shell
> npm install --save-dev eslint
...(略)...
> eslint -v
v1.10.1
> eslint --init

インストールした ESLint のバージョンを確認 (v1.10.0以上) して、eslint --init コマンドを使います。
すると、まずは

shell
? How would you like to configure ESLint? (Use arrow keys)
> Answer questions about your style
  Use a popular style guide
? どうやって ESLint を設定しますか? (矢印キーで選択してください)
> スタイルに関する質問に答える
  人気のスタイルガイドを使う

設定の作り方を聞かれるので、矢印キーで Use a popular style guide を選んで Enter!

shell
? How would you like to configure ESLint? Use a popular style guide
? Which style guide do you want to follow? (Use arrow keys)
> Google
  AirBnB
  Standard
? How would you like to configure ESLint? Use a popular style guide
? どのスタイル ガイドを使いますか? (矢印キーで選択してください)
> Google
  AirBnB
  Standard

現在 (2015/11/21) は3つから選択することができます。
共有設定でらくらく ESLint のほうに簡単な解説がありますので御覧ください。

十字キーで好みの設定を選んで Enter!

shell
? How would you like to configure ESLint? Use a popular style guide
? Which style guide do you want to follow? Google
? What format do you want your config file to be in? (Use arrow keys)
> JavaScript
  YAML
  JSON
? How would you like to configure ESLint? Use a popular style guide
? Which style guide do you want to follow? Google
? どのフォーマットで設定ファイルを出力しますか? (矢印キーで選択してください)
> JavaScript
  YAML
  JSON

十字キーで好みのフォーマットを選んで Enter!


以上です。
この後 少し待つと .eslintrc (拡張子付き) が作られ、必要な共有設定とプラグインがインストールされ、package.json が更新されます。

なお、ここで設定したスタイルは後で変更したり、一部だけ上書きしたりできます。
詳しくは ESLint 最初の一歩 を御覧ください。

42
49
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
42
49