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.

Support whitelist with `no-implicit-globals`

See original GitHub issue

What rule do you want to change?

no-implicit-globals

Does this change cause the rule to produce more or fewer warnings?

Fewer warnings when new config is set.

How will the change be implemented? (New option, new default behavior, etc.)?

A new option.

Please provide some example code that this change will affect:

All of the examples which currently report, e.g.,

var foo = 1;
function bar() {}

or for non-strict mode:

foo = 1;

Also for the following when lexicalBindings is true.

const foo = 1;
let baz;
class Bar {}

What does the rule currently do for this code?

Reports them.

What will the rule do after it’s changed?

Not report them. E.g., when the rules is defined as /* eslint no-implicit-globals: ['error', {allowed: ['foo', 'baz', 'Bar', 'bar']}] */

Are you willing to submit a pull request to implement this change?

Possibly, yes.

The whitelist is intended to be particularly useful when auditing third-party code, ensuring that it doesn’t set any other globals than are expected (while still allowing it to set some expected globals). However, this could be useful for any project which wishes to avoid accidentally setting globals (while still allowing it to set some and not being forced into the style of setting on window–which one might wish to forbid separately with no-restricted-syntax anyways).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Mar 23, 2020

This is actually the first time I’ve heard of ESLint being used this way, so I don’t think it’s a common use case. It’s definitely cool, though, and I do think it would be better to have a plugin with custom rules. I’m happy to defer to team consensus on this 😃

0reactions
eslint-deprecated[bot]commented, Apr 25, 2020

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-implicit-globals - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
ESLint "no-implicit-globals" rule is being ignored
Disallows the use of undeclared variables unless mentioned in /*global */ comments. The most common reason why I've seen this rule being ...
Read more >
Note if `/* exported */` applies when using `--no-inline ... - GitHub
So , will it make sense to support it for --no-inline-config command like ... as it is with globals (though with no-implicit-globals lacking...
Read more >
Create safe sender lists in EOP - Office 365 - Microsoft Learn
Use this setting if the sending domain does not use email ... Outside the organization: This condition is implicit, but it's OK to...
Read more >
Implicit Broadcast Exceptions | Android Developers
Implicit broadcasts that are exempted from background restrictions.
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