• 追加された行はこの色です。
  • 削除された行はこの色です。
#author("2021-02-17T06:07:54+09:00","default:ryuichi","ryuichi")
* ESLint + TypeScript [#p51dbd4d]
#author("2021-02-17T06:42:53+09:00","default:ryuichi","ryuichi")
* ESLint + TypeScript [#r3007ee9]

** 前提 [#sa9fac80]

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

## インストール
** インストール [#jf3df6e5]

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

** 設定 [#z8b07b8e]
** 設定 [#se7fd683]

''.eslintrc.js'' 👇👇👇
	
	module.exports = {
	  root: true,
	  parser: '@typescript-eslint/parser',
	  plugins: [
	    '@typescript-eslint',
	  ],
	  extends: [
	    'eslint:recommended',
	    'plugin:@typescript-eslint/recommended',
	  ],
	};
*** ESLintの設定 [#m4aa6e63]

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

*** Lintスクリプトの設定 [#j1742417]
 📄package.json:
 
 {
   "scripts": {
     ...
     "lint": "eslint . --ext .ts",
     "lint-and-fix": "eslint . --ext .ts --fix"
   }
 }

** Lintの実行 [#ha7edc9e]

 npm run lint
 npm run lint-fix

** 参考 [#f021ee82]
- https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md
- https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/configs
- https://khalilstemmler.com/blogs/typescript/eslint-for-typescript/



トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS