LoginSignup
1
0

More than 5 years have passed since last update.

macのatom上でTypeScriptのlinterを使う

Last updated at Posted at 2015-07-05

ちょっくらTypeScriptでも勉強するかと思ってlinter-tslintを入れた。環境はOS X 10.10.4。
公式に書いてあることをそのままやっただけ。

前提

以下は既にインストールされているものとする。
* node
* atom

各種インストール

atomのlintツールは、Linterとatom-lintの二つがある。
今回は見た目がかっこいいという理由で、Linterでの導入手順を示す。

まず、Linterとlinter-tslintをインストールする。
atomエディタ上からでも、コマンドラインからでもよい。
コマンドラインからだと、以下のような感じ。

$ apm install linter
$ apm install linter-tslint

あと、tslintのバイナリが必要なので、$ npm install -g tslintでインストールする。

パスを通す

atom上のlinter-tslintのSetting画面で、$ which tslintで表示されたパスを入力。
Kobito.DKKPNN.png

Kobito.uL86cW.png

一度atomを終了して再度立ち上げると、tslintがatom上で動作するようになる。

注意点

nvm+zsh環境

nvm+zsh環境の場合は、nvmのロード処理を.zshrcではなく.zshenvに記述しなければならない。nvm公式のシェルスクリプトでは、.zshrcに以下のような記述が追加される。

export NVM_DIR="/Users/username/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

これを、コメントアウトし、.zshenvに同様の内容を記述すればOK.

nodeのversion

nodeの0.12系では、適切なパスをlinter-tslintに設定してもnot foundになる。
自分はnvmを使っていたので、0.10系を利用するように変更すると解決した。

$ nvm install 0.10

参考

linter-tslint
AtomのLinter

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0