これは
TypeScriptの学習にとても役立ちそうなドキュメントを教えてもらったので
コツコツと読んでいく記事です。
参考
著作権者:フューチャー株式会社(Future Corporation)様
基本の環境構築
ビルドのツールのインストールと設定
editconfigの設定をしてインデントを統一する。
editconfig内に以下のような記述をする。
root = true [*] indent_style = space indent_size = 4 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true
prettierのインストール
$ npm install --save-dev typescript prettier eslint @typescript-eslint/eslint-plugin eslint-plugin-prettier eslint-config-prettier npm-run-all
便利機能として、
設定ファイルはnpx tsc --init
を実行すると雛形を作ってくれる。
ESLintの設定を作る
eslintrc
{ "plugin": [ "prettier" ], "extends": [ "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended" ], "rules": { "no-console": [ false ], "@typescript-eslint/indent": "ingore", "prettier/prettier": "error" } }
npm run lintやnpm run fixでコードチェックやスタイル修正を行うために
ESLintを起動するタスクをpackage.jsonに追加する。
"scripts": { "lint": "eslint .", "fix": "eslint --fix ." }
今日はここまで。