ESLint + TypeScript

前提

  • 2019年TSLintはdeprecatedになったので、2020年以降はESLintを代わりに使う

インストール

 npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin

設定

ESLintの設定

 📄.eslintrc.js:
 
 module.exports = {
   root: true,
   parser: '@typescript-eslint/parser',
   plugins: [
     '@typescript-eslint',
   ],
   extends: [
     'eslint:recommended',
     'plugin:@typescript-eslint/recommended',
   ],
 };

Lintスクリプトの設定

 📄package.json:
 
 {
   "scripts": {
     ...
     "lint": "eslint . --ext .ts",
     "lint-and-fix": "eslint . --ext .ts --fix"
   }
 }

Lintの実行

 npm run lint
 npm run lint-fix

参考


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2021-02-17 (水) 06:42:53