codeclimate / codeclimate-eslint

Code Climate Engine for ESLint
MIT License
95 stars 93 forks source link

"env" variable from react-native should work. #413

Closed quinnbaetz closed 3 years ago

quinnbaetz commented 6 years ago

Bug Template

Actual Behavior

/usr/src/app/lib/validate_config.js:17 throw e; ^

Error: /code/.eslintrc.js: Environment key "react-native/react-native" is unknown

at Object.keys.forEach.env (/usr/local/node_modules/eslint/lib/config/config-validator.js:138:23)
at Array.forEach (native)
at validateEnvironment (/usr/local/node_modules/eslint/lib/config/config-validator.js:131:34)
at Object.validate (/usr/local/node_modules/eslint/lib/config/config-validator.js:160:5)
at Object.load (/usr/local/node_modules/eslint/lib/config/config-file.js:559:19)
at loadConfig (/usr/local/node_modules/eslint/lib/config.js:63:33)
at getLocalConfig (/usr/local/node_modules/eslint/lib/config.js:130:29)
at Config.getConfig (/usr/local/node_modules/eslint/lib/config.js:260:26)
at Config.getConfig (/usr/src/app/lib/eslint-patch.js:45:46)
at CLIEngine.getConfigForFile (/usr/local/node_modules/eslint/lib/cli-engine.js:776:29)

Expected Behavior

The engine should support plugins allowing global variables through the env.

Steps to reproduce

Add the following to .eslintrc.js

module.exports = {
  "parser": "babel-eslint",
  "extends": "airbnb",
  "plugins": ["react", "react-native" ],
  "env": {
    "react-native/react-native": true,
  }
}

Relevant links

https://www.npmjs.com/package/eslint-plugin-react-native


wfleming commented 6 years ago

Hi @quinnbaetz, can you provide a bit more detail on what ENV vars in your environment need to be available to the plugin and why? I'm not very familiar with the eslint-plugin-react-native plugin, so I'm not clear on what env it's using for this.

quinnbaetz commented 6 years ago

It "whitelists all browser-like globals". Currently I would use it for fetch and require. I have added those to globals directly, but the above should still work.

louy commented 5 years ago

Any luck with this one?

efueger commented 3 years ago

HI @quinnbaetz - apologies for dropping this!

sguha00 commented 3 years ago

I'm still getting this issue:

/usr/src/app/lib/validate_config.js:17
        throw e;
        ^

Error: /code/.eslintrc:
    Environment key "react-native/react-native" is unknown

    at Object.keys.forEach.env (/usr/local/node_modules/eslint/lib/config/config-validator.js:138:23)
    at Array.forEach (native)
    at validateEnvironment (/usr/local/node_modules/eslint/lib/config/config-validator.js:131:34)
    at Object.validate (/usr/local/node_modules/eslint/lib/config/config-validator.js:160:5)
    at Object.load (/usr/local/node_modules/eslint/lib/config/config-file.js:559:19)
    at loadConfig (/usr/local/node_modules/eslint/lib/config.js:63:33)
    at getLocalConfig (/usr/local/node_modules/eslint/lib/config.js:130:29)
    at Config.getConfig (/usr/local/node_modules/eslint/lib/config.js:260:26)
    at Config.getConfig (/usr/src/app/lib/eslint-patch.js:45:46)
    at CLIEngine.getConfigForFile (/usr/local/node_modules/eslint/lib/cli-engine.js:776:29)