LoginSignup
5
4

More than 5 years have passed since last update.

インラインのコメントから coffeelint の設定を有効/無効化する

Last updated at Posted at 2014-02-16

インラインのコメントから設定を有効/無効化する機能は、他言語の lint だったら、当たり前の様にあるので、無いはずないだろうと思っても、ドキュメントではどこにも見当たらず、テストコードを見たら、実装されていました。

test/test_comment_config.coffee on master

# coffeelint: disable=no_trailing_semicolons
a 'you get a semi-colon';
b 'you get a semi-colon';
# coffeelint: enable=no_trailing_semicolons
c 'everybody gets a semi-colon';

a, b は無視されるそうな。

逆も可能で、

# coffeelint: enable=no_implicit_parens
a 'implicit parens here'
b 'implicit parens', 'also here'
# coffeelint: disable=no_implicit_parens
c 'implicit parens allowed here'

今度は、a, b が怒られ、c は無視される。

更に enable とだけ言うと、全部 (??) 有効化できる風。

# coffeelint: disable=no_trailing_semicolons,no_implicit_parens
a 'you get a semi-colon';
b 'you get a semi-colon';
# coffeelint: enable
c 'everybody gets a semi-colon';

テストコードは無いですが、きっと disable もできるんでしょう。

これの有効範囲がどこまでなのか気になります。見た感じ、一度、有効/無効化した設定は、もう一度逆のことを設定してやらない限り、そのまま引き継がれるっぽいです。

coffeelint.coffee#171 付近 で実装されているようで、じっくり読書して理解を深めたいですが、今日は寝るので、今度調査します。

5
4
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
5
4