Created
October 7, 2016 21:31
-
-
Save rahatarmanahmed/0403b41e4eae8f5efda1650b0613e8a7 to your computer and use it in GitHub Desktop.
ESLint config that dynamically generates globals from a .js file with constants
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: Uses the fork at https://github.com/cvializ/acorn-globals because upstream doesn't recognize var declarations as global