Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLint ES6 Redux global-required Unexpected require();

Tags:

enter image description here

I have this problem with ESLint and can't soulve on my own, those stores are separated for each enviroement as you can see on the screenshot, how could I fix that to make ESLint happy and I to learn a new thing?

like image 840
Pedro Costa Neves Avatar asked May 27 '16 15:05

Pedro Costa Neves


People also ask

How do I disable global require in ESLint?

If you need to require() an optional dependency inside of a try / catch , you can disable this rule for just that dependency using the // eslint-disable-line global-require comment.

How do I turn off ESLint rule?

If you want to disable an ESLint rule in a file or on a specific line, you can add a comment. On a single line: const message = 'foo'; console. log(message); // eslint-disable-line no-console // eslint-disable-next-line no-console console.


2 Answers

It's because you're requiring in branched code: http://eslint.org/docs/rules/global-require.

If you don't want to change your code, just add disabling comments:

/* eslint-disable global-require */  // your code here  /* eslint-enable global-require */ 
like image 82
Lee Avatar answered Sep 19 '22 11:09

Lee


You can disable it in your .eslintrc file.

{    rules: {      "global-require": 0       } } 
like image 43
Bimal Grg Avatar answered Sep 18 '22 11:09

Bimal Grg