Closed9

npm init @eslint/config 実行時の選択内容についてソースを確認してみる

k-ta-yamadak-ta-yamada

https://www.npmjs.com/package/@eslint/create-config

https://github.com/eslint/create-config

ESLint の導入にて以下のコマンドが公式で紹介されている。

npm init @eslint/config

https://eslint.org/docs/latest/use/getting-started

その際に以下のような選択を行う。

npm init @eslint/config での選択
✔ How would you like to use ESLint? · problems
✔ What type of modules does your project use? · esm
✔ Which framework does your project use? · none
✔ Does your project use TypeScript? · No / __Yes__
✔ Where does your code run? · node
✔ What format do you want your config file to be in? · JavaScript
Local ESLint installation not found.
The config that you've selected requires the following dependencies:

@typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest eslint@latest
✔ Would you like to install them now? · No / __Yes__
✔ Which package manager do you want to use? · npm

それぞれの選択によって実際に何がおきるのか @eslint/create-config を確認してみた。

k-ta-yamadak-ta-yamada

purpose

purpose
? How would you like to use ESLint? …
  To check syntax only
❯ To check syntax and find problems
  To check syntax, find problems, and enforce code style

https://github.com/eslint/create-config/blob/main/lib/init/config-initializer.js#L407-L419

https://github.com/eslint/create-config/blob/main/lib/init/config-initializer.js#L228-L238

style の場合にインデントなどの設定などを追加で質問されるようになる。
そのあたりは ESLint Stylistic で対応の方針なので、デフォルトでもある plobrems を選択する。

k-ta-yamadak-ta-yamada

env

env
? Where does your code run? …  (Press <space> to select, <a> to toggle all, <i> to invert selection)
✔ Browser
  Node

https://github.com/eslint/create-config/blob/main/lib/init/config-initializer.js#L468-L478

複数選択のため、スペースキーでそれぞれ on / off すること。
カーソルで上下移動して Enter を押してもそれが選択されるわけではない。
勘違いして Node を選んだつもりが Browser のままになっていた。

このスクラップは3ヶ月前にクローズされました