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.

Rule Change: no-implicit-globals should not report exported

See original GitHub issue

What rule do you want to change?

no-implicit-globals

What change to do you want to make?

Implement suggestions

How do you think the change should be implemented?

A new default behavior

Example code

/* exported testFunc */

/**
 * @returns {int}
 */
function testFunc() {
    "use strict";

    return 1 + 2;
}

What does the rule currently do for this code?

When using with lexicalBindings /*eslint no-implicit-globals: ["error", {"lexicalBindings": true}]*/ it gives an error

What will the rule do after it’s changed?

Not report an error, if the variable/function is “exported”

Additional comments

This was already requested previously but closed due to age https://github.com/eslint/eslint/issues/10066

Essentially it should have the same behavior as rule no-unused-vars, where exported variables/functions don’t count as unused

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Sep 19, 2022

Not report an error, if the variable/function is “exported”

Makes sense to me 👍

I think the main purpose of this rule is to prevent accidental creation of global variables. Declaring /* exported testFunc */ indicates the intention to create a global testFunc, and would be an alternative to the style window.testFunc = function (){} that this rule currently enforces.

0reactions
nzakascommented, Oct 3, 2022

However, if this requires adding a new property on Variable objects (https://github.com/eslint/eslint/pull/16343#discussion_r978961061), then it seems more appropriate to mark the change as a feat, as it will include an addition to the core.

Sounds good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-implicit-globals - ESLint - Pluggable JavaScript Linter
This rule disallows var and function declarations at the top-level script scope. This does not apply to ES and CommonJS modules since they...
Read more >
ESLint "no-implicit-globals" rule is being ignored
You are missing the rule no-undef. Disallows the use of undeclared variables unless mentioned in /*global */ comments.
Read more >
Managing Globals | InterSystems IRIS Data Platform 2022.2
The Management Portal provides tools for managing globals, and the system ... (Viewing and exporting do not affect the database and are safe...
Read more >
eslint-plugin-coffee - npm
For rules which don't "just work" for CoffeeScript, eslint-plugin-coffee aims ... should also be disabled if need be: "import/no-anonymous-default-export": ...
Read more >
Reports - Global Trade Alert
The Global Trade Alert Team | 04 May 2020. The purpose of this initiative is to collect information on changes in trade policy...
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