I cannot delete warnings from Eslint

Asked

Viewed 124 times

2

I am learning React-Native, I have never had much experience with Javascript, I have installed the Eslint extension and I am trying to follow the line looking for the best syntax.

But there are two warnings I couldn’t get rid of and I can’t understand why.

The first every time I put one alert() no matter the content

[eslint] 'alert' is not defined. (no-undef)
function alert(message?: any): void

The second no require

<Image source={require('./imgs/logo.png')} />

Also no matter the content

[eslint] Unexpected require(). (global-require)
function require(name: string): any

The app works ok even with these warnings but would like to understand them

1 answer

3


In Eslint you have a configuration file, then you can tell Eslint the environments you work for it to have some global variables like alert and require (*).

Thus, in the configuration file .eslintrc.js put whatever you need:

env: {
    browser: true,
    commonjs: true,
    es6: true,
    node: true
},

* - see documentation here

  • I understood, but in mine .eslintrc.json have only that {&#xA; "extends": "rallycoding"&#xA;}

  • And when I put it like that you said just make mistakes

  • 1

    @Matthew in this case the file should look like this: {"extends":"rallycoding","env":{"browser":true,"commonjs":true,"es6":true,"node":true}}

  • 1

    Thanks now it worked out

Browser other questions tagged

You are not signed in. Login or sign up in order to post.