Skip to content

Instantly share code, notes, and snippets.

@rahatarmanahmed
Created October 7, 2016 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahatarmanahmed/0403b41e4eae8f5efda1650b0613e8a7 to your computer and use it in GitHub Desktop.
Save rahatarmanahmed/0403b41e4eae8f5efda1650b0613e8a7 to your computer and use it in GitHub Desktop.
ESLint config that dynamically generates globals from a .js file with constants
var fs = require('fs');
var getGlobals = require('acorn-globals');
var globals = {
angular: true,
DashboardApp: true,
inject: true
};
var constants = fs.readFileSync(__dirname + '/dna-webapp/app/appConstants.js', 'utf8').toString();
getGlobals(constants, {includeFileVars: true}).forEach(function (global) {
globals[global.name] = true
});
module.exports = {
"extends": ["eslint:recommended"],
"env": {
"node": true,
"browser": true,
"jasmine": true,
"protractor": true
},
"globals": globals,
"rules": {
"semi": [2, "always"]
}
};
@rahatarmanahmed
Copy link
Author

NOTE: Uses the fork at https://github.com/cvializ/acorn-globals because upstream doesn't recognize var declarations as global

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment