LoginSignup
1
0

More than 1 year has passed since last update.

ESLintのdisableコメントに注釈(コメント)を付ける方法

Last updated at Posted at 2023-02-16

コメントの付け方を知らないとdisableコメントの上にコメントを書き2行になってしまいます。
ですが、disableの後に続けてコメントを記載する方法があります。
方法はdisableコメントの後に--(スペース、ハイフン2つ、スペース)をつけるとコメントを記述することができます。

// hogeは使わない
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const hoge = 'hoge'
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- disableする理由も書けてスマートです
const hoge = 'hoge'

/* eslint-disable @typescript-eslint/no-unused-vars -- 囲む場合も同様です */
const hoge = 'hoge'
/* eslint-enable @typescript-eslint/no-unused-vars -- 上下どちらにもコメントできます */
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