sindresorhus/eslint-plugin-unicorn

`prevent-abbreviations`: Smarter `whitelist` option possibly deprecating `ignore` option

クローズ

#930 opened on 2020/12/09

 (1 件のコメント) (6 件のリアクション) (0 人の担当者)JavaScript (468 件のフォーク)user submission
enhancementhelp wanted

Repository metrics

Stars
 (5,022 個のスター)
PR merge metrics
 (平均マージ 1d 16h) (30d で 399 merged PRs)

説明

There are now two options to exclude an identifier from linting: older whitelist and newer ignore. I think whitelist alone would suffice with the following modification.

We could make whitelist match any subsequence of the split identifier. For example (following up this https://github.com/sindresorhus/eslint-plugin-unicorn/issues/567#issuecomment-591007369): For fooE2eBar all of these would be checked against whitelist:

  • foo
  • e
  • 2
  • bar
  • barE
  • e2
  • 2e
  • eBar
  • fooE2
  • e2e
  • 2eBar
  • fooE2e
  • e2eBar
  • fooE2eBar

And if any of them is in the whitelist that subsequence is ignored.

But in my opinion it should not ignore the whole identifier if only subsequence matches whitelist.

For example, if the user had e2e in their whitelist, e2eErr should still be fixed to e2eError.

From https://github.com/sindresorhus/eslint-plugin-unicorn/pull/891#issuecomment-713729469

コントリビューターガイド