Rule Change: no-implicit-globals should not report exported
See original GitHub issueWhat 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:
- Created a year ago
- Reactions:3
- Comments:9 (7 by maintainers)
Top 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 >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
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 globaltestFunc
, and would be an alternative to the stylewindow.testFunc = function (){}
that this rule currently enforces.Sounds good.