- Step by Stepで始めるESLint
インストール†
- コマンド実行
npm install --global eslint
- .eslintrc の最低限
{ "parserOptions": { "ecmaVersion": 2017 }, "env": { "es6": true } }
.eslintrc†
(node:91121) [ESLINT_PERSONAL_CONFIG_LOAD] DeprecationWarning: '~/.eslintrc.*' config files have been deprecated.
- https://eslint.org/docs/user-guide/migrating-to-7.0.0
- https://eslint.org/docs/user-guide/configuring/#configuration-file-formats
- .eslintrc without file extension is deprecated
tsconfig.eslint.json†
- ESLintで「Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.」のエラーが出たら
emacs†
- Emacs で JavaScript コーディングを快適に
- .emacs 設定
(require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize)
- emacs 上で実行
M-x package-install <改行> js-auto-format-mode <改行> M-x package-install <改行> add-node-modules-path <改行>
- .emacs 設定
(add-hook 'js-mode-hook #'js-auto-format-mode) (add-hook 'js-mode-hook #'add-node-modules-path)
これで、 js ファイルを開くと有効になる。手動で反映させたい場合は、
M-x js-auto-format-execute
設定例†
- 共有設定でらくらく ESLint
その他†
- うわっ...私の.eslintrc、無駄が多すぎ...?
- eslint: error Parsing error: The keyword 'const' is reserved
- javascriptでエラーが出てしまいます(ERROR: Parsing error: The keyword 'const' is reserved)