Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No-undef ignore pattern

Tags:

eslint

Is there any way to exclude specific patterns from no-undef error. I tried 'no-undef': [2, { ignoreBuiltinGlobals: ['app'] }] where app is my global variable defined by webpack.defineplugin. If I switch this rule off - no errors appear.

I also tried to insert app: true in globals section of .eslintrc.js

Or another way to get my variable 'def' without errors

like image 519
IC_ Avatar asked Nov 15 '17 14:11

IC_


People also ask

What happens if var x = undefined in a loop?

This produces a different outcome than defining var x = undefined in the loop, as x is no longer reset to undefined each time through the loop. If you’re using such an initialization inside of a loop, then you should disable this rule. Example of correct code for this rule, because it is disabled on a specific line:

Is expect () undefined in jest undefined?

If you tell ESLint the environment is jest test () and expect () won't be considered as undefined. And since the default test files for jest are "**/*.spec.js", "**/__mocks__/**" I'd suggest you to add

What happens when you initialize a variable to undefined?

There is one situation where initializing to undefined behaves differently than omitting the initialization, and that’s when a var declaration occurs inside of a loop. For example: In this case, the var x is hoisted out of the loop, effectively creating: If you were to remove the initialization, then the behavior of the loop changes:

How do I ignore errors in a regular expression?

Errors can be ignored by adding a regular expression to the configuration file under the ignoreErrors key. To ignore an error by a regular expression in the whole project, add a string entry: To ignore errors by a regular expression only in a specific file, add an entry with message and path or paths keys.


1 Answers

I understand that you want eslint to ignore the app global variable.

Did you try /*global app */?

More info here

like image 56
ztadic91 Avatar answered Sep 20 '22 16:09

ztadic91