question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

valid-typeof: recommend "requireStringLiterals" true by default

See original GitHub issue

The 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
wmertenscommented, Feb 7, 2021

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?

0reactions
nzakascommented, Aug 28, 2021

We aren’t moving forward with this, so closing.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found