github-pages-deploy-action/node_modules/eslint-plugin-github/lib/rules/no-implicit-buggy-globals.js

32 lines
748 B
JavaScript
Raw Normal View History

2020-03-31 20:42:07 +08:00
module.exports = {
meta: {
docs: {},
schema: []
},
create(context) {
return {
Program() {
var scope = context.getScope()
scope.variables.forEach(function(variable) {
if (variable.writeable) {
return
}
variable.defs.forEach(function(def) {
if (
def.type === 'FunctionName' ||
def.type === 'ClassName' ||
(def.type === 'Variable' && def.parent.kind === 'const') ||
(def.type === 'Variable' && def.parent.kind === 'let')
) {
context.report(def.node, 'Implicit global variable, assign as global property instead.')
}
})
})
}
}
}
}