Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow some strings in string-content #681

Open
fregante opened this issue Apr 11, 2020 · 3 comments
Open

Allow some strings in string-content #681

fregante opened this issue Apr 11, 2020 · 3 comments

Comments

@fregante
Copy link
Collaborator

fregante commented Apr 11, 2020

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

Issues reported in xojs/xo#439 (comment)

I initially suggested this rule in #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.

@fisker
Copy link
Collaborator

fisker commented Apr 11, 2020

I think node selector is a good idea, but people might not familiar with that syntax.

@fisker
Copy link
Collaborator

fisker commented Apr 11, 2020

@fregante
Copy link
Collaborator Author

fregante commented Apr 11, 2020

people might not familiar with that syntax.
Indeed.

I use it too, but I just copy-pasted it from some GitHub issue.

@fregante fregante changed the title Add some sort of whitelist to string-content Allow some strings in to string-content Nov 9, 2021
@fregante fregante changed the title Allow some strings in to string-content Allow some strings in string-content Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@sindresorhus @fisker @fregante and others