valid-typeof: recommend "requireStringLiterals" true by default
See original GitHub issueThe version of ESLint you are using. 7.18
The problem you want to solve.
I typed typeof v !== undefined
instead of typeof v !== 'undefined'
and eslint with the recommended settings didn’t warn me. This was one of those hard to find stupid bugs.
Your take on the correct solution to problem.
Since typeof
nowadays only returns strings, I propose that the option requireStringLiterals
be true
by default in the eslint:recommended
settings.
Are you willing to submit a pull request to implement this change? Sure
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (8 by maintainers)
Top Results From Across the Web
valid-typeof - ESLint - Pluggable JavaScript Linter
This rule enforces comparing typeof expressions to valid string literals. Options. This rule has an object option: "requireStringLiterals": true requires typeof ...
Read more >valid-typeof_规则| Rules_Eslint_参考手册_非常教程
valid-typeof. "extends": "eslint:recommended" 配置文件中的属性启用此规则。 ... "requireStringLiterals": true 要求 typeof 表达式仅与字符串文字或其他 typeof ...
Read more >@thibaudcolas/eslint-plugin-cookbook - Package Manager
config: now exports only the recommended config, Prettier-compatible. There is no reason to have separate config since it no longer mandates Prettier usage....
Read more >eslint-config-imweb - npm
Rule Name:react/require-default-props ... Rule Name:import/prefer-default-export ["off"] ... Rule Name:valid-typeof
Read more >gitea/.eslintrc at drachenfels-de/main - gitea - Gitea: Git with a cup of ...
import/extensions: [2, always, {ignorePackages: true}] ... import/no-anonymous-default-export: [0] ... valid-typeof: [2, {requireStringLiterals: true}].
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
But wouldn’t it be ok to show an error in this case, so that only crazy people that redefine
undefined
have to explicitly disable the setting?Are people like that even running eslint?
We aren’t moving forward with this, so closing.