sindresorhus/eslint-plugin-unicorn

Allow some strings in `string-content`

クローズ

#681 opened on 2020/04/11

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

Repository metrics

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

説明

Rule: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/string-content.md

Issues reported in https://github.com/xojs/xo/pull/439#issuecomment-598751860

I initially suggested this rule in https://github.com/sindresorhus/eslint-plugin-unicorn/issues/327 but I'm not able to use it for my original case because it applies to strings that shouldn't be changed.

I think this rule should instead be applied only in some cases, via whitelist.

An example would be:

  • use variable name, e.g. const description = 'More...'
  • use property name, e.g. {description: 'More...'}
  • use TypeScript type, e.g. FeatureMeta['description']
  • use AST like indent rule’s ignoreNodes (not sure if this is applicable)
  • use JSX attributes and textContent

This would probably replace the current tag-based blacklist.

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