#author("2021-02-17T06:42:38+09:00","default:ryuichi","ryuichi")
#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
** 設定 [#se7fd683]
*** ESLintの設定 [#m4aa6e63]
📄.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/