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.

Option to disable inline global declarations

See original GitHub issue

Tell us about your environment

  • ESLint Version: v3.19.0
  • Node Version: v6.10.0
  • npm Version: 3.10.10

What parser (default, Babel-ESLint, etc.) are you using? babel-eslint

The problem you want to solve. Disallowing developers to introduce new globals.

ESLint allows two ways of specifying global variables—setting globals in a configuration file and as a comment in a JavaScript file /* global var1, var2 */.

http://eslint.org/docs/user-guide/configuring#specifying-globals

Your take on the correct solution to problem While globals are sometimes necessary, I’d like to be able to only allow globals that are specified by the globals in a config file and not as comments inside a JavaScript file. The reason for this is that we have a large codebase and we’d like to be able to enforce which globals we allow at a top level without allowing individual developers to be able to override this in their own files. While we can do this by making sure people don’t change the .eslintrc file it’s harder to watch for people doing /* global var1, var2 */ in a file.

I noticed this issue the other day when someone was porting some code that contained /* global jq */ to a place where jQuery was not defined on the global scope and thus ESLint didn’t help with catching this.

Of course I can use a different tool or a custom ESLint rule to disable comments like /* global var1, var2 */ but it would be nice if this could be included natively as part of ESLint.

I’m unsure the best way to do this. Intuitively it makes more sense to me for this to be an option to no-undef but given that this logic appears to be handled well before the code in no-undef is even run it might make more sense to happen in the configuration file.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Jul 10, 2017

@ljharb In general, I take your point; however, one could manage CLI options per project using npm scripts in package.json.

That said, I wouldn’t be opposed to leveraging optionator to expand inline-config to support key/value options to augment its current Boolean mode. Might be worth creating a separate issue?

0reactions
not-an-aardvarkcommented, Nov 3, 2017

Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn’t get consensus from the team, so I’m closing it. We define consensus as having three 👍s from team members, as well as a team member willing to champion the proposal. This is a high bar by design – we can’t realistically accept and maintain every feature request in the long term, so we only accept feature requests which are useful enough that there is consensus among the team that they’re worth adding.

Since ESLint is pluggable and can load custom rules at runtime, the lack of consensus among the ESLint team doesn’t need to be a blocker for you using this in your project, if you’d find it useful. It just means that you would need to implement a rule yourself to disallow /* global */ comments, rather than using core behavior that is packaged with ESLint.

Read more comments on GitHub >

github_iconTop Results From Across the Web

intellij idea - Suppress NOTHING_TO_INLINE warning globally
Therefore, to ignore compiler warnings about using inline functions, I have to use lots of Suppress("NOTHING_TO_INLINE") annotations through out ...
Read more >
/Ob (Inline Function Expansion) | Microsoft Learn
The compiler treats the inline expansion options and keywords as suggestions. There's no guarantee that any function will be expanded inline.
Read more >
Selectively Disable Inlining for Functions - LLVM Discourse
Dear All, I was wondering if there is a standard way of specifying a list of functions that *should not* be inlined by...
Read more >
Inline (Using the GNU Compiler Collection (GCC))
One is available with -std=gnu89 or -fgnu89-inline or when gnu_inline attribute is present on all inline declarations, another when -std=c99 , -std=gnu99 or...
Read more >
MATLAB coder.inline - MathWorks
If you use the codegen (MATLAB Coder) or the fiaccel (Fixed-Point Designer) command, you can disable inlining for all functions by using the...
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