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.

Create no-global-assign rule

See original GitHub issue

What version are you using?

2.2.0

What did you do?

I have the file test.js:

/*global a:false */
a = 5;

I have the configuration .eslintrc.yaml:

root: true
rules:
  no-undef: 2

I linted the file with the command-line argument eslint test.js.

What happened?

It did not report any errors.

What did you expect to happen?

I expect it to warn me that I am assigning to a global variable with the false flag, as described in the documentation.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

3reactions
mikesherovcommented, Apr 27, 2016

Ok, yeah, I think we can mark this as JSHint compat though, no? And I won’t work on this until JSCS compat is done, but I would like to champion this, so when it gets 3 thumbs, I can assign it to myself?

3reactions
mikesherovcommented, Apr 27, 2016

ok, I’ll champion this. Important to maintain feature parity with JSHint here. I recommend:

  1. Fixing docs for no-undef, and also have them point to this new rule.
  2. Recognizing the \* global var:true *\ annotation as exceptions to this rule.
  3. ignore \* global var:false *\ as that only applies to no-undef.
  4. Also recognizing an array of exceptions to this rule.
  5. Rule shall be named no-global-assign.

Given 2 & 4, a dev coming from JSHint SHOULD convert \* global var: true *\ to // eslint no-global-assign ["error", ["var"]] *\, but isn’t absolutely required to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Eslint Error while working with Trails js - Stack Overflow
1 Answer 1 ... The no-global-assign rule was added in ESLint 3.3.0. You need to use that version or later, if you want...
Read more >
no-undef - ESLint - Pluggable JavaScript Linter
This rule can help you locate potential ReferenceErrors resulting from misspellings ... See no-global-assign if you also want to disallow those assignments.
Read more >
How to benchmark ESLint rules - JavaScript in Plain English
The performance of ESLint rules can be benchmarked by setting the environment variable TIMING=1. ... no-global-assign | 0.630 | 0.4%
Read more >
List of available rules - ESLint - Pluggable JavaScript linter
No rules are enabled by default. ... Possible Errors. These rules relate to possible syntax or logic errors in JavaScript code: ... no-global-assign....
Read more >
Rules - JavaScript Standard Style
This is a summary of the standard JavaScript rules. The best way to ... Declare browser globals with a /* global */ comment....
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