@elfinct/eslint-plugin-elfin
Advanced tools
Comparing version 0.0.3 to 0.0.4
"use strict"; | ||
var getStaticPropertyName = require('../utils').getStaticPropertyName; | ||
var _a = require('../utils'), getStaticPropertyName = _a.getStaticPropertyName, getVariableByName = _a.getVariableByName; | ||
module.exports = { | ||
@@ -98,4 +98,9 @@ meta: { | ||
var scope = context.getScope(); | ||
// 收集所有的console && 输出 | ||
scope.through.filter(isConsole).forEach(report); | ||
var consoleVar = getVariableByName(scope, 'console'); | ||
var shadowed = consoleVar && consoleVar.defs.length > 0; | ||
var references = consoleVar ? consoleVar.references : scope.through.filter(isConsole); | ||
if (!shadowed) { | ||
// 收集所有的console && 输出 | ||
references.filter(isConsole).forEach(report); | ||
} | ||
}, | ||
@@ -102,0 +107,0 @@ }; |
@@ -70,2 +70,21 @@ "use strict"; | ||
exports.getStaticPropertyName = getStaticPropertyName; | ||
/** | ||
* Finds the variable by a given name in a given scope and its upper scopes. | ||
* | ||
* @param {eslint-scope.Scope} initScope - A scope to start find. | ||
* @param {string} name - A variable name to find. | ||
* @returns {eslint-scope.Variable|null} A found variable or `null`. | ||
*/ | ||
function getVariableByName(initScope, name) { | ||
var scope = initScope; | ||
while (scope) { | ||
var variable = scope.set.get(name); | ||
if (variable) { | ||
return variable; | ||
} | ||
scope = scope.upper; | ||
} | ||
return null; | ||
} | ||
exports.getVariableByName = getVariableByName; | ||
//# sourceMappingURL=ast.js.map |
{ | ||
"name": "@elfinct/eslint-plugin-elfin", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
57412
1253