id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3,000 | eslint/eslint | lib/rules/no-implicit-coercion.js | isEmptyString | function isEmptyString(node) {
return astUtils.isStringLiteral(node) && (node.value === "" || (node.type === "TemplateLiteral" && node.quasis.length === 1 && node.quasis[0].value.cooked === ""));
} | javascript | function isEmptyString(node) {
return astUtils.isStringLiteral(node) && (node.value === "" || (node.type === "TemplateLiteral" && node.quasis.length === 1 && node.quasis[0].value.cooked === ""));
} | [
"function",
"isEmptyString",
"(",
"node",
")",
"{",
"return",
"astUtils",
".",
"isStringLiteral",
"(",
"node",
")",
"&&",
"(",
"node",
".",
"value",
"===",
"\"\"",
"||",
"(",
"node",
".",
"type",
"===",
"\"TemplateLiteral\"",
"&&",
"node",
".",
"quasis",
... | Checks whether a node is an empty string literal or not.
@param {ASTNode} node The node to check.
@returns {boolean} Whether or not the passed in node is an
empty string literal or not. | [
"Checks",
"whether",
"a",
"node",
"is",
"an",
"empty",
"string",
"literal",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-implicit-coercion.js#L115-L117 |
3,001 | eslint/eslint | lib/rules/no-implicit-coercion.js | report | function report(node, recommendation, shouldFix) {
context.report({
node,
message: "use `{{recommendation}}` instead.",
data: {
recommendation
},
fix(fixer) {
if (!shouldFix) {
... | javascript | function report(node, recommendation, shouldFix) {
context.report({
node,
message: "use `{{recommendation}}` instead.",
data: {
recommendation
},
fix(fixer) {
if (!shouldFix) {
... | [
"function",
"report",
"(",
"node",
",",
"recommendation",
",",
"shouldFix",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"message",
":",
"\"use `{{recommendation}}` instead.\"",
",",
"data",
":",
"{",
"recommendation",
"}",
",",
"fix",
"(",
"fi... | Reports an error and autofixes the node
@param {ASTNode} node - An ast node to report the error on.
@param {string} recommendation - The recommended code for the issue
@param {bool} shouldFix - Whether this report should fix the node
@returns {void} | [
"Reports",
"an",
"error",
"and",
"autofixes",
"the",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-implicit-coercion.js#L204-L228 |
3,002 | eslint/eslint | lib/rules/one-var.js | startBlock | function startBlock() {
blockStack.push({
let: { initialized: false, uninitialized: false },
const: { initialized: false, uninitialized: false }
});
} | javascript | function startBlock() {
blockStack.push({
let: { initialized: false, uninitialized: false },
const: { initialized: false, uninitialized: false }
});
} | [
"function",
"startBlock",
"(",
")",
"{",
"blockStack",
".",
"push",
"(",
"{",
"let",
":",
"{",
"initialized",
":",
"false",
",",
"uninitialized",
":",
"false",
"}",
",",
"const",
":",
"{",
"initialized",
":",
"false",
",",
"uninitialized",
":",
"false",
... | Increments the blockStack counter.
@returns {void}
@private | [
"Increments",
"the",
"blockStack",
"counter",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L109-L114 |
3,003 | eslint/eslint | lib/rules/one-var.js | isRequire | function isRequire(decl) {
return decl.init && decl.init.type === "CallExpression" && decl.init.callee.name === "require";
} | javascript | function isRequire(decl) {
return decl.init && decl.init.type === "CallExpression" && decl.init.callee.name === "require";
} | [
"function",
"isRequire",
"(",
"decl",
")",
"{",
"return",
"decl",
".",
"init",
"&&",
"decl",
".",
"init",
".",
"type",
"===",
"\"CallExpression\"",
"&&",
"decl",
".",
"init",
".",
"callee",
".",
"name",
"===",
"\"require\"",
";",
"}"
] | Check if a variable declaration is a require.
@param {ASTNode} decl variable declaration Node
@returns {bool} if decl is a require, return true; else return false.
@private | [
"Check",
"if",
"a",
"variable",
"declaration",
"is",
"a",
"require",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L151-L153 |
3,004 | eslint/eslint | lib/rules/one-var.js | countDeclarations | function countDeclarations(declarations) {
const counts = { uninitialized: 0, initialized: 0 };
for (let i = 0; i < declarations.length; i++) {
if (declarations[i].init === null) {
counts.uninitialized++;
} else {
counts.in... | javascript | function countDeclarations(declarations) {
const counts = { uninitialized: 0, initialized: 0 };
for (let i = 0; i < declarations.length; i++) {
if (declarations[i].init === null) {
counts.uninitialized++;
} else {
counts.in... | [
"function",
"countDeclarations",
"(",
"declarations",
")",
"{",
"const",
"counts",
"=",
"{",
"uninitialized",
":",
"0",
",",
"initialized",
":",
"0",
"}",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"declarations",
".",
"length",
";",
"i",
... | Counts the number of initialized and uninitialized declarations in a list of declarations
@param {ASTNode[]} declarations List of declarations
@returns {Object} Counts of 'uninitialized' and 'initialized' declarations
@private | [
"Counts",
"the",
"number",
"of",
"initialized",
"and",
"uninitialized",
"declarations",
"in",
"a",
"list",
"of",
"declarations"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L205-L216 |
3,005 | eslint/eslint | lib/rules/one-var.js | hasOnlyOneStatement | function hasOnlyOneStatement(statementType, declarations) {
const declarationCounts = countDeclarations(declarations);
const currentOptions = options[statementType] || {};
const currentScope = getCurrentScope(statementType);
const hasRequires = declarations.some(isRequir... | javascript | function hasOnlyOneStatement(statementType, declarations) {
const declarationCounts = countDeclarations(declarations);
const currentOptions = options[statementType] || {};
const currentScope = getCurrentScope(statementType);
const hasRequires = declarations.some(isRequir... | [
"function",
"hasOnlyOneStatement",
"(",
"statementType",
",",
"declarations",
")",
"{",
"const",
"declarationCounts",
"=",
"countDeclarations",
"(",
"declarations",
")",
";",
"const",
"currentOptions",
"=",
"options",
"[",
"statementType",
"]",
"||",
"{",
"}",
";"... | Determines if there is more than one var statement in the current scope.
@param {string} statementType node.kind, one of: "var", "let", or "const"
@param {ASTNode[]} declarations List of declarations
@returns {boolean} Returns true if it is the first var declaration, false if not.
@private | [
"Determines",
"if",
"there",
"is",
"more",
"than",
"one",
"var",
"statement",
"in",
"the",
"current",
"scope",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L225-L257 |
3,006 | eslint/eslint | lib/rules/one-var.js | joinDeclarations | function joinDeclarations(declarations) {
const declaration = declarations[0];
const body = Array.isArray(declaration.parent.parent.body) ? declaration.parent.parent.body : [];
const currentIndex = body.findIndex(node => node.range[0] === declaration.parent.range[0]);
con... | javascript | function joinDeclarations(declarations) {
const declaration = declarations[0];
const body = Array.isArray(declaration.parent.parent.body) ? declaration.parent.parent.body : [];
const currentIndex = body.findIndex(node => node.range[0] === declaration.parent.range[0]);
con... | [
"function",
"joinDeclarations",
"(",
"declarations",
")",
"{",
"const",
"declaration",
"=",
"declarations",
"[",
"0",
"]",
";",
"const",
"body",
"=",
"Array",
".",
"isArray",
"(",
"declaration",
".",
"parent",
".",
"parent",
".",
"body",
")",
"?",
"declara... | Fixer to join VariableDeclaration's into a single declaration
@param {VariableDeclarator[]} declarations The `VariableDeclaration` to join
@returns {Function} The fixer function | [
"Fixer",
"to",
"join",
"VariableDeclaration",
"s",
"into",
"a",
"single",
"declaration"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L264-L286 |
3,007 | eslint/eslint | lib/rules/one-var.js | splitDeclarations | function splitDeclarations(declaration) {
return fixer => declaration.declarations.map(declarator => {
const tokenAfterDeclarator = sourceCode.getTokenAfter(declarator);
if (tokenAfterDeclarator === null) {
return null;
}
... | javascript | function splitDeclarations(declaration) {
return fixer => declaration.declarations.map(declarator => {
const tokenAfterDeclarator = sourceCode.getTokenAfter(declarator);
if (tokenAfterDeclarator === null) {
return null;
}
... | [
"function",
"splitDeclarations",
"(",
"declaration",
")",
"{",
"return",
"fixer",
"=>",
"declaration",
".",
"declarations",
".",
"map",
"(",
"declarator",
"=>",
"{",
"const",
"tokenAfterDeclarator",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"declarator",
")",
... | Fixer to split a VariableDeclaration into individual declarations
@param {VariableDeclaration} declaration The `VariableDeclaration` to split
@returns {Function} The fixer function | [
"Fixer",
"to",
"split",
"a",
"VariableDeclaration",
"into",
"individual",
"declarations"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L293-L340 |
3,008 | eslint/eslint | lib/rules/require-atomic-updates.js | getScope | function getScope(identifier) {
for (let currentNode = identifier; currentNode; currentNode = currentNode.parent) {
const scope = sourceCode.scopeManager.acquire(currentNode, true);
if (scope) {
return scope;
}
}
re... | javascript | function getScope(identifier) {
for (let currentNode = identifier; currentNode; currentNode = currentNode.parent) {
const scope = sourceCode.scopeManager.acquire(currentNode, true);
if (scope) {
return scope;
}
}
re... | [
"function",
"getScope",
"(",
"identifier",
")",
"{",
"for",
"(",
"let",
"currentNode",
"=",
"identifier",
";",
"currentNode",
";",
"currentNode",
"=",
"currentNode",
".",
"parent",
")",
"{",
"const",
"scope",
"=",
"sourceCode",
".",
"scopeManager",
".",
"acq... | Gets the variable scope around this variable reference
@param {ASTNode} identifier An `Identifier` AST node
@returns {Scope|null} An escope Scope | [
"Gets",
"the",
"variable",
"scope",
"around",
"this",
"variable",
"reference"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/require-atomic-updates.js#L48-L57 |
3,009 | eslint/eslint | lib/rules/require-atomic-updates.js | resolveVariableInScope | function resolveVariableInScope(identifier, scope) {
return scope.variables.find(variable => variable.name === identifier.name) ||
(scope.upper ? resolveVariableInScope(identifier, scope.upper) : null);
} | javascript | function resolveVariableInScope(identifier, scope) {
return scope.variables.find(variable => variable.name === identifier.name) ||
(scope.upper ? resolveVariableInScope(identifier, scope.upper) : null);
} | [
"function",
"resolveVariableInScope",
"(",
"identifier",
",",
"scope",
")",
"{",
"return",
"scope",
".",
"variables",
".",
"find",
"(",
"variable",
"=>",
"variable",
".",
"name",
"===",
"identifier",
".",
"name",
")",
"||",
"(",
"scope",
".",
"upper",
"?",... | Resolves a given identifier to a given scope
@param {ASTNode} identifier An `Identifier` AST node
@param {Scope} scope An escope Scope
@returns {Variable|null} An escope Variable corresponding to the given identifier | [
"Resolves",
"a",
"given",
"identifier",
"to",
"a",
"given",
"scope"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/require-atomic-updates.js#L65-L68 |
3,010 | eslint/eslint | lib/rules/require-atomic-updates.js | resolveVariable | function resolveVariable(identifier) {
if (!resolvedVariableCache.has(identifier)) {
const surroundingScope = getScope(identifier);
if (surroundingScope) {
resolvedVariableCache.set(identifier, resolveVariableInScope(identifier, surroundingScope));
... | javascript | function resolveVariable(identifier) {
if (!resolvedVariableCache.has(identifier)) {
const surroundingScope = getScope(identifier);
if (surroundingScope) {
resolvedVariableCache.set(identifier, resolveVariableInScope(identifier, surroundingScope));
... | [
"function",
"resolveVariable",
"(",
"identifier",
")",
"{",
"if",
"(",
"!",
"resolvedVariableCache",
".",
"has",
"(",
"identifier",
")",
")",
"{",
"const",
"surroundingScope",
"=",
"getScope",
"(",
"identifier",
")",
";",
"if",
"(",
"surroundingScope",
")",
... | Resolves an identifier to a variable
@param {ASTNode} identifier An identifier node
@returns {Variable|null} The escope Variable that uses this identifier | [
"Resolves",
"an",
"identifier",
"to",
"a",
"variable"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/require-atomic-updates.js#L75-L87 |
3,011 | eslint/eslint | lib/rules/require-atomic-updates.js | isLocalVariableWithoutEscape | function isLocalVariableWithoutEscape(expression, surroundingFunction) {
if (expression.type !== "Identifier") {
return false;
}
const variable = resolveVariable(expression);
if (!variable) {
return false;
}
retur... | javascript | function isLocalVariableWithoutEscape(expression, surroundingFunction) {
if (expression.type !== "Identifier") {
return false;
}
const variable = resolveVariable(expression);
if (!variable) {
return false;
}
retur... | [
"function",
"isLocalVariableWithoutEscape",
"(",
"expression",
",",
"surroundingFunction",
")",
"{",
"if",
"(",
"expression",
".",
"type",
"!==",
"\"Identifier\"",
")",
"{",
"return",
"false",
";",
"}",
"const",
"variable",
"=",
"resolveVariable",
"(",
"expression... | Checks if an expression is a variable that can only be observed within the given function.
@param {ASTNode} expression The expression to check
@param {ASTNode} surroundingFunction The function node
@returns {boolean} `true` if the expression is a variable which is local to the given function, and is never
referenced in... | [
"Checks",
"if",
"an",
"expression",
"is",
"a",
"variable",
"that",
"can",
"only",
"be",
"observed",
"within",
"the",
"given",
"function",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/require-atomic-updates.js#L96-L109 |
3,012 | eslint/eslint | lib/rules/require-atomic-updates.js | reportAssignment | function reportAssignment(assignmentExpression) {
context.report({
node: assignmentExpression,
messageId: "nonAtomicUpdate",
data: {
value: sourceCode.getText(assignmentExpression.left)
}
});
} | javascript | function reportAssignment(assignmentExpression) {
context.report({
node: assignmentExpression,
messageId: "nonAtomicUpdate",
data: {
value: sourceCode.getText(assignmentExpression.left)
}
});
} | [
"function",
"reportAssignment",
"(",
"assignmentExpression",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
":",
"assignmentExpression",
",",
"messageId",
":",
"\"nonAtomicUpdate\"",
",",
"data",
":",
"{",
"value",
":",
"sourceCode",
".",
"getText",
"(",
... | Reports an AssignmentExpression node that has a non-atomic update
@param {ASTNode} assignmentExpression The assignment that is potentially unsafe
@returns {void} | [
"Reports",
"an",
"AssignmentExpression",
"node",
"that",
"has",
"a",
"non",
"-",
"atomic",
"update"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/require-atomic-updates.js#L116-L124 |
3,013 | eslint/eslint | lib/config/config-validator.js | validateRuleSeverity | function validateRuleSeverity(options) {
const severity = Array.isArray(options) ? options[0] : options;
const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
return normSeverity;
... | javascript | function validateRuleSeverity(options) {
const severity = Array.isArray(options) ? options[0] : options;
const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
return normSeverity;
... | [
"function",
"validateRuleSeverity",
"(",
"options",
")",
"{",
"const",
"severity",
"=",
"Array",
".",
"isArray",
"(",
"options",
")",
"?",
"options",
"[",
"0",
"]",
":",
"options",
";",
"const",
"normSeverity",
"=",
"typeof",
"severity",
"===",
"\"string\"",... | Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
@param {options} options The given options for the rule.
@returns {number|string} The rule's severity value | [
"Validates",
"a",
"rule",
"s",
"severity",
"and",
"returns",
"the",
"severity",
"value",
".",
"Throws",
"an",
"error",
"if",
"the",
"severity",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-validator.js#L72-L82 |
3,014 | eslint/eslint | lib/config/config-validator.js | validateRuleSchema | function validateRuleSchema(rule, localOptions) {
if (!ruleValidators.has(rule)) {
const schema = getRuleOptionsSchema(rule);
if (schema) {
ruleValidators.set(rule, ajv.compile(schema));
}
}
const validateRule = ruleValidators.get(rule);
if (validateRule) {
... | javascript | function validateRuleSchema(rule, localOptions) {
if (!ruleValidators.has(rule)) {
const schema = getRuleOptionsSchema(rule);
if (schema) {
ruleValidators.set(rule, ajv.compile(schema));
}
}
const validateRule = ruleValidators.get(rule);
if (validateRule) {
... | [
"function",
"validateRuleSchema",
"(",
"rule",
",",
"localOptions",
")",
"{",
"if",
"(",
"!",
"ruleValidators",
".",
"has",
"(",
"rule",
")",
")",
"{",
"const",
"schema",
"=",
"getRuleOptionsSchema",
"(",
"rule",
")",
";",
"if",
"(",
"schema",
")",
"{",
... | Validates the non-severity options passed to a rule, based on its schema.
@param {{create: Function}} rule The rule to validate
@param {Array} localOptions The options for the rule, excluding severity
@returns {void} | [
"Validates",
"the",
"non",
"-",
"severity",
"options",
"passed",
"to",
"a",
"rule",
"based",
"on",
"its",
"schema",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-validator.js#L90-L109 |
3,015 | eslint/eslint | lib/config/config-validator.js | validateRules | function validateRules(rulesConfig, ruleMapper, source = null) {
if (!rulesConfig) {
return;
}
Object.keys(rulesConfig).forEach(id => {
validateRuleOptions(ruleMapper(id), id, rulesConfig[id], source);
});
} | javascript | function validateRules(rulesConfig, ruleMapper, source = null) {
if (!rulesConfig) {
return;
}
Object.keys(rulesConfig).forEach(id => {
validateRuleOptions(ruleMapper(id), id, rulesConfig[id], source);
});
} | [
"function",
"validateRules",
"(",
"rulesConfig",
",",
"ruleMapper",
",",
"source",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"rulesConfig",
")",
"{",
"return",
";",
"}",
"Object",
".",
"keys",
"(",
"rulesConfig",
")",
".",
"forEach",
"(",
"id",
"=>",
"{",... | Validates a rules config object
@param {Object} rulesConfig The rules config object to validate.
@param {function(string): {create: Function}} ruleMapper A mapper function from strings to loaded rules
@param {string} source The name of the configuration source to report in any errors.
@returns {void} | [
"Validates",
"a",
"rules",
"config",
"object"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-validator.js#L171-L179 |
3,016 | eslint/eslint | lib/config/config-validator.js | validateGlobals | function validateGlobals(globalsConfig, source = null) {
if (!globalsConfig) {
return;
}
Object.entries(globalsConfig)
.forEach(([configuredGlobal, configuredValue]) => {
try {
ConfigOps.normalizeConfigGlobal(configuredValue);
} catch (err) {
... | javascript | function validateGlobals(globalsConfig, source = null) {
if (!globalsConfig) {
return;
}
Object.entries(globalsConfig)
.forEach(([configuredGlobal, configuredValue]) => {
try {
ConfigOps.normalizeConfigGlobal(configuredValue);
} catch (err) {
... | [
"function",
"validateGlobals",
"(",
"globalsConfig",
",",
"source",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"globalsConfig",
")",
"{",
"return",
";",
"}",
"Object",
".",
"entries",
"(",
"globalsConfig",
")",
".",
"forEach",
"(",
"(",
"[",
"configuredGlobal"... | Validates a `globals` section of a config file
@param {Object} globalsConfig The `glboals` section
@param {string|null} source The name of the configuration source to report in the event of an error.
@returns {void} | [
"Validates",
"a",
"globals",
"section",
"of",
"a",
"config",
"file"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-validator.js#L187-L200 |
3,017 | eslint/eslint | lib/config/config-validator.js | formatErrors | function formatErrors(errors) {
return errors.map(error => {
if (error.keyword === "additionalProperties") {
const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;
return `Unexpected to... | javascript | function formatErrors(errors) {
return errors.map(error => {
if (error.keyword === "additionalProperties") {
const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;
return `Unexpected to... | [
"function",
"formatErrors",
"(",
"errors",
")",
"{",
"return",
"errors",
".",
"map",
"(",
"error",
"=>",
"{",
"if",
"(",
"error",
".",
"keyword",
"===",
"\"additionalProperties\"",
")",
"{",
"const",
"formattedPropertyPath",
"=",
"error",
".",
"dataPath",
".... | Formats an array of schema validation errors.
@param {Array} errors An array of error messages to format.
@returns {string} Formatted error message | [
"Formats",
"an",
"array",
"of",
"schema",
"validation",
"errors",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-validator.js#L207-L226 |
3,018 | eslint/eslint | lib/config/config-validator.js | validateConfigSchema | function validateConfigSchema(config, source = null) {
validateSchema = validateSchema || ajv.compile(configSchema);
if (!validateSchema(config)) {
throw new Error(`ESLint configuration in ${source} is invalid:\n${formatErrors(validateSchema.errors)}`);
}
if (Object.hasOwnProperty.call(config,... | javascript | function validateConfigSchema(config, source = null) {
validateSchema = validateSchema || ajv.compile(configSchema);
if (!validateSchema(config)) {
throw new Error(`ESLint configuration in ${source} is invalid:\n${formatErrors(validateSchema.errors)}`);
}
if (Object.hasOwnProperty.call(config,... | [
"function",
"validateConfigSchema",
"(",
"config",
",",
"source",
"=",
"null",
")",
"{",
"validateSchema",
"=",
"validateSchema",
"||",
"ajv",
".",
"compile",
"(",
"configSchema",
")",
";",
"if",
"(",
"!",
"validateSchema",
"(",
"config",
")",
")",
"{",
"t... | Validates the top level properties of the config object.
@param {Object} config The config object to validate.
@param {string} source The name of the configuration source to report in any errors.
@returns {void} | [
"Validates",
"the",
"top",
"level",
"properties",
"of",
"the",
"config",
"object",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-validator.js#L253-L263 |
3,019 | eslint/eslint | lib/rules/prefer-const.js | canBecomeVariableDeclaration | function canBecomeVariableDeclaration(identifier) {
let node = identifier.parent;
while (PATTERN_TYPE.test(node.type)) {
node = node.parent;
}
return (
node.type === "VariableDeclarator" ||
(
node.type === "AssignmentExpression" &&
node.parent.type === "... | javascript | function canBecomeVariableDeclaration(identifier) {
let node = identifier.parent;
while (PATTERN_TYPE.test(node.type)) {
node = node.parent;
}
return (
node.type === "VariableDeclarator" ||
(
node.type === "AssignmentExpression" &&
node.parent.type === "... | [
"function",
"canBecomeVariableDeclaration",
"(",
"identifier",
")",
"{",
"let",
"node",
"=",
"identifier",
".",
"parent",
";",
"while",
"(",
"PATTERN_TYPE",
".",
"test",
"(",
"node",
".",
"type",
")",
")",
"{",
"node",
"=",
"node",
".",
"parent",
";",
"}... | Checks whether a given Identifier node becomes a VariableDeclaration or not.
@param {ASTNode} identifier - An Identifier node to check.
@returns {boolean} `true` if the node can become a VariableDeclaration. | [
"Checks",
"whether",
"a",
"given",
"Identifier",
"node",
"becomes",
"a",
"VariableDeclaration",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-const.js#L34-L49 |
3,020 | eslint/eslint | lib/rules/prefer-const.js | isOuterVariableInDestructing | function isOuterVariableInDestructing(name, initScope) {
if (initScope.through.find(ref => ref.resolved && ref.resolved.name === name)) {
return true;
}
const variable = astUtils.getVariableByName(initScope, name);
if (variable !== null) {
return variable.defs.some(def => def.type ===... | javascript | function isOuterVariableInDestructing(name, initScope) {
if (initScope.through.find(ref => ref.resolved && ref.resolved.name === name)) {
return true;
}
const variable = astUtils.getVariableByName(initScope, name);
if (variable !== null) {
return variable.defs.some(def => def.type ===... | [
"function",
"isOuterVariableInDestructing",
"(",
"name",
",",
"initScope",
")",
"{",
"if",
"(",
"initScope",
".",
"through",
".",
"find",
"(",
"ref",
"=>",
"ref",
".",
"resolved",
"&&",
"ref",
".",
"resolved",
".",
"name",
"===",
"name",
")",
")",
"{",
... | Checks if an property or element is from outer scope or function parameters
in destructing pattern.
@param {string} name - A variable name to be checked.
@param {eslint-scope.Scope} initScope - A scope to start find.
@returns {boolean} Indicates if the variable is from outer scope or function parameters. | [
"Checks",
"if",
"an",
"property",
"or",
"element",
"is",
"from",
"outer",
"scope",
"or",
"function",
"parameters",
"in",
"destructing",
"pattern",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-const.js#L59-L72 |
3,021 | eslint/eslint | lib/rules/prefer-const.js | hasMemberExpressionAssignment | function hasMemberExpressionAssignment(node) {
switch (node.type) {
case "ObjectPattern":
return node.properties.some(prop => {
if (prop) {
/*
* Spread elements have an argument property while
* others have a value pr... | javascript | function hasMemberExpressionAssignment(node) {
switch (node.type) {
case "ObjectPattern":
return node.properties.some(prop => {
if (prop) {
/*
* Spread elements have an argument property while
* others have a value pr... | [
"function",
"hasMemberExpressionAssignment",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"\"ObjectPattern\"",
":",
"return",
"node",
".",
"properties",
".",
"some",
"(",
"prop",
"=>",
"{",
"if",
"(",
"prop",
")",
"{",
"/*... | Determines if a destructuring assignment node contains
any MemberExpression nodes. This is used to determine if a
variable that is only written once using destructuring can be
safely converted into a const declaration.
@param {ASTNode} node The ObjectPattern or ArrayPattern node to check.
@returns {boolean} True if the... | [
"Determines",
"if",
"a",
"destructuring",
"assignment",
"node",
"contains",
"any",
"MemberExpression",
"nodes",
".",
"This",
"is",
"used",
"to",
"determine",
"if",
"a",
"variable",
"that",
"is",
"only",
"written",
"once",
"using",
"destructuring",
"can",
"be",
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-const.js#L109-L146 |
3,022 | eslint/eslint | lib/rules/prefer-const.js | getIdentifierIfShouldBeConst | function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) {
if (variable.eslintUsed && variable.scope.type === "global") {
return null;
}
// Finds the unique WriteReference.
let writer = null;
let isReadBeforeInit = false;
const references = variable.references;
for (... | javascript | function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) {
if (variable.eslintUsed && variable.scope.type === "global") {
return null;
}
// Finds the unique WriteReference.
let writer = null;
let isReadBeforeInit = false;
const references = variable.references;
for (... | [
"function",
"getIdentifierIfShouldBeConst",
"(",
"variable",
",",
"ignoreReadBeforeAssign",
")",
"{",
"if",
"(",
"variable",
".",
"eslintUsed",
"&&",
"variable",
".",
"scope",
".",
"type",
"===",
"\"global\"",
")",
"{",
"return",
"null",
";",
"}",
"// Finds the ... | Gets an identifier node of a given variable.
If the initialization exists or one or more reading references exist before
the first assignment, the identifier node is the node of the declaration.
Otherwise, the identifier node is the node of the first assignment.
If the variable should not change to const, this functi... | [
"Gets",
"an",
"identifier",
"node",
"of",
"a",
"given",
"variable",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-const.js#L173-L258 |
3,023 | eslint/eslint | lib/rules/prefer-const.js | findUp | function findUp(node, type, shouldStop) {
if (!node || shouldStop(node)) {
return null;
}
if (node.type === type) {
return node;
}
return findUp(node.parent, type, shouldStop);
} | javascript | function findUp(node, type, shouldStop) {
if (!node || shouldStop(node)) {
return null;
}
if (node.type === type) {
return node;
}
return findUp(node.parent, type, shouldStop);
} | [
"function",
"findUp",
"(",
"node",
",",
"type",
",",
"shouldStop",
")",
"{",
"if",
"(",
"!",
"node",
"||",
"shouldStop",
"(",
"node",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"node",
".",
"type",
"===",
"type",
")",
"{",
"return",
"n... | Finds the nearest parent of node with a given type.
@param {ASTNode} node – The node to search from.
@param {string} type – The type field of the parent node.
@param {Function} shouldStop – a predicate that returns true if the traversal should stop, and false otherwise.
@returns {ASTNode} The closest ancestor with the... | [
"Finds",
"the",
"nearest",
"parent",
"of",
"node",
"with",
"a",
"given",
"type",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-const.js#L317-L325 |
3,024 | eslint/eslint | lib/rules/prefer-const.js | checkGroup | function checkGroup(nodes) {
const nodesToReport = nodes.filter(Boolean);
if (nodes.length && (shouldMatchAnyDestructuredVariable || nodesToReport.length === nodes.length)) {
const varDeclParent = findUp(nodes[0], "VariableDeclaration", parentNode => parentNode.type.endsWith("St... | javascript | function checkGroup(nodes) {
const nodesToReport = nodes.filter(Boolean);
if (nodes.length && (shouldMatchAnyDestructuredVariable || nodesToReport.length === nodes.length)) {
const varDeclParent = findUp(nodes[0], "VariableDeclaration", parentNode => parentNode.type.endsWith("St... | [
"function",
"checkGroup",
"(",
"nodes",
")",
"{",
"const",
"nodesToReport",
"=",
"nodes",
".",
"filter",
"(",
"Boolean",
")",
";",
"if",
"(",
"nodes",
".",
"length",
"&&",
"(",
"shouldMatchAnyDestructuredVariable",
"||",
"nodesToReport",
".",
"length",
"===",
... | Reports given identifier nodes if all of the nodes should be declared
as const.
The argument 'nodes' is an array of Identifier nodes.
This node is the result of 'getIdentifierIfShouldBeConst()', so it's
nullable. In simple declaration or assignment cases, the length of
the array is 1. In destructuring cases, the lengt... | [
"Reports",
"given",
"identifier",
"nodes",
"if",
"all",
"of",
"the",
"nodes",
"should",
"be",
"declared",
"as",
"const",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-const.js#L382-L457 |
3,025 | eslint/eslint | lib/rules/object-shorthand.js | isConstructor | function isConstructor(name) {
const match = CTOR_PREFIX_REGEX.exec(name);
// Not a constructor if name has no characters apart from '_', '$' and digits e.g. '_', '$$', '_8'
if (!match) {
return false;
}
const firstChar = name.charAt(match.in... | javascript | function isConstructor(name) {
const match = CTOR_PREFIX_REGEX.exec(name);
// Not a constructor if name has no characters apart from '_', '$' and digits e.g. '_', '$$', '_8'
if (!match) {
return false;
}
const firstChar = name.charAt(match.in... | [
"function",
"isConstructor",
"(",
"name",
")",
"{",
"const",
"match",
"=",
"CTOR_PREFIX_REGEX",
".",
"exec",
"(",
"name",
")",
";",
"// Not a constructor if name has no characters apart from '_', '$' and digits e.g. '_', '$$', '_8'",
"if",
"(",
"!",
"match",
")",
"{",
"... | Determines if the first character of the name is a capital letter.
@param {string} name The name of the node to evaluate.
@returns {boolean} True if the first character of the property name is a capital letter, false if not.
@private | [
"Determines",
"if",
"the",
"first",
"character",
"of",
"the",
"name",
"is",
"a",
"capital",
"letter",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/object-shorthand.js#L124-L135 |
3,026 | eslint/eslint | lib/rules/object-shorthand.js | makeFunctionShorthand | function makeFunctionShorthand(fixer, node) {
const firstKeyToken = node.computed
? sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken)
: sourceCode.getFirstToken(node.key);
const lastKeyToken = node.computed
? sourceCode.getFirstTokenBe... | javascript | function makeFunctionShorthand(fixer, node) {
const firstKeyToken = node.computed
? sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken)
: sourceCode.getFirstToken(node.key);
const lastKeyToken = node.computed
? sourceCode.getFirstTokenBe... | [
"function",
"makeFunctionShorthand",
"(",
"fixer",
",",
"node",
")",
"{",
"const",
"firstKeyToken",
"=",
"node",
".",
"computed",
"?",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
",",
"astUtils",
".",
"isOpeningBracketToken",
")",
":",
"sourceCode",
".",
... | Fixes a FunctionExpression node by making it into a shorthand property.
@param {SourceCodeFixer} fixer The fixer object
@param {ASTNode} node A `Property` node that has a `FunctionExpression` or `ArrowFunctionExpression` as its value
@returns {Object} A fix for this node | [
"Fixes",
"a",
"FunctionExpression",
"node",
"by",
"making",
"it",
"into",
"a",
"shorthand",
"property",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/object-shorthand.js#L237-L278 |
3,027 | eslint/eslint | lib/rules/object-shorthand.js | enterFunction | function enterFunction() {
lexicalScopeStack.unshift(new Set());
context.getScope().variables.filter(variable => variable.name === "arguments").forEach(variable => {
variable.references.map(ref => ref.identifier).forEach(identifier => argumentsIdentifiers.add(identifier));
... | javascript | function enterFunction() {
lexicalScopeStack.unshift(new Set());
context.getScope().variables.filter(variable => variable.name === "arguments").forEach(variable => {
variable.references.map(ref => ref.identifier).forEach(identifier => argumentsIdentifiers.add(identifier));
... | [
"function",
"enterFunction",
"(",
")",
"{",
"lexicalScopeStack",
".",
"unshift",
"(",
"new",
"Set",
"(",
")",
")",
";",
"context",
".",
"getScope",
"(",
")",
".",
"variables",
".",
"filter",
"(",
"variable",
"=>",
"variable",
".",
"name",
"===",
"\"argum... | Enters a function. This creates a new lexical identifier scope, so a new Set of arrow functions is pushed onto the stack.
Also, this marks all `arguments` identifiers so that they can be detected later.
@returns {void} | [
"Enters",
"a",
"function",
".",
"This",
"creates",
"a",
"new",
"lexical",
"identifier",
"scope",
"so",
"a",
"new",
"Set",
"of",
"arrow",
"functions",
"is",
"pushed",
"onto",
"the",
"stack",
".",
"Also",
"this",
"marks",
"all",
"arguments",
"identifiers",
"... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/object-shorthand.js#L321-L326 |
3,028 | eslint/eslint | lib/rules/radix.js | isParseIntMethod | function isParseIntMethod(node) {
return (
node.type === "MemberExpression" &&
!node.computed &&
node.property.type === "Identifier" &&
node.property.name === "parseInt"
);
} | javascript | function isParseIntMethod(node) {
return (
node.type === "MemberExpression" &&
!node.computed &&
node.property.type === "Identifier" &&
node.property.name === "parseInt"
);
} | [
"function",
"isParseIntMethod",
"(",
"node",
")",
"{",
"return",
"(",
"node",
".",
"type",
"===",
"\"MemberExpression\"",
"&&",
"!",
"node",
".",
"computed",
"&&",
"node",
".",
"property",
".",
"type",
"===",
"\"Identifier\"",
"&&",
"node",
".",
"property",
... | Checks whether a given node is a MemberExpression of `parseInt` method or not.
@param {ASTNode} node - A node to check.
@returns {boolean} `true` if the node is a MemberExpression of `parseInt`
method. | [
"Checks",
"whether",
"a",
"given",
"node",
"is",
"a",
"MemberExpression",
"of",
"parseInt",
"method",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/radix.js#L38-L45 |
3,029 | eslint/eslint | lib/rules/radix.js | isValidRadix | function isValidRadix(radix) {
return !(
(radix.type === "Literal" && typeof radix.value !== "number") ||
(radix.type === "Identifier" && radix.name === "undefined")
);
} | javascript | function isValidRadix(radix) {
return !(
(radix.type === "Literal" && typeof radix.value !== "number") ||
(radix.type === "Identifier" && radix.name === "undefined")
);
} | [
"function",
"isValidRadix",
"(",
"radix",
")",
"{",
"return",
"!",
"(",
"(",
"radix",
".",
"type",
"===",
"\"Literal\"",
"&&",
"typeof",
"radix",
".",
"value",
"!==",
"\"number\"",
")",
"||",
"(",
"radix",
".",
"type",
"===",
"\"Identifier\"",
"&&",
"rad... | Checks whether a given node is a valid value of radix or not.
The following values are invalid.
- A literal except numbers.
- undefined.
@param {ASTNode} radix - A node of radix to check.
@returns {boolean} `true` if the node is valid. | [
"Checks",
"whether",
"a",
"given",
"node",
"is",
"a",
"valid",
"value",
"of",
"radix",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/radix.js#L58-L63 |
3,030 | eslint/eslint | lib/rules/radix.js | checkArguments | function checkArguments(node) {
const args = node.arguments;
switch (args.length) {
case 0:
context.report({
node,
message: "Missing parameters."
});
break;
... | javascript | function checkArguments(node) {
const args = node.arguments;
switch (args.length) {
case 0:
context.report({
node,
message: "Missing parameters."
});
break;
... | [
"function",
"checkArguments",
"(",
"node",
")",
"{",
"const",
"args",
"=",
"node",
".",
"arguments",
";",
"switch",
"(",
"args",
".",
"length",
")",
"{",
"case",
"0",
":",
"context",
".",
"report",
"(",
"{",
"node",
",",
"message",
":",
"\"Missing para... | Checks the arguments of a given CallExpression node and reports it if it
offends this rule.
@param {ASTNode} node - A CallExpression node to check.
@returns {void} | [
"Checks",
"the",
"arguments",
"of",
"a",
"given",
"CallExpression",
"node",
"and",
"reports",
"it",
"if",
"it",
"offends",
"this",
"rule",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/radix.js#L107-L141 |
3,031 | eslint/eslint | lib/rules/no-this-before-super.js | setInvalid | function setInvalid(node) {
const segments = funcInfo.codePath.currentSegments;
for (let i = 0; i < segments.length; ++i) {
const segment = segments[i];
if (segment.reachable) {
segInfoMap[segment.id].invalidNodes.push(node);
... | javascript | function setInvalid(node) {
const segments = funcInfo.codePath.currentSegments;
for (let i = 0; i < segments.length; ++i) {
const segment = segments[i];
if (segment.reachable) {
segInfoMap[segment.id].invalidNodes.push(node);
... | [
"function",
"setInvalid",
"(",
"node",
")",
"{",
"const",
"segments",
"=",
"funcInfo",
".",
"codePath",
".",
"currentSegments",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"segments",
".",
"length",
";",
"++",
"i",
")",
"{",
"const",
"segme... | Sets a given node as invalid.
@param {ASTNode} node - A node to set as invalid. This is one of
a ThisExpression and a Super.
@returns {void} | [
"Sets",
"a",
"given",
"node",
"as",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-this-before-super.js#L106-L116 |
3,032 | eslint/eslint | lib/rules/no-this-before-super.js | setSuperCalled | function setSuperCalled() {
const segments = funcInfo.codePath.currentSegments;
for (let i = 0; i < segments.length; ++i) {
const segment = segments[i];
if (segment.reachable) {
segInfoMap[segment.id].superCalled = true;
}
... | javascript | function setSuperCalled() {
const segments = funcInfo.codePath.currentSegments;
for (let i = 0; i < segments.length; ++i) {
const segment = segments[i];
if (segment.reachable) {
segInfoMap[segment.id].superCalled = true;
}
... | [
"function",
"setSuperCalled",
"(",
")",
"{",
"const",
"segments",
"=",
"funcInfo",
".",
"codePath",
".",
"currentSegments",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"segments",
".",
"length",
";",
"++",
"i",
")",
"{",
"const",
"segment",
... | Sets the current segment as `super` was called.
@returns {void} | [
"Sets",
"the",
"current",
"segment",
"as",
"super",
"was",
"called",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-this-before-super.js#L122-L132 |
3,033 | eslint/eslint | lib/util/report-translator.js | assertValidNodeInfo | function assertValidNodeInfo(descriptor) {
if (descriptor.node) {
assert(typeof descriptor.node === "object", "Node must be an object");
} else {
assert(descriptor.loc, "Node must be provided when reporting error if location is not provided");
}
} | javascript | function assertValidNodeInfo(descriptor) {
if (descriptor.node) {
assert(typeof descriptor.node === "object", "Node must be an object");
} else {
assert(descriptor.loc, "Node must be provided when reporting error if location is not provided");
}
} | [
"function",
"assertValidNodeInfo",
"(",
"descriptor",
")",
"{",
"if",
"(",
"descriptor",
".",
"node",
")",
"{",
"assert",
"(",
"typeof",
"descriptor",
".",
"node",
"===",
"\"object\"",
",",
"\"Node must be an object\"",
")",
";",
"}",
"else",
"{",
"assert",
... | Asserts that either a loc or a node was provided, and the node is valid if it was provided.
@param {MessageDescriptor} descriptor A descriptor to validate
@returns {void}
@throws AssertionError if neither a node nor a loc was provided, or if the node is not an object | [
"Asserts",
"that",
"either",
"a",
"loc",
"or",
"a",
"node",
"was",
"provided",
"and",
"the",
"node",
"is",
"valid",
"if",
"it",
"was",
"provided",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/report-translator.js#L92-L98 |
3,034 | eslint/eslint | lib/util/report-translator.js | normalizeReportLoc | function normalizeReportLoc(descriptor) {
if (descriptor.loc) {
if (descriptor.loc.start) {
return descriptor.loc;
}
return { start: descriptor.loc, end: null };
}
return descriptor.node.loc;
} | javascript | function normalizeReportLoc(descriptor) {
if (descriptor.loc) {
if (descriptor.loc.start) {
return descriptor.loc;
}
return { start: descriptor.loc, end: null };
}
return descriptor.node.loc;
} | [
"function",
"normalizeReportLoc",
"(",
"descriptor",
")",
"{",
"if",
"(",
"descriptor",
".",
"loc",
")",
"{",
"if",
"(",
"descriptor",
".",
"loc",
".",
"start",
")",
"{",
"return",
"descriptor",
".",
"loc",
";",
"}",
"return",
"{",
"start",
":",
"descr... | Normalizes a MessageDescriptor to always have a `loc` with `start` and `end` properties
@param {MessageDescriptor} descriptor A descriptor for the report from a rule.
@returns {{start: Location, end: (Location|null)}} An updated location that infers the `start` and `end` properties
from the `node` of the original descr... | [
"Normalizes",
"a",
"MessageDescriptor",
"to",
"always",
"have",
"a",
"loc",
"with",
"start",
"and",
"end",
"properties"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/report-translator.js#L106-L114 |
3,035 | eslint/eslint | lib/util/report-translator.js | compareFixesByRange | function compareFixesByRange(a, b) {
return a.range[0] - b.range[0] || a.range[1] - b.range[1];
} | javascript | function compareFixesByRange(a, b) {
return a.range[0] - b.range[0] || a.range[1] - b.range[1];
} | [
"function",
"compareFixesByRange",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
".",
"range",
"[",
"0",
"]",
"-",
"b",
".",
"range",
"[",
"0",
"]",
"||",
"a",
".",
"range",
"[",
"1",
"]",
"-",
"b",
".",
"range",
"[",
"1",
"]",
";",
"}"
] | Compares items in a fixes array by range.
@param {Fix} a The first message.
@param {Fix} b The second message.
@returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
@private | [
"Compares",
"items",
"in",
"a",
"fixes",
"array",
"by",
"range",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/report-translator.js#L123-L125 |
3,036 | eslint/eslint | lib/util/report-translator.js | mergeFixes | function mergeFixes(fixes, sourceCode) {
if (fixes.length === 0) {
return null;
}
if (fixes.length === 1) {
return fixes[0];
}
fixes.sort(compareFixesByRange);
const originalText = sourceCode.text;
const start = fixes[0].range[0];
const end = fixes[fixes.length - 1].ran... | javascript | function mergeFixes(fixes, sourceCode) {
if (fixes.length === 0) {
return null;
}
if (fixes.length === 1) {
return fixes[0];
}
fixes.sort(compareFixesByRange);
const originalText = sourceCode.text;
const start = fixes[0].range[0];
const end = fixes[fixes.length - 1].ran... | [
"function",
"mergeFixes",
"(",
"fixes",
",",
"sourceCode",
")",
"{",
"if",
"(",
"fixes",
".",
"length",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"fixes",
".",
"length",
"===",
"1",
")",
"{",
"return",
"fixes",
"[",
"0",
"]",
"... | Merges the given fixes array into one.
@param {Fix[]} fixes The fixes to merge.
@param {SourceCode} sourceCode The source code object to get the text between fixes.
@returns {{text: string, range: number[]}} The merged fixes | [
"Merges",
"the",
"given",
"fixes",
"array",
"into",
"one",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/report-translator.js#L133-L161 |
3,037 | eslint/eslint | lib/util/report-translator.js | normalizeFixes | function normalizeFixes(descriptor, sourceCode) {
if (typeof descriptor.fix !== "function") {
return null;
}
// @type {null | Fix | Fix[] | IterableIterator<Fix>}
const fix = descriptor.fix(ruleFixer);
// Merge to one.
if (fix && Symbol.iterator in fix) {
return mergeFixes(Arra... | javascript | function normalizeFixes(descriptor, sourceCode) {
if (typeof descriptor.fix !== "function") {
return null;
}
// @type {null | Fix | Fix[] | IterableIterator<Fix>}
const fix = descriptor.fix(ruleFixer);
// Merge to one.
if (fix && Symbol.iterator in fix) {
return mergeFixes(Arra... | [
"function",
"normalizeFixes",
"(",
"descriptor",
",",
"sourceCode",
")",
"{",
"if",
"(",
"typeof",
"descriptor",
".",
"fix",
"!==",
"\"function\"",
")",
"{",
"return",
"null",
";",
"}",
"// @type {null | Fix | Fix[] | IterableIterator<Fix>}",
"const",
"fix",
"=",
... | Gets one fix object from the given descriptor.
If the descriptor retrieves multiple fixes, this merges those to one.
@param {MessageDescriptor} descriptor The report descriptor.
@param {SourceCode} sourceCode The source code object to get text between fixes.
@returns {({text: string, range: number[]}|null)} The fix for... | [
"Gets",
"one",
"fix",
"object",
"from",
"the",
"given",
"descriptor",
".",
"If",
"the",
"descriptor",
"retrieves",
"multiple",
"fixes",
"this",
"merges",
"those",
"to",
"one",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/report-translator.js#L170-L183 |
3,038 | eslint/eslint | lib/util/report-translator.js | createProblem | function createProblem(options) {
const problem = {
ruleId: options.ruleId,
severity: options.severity,
message: options.message,
line: options.loc.start.line,
column: options.loc.start.column + 1,
nodeType: options.node && options.node.type || null
};
/*
... | javascript | function createProblem(options) {
const problem = {
ruleId: options.ruleId,
severity: options.severity,
message: options.message,
line: options.loc.start.line,
column: options.loc.start.column + 1,
nodeType: options.node && options.node.type || null
};
/*
... | [
"function",
"createProblem",
"(",
"options",
")",
"{",
"const",
"problem",
"=",
"{",
"ruleId",
":",
"options",
".",
"ruleId",
",",
"severity",
":",
"options",
".",
"severity",
",",
"message",
":",
"options",
".",
"message",
",",
"line",
":",
"options",
"... | Creates information about the report from a descriptor
@param {Object} options Information about the problem
@param {string} options.ruleId Rule ID
@param {(0|1|2)} options.severity Rule severity
@param {(ASTNode|null)} options.node Node
@param {string} options.message Error message
@param {string} [options.messageId] ... | [
"Creates",
"information",
"about",
"the",
"report",
"from",
"a",
"descriptor"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/report-translator.js#L197-L225 |
3,039 | eslint/eslint | lib/rules/arrow-parens.js | parens | function parens(node) {
const isAsync = node.async;
const firstTokenOfParam = sourceCode.getFirstToken(node, isAsync ? 1 : 0);
/**
* Remove the parenthesis around a parameter
* @param {Fixer} fixer Fixer
* @returns {string} fixed parameter
... | javascript | function parens(node) {
const isAsync = node.async;
const firstTokenOfParam = sourceCode.getFirstToken(node, isAsync ? 1 : 0);
/**
* Remove the parenthesis around a parameter
* @param {Fixer} fixer Fixer
* @returns {string} fixed parameter
... | [
"function",
"parens",
"(",
"node",
")",
"{",
"const",
"isAsync",
"=",
"node",
".",
"async",
";",
"const",
"firstTokenOfParam",
"=",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
",",
"isAsync",
"?",
"1",
":",
"0",
")",
";",
"/**\n * Remove the... | Determines whether a arrow function argument end with `)`
@param {ASTNode} node The arrow function node.
@returns {void} | [
"Determines",
"whether",
"a",
"arrow",
"function",
"argument",
"end",
"with",
")"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/arrow-parens.js#L66-L158 |
3,040 | eslint/eslint | lib/rules/arrow-parens.js | fixParamsWithParenthesis | function fixParamsWithParenthesis(fixer) {
const paramToken = sourceCode.getTokenAfter(firstTokenOfParam);
/*
* ES8 allows Trailing commas in function parameter lists and calls
* https://github.com/eslint/eslint/issues/8834
*/
... | javascript | function fixParamsWithParenthesis(fixer) {
const paramToken = sourceCode.getTokenAfter(firstTokenOfParam);
/*
* ES8 allows Trailing commas in function parameter lists and calls
* https://github.com/eslint/eslint/issues/8834
*/
... | [
"function",
"fixParamsWithParenthesis",
"(",
"fixer",
")",
"{",
"const",
"paramToken",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"firstTokenOfParam",
")",
";",
"/*\n * ES8 allows Trailing commas in function parameter lists and calls\n * https://git... | Remove the parenthesis around a parameter
@param {Fixer} fixer Fixer
@returns {string} fixed parameter | [
"Remove",
"the",
"parenthesis",
"around",
"a",
"parameter"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/arrow-parens.js#L75-L90 |
3,041 | eslint/eslint | lib/rules/no-self-assign.js | isSameProperty | function isSameProperty(left, right) {
if (left.property.type === "Identifier" &&
left.property.type === right.property.type &&
left.property.name === right.property.name &&
left.computed === right.computed
) {
return true;
}
const lname = astUtils.getStaticPropertyName(... | javascript | function isSameProperty(left, right) {
if (left.property.type === "Identifier" &&
left.property.type === right.property.type &&
left.property.name === right.property.name &&
left.computed === right.computed
) {
return true;
}
const lname = astUtils.getStaticPropertyName(... | [
"function",
"isSameProperty",
"(",
"left",
",",
"right",
")",
"{",
"if",
"(",
"left",
".",
"property",
".",
"type",
"===",
"\"Identifier\"",
"&&",
"left",
".",
"property",
".",
"type",
"===",
"right",
".",
"property",
".",
"type",
"&&",
"left",
".",
"p... | Checks whether the property of 2 given member expression nodes are the same
property or not.
@param {ASTNode} left - A member expression node to check.
@param {ASTNode} right - Another member expression node to check.
@returns {boolean} `true` if the member expressions have the same property. | [
"Checks",
"whether",
"the",
"property",
"of",
"2",
"given",
"member",
"expression",
"nodes",
"are",
"the",
"same",
"property",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-self-assign.js#L28-L41 |
3,042 | eslint/eslint | lib/rules/no-self-assign.js | isSameMember | function isSameMember(left, right) {
if (!isSameProperty(left, right)) {
return false;
}
const lobj = left.object;
const robj = right.object;
if (lobj.type !== robj.type) {
return false;
}
if (lobj.type === "MemberExpression") {
return isSameMember(lobj, robj);
... | javascript | function isSameMember(left, right) {
if (!isSameProperty(left, right)) {
return false;
}
const lobj = left.object;
const robj = right.object;
if (lobj.type !== robj.type) {
return false;
}
if (lobj.type === "MemberExpression") {
return isSameMember(lobj, robj);
... | [
"function",
"isSameMember",
"(",
"left",
",",
"right",
")",
"{",
"if",
"(",
"!",
"isSameProperty",
"(",
"left",
",",
"right",
")",
")",
"{",
"return",
"false",
";",
"}",
"const",
"lobj",
"=",
"left",
".",
"object",
";",
"const",
"robj",
"=",
"right",... | Checks whether 2 given member expression nodes are the reference to the same
property or not.
@param {ASTNode} left - A member expression node to check.
@param {ASTNode} right - Another member expression node to check.
@returns {boolean} `true` if the member expressions are the reference to the
same property or not. | [
"Checks",
"whether",
"2",
"given",
"member",
"expression",
"nodes",
"are",
"the",
"reference",
"to",
"the",
"same",
"property",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-self-assign.js#L52-L67 |
3,043 | eslint/eslint | lib/rules/no-self-assign.js | eachSelfAssignment | function eachSelfAssignment(left, right, props, report) {
if (!left || !right) {
// do nothing
} else if (
left.type === "Identifier" &&
right.type === "Identifier" &&
left.name === right.name
) {
report(right);
} else if (
left.type === "ArrayPattern" &&... | javascript | function eachSelfAssignment(left, right, props, report) {
if (!left || !right) {
// do nothing
} else if (
left.type === "Identifier" &&
right.type === "Identifier" &&
left.name === right.name
) {
report(right);
} else if (
left.type === "ArrayPattern" &&... | [
"function",
"eachSelfAssignment",
"(",
"left",
",",
"right",
",",
"props",
",",
"report",
")",
"{",
"if",
"(",
"!",
"left",
"||",
"!",
"right",
")",
"{",
"// do nothing",
"}",
"else",
"if",
"(",
"left",
".",
"type",
"===",
"\"Identifier\"",
"&&",
"righ... | Traverses 2 Pattern nodes in parallel, then reports self-assignments.
@param {ASTNode|null} left - A left node to traverse. This is a Pattern or
a Property.
@param {ASTNode|null} right - A right node to traverse. This is a Pattern or
a Property.
@param {boolean} props - The flag to check member expressions as well.
@p... | [
"Traverses",
"2",
"Pattern",
"nodes",
"in",
"parallel",
"then",
"reports",
"self",
"-",
"assignments",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-self-assign.js#L80-L160 |
3,044 | eslint/eslint | lib/rules/no-self-assign.js | report | function report(node) {
context.report({
node,
message: "'{{name}}' is assigned to itself.",
data: {
name: sourceCode.getText(node).replace(SPACES, "")
}
});
} | javascript | function report(node) {
context.report({
node,
message: "'{{name}}' is assigned to itself.",
data: {
name: sourceCode.getText(node).replace(SPACES, "")
}
});
} | [
"function",
"report",
"(",
"node",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"message",
":",
"\"'{{name}}' is assigned to itself.\"",
",",
"data",
":",
"{",
"name",
":",
"sourceCode",
".",
"getText",
"(",
"node",
")",
".",
"replace",
"(",
... | Reports a given node as self assignments.
@param {ASTNode} node - A node to report. This is an Identifier node.
@returns {void} | [
"Reports",
"a",
"given",
"node",
"as",
"self",
"assignments",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-self-assign.js#L201-L209 |
3,045 | eslint/eslint | lib/rules/comma-style.js | getFixerFunction | function getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) {
const text =
sourceCode.text.slice(previousItemToken.range[1], commaToken.range[0]) +
sourceCode.text.slice(commaToken.range[1], currentItemToken.range[0]);
const range = [prev... | javascript | function getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) {
const text =
sourceCode.text.slice(previousItemToken.range[1], commaToken.range[0]) +
sourceCode.text.slice(commaToken.range[1], currentItemToken.range[0]);
const range = [prev... | [
"function",
"getFixerFunction",
"(",
"styleType",
",",
"previousItemToken",
",",
"commaToken",
",",
"currentItemToken",
")",
"{",
"const",
"text",
"=",
"sourceCode",
".",
"text",
".",
"slice",
"(",
"previousItemToken",
".",
"range",
"[",
"1",
"]",
",",
"commaT... | Determines the fixer function for a given style.
@param {string} styleType comma style
@param {ASTNode} previousItemToken The token to check.
@param {ASTNode} commaToken The token to check.
@param {ASTNode} currentItemToken The token to check.
@returns {Function} Fixer function
@private | [
"Determines",
"the",
"fixer",
"function",
"for",
"a",
"given",
"style",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/comma-style.js#L110-L119 |
3,046 | eslint/eslint | lib/rules/comma-style.js | validateCommaItemSpacing | function validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem) {
// if single line
if (astUtils.isTokenOnSameLine(commaToken, currentItemToken) &&
astUtils.isTokenOnSameLine(previousItemToken, commaToken)) {
// do nothing.
... | javascript | function validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem) {
// if single line
if (astUtils.isTokenOnSameLine(commaToken, currentItemToken) &&
astUtils.isTokenOnSameLine(previousItemToken, commaToken)) {
// do nothing.
... | [
"function",
"validateCommaItemSpacing",
"(",
"previousItemToken",
",",
"commaToken",
",",
"currentItemToken",
",",
"reportItem",
")",
"{",
"// if single line",
"if",
"(",
"astUtils",
".",
"isTokenOnSameLine",
"(",
"commaToken",
",",
"currentItemToken",
")",
"&&",
"ast... | Validates the spacing around single items in lists.
@param {Token} previousItemToken The last token from the previous item.
@param {Token} commaToken The token representing the comma.
@param {Token} currentItemToken The first token of the current item.
@param {Token} reportItem The item to use when reporting an error.
... | [
"Validates",
"the",
"spacing",
"around",
"single",
"items",
"in",
"lists",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/comma-style.js#L130-L177 |
3,047 | eslint/eslint | lib/rules/accessor-pairs.js | isArgumentOfMethodCall | function isArgumentOfMethodCall(node, index, object, property) {
const parent = node.parent;
return (
parent.type === "CallExpression" &&
parent.callee.type === "MemberExpression" &&
parent.callee.computed === false &&
isIdentifier(parent.callee.object, object) &&
isIden... | javascript | function isArgumentOfMethodCall(node, index, object, property) {
const parent = node.parent;
return (
parent.type === "CallExpression" &&
parent.callee.type === "MemberExpression" &&
parent.callee.computed === false &&
isIdentifier(parent.callee.object, object) &&
isIden... | [
"function",
"isArgumentOfMethodCall",
"(",
"node",
",",
"index",
",",
"object",
",",
"property",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"return",
"(",
"parent",
".",
"type",
"===",
"\"CallExpression\"",
"&&",
"parent",
".",
"callee",
... | Checks whether or not a given node is an argument of a specified method call.
@param {ASTNode} node - A node to check.
@param {number} index - An expected index of the node in arguments.
@param {string} object - An expected name of the object of the method.
@param {string} property - An expected name of the method.
@re... | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"node",
"is",
"an",
"argument",
"of",
"a",
"specified",
"method",
"call",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/accessor-pairs.js#L30-L41 |
3,048 | eslint/eslint | lib/util/glob-utils.js | processPath | function processPath(options) {
const cwd = (options && options.cwd) || process.cwd();
let extensions = (options && options.extensions) || [".js"];
extensions = extensions.map(ext => ext.replace(/^\./u, ""));
let suffix = "/**";
if (extensions.length === 1) {
suffix += `/*.${extensions[0]... | javascript | function processPath(options) {
const cwd = (options && options.cwd) || process.cwd();
let extensions = (options && options.extensions) || [".js"];
extensions = extensions.map(ext => ext.replace(/^\./u, ""));
let suffix = "/**";
if (extensions.length === 1) {
suffix += `/*.${extensions[0]... | [
"function",
"processPath",
"(",
"options",
")",
"{",
"const",
"cwd",
"=",
"(",
"options",
"&&",
"options",
".",
"cwd",
")",
"||",
"process",
".",
"cwd",
"(",
")",
";",
"let",
"extensions",
"=",
"(",
"options",
"&&",
"options",
".",
"extensions",
")",
... | Checks if a provided path is a directory and returns a glob string matching
all files under that directory if so, the path itself otherwise.
Reason for this is that `glob` needs `/**` to collect all the files under a
directory where as our previous implementation without `glob` simply walked
a directory that is passed... | [
"Checks",
"if",
"a",
"provided",
"path",
"is",
"a",
"directory",
"and",
"returns",
"a",
"glob",
"string",
"matching",
"all",
"files",
"under",
"that",
"directory",
"if",
"so",
"the",
"path",
"itself",
"otherwise",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/glob-utils.js#L51-L86 |
3,049 | eslint/eslint | lib/util/glob-utils.js | listFilesToProcess | function listFilesToProcess(globPatterns, providedOptions) {
const options = providedOptions || { ignore: true };
const cwd = options.cwd || process.cwd();
const getIgnorePaths = lodash.memoize(
optionsObj =>
new IgnoredPaths(optionsObj)
);
/*
* The test "should use defaul... | javascript | function listFilesToProcess(globPatterns, providedOptions) {
const options = providedOptions || { ignore: true };
const cwd = options.cwd || process.cwd();
const getIgnorePaths = lodash.memoize(
optionsObj =>
new IgnoredPaths(optionsObj)
);
/*
* The test "should use defaul... | [
"function",
"listFilesToProcess",
"(",
"globPatterns",
",",
"providedOptions",
")",
"{",
"const",
"options",
"=",
"providedOptions",
"||",
"{",
"ignore",
":",
"true",
"}",
";",
"const",
"cwd",
"=",
"options",
".",
"cwd",
"||",
"process",
".",
"cwd",
"(",
"... | Build a list of absolute filesnames on which ESLint will act.
Ignored files are excluded from the results, as are duplicates.
@param {string[]} globPatterns Glob patterns.
@param {Object} [providedOptions] An options object.
@param {string} [providedOptions.cwd] ... | [
"Build",
"a",
"list",
"of",
"absolute",
"filesnames",
"on",
"which",
"ESLint",
"will",
"act",
".",
"Ignored",
"files",
"are",
"excluded",
"from",
"the",
"results",
"as",
"are",
"duplicates",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/glob-utils.js#L191-L280 |
3,050 | eslint/eslint | lib/rules/no-prototype-builtins.js | disallowBuiltIns | function disallowBuiltIns(node) {
if (node.callee.type !== "MemberExpression" || node.callee.computed) {
return;
}
const propName = node.callee.property.name;
if (DISALLOWED_PROPS.indexOf(propName) > -1) {
context.report({
... | javascript | function disallowBuiltIns(node) {
if (node.callee.type !== "MemberExpression" || node.callee.computed) {
return;
}
const propName = node.callee.property.name;
if (DISALLOWED_PROPS.indexOf(propName) > -1) {
context.report({
... | [
"function",
"disallowBuiltIns",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"callee",
".",
"type",
"!==",
"\"MemberExpression\"",
"||",
"node",
".",
"callee",
".",
"computed",
")",
"{",
"return",
";",
"}",
"const",
"propName",
"=",
"node",
".",
"calle... | Reports if a disallowed property is used in a CallExpression
@param {ASTNode} node The CallExpression node.
@returns {void} | [
"Reports",
"if",
"a",
"disallowed",
"property",
"is",
"used",
"in",
"a",
"CallExpression"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-prototype-builtins.js#L37-L51 |
3,051 | eslint/eslint | lib/rules/no-useless-escape.js | report | function report(node, startOffset, character) {
context.report({
node,
loc: sourceCode.getLocFromIndex(sourceCode.getIndexFromLoc(node.loc.start) + startOffset),
message: "Unnecessary escape character: \\{{character}}.",
data: { character }
... | javascript | function report(node, startOffset, character) {
context.report({
node,
loc: sourceCode.getLocFromIndex(sourceCode.getIndexFromLoc(node.loc.start) + startOffset),
message: "Unnecessary escape character: \\{{character}}.",
data: { character }
... | [
"function",
"report",
"(",
"node",
",",
"startOffset",
",",
"character",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"loc",
":",
"sourceCode",
".",
"getLocFromIndex",
"(",
"sourceCode",
".",
"getIndexFromLoc",
"(",
"node",
".",
"loc",
".",
... | Reports a node
@param {ASTNode} node The node to report
@param {number} startOffset The backslash's offset from the start of the node
@param {string} character The uselessly escaped character (not including the backslash)
@returns {void} | [
"Reports",
"a",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-escape.js#L104-L111 |
3,052 | eslint/eslint | lib/rules/no-useless-escape.js | validateString | function validateString(node, match) {
const isTemplateElement = node.type === "TemplateElement";
const escapedChar = match[0][1];
let isUnnecessaryEscape = !VALID_STRING_ESCAPES.has(escapedChar);
let isQuoteEscape;
if (isTemplateElement) {
is... | javascript | function validateString(node, match) {
const isTemplateElement = node.type === "TemplateElement";
const escapedChar = match[0][1];
let isUnnecessaryEscape = !VALID_STRING_ESCAPES.has(escapedChar);
let isQuoteEscape;
if (isTemplateElement) {
is... | [
"function",
"validateString",
"(",
"node",
",",
"match",
")",
"{",
"const",
"isTemplateElement",
"=",
"node",
".",
"type",
"===",
"\"TemplateElement\"",
";",
"const",
"escapedChar",
"=",
"match",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"let",
"isUnnecessaryEscape... | Checks if the escape character in given string slice is unnecessary.
@private
@param {ASTNode} node - node to validate.
@param {string} match - string slice to validate.
@returns {void} | [
"Checks",
"if",
"the",
"escape",
"character",
"in",
"given",
"string",
"slice",
"is",
"unnecessary",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-escape.js#L121-L150 |
3,053 | eslint/eslint | lib/rules/no-useless-escape.js | check | function check(node) {
const isTemplateElement = node.type === "TemplateElement";
if (
isTemplateElement &&
node.parent &&
node.parent.parent &&
node.parent.parent.type === "TaggedTemplateExpression" &&
node.parent ... | javascript | function check(node) {
const isTemplateElement = node.type === "TemplateElement";
if (
isTemplateElement &&
node.parent &&
node.parent.parent &&
node.parent.parent.type === "TaggedTemplateExpression" &&
node.parent ... | [
"function",
"check",
"(",
"node",
")",
"{",
"const",
"isTemplateElement",
"=",
"node",
".",
"type",
"===",
"\"TemplateElement\"",
";",
"if",
"(",
"isTemplateElement",
"&&",
"node",
".",
"parent",
"&&",
"node",
".",
"parent",
".",
"parent",
"&&",
"node",
".... | Checks if a node has an escape.
@param {ASTNode} node - node to check.
@returns {void} | [
"Checks",
"if",
"a",
"node",
"has",
"an",
"escape",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-escape.js#L158-L219 |
3,054 | eslint/eslint | lib/formatters/table.js | drawTable | function drawTable(messages) {
const rows = [];
if (messages.length === 0) {
return "";
}
rows.push([
chalk.bold("Line"),
chalk.bold("Column"),
chalk.bold("Type"),
chalk.bold("Message"),
chalk.bold("Rule ID")
]);
messages.forEach(message => {
... | javascript | function drawTable(messages) {
const rows = [];
if (messages.length === 0) {
return "";
}
rows.push([
chalk.bold("Line"),
chalk.bold("Column"),
chalk.bold("Type"),
chalk.bold("Message"),
chalk.bold("Rule ID")
]);
messages.forEach(message => {
... | [
"function",
"drawTable",
"(",
"messages",
")",
"{",
"const",
"rows",
"=",
"[",
"]",
";",
"if",
"(",
"messages",
".",
"length",
"===",
"0",
")",
"{",
"return",
"\"\"",
";",
"}",
"rows",
".",
"push",
"(",
"[",
"chalk",
".",
"bold",
"(",
"\"Line\"",
... | Draws text table.
@param {Array<Object>} messages Error messages relating to a specific file.
@returns {string} A text table. | [
"Draws",
"text",
"table",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/formatters/table.js#L33-L94 |
3,055 | eslint/eslint | lib/util/npm-utils.js | fetchPeerDependencies | function fetchPeerDependencies(packageName) {
const npmProcess = spawn.sync(
"npm",
["show", "--json", packageName, "peerDependencies"],
{ encoding: "utf8" }
);
const error = npmProcess.error;
if (error && error.code === "ENOENT") {
return null;
}
const fetchedT... | javascript | function fetchPeerDependencies(packageName) {
const npmProcess = spawn.sync(
"npm",
["show", "--json", packageName, "peerDependencies"],
{ encoding: "utf8" }
);
const error = npmProcess.error;
if (error && error.code === "ENOENT") {
return null;
}
const fetchedT... | [
"function",
"fetchPeerDependencies",
"(",
"packageName",
")",
"{",
"const",
"npmProcess",
"=",
"spawn",
".",
"sync",
"(",
"\"npm\"",
",",
"[",
"\"show\"",
",",
"\"--json\"",
",",
"packageName",
",",
"\"peerDependencies\"",
"]",
",",
"{",
"encoding",
":",
"\"ut... | Fetch `peerDependencies` of the given package by `npm show` command.
@param {string} packageName The package name to fetch peerDependencies.
@returns {Object} Gotten peerDependencies. Returns null if npm was not found. | [
"Fetch",
"peerDependencies",
"of",
"the",
"given",
"package",
"by",
"npm",
"show",
"command",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/npm-utils.js#L70-L87 |
3,056 | eslint/eslint | lib/util/npm-utils.js | check | function check(packages, opt) {
let deps = [];
const pkgJson = (opt) ? findPackageJson(opt.startDir) : findPackageJson();
let fileJson;
if (!pkgJson) {
throw new Error("Could not find a package.json file. Run 'npm init' to create one.");
}
try {
fileJson = JSON.parse(fs.readFil... | javascript | function check(packages, opt) {
let deps = [];
const pkgJson = (opt) ? findPackageJson(opt.startDir) : findPackageJson();
let fileJson;
if (!pkgJson) {
throw new Error("Could not find a package.json file. Run 'npm init' to create one.");
}
try {
fileJson = JSON.parse(fs.readFil... | [
"function",
"check",
"(",
"packages",
",",
"opt",
")",
"{",
"let",
"deps",
"=",
"[",
"]",
";",
"const",
"pkgJson",
"=",
"(",
"opt",
")",
"?",
"findPackageJson",
"(",
"opt",
".",
"startDir",
")",
":",
"findPackageJson",
"(",
")",
";",
"let",
"fileJson... | Check whether node modules are include in a project's package.json.
@param {string[]} packages Array of node module names
@param {Object} opt Options Object
@param {boolean} opt.dependencies Set to true to check for direct dependencies
@param {boolean} opt.devDependencies Set to t... | [
"Check",
"whether",
"node",
"modules",
"are",
"include",
"in",
"a",
"project",
"s",
"package",
".",
"json",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/npm-utils.js#L100-L132 |
3,057 | eslint/eslint | lib/rules/vars-on-top.js | looksLikeImport | function looksLikeImport(node) {
return node.type === "ImportDeclaration" || node.type === "ImportSpecifier" ||
node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier";
} | javascript | function looksLikeImport(node) {
return node.type === "ImportDeclaration" || node.type === "ImportSpecifier" ||
node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier";
} | [
"function",
"looksLikeImport",
"(",
"node",
")",
"{",
"return",
"node",
".",
"type",
"===",
"\"ImportDeclaration\"",
"||",
"node",
".",
"type",
"===",
"\"ImportSpecifier\"",
"||",
"node",
".",
"type",
"===",
"\"ImportDefaultSpecifier\"",
"||",
"node",
".",
"type... | Check to see if its a ES6 import declaration
@param {ASTNode} node - any node
@returns {boolean} whether the given node represents a import declaration | [
"Check",
"to",
"see",
"if",
"its",
"a",
"ES6",
"import",
"declaration"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/vars-on-top.js#L49-L52 |
3,058 | eslint/eslint | lib/rules/vars-on-top.js | isVariableDeclaration | function isVariableDeclaration(node) {
return (
node.type === "VariableDeclaration" ||
(
node.type === "ExportNamedDeclaration" &&
node.declaration &&
node.declaration.type === "VariableDeclaration"
)... | javascript | function isVariableDeclaration(node) {
return (
node.type === "VariableDeclaration" ||
(
node.type === "ExportNamedDeclaration" &&
node.declaration &&
node.declaration.type === "VariableDeclaration"
)... | [
"function",
"isVariableDeclaration",
"(",
"node",
")",
"{",
"return",
"(",
"node",
".",
"type",
"===",
"\"VariableDeclaration\"",
"||",
"(",
"node",
".",
"type",
"===",
"\"ExportNamedDeclaration\"",
"&&",
"node",
".",
"declaration",
"&&",
"node",
".",
"declarati... | Checks whether a given node is a variable declaration or not.
@param {ASTNode} node - any node
@returns {boolean} `true` if the node is a variable declaration. | [
"Checks",
"whether",
"a",
"given",
"node",
"is",
"a",
"variable",
"declaration",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/vars-on-top.js#L60-L69 |
3,059 | eslint/eslint | lib/rules/vars-on-top.js | isVarOnTop | function isVarOnTop(node, statements) {
const l = statements.length;
let i = 0;
// skip over directives
for (; i < l; ++i) {
if (!looksLikeDirective(statements[i]) && !looksLikeImport(statements[i])) {
break;
}
... | javascript | function isVarOnTop(node, statements) {
const l = statements.length;
let i = 0;
// skip over directives
for (; i < l; ++i) {
if (!looksLikeDirective(statements[i]) && !looksLikeImport(statements[i])) {
break;
}
... | [
"function",
"isVarOnTop",
"(",
"node",
",",
"statements",
")",
"{",
"const",
"l",
"=",
"statements",
".",
"length",
";",
"let",
"i",
"=",
"0",
";",
"// skip over directives",
"for",
"(",
";",
"i",
"<",
"l",
";",
"++",
"i",
")",
"{",
"if",
"(",
"!",... | Checks whether this variable is on top of the block body
@param {ASTNode} node - The node to check
@param {ASTNode[]} statements - collection of ASTNodes for the parent node block
@returns {boolean} True if var is on top otherwise false | [
"Checks",
"whether",
"this",
"variable",
"is",
"on",
"top",
"of",
"the",
"block",
"body"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/vars-on-top.js#L77-L98 |
3,060 | eslint/eslint | lib/rules/vars-on-top.js | globalVarCheck | function globalVarCheck(node, parent) {
if (!isVarOnTop(node, parent.body)) {
context.report({ node, messageId: "top" });
}
} | javascript | function globalVarCheck(node, parent) {
if (!isVarOnTop(node, parent.body)) {
context.report({ node, messageId: "top" });
}
} | [
"function",
"globalVarCheck",
"(",
"node",
",",
"parent",
")",
"{",
"if",
"(",
"!",
"isVarOnTop",
"(",
"node",
",",
"parent",
".",
"body",
")",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"messageId",
":",
"\"top\"",
"}",
")",
";",
"... | Checks whether variable is on top at the global level
@param {ASTNode} node - The node to check
@param {ASTNode} parent - Parent of the node
@returns {void} | [
"Checks",
"whether",
"variable",
"is",
"on",
"top",
"at",
"the",
"global",
"level"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/vars-on-top.js#L106-L110 |
3,061 | eslint/eslint | lib/rules/vars-on-top.js | blockScopeVarCheck | function blockScopeVarCheck(node, parent, grandParent) {
if (!(/Function/u.test(grandParent.type) &&
parent.type === "BlockStatement" &&
isVarOnTop(node, parent.body))) {
context.report({ node, messageId: "top" });
}
} | javascript | function blockScopeVarCheck(node, parent, grandParent) {
if (!(/Function/u.test(grandParent.type) &&
parent.type === "BlockStatement" &&
isVarOnTop(node, parent.body))) {
context.report({ node, messageId: "top" });
}
} | [
"function",
"blockScopeVarCheck",
"(",
"node",
",",
"parent",
",",
"grandParent",
")",
"{",
"if",
"(",
"!",
"(",
"/",
"Function",
"/",
"u",
".",
"test",
"(",
"grandParent",
".",
"type",
")",
"&&",
"parent",
".",
"type",
"===",
"\"BlockStatement\"",
"&&",... | Checks whether variable is on top at functional block scope level
@param {ASTNode} node - The node to check
@param {ASTNode} parent - Parent of the node
@param {ASTNode} grandParent - Parent of the node's parent
@returns {void} | [
"Checks",
"whether",
"variable",
"is",
"on",
"top",
"at",
"functional",
"block",
"scope",
"level"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/vars-on-top.js#L119-L125 |
3,062 | eslint/eslint | tools/internal-rules/consistent-docs-url.js | checkMetaDocsUrl | function checkMetaDocsUrl(context, exportsNode) {
if (exportsNode.type !== "ObjectExpression") {
// if the exported node is not the correct format, "internal-no-invalid-meta" will already report this.
return;
}
const metaProperty = getPropertyFromObject("meta", exportsNode);
const meta... | javascript | function checkMetaDocsUrl(context, exportsNode) {
if (exportsNode.type !== "ObjectExpression") {
// if the exported node is not the correct format, "internal-no-invalid-meta" will already report this.
return;
}
const metaProperty = getPropertyFromObject("meta", exportsNode);
const meta... | [
"function",
"checkMetaDocsUrl",
"(",
"context",
",",
"exportsNode",
")",
"{",
"if",
"(",
"exportsNode",
".",
"type",
"!==",
"\"ObjectExpression\"",
")",
"{",
"// if the exported node is not the correct format, \"internal-no-invalid-meta\" will already report this.",
"return",
"... | Verifies that the meta.docs.url property is present and has the correct value.
@param {RuleContext} context The ESLint rule context.
@param {ASTNode} exportsNode ObjectExpression node that the rule exports.
@returns {void} | [
"Verifies",
"that",
"the",
"meta",
".",
"docs",
".",
"url",
"property",
"is",
"present",
"and",
"has",
"the",
"correct",
"value",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/tools/internal-rules/consistent-docs-url.js#L46-L84 |
3,063 | eslint/eslint | lib/rules/no-restricted-globals.js | reportReference | function reportReference(reference) {
const name = reference.identifier.name,
customMessage = restrictedGlobalMessages[name],
message = customMessage
? CUSTOM_MESSAGE_TEMPLATE
: DEFAULT_MESSAGE_TEMPLATE;
context.report({
... | javascript | function reportReference(reference) {
const name = reference.identifier.name,
customMessage = restrictedGlobalMessages[name],
message = customMessage
? CUSTOM_MESSAGE_TEMPLATE
: DEFAULT_MESSAGE_TEMPLATE;
context.report({
... | [
"function",
"reportReference",
"(",
"reference",
")",
"{",
"const",
"name",
"=",
"reference",
".",
"identifier",
".",
"name",
",",
"customMessage",
"=",
"restrictedGlobalMessages",
"[",
"name",
"]",
",",
"message",
"=",
"customMessage",
"?",
"CUSTOM_MESSAGE_TEMPLA... | Report a variable to be used as a restricted global.
@param {Reference} reference the variable reference
@returns {void}
@private | [
"Report",
"a",
"variable",
"to",
"be",
"used",
"as",
"a",
"restricted",
"global",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-restricted-globals.js#L75-L90 |
3,064 | eslint/eslint | lib/rules/newline-before-return.js | isFirstNode | function isFirstNode(node) {
const parentType = node.parent.type;
if (node.parent.body) {
return Array.isArray(node.parent.body)
? node.parent.body[0] === node
: node.parent.body === node;
}
if (parentType === "IfS... | javascript | function isFirstNode(node) {
const parentType = node.parent.type;
if (node.parent.body) {
return Array.isArray(node.parent.body)
? node.parent.body[0] === node
: node.parent.body === node;
}
if (parentType === "IfS... | [
"function",
"isFirstNode",
"(",
"node",
")",
"{",
"const",
"parentType",
"=",
"node",
".",
"parent",
".",
"type",
";",
"if",
"(",
"node",
".",
"parent",
".",
"body",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"node",
".",
"parent",
".",
"body"... | Checks whether node is the first node after statement or in block
@param {ASTNode} node - node to check
@returns {boolean} Whether or not the node is the first node after statement or in block
@private | [
"Checks",
"whether",
"node",
"is",
"the",
"first",
"node",
"after",
"statement",
"or",
"in",
"block"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/newline-before-return.js#L59-L79 |
3,065 | eslint/eslint | lib/rules/newline-before-return.js | calcCommentLines | function calcCommentLines(node, lineNumTokenBefore) {
const comments = sourceCode.getCommentsBefore(node);
let numLinesComments = 0;
if (!comments.length) {
return numLinesComments;
}
comments.forEach(comment => {
numLinesComm... | javascript | function calcCommentLines(node, lineNumTokenBefore) {
const comments = sourceCode.getCommentsBefore(node);
let numLinesComments = 0;
if (!comments.length) {
return numLinesComments;
}
comments.forEach(comment => {
numLinesComm... | [
"function",
"calcCommentLines",
"(",
"node",
",",
"lineNumTokenBefore",
")",
"{",
"const",
"comments",
"=",
"sourceCode",
".",
"getCommentsBefore",
"(",
"node",
")",
";",
"let",
"numLinesComments",
"=",
"0",
";",
"if",
"(",
"!",
"comments",
".",
"length",
")... | Returns the number of lines of comments that precede the node
@param {ASTNode} node - node to check for overlapping comments
@param {number} lineNumTokenBefore - line number of previous token, to check for overlapping comments
@returns {number} Number of lines of comments that precede the node
@private | [
"Returns",
"the",
"number",
"of",
"lines",
"of",
"comments",
"that",
"precede",
"the",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/newline-before-return.js#L88-L114 |
3,066 | eslint/eslint | lib/rules/newline-before-return.js | getLineNumberOfTokenBefore | function getLineNumberOfTokenBefore(node) {
const tokenBefore = sourceCode.getTokenBefore(node);
let lineNumTokenBefore;
/**
* Global return (at the beginning of a script) is a special case.
* If there is no token before `return`, then we expect no line
... | javascript | function getLineNumberOfTokenBefore(node) {
const tokenBefore = sourceCode.getTokenBefore(node);
let lineNumTokenBefore;
/**
* Global return (at the beginning of a script) is a special case.
* If there is no token before `return`, then we expect no line
... | [
"function",
"getLineNumberOfTokenBefore",
"(",
"node",
")",
"{",
"const",
"tokenBefore",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"node",
")",
";",
"let",
"lineNumTokenBefore",
";",
"/**\n * Global return (at the beginning of a script) is a special case.\n ... | Returns the line number of the token before the node that is passed in as an argument
@param {ASTNode} node - The node to use as the start of the calculation
@returns {number} Line number of the token before `node`
@private | [
"Returns",
"the",
"line",
"number",
"of",
"the",
"token",
"before",
"the",
"node",
"that",
"is",
"passed",
"in",
"as",
"an",
"argument"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/newline-before-return.js#L122-L141 |
3,067 | eslint/eslint | lib/rules/newline-before-return.js | hasNewlineBefore | function hasNewlineBefore(node) {
const lineNumNode = node.loc.start.line;
const lineNumTokenBefore = getLineNumberOfTokenBefore(node);
const commentLines = calcCommentLines(node, lineNumTokenBefore);
return (lineNumNode - lineNumTokenBefore - commentLines) > 1;
... | javascript | function hasNewlineBefore(node) {
const lineNumNode = node.loc.start.line;
const lineNumTokenBefore = getLineNumberOfTokenBefore(node);
const commentLines = calcCommentLines(node, lineNumTokenBefore);
return (lineNumNode - lineNumTokenBefore - commentLines) > 1;
... | [
"function",
"hasNewlineBefore",
"(",
"node",
")",
"{",
"const",
"lineNumNode",
"=",
"node",
".",
"loc",
".",
"start",
".",
"line",
";",
"const",
"lineNumTokenBefore",
"=",
"getLineNumberOfTokenBefore",
"(",
"node",
")",
";",
"const",
"commentLines",
"=",
"calc... | Checks whether node is preceded by a newline
@param {ASTNode} node - node to check
@returns {boolean} Whether or not the node is preceded by a newline
@private | [
"Checks",
"whether",
"node",
"is",
"preceded",
"by",
"a",
"newline"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/newline-before-return.js#L149-L155 |
3,068 | eslint/eslint | lib/rules/newline-before-return.js | canFix | function canFix(node) {
const leadingComments = sourceCode.getCommentsBefore(node);
const lastLeadingComment = leadingComments[leadingComments.length - 1];
const tokenBefore = sourceCode.getTokenBefore(node);
if (leadingComments.length === 0) {
return tru... | javascript | function canFix(node) {
const leadingComments = sourceCode.getCommentsBefore(node);
const lastLeadingComment = leadingComments[leadingComments.length - 1];
const tokenBefore = sourceCode.getTokenBefore(node);
if (leadingComments.length === 0) {
return tru... | [
"function",
"canFix",
"(",
"node",
")",
"{",
"const",
"leadingComments",
"=",
"sourceCode",
".",
"getCommentsBefore",
"(",
"node",
")",
";",
"const",
"lastLeadingComment",
"=",
"leadingComments",
"[",
"leadingComments",
".",
"length",
"-",
"1",
"]",
";",
"cons... | Checks whether it is safe to apply a fix to a given return statement.
The fix is not considered safe if the given return statement has leading comments,
as we cannot safely determine if the newline should be added before or after the comments.
For more information, see: https://github.com/eslint/eslint/issues/5958#iss... | [
"Checks",
"whether",
"it",
"is",
"safe",
"to",
"apply",
"a",
"fix",
"to",
"a",
"given",
"return",
"statement",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/newline-before-return.js#L168-L192 |
3,069 | eslint/eslint | lib/rules/no-fallthrough.js | hasFallthroughComment | function hasFallthroughComment(node, context, fallthroughCommentPattern) {
const sourceCode = context.getSourceCode();
const comment = lodash.last(sourceCode.getCommentsBefore(node));
return Boolean(comment && fallthroughCommentPattern.test(comment.value));
} | javascript | function hasFallthroughComment(node, context, fallthroughCommentPattern) {
const sourceCode = context.getSourceCode();
const comment = lodash.last(sourceCode.getCommentsBefore(node));
return Boolean(comment && fallthroughCommentPattern.test(comment.value));
} | [
"function",
"hasFallthroughComment",
"(",
"node",
",",
"context",
",",
"fallthroughCommentPattern",
")",
"{",
"const",
"sourceCode",
"=",
"context",
".",
"getSourceCode",
"(",
")",
";",
"const",
"comment",
"=",
"lodash",
".",
"last",
"(",
"sourceCode",
".",
"g... | Checks whether or not a given node has a fallthrough comment.
@param {ASTNode} node - A SwitchCase node to get comments.
@param {RuleContext} context - A rule context which stores comments.
@param {RegExp} fallthroughCommentPattern - A pattern to match comment to.
@returns {boolean} `true` if the node has a valid fallt... | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"node",
"has",
"a",
"fallthrough",
"comment",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-fallthrough.js#L26-L31 |
3,070 | eslint/eslint | lib/rules/no-fallthrough.js | hasBlankLinesBetween | function hasBlankLinesBetween(node, token) {
return token.loc.start.line > node.loc.end.line + 1;
} | javascript | function hasBlankLinesBetween(node, token) {
return token.loc.start.line > node.loc.end.line + 1;
} | [
"function",
"hasBlankLinesBetween",
"(",
"node",
",",
"token",
")",
"{",
"return",
"token",
".",
"loc",
".",
"start",
".",
"line",
">",
"node",
".",
"loc",
".",
"end",
".",
"line",
"+",
"1",
";",
"}"
] | Checks whether a node and a token are separated by blank lines
@param {ASTNode} node - The node to check
@param {Token} token - The token to compare against
@returns {boolean} `true` if there are blank lines between node and token | [
"Checks",
"whether",
"a",
"node",
"and",
"a",
"token",
"are",
"separated",
"by",
"blank",
"lines"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-fallthrough.js#L48-L50 |
3,071 | eslint/eslint | lib/rules/quotes.js | isJSXLiteral | function isJSXLiteral(node) {
return node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment";
} | javascript | function isJSXLiteral(node) {
return node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment";
} | [
"function",
"isJSXLiteral",
"(",
"node",
")",
"{",
"return",
"node",
".",
"parent",
".",
"type",
"===",
"\"JSXAttribute\"",
"||",
"node",
".",
"parent",
".",
"type",
"===",
"\"JSXElement\"",
"||",
"node",
".",
"parent",
".",
"type",
"===",
"\"JSXFragment\"",... | Determines if a given node is part of JSX syntax.
This function returns `true` in the following cases:
- `<div className="foo"></div>` ... If the literal is an attribute value, the parent of the literal is `JSXAttribute`.
- `<div>foo</div>` ... If the literal is a text content, the parent of the literal is `JSXElemen... | [
"Determines",
"if",
"a",
"given",
"node",
"is",
"part",
"of",
"JSX",
"syntax",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/quotes.js#L151-L153 |
3,072 | eslint/eslint | lib/rules/quotes.js | isAllowedAsNonBacktick | function isAllowedAsNonBacktick(node) {
const parent = node.parent;
switch (parent.type) {
// Directive Prologues.
case "ExpressionStatement":
return isPartOfDirectivePrologue(node);
// LiteralPropertyName.
ca... | javascript | function isAllowedAsNonBacktick(node) {
const parent = node.parent;
switch (parent.type) {
// Directive Prologues.
case "ExpressionStatement":
return isPartOfDirectivePrologue(node);
// LiteralPropertyName.
ca... | [
"function",
"isAllowedAsNonBacktick",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"switch",
"(",
"parent",
".",
"type",
")",
"{",
"// Directive Prologues.",
"case",
"\"ExpressionStatement\"",
":",
"return",
"isPartOfDirectivePrologue",... | Checks whether or not a given node is allowed as non backtick.
@param {ASTNode} node - A node to check.
@returns {boolean} Whether or not the node is allowed as non backtick.
@private | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"node",
"is",
"allowed",
"as",
"non",
"backtick",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/quotes.js#L205-L229 |
3,073 | eslint/eslint | lib/rules/quotes.js | isUsingFeatureOfTemplateLiteral | function isUsingFeatureOfTemplateLiteral(node) {
const hasTag = node.parent.type === "TaggedTemplateExpression" && node === node.parent.quasi;
if (hasTag) {
return true;
}
const hasStringInterpolation = node.expressions.length > 0;
if (hasSt... | javascript | function isUsingFeatureOfTemplateLiteral(node) {
const hasTag = node.parent.type === "TaggedTemplateExpression" && node === node.parent.quasi;
if (hasTag) {
return true;
}
const hasStringInterpolation = node.expressions.length > 0;
if (hasSt... | [
"function",
"isUsingFeatureOfTemplateLiteral",
"(",
"node",
")",
"{",
"const",
"hasTag",
"=",
"node",
".",
"parent",
".",
"type",
"===",
"\"TaggedTemplateExpression\"",
"&&",
"node",
"===",
"node",
".",
"parent",
".",
"quasi",
";",
"if",
"(",
"hasTag",
")",
... | Checks whether or not a given TemplateLiteral node is actually using any of the special features provided by template literal strings.
@param {ASTNode} node - A TemplateLiteral node to check.
@returns {boolean} Whether or not the TemplateLiteral node is using any of the special features provided by template literal str... | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"TemplateLiteral",
"node",
"is",
"actually",
"using",
"any",
"of",
"the",
"special",
"features",
"provided",
"by",
"template",
"literal",
"strings",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/quotes.js#L237-L257 |
3,074 | eslint/eslint | lib/config/config-initializer.js | getPeerDependencies | function getPeerDependencies(moduleName) {
let result = getPeerDependencies.cache.get(moduleName);
if (!result) {
log.info(`Checking peerDependencies of ${moduleName}`);
result = npmUtils.fetchPeerDependencies(moduleName);
getPeerDependencies.cache.set(moduleName, result);
}
r... | javascript | function getPeerDependencies(moduleName) {
let result = getPeerDependencies.cache.get(moduleName);
if (!result) {
log.info(`Checking peerDependencies of ${moduleName}`);
result = npmUtils.fetchPeerDependencies(moduleName);
getPeerDependencies.cache.set(moduleName, result);
}
r... | [
"function",
"getPeerDependencies",
"(",
"moduleName",
")",
"{",
"let",
"result",
"=",
"getPeerDependencies",
".",
"cache",
".",
"get",
"(",
"moduleName",
")",
";",
"if",
"(",
"!",
"result",
")",
"{",
"log",
".",
"info",
"(",
"`",
"${",
"moduleName",
"}",... | Get the peer dependencies of the given module.
This adds the gotten value to cache at the first time, then reuses it.
In a process, this function is called twice, but `npmUtils.fetchPeerDependencies` needs to access network which is relatively slow.
@param {string} moduleName The module name to get.
@returns {Object} T... | [
"Get",
"the",
"peer",
"dependencies",
"of",
"the",
"given",
"module",
".",
"This",
"adds",
"the",
"gotten",
"value",
"to",
"cache",
"at",
"the",
"first",
"time",
"then",
"reuses",
"it",
".",
"In",
"a",
"process",
"this",
"function",
"is",
"called",
"twic... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-initializer.js#L74-L85 |
3,075 | eslint/eslint | lib/config/config-initializer.js | getModulesList | function getModulesList(config, installESLint) {
const modules = {};
// Create a list of modules which should be installed based on config
if (config.plugins) {
for (const plugin of config.plugins) {
modules[`eslint-plugin-${plugin}`] = "latest";
}
}
if (config.extends &... | javascript | function getModulesList(config, installESLint) {
const modules = {};
// Create a list of modules which should be installed based on config
if (config.plugins) {
for (const plugin of config.plugins) {
modules[`eslint-plugin-${plugin}`] = "latest";
}
}
if (config.extends &... | [
"function",
"getModulesList",
"(",
"config",
",",
"installESLint",
")",
"{",
"const",
"modules",
"=",
"{",
"}",
";",
"// Create a list of modules which should be installed based on config",
"if",
"(",
"config",
".",
"plugins",
")",
"{",
"for",
"(",
"const",
"plugin"... | Return necessary plugins, configs, parsers, etc. based on the config
@param {Object} config config object
@param {boolean} [installESLint=true] If `false` is given, it does not install eslint.
@returns {string[]} An array of modules to be installed. | [
"Return",
"necessary",
"plugins",
"configs",
"parsers",
"etc",
".",
"based",
"on",
"the",
"config"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-initializer.js#L94-L127 |
3,076 | eslint/eslint | lib/config/config-initializer.js | processAnswers | function processAnswers(answers) {
let config = {
rules: {},
env: {},
parserOptions: {},
extends: []
};
// set the latest ECMAScript version
config.parserOptions.ecmaVersion = DEFAULT_ECMA_VERSION;
config.env.es6 = true;
config.globals = {
Atomics: "reado... | javascript | function processAnswers(answers) {
let config = {
rules: {},
env: {},
parserOptions: {},
extends: []
};
// set the latest ECMAScript version
config.parserOptions.ecmaVersion = DEFAULT_ECMA_VERSION;
config.env.es6 = true;
config.globals = {
Atomics: "reado... | [
"function",
"processAnswers",
"(",
"answers",
")",
"{",
"let",
"config",
"=",
"{",
"rules",
":",
"{",
"}",
",",
"env",
":",
"{",
"}",
",",
"parserOptions",
":",
"{",
"}",
",",
"extends",
":",
"[",
"]",
"}",
";",
"// set the latest ECMAScript version",
... | process user's answers and create config object
@param {Object} answers answers received from inquirer
@returns {Object} config object | [
"process",
"user",
"s",
"answers",
"and",
"create",
"config",
"object"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-initializer.js#L245-L309 |
3,077 | eslint/eslint | lib/config/config-initializer.js | getConfigForStyleGuide | function getConfigForStyleGuide(guide) {
const guides = {
google: { extends: "google" },
airbnb: { extends: "airbnb" },
"airbnb-base": { extends: "airbnb-base" },
standard: { extends: "standard" }
};
if (!guides[guide]) {
throw new Error("You referenced an unsupporte... | javascript | function getConfigForStyleGuide(guide) {
const guides = {
google: { extends: "google" },
airbnb: { extends: "airbnb" },
"airbnb-base": { extends: "airbnb-base" },
standard: { extends: "standard" }
};
if (!guides[guide]) {
throw new Error("You referenced an unsupporte... | [
"function",
"getConfigForStyleGuide",
"(",
"guide",
")",
"{",
"const",
"guides",
"=",
"{",
"google",
":",
"{",
"extends",
":",
"\"google\"",
"}",
",",
"airbnb",
":",
"{",
"extends",
":",
"\"airbnb\"",
"}",
",",
"\"airbnb-base\"",
":",
"{",
"extends",
":",
... | process user's style guide of choice and return an appropriate config object.
@param {string} guide name of the chosen style guide
@returns {Object} config object | [
"process",
"user",
"s",
"style",
"guide",
"of",
"choice",
"and",
"return",
"an",
"appropriate",
"config",
"object",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-initializer.js#L316-L329 |
3,078 | eslint/eslint | lib/config/config-initializer.js | getLocalESLintVersion | function getLocalESLintVersion() {
try {
const eslintPath = relativeModuleResolver("eslint", path.join(process.cwd(), "__placeholder__.js"));
const eslint = require(eslintPath);
return eslint.linter.version || null;
} catch (_err) {
return null;
}
} | javascript | function getLocalESLintVersion() {
try {
const eslintPath = relativeModuleResolver("eslint", path.join(process.cwd(), "__placeholder__.js"));
const eslint = require(eslintPath);
return eslint.linter.version || null;
} catch (_err) {
return null;
}
} | [
"function",
"getLocalESLintVersion",
"(",
")",
"{",
"try",
"{",
"const",
"eslintPath",
"=",
"relativeModuleResolver",
"(",
"\"eslint\"",
",",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"\"__placeholder__.js\"",
")",
")",
";",
"const",
"e... | Get the version of the local ESLint.
@returns {string|null} The version. If the local ESLint was not found, returns null. | [
"Get",
"the",
"version",
"of",
"the",
"local",
"ESLint",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-initializer.js#L335-L344 |
3,079 | eslint/eslint | lib/config/config-initializer.js | hasESLintVersionConflict | function hasESLintVersionConflict(answers) {
// Get the local ESLint version.
const localESLintVersion = getLocalESLintVersion();
if (!localESLintVersion) {
return false;
}
// Get the required range of ESLint version.
const configName = getStyleGuideName(answers);
const moduleName... | javascript | function hasESLintVersionConflict(answers) {
// Get the local ESLint version.
const localESLintVersion = getLocalESLintVersion();
if (!localESLintVersion) {
return false;
}
// Get the required range of ESLint version.
const configName = getStyleGuideName(answers);
const moduleName... | [
"function",
"hasESLintVersionConflict",
"(",
"answers",
")",
"{",
"// Get the local ESLint version.",
"const",
"localESLintVersion",
"=",
"getLocalESLintVersion",
"(",
")",
";",
"if",
"(",
"!",
"localESLintVersion",
")",
"{",
"return",
"false",
";",
"}",
"// Get the r... | Check whether the local ESLint version conflicts with the required version of the chosen shareable config.
@param {Object} answers The answers object.
@returns {boolean} `true` if the local ESLint is found then it conflicts with the required version of the chosen shareable config. | [
"Check",
"whether",
"the",
"local",
"ESLint",
"version",
"conflicts",
"with",
"the",
"required",
"version",
"of",
"the",
"chosen",
"shareable",
"config",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-initializer.js#L363-L392 |
3,080 | eslint/eslint | lib/rules/no-useless-return.js | isInFinally | function isInFinally(node) {
for (
let currentNode = node;
currentNode && currentNode.parent && !astUtils.isFunction(currentNode);
currentNode = currentNode.parent
) {
if (currentNode.parent.type === "TryStatement" && currentNode.parent.finalizer === currentNode) {
re... | javascript | function isInFinally(node) {
for (
let currentNode = node;
currentNode && currentNode.parent && !astUtils.isFunction(currentNode);
currentNode = currentNode.parent
) {
if (currentNode.parent.type === "TryStatement" && currentNode.parent.finalizer === currentNode) {
re... | [
"function",
"isInFinally",
"(",
"node",
")",
"{",
"for",
"(",
"let",
"currentNode",
"=",
"node",
";",
"currentNode",
"&&",
"currentNode",
".",
"parent",
"&&",
"!",
"astUtils",
".",
"isFunction",
"(",
"currentNode",
")",
";",
"currentNode",
"=",
"currentNode"... | Checks whether the given return statement is in a `finally` block or not.
@param {ASTNode} node - The return statement node to check.
@returns {boolean} `true` if the node is in a `finally` block. | [
"Checks",
"whether",
"the",
"given",
"return",
"statement",
"is",
"in",
"a",
"finally",
"block",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-return.js#L49-L61 |
3,081 | eslint/eslint | lib/rules/no-useless-return.js | getUselessReturns | function getUselessReturns(uselessReturns, prevSegments, providedTraversedSegments) {
const traversedSegments = providedTraversedSegments || new WeakSet();
for (const segment of prevSegments) {
if (!segment.reachable) {
if (!traversedSegments.has(segment)) {
... | javascript | function getUselessReturns(uselessReturns, prevSegments, providedTraversedSegments) {
const traversedSegments = providedTraversedSegments || new WeakSet();
for (const segment of prevSegments) {
if (!segment.reachable) {
if (!traversedSegments.has(segment)) {
... | [
"function",
"getUselessReturns",
"(",
"uselessReturns",
",",
"prevSegments",
",",
"providedTraversedSegments",
")",
"{",
"const",
"traversedSegments",
"=",
"providedTraversedSegments",
"||",
"new",
"WeakSet",
"(",
")",
";",
"for",
"(",
"const",
"segment",
"of",
"pre... | Collects useless return statements from the given previous segments.
A previous segment may be an unreachable segment.
In that case, the information object of the unreachable segment is not
initialized because `onCodePathSegmentStart` event is not notified for
unreachable segments.
This goes to the previous segments o... | [
"Collects",
"useless",
"return",
"statements",
"from",
"the",
"given",
"previous",
"segments",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-return.js#L118-L138 |
3,082 | eslint/eslint | lib/rules/no-useless-return.js | markReturnStatementsOnSegmentAsUsed | function markReturnStatementsOnSegmentAsUsed(segment) {
if (!segment.reachable) {
usedUnreachableSegments.add(segment);
segment.allPrevSegments
.filter(isReturned)
.filter(prevSegment => !usedUnreachableSegments.has(prevSegment))
... | javascript | function markReturnStatementsOnSegmentAsUsed(segment) {
if (!segment.reachable) {
usedUnreachableSegments.add(segment);
segment.allPrevSegments
.filter(isReturned)
.filter(prevSegment => !usedUnreachableSegments.has(prevSegment))
... | [
"function",
"markReturnStatementsOnSegmentAsUsed",
"(",
"segment",
")",
"{",
"if",
"(",
"!",
"segment",
".",
"reachable",
")",
"{",
"usedUnreachableSegments",
".",
"add",
"(",
"segment",
")",
";",
"segment",
".",
"allPrevSegments",
".",
"filter",
"(",
"isReturne... | Removes the return statements on the given segment from the useless return
statement list.
This segment may be an unreachable segment.
In that case, the information object of the unreachable segment is not
initialized because `onCodePathSegmentStart` event is not notified for
unreachable segments.
This goes to the pre... | [
"Removes",
"the",
"return",
"statements",
"on",
"the",
"given",
"segment",
"from",
"the",
"useless",
"return",
"statement",
"list",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-return.js#L158-L174 |
3,083 | eslint/eslint | lib/rules/keyword-spacing.js | parseOptions | function parseOptions(options = {}) {
const before = options.before !== false;
const after = options.after !== false;
const defaultValue = {
before: before ? expectSpaceBefore : unexpectSpaceBefore,
after: after ? expectSpaceAfter : unexpectSpaceAfter
... | javascript | function parseOptions(options = {}) {
const before = options.before !== false;
const after = options.after !== false;
const defaultValue = {
before: before ? expectSpaceBefore : unexpectSpaceBefore,
after: after ? expectSpaceAfter : unexpectSpaceAfter
... | [
"function",
"parseOptions",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"before",
"=",
"options",
".",
"before",
"!==",
"false",
";",
"const",
"after",
"=",
"options",
".",
"after",
"!==",
"false",
";",
"const",
"defaultValue",
"=",
"{",
"before",
... | Parses the option object and determines check methods for each keyword.
@param {Object|undefined} options - The option object to parse.
@returns {Object} - Normalized option object.
Keys are keywords (there are for every keyword).
Values are instances of `{"before": function, "after": function}`. | [
"Parses",
"the",
"option",
"object",
"and",
"determines",
"check",
"methods",
"for",
"each",
"keyword",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L231-L259 |
3,084 | eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingBefore | function checkSpacingBefore(token, pattern) {
checkMethodMap[token.value].before(token, pattern || PREV_TOKEN);
} | javascript | function checkSpacingBefore(token, pattern) {
checkMethodMap[token.value].before(token, pattern || PREV_TOKEN);
} | [
"function",
"checkSpacingBefore",
"(",
"token",
",",
"pattern",
")",
"{",
"checkMethodMap",
"[",
"token",
".",
"value",
"]",
".",
"before",
"(",
"token",
",",
"pattern",
"||",
"PREV_TOKEN",
")",
";",
"}"
] | Reports a given token if usage of spacing followed by the token is
invalid.
@param {Token} token - A token to report.
@param {RegExp|undefined} pattern - Optional. A pattern of the previous
token to check.
@returns {void} | [
"Reports",
"a",
"given",
"token",
"if",
"usage",
"of",
"spacing",
"followed",
"by",
"the",
"token",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L272-L274 |
3,085 | eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingAfter | function checkSpacingAfter(token, pattern) {
checkMethodMap[token.value].after(token, pattern || NEXT_TOKEN);
} | javascript | function checkSpacingAfter(token, pattern) {
checkMethodMap[token.value].after(token, pattern || NEXT_TOKEN);
} | [
"function",
"checkSpacingAfter",
"(",
"token",
",",
"pattern",
")",
"{",
"checkMethodMap",
"[",
"token",
".",
"value",
"]",
".",
"after",
"(",
"token",
",",
"pattern",
"||",
"NEXT_TOKEN",
")",
";",
"}"
] | Reports a given token if usage of spacing preceded by the token is
invalid.
@param {Token} token - A token to report.
@param {RegExp|undefined} pattern - Optional. A pattern of the next
token to check.
@returns {void} | [
"Reports",
"a",
"given",
"token",
"if",
"usage",
"of",
"spacing",
"preceded",
"by",
"the",
"token",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L285-L287 |
3,086 | eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingAroundFirstToken | function checkSpacingAroundFirstToken(node) {
const firstToken = node && sourceCode.getFirstToken(node);
if (firstToken && firstToken.type === "Keyword") {
checkSpacingAround(firstToken);
}
} | javascript | function checkSpacingAroundFirstToken(node) {
const firstToken = node && sourceCode.getFirstToken(node);
if (firstToken && firstToken.type === "Keyword") {
checkSpacingAround(firstToken);
}
} | [
"function",
"checkSpacingAroundFirstToken",
"(",
"node",
")",
"{",
"const",
"firstToken",
"=",
"node",
"&&",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
")",
";",
"if",
"(",
"firstToken",
"&&",
"firstToken",
".",
"type",
"===",
"\"Keyword\"",
")",
"{",
... | Reports the first token of a given node if the first token is a keyword
and usage of spacing around the token is invalid.
@param {ASTNode|null} node - A node to report.
@returns {void} | [
"Reports",
"the",
"first",
"token",
"of",
"a",
"given",
"node",
"if",
"the",
"first",
"token",
"is",
"a",
"keyword",
"and",
"usage",
"of",
"spacing",
"around",
"the",
"token",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L307-L313 |
3,087 | eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingBeforeFirstToken | function checkSpacingBeforeFirstToken(node) {
const firstToken = node && sourceCode.getFirstToken(node);
if (firstToken && firstToken.type === "Keyword") {
checkSpacingBefore(firstToken);
}
} | javascript | function checkSpacingBeforeFirstToken(node) {
const firstToken = node && sourceCode.getFirstToken(node);
if (firstToken && firstToken.type === "Keyword") {
checkSpacingBefore(firstToken);
}
} | [
"function",
"checkSpacingBeforeFirstToken",
"(",
"node",
")",
"{",
"const",
"firstToken",
"=",
"node",
"&&",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
")",
";",
"if",
"(",
"firstToken",
"&&",
"firstToken",
".",
"type",
"===",
"\"Keyword\"",
")",
"{",
... | Reports the first token of a given node if the first token is a keyword
and usage of spacing followed by the token is invalid.
This is used for unary operators (e.g. `typeof`), `function`, and `super`.
Other rules are handling usage of spacing preceded by those keywords.
@param {ASTNode|null} node - A node to report.... | [
"Reports",
"the",
"first",
"token",
"of",
"a",
"given",
"node",
"if",
"the",
"first",
"token",
"is",
"a",
"keyword",
"and",
"usage",
"of",
"spacing",
"followed",
"by",
"the",
"token",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L325-L331 |
3,088 | eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingAroundTokenBefore | function checkSpacingAroundTokenBefore(node) {
if (node) {
const token = sourceCode.getTokenBefore(node, astUtils.isKeywordToken);
checkSpacingAround(token);
}
} | javascript | function checkSpacingAroundTokenBefore(node) {
if (node) {
const token = sourceCode.getTokenBefore(node, astUtils.isKeywordToken);
checkSpacingAround(token);
}
} | [
"function",
"checkSpacingAroundTokenBefore",
"(",
"node",
")",
"{",
"if",
"(",
"node",
")",
"{",
"const",
"token",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"node",
",",
"astUtils",
".",
"isKeywordToken",
")",
";",
"checkSpacingAround",
"(",
"token",
")",... | Reports the previous token of a given node if the token is a keyword and
usage of spacing around the token is invalid.
@param {ASTNode|null} node - A node to report.
@returns {void} | [
"Reports",
"the",
"previous",
"token",
"of",
"a",
"given",
"node",
"if",
"the",
"token",
"is",
"a",
"keyword",
"and",
"usage",
"of",
"spacing",
"around",
"the",
"token",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L340-L346 |
3,089 | eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingForFunction | function checkSpacingForFunction(node) {
const firstToken = node && sourceCode.getFirstToken(node);
if (firstToken &&
((firstToken.type === "Keyword" && firstToken.value === "function") ||
firstToken.value === "async")
) {
checkSpacing... | javascript | function checkSpacingForFunction(node) {
const firstToken = node && sourceCode.getFirstToken(node);
if (firstToken &&
((firstToken.type === "Keyword" && firstToken.value === "function") ||
firstToken.value === "async")
) {
checkSpacing... | [
"function",
"checkSpacingForFunction",
"(",
"node",
")",
"{",
"const",
"firstToken",
"=",
"node",
"&&",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
")",
";",
"if",
"(",
"firstToken",
"&&",
"(",
"(",
"firstToken",
".",
"type",
"===",
"\"Keyword\"",
"&&",... | Reports `async` or `function` keywords of a given node if usage of
spacing around those keywords is invalid.
@param {ASTNode} node - A node to report.
@returns {void} | [
"Reports",
"async",
"or",
"function",
"keywords",
"of",
"a",
"given",
"node",
"if",
"usage",
"of",
"spacing",
"around",
"those",
"keywords",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L355-L364 |
3,090 | eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingForTryStatement | function checkSpacingForTryStatement(node) {
checkSpacingAroundFirstToken(node);
checkSpacingAroundFirstToken(node.handler);
checkSpacingAroundTokenBefore(node.finalizer);
} | javascript | function checkSpacingForTryStatement(node) {
checkSpacingAroundFirstToken(node);
checkSpacingAroundFirstToken(node.handler);
checkSpacingAroundTokenBefore(node.finalizer);
} | [
"function",
"checkSpacingForTryStatement",
"(",
"node",
")",
"{",
"checkSpacingAroundFirstToken",
"(",
"node",
")",
";",
"checkSpacingAroundFirstToken",
"(",
"node",
".",
"handler",
")",
";",
"checkSpacingAroundTokenBefore",
"(",
"node",
".",
"finalizer",
")",
";",
... | Reports `try`, `catch`, and `finally` keywords of a given node if usage
of spacing around those keywords is invalid.
@param {ASTNode} node - A node to report.
@returns {void} | [
"Reports",
"try",
"catch",
"and",
"finally",
"keywords",
"of",
"a",
"given",
"node",
"if",
"usage",
"of",
"spacing",
"around",
"those",
"keywords",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L397-L401 |
3,091 | eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingForForOfStatement | function checkSpacingForForOfStatement(node) {
if (node.await) {
checkSpacingBefore(sourceCode.getFirstToken(node, 0));
checkSpacingAfter(sourceCode.getFirstToken(node, 1));
} else {
checkSpacingAroundFirstToken(node);
}
che... | javascript | function checkSpacingForForOfStatement(node) {
if (node.await) {
checkSpacingBefore(sourceCode.getFirstToken(node, 0));
checkSpacingAfter(sourceCode.getFirstToken(node, 1));
} else {
checkSpacingAroundFirstToken(node);
}
che... | [
"function",
"checkSpacingForForOfStatement",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"await",
")",
"{",
"checkSpacingBefore",
"(",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
",",
"0",
")",
")",
";",
"checkSpacingAfter",
"(",
"sourceCode",
".",
"... | Reports `for` and `of` keywords of a given node if usage of spacing
around those keywords is invalid.
@param {ASTNode} node - A node to report.
@returns {void} | [
"Reports",
"for",
"and",
"of",
"keywords",
"of",
"a",
"given",
"node",
"if",
"usage",
"of",
"spacing",
"around",
"those",
"keywords",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L434-L442 |
3,092 | eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingForModuleDeclaration | function checkSpacingForModuleDeclaration(node) {
const firstToken = sourceCode.getFirstToken(node);
checkSpacingBefore(firstToken, PREV_TOKEN_M);
checkSpacingAfter(firstToken, NEXT_TOKEN_M);
if (node.type === "ExportDefaultDeclaration") {
checkSpacingAr... | javascript | function checkSpacingForModuleDeclaration(node) {
const firstToken = sourceCode.getFirstToken(node);
checkSpacingBefore(firstToken, PREV_TOKEN_M);
checkSpacingAfter(firstToken, NEXT_TOKEN_M);
if (node.type === "ExportDefaultDeclaration") {
checkSpacingAr... | [
"function",
"checkSpacingForModuleDeclaration",
"(",
"node",
")",
"{",
"const",
"firstToken",
"=",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
")",
";",
"checkSpacingBefore",
"(",
"firstToken",
",",
"PREV_TOKEN_M",
")",
";",
"checkSpacingAfter",
"(",
"firstToke... | Reports `import`, `export`, `as`, and `from` keywords of a given node if
usage of spacing around those keywords is invalid.
This rule handles the `*` token in module declarations.
import*as A from "./a"; /*error Expected space(s) after "import".
error Expected space(s) before "as".
@param {ASTNode} node - A node to ... | [
"Reports",
"import",
"export",
"as",
"and",
"from",
"keywords",
"of",
"a",
"given",
"node",
"if",
"usage",
"of",
"spacing",
"around",
"those",
"keywords",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L456-L472 |
3,093 | eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingForProperty | function checkSpacingForProperty(node) {
if (node.static) {
checkSpacingAroundFirstToken(node);
}
if (node.kind === "get" ||
node.kind === "set" ||
(
(node.method || node.type === "MethodDefinition") &&
... | javascript | function checkSpacingForProperty(node) {
if (node.static) {
checkSpacingAroundFirstToken(node);
}
if (node.kind === "get" ||
node.kind === "set" ||
(
(node.method || node.type === "MethodDefinition") &&
... | [
"function",
"checkSpacingForProperty",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"static",
")",
"{",
"checkSpacingAroundFirstToken",
"(",
"node",
")",
";",
"}",
"if",
"(",
"node",
".",
"kind",
"===",
"\"get\"",
"||",
"node",
".",
"kind",
"===",
"\"s... | Reports `static`, `get`, and `set` keywords of a given node if usage of
spacing around those keywords is invalid.
@param {ASTNode} node - A node to report.
@returns {void} | [
"Reports",
"static",
"get",
"and",
"set",
"keywords",
"of",
"a",
"given",
"node",
"if",
"usage",
"of",
"spacing",
"around",
"those",
"keywords",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L494-L526 |
3,094 | eslint/eslint | lib/util/lint-result-cache.js | hashOfConfigFor | function hashOfConfigFor(configHelper, filename) {
const config = configHelper.getConfig(filename);
if (!configHashCache.has(config)) {
configHashCache.set(config, hash(`${pkg.version}_${stringify(config)}`));
}
return configHashCache.get(config);
} | javascript | function hashOfConfigFor(configHelper, filename) {
const config = configHelper.getConfig(filename);
if (!configHashCache.has(config)) {
configHashCache.set(config, hash(`${pkg.version}_${stringify(config)}`));
}
return configHashCache.get(config);
} | [
"function",
"hashOfConfigFor",
"(",
"configHelper",
",",
"filename",
")",
"{",
"const",
"config",
"=",
"configHelper",
".",
"getConfig",
"(",
"filename",
")",
";",
"if",
"(",
"!",
"configHashCache",
".",
"has",
"(",
"config",
")",
")",
"{",
"configHashCache"... | Calculates the hash of the config file used to validate a given file
@param {Object} configHelper The config helper for retrieving configuration information
@param {string} filename The path of the file to retrieve a config object for to calculate the hash
@returns {string} The hash of the config | [
"Calculates",
"the",
"hash",
"of",
"the",
"config",
"file",
"used",
"to",
"validate",
"a",
"given",
"file"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/lint-result-cache.js#L30-L38 |
3,095 | eslint/eslint | lib/rules/constructor-super.js | isPossibleConstructor | function isPossibleConstructor(node) {
if (!node) {
return false;
}
switch (node.type) {
case "ClassExpression":
case "FunctionExpression":
case "ThisExpression":
case "MemberExpression":
case "CallExpression":
case "NewExpression":
case "Yiel... | javascript | function isPossibleConstructor(node) {
if (!node) {
return false;
}
switch (node.type) {
case "ClassExpression":
case "FunctionExpression":
case "ThisExpression":
case "MemberExpression":
case "CallExpression":
case "NewExpression":
case "Yiel... | [
"function",
"isPossibleConstructor",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
")",
"{",
"return",
"false",
";",
"}",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"\"ClassExpression\"",
":",
"case",
"\"FunctionExpression\"",
":",
"case",
"\"T... | Checks whether a given node can be a constructor or not.
@param {ASTNode} node - A node to check.
@returns {boolean} `true` if the node can be a constructor. | [
"Checks",
"whether",
"a",
"given",
"node",
"can",
"be",
"a",
"constructor",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/constructor-super.js#L43-L87 |
3,096 | eslint/eslint | lib/rules/no-restricted-properties.js | checkPropertyAccess | function checkPropertyAccess(node, objectName, propertyName) {
if (propertyName === null) {
return;
}
const matchedObject = restrictedProperties.get(objectName);
const matchedObjectProperty = matchedObject ? matchedObject.get(propertyName) : globallyRestri... | javascript | function checkPropertyAccess(node, objectName, propertyName) {
if (propertyName === null) {
return;
}
const matchedObject = restrictedProperties.get(objectName);
const matchedObjectProperty = matchedObject ? matchedObject.get(propertyName) : globallyRestri... | [
"function",
"checkPropertyAccess",
"(",
"node",
",",
"objectName",
",",
"propertyName",
")",
"{",
"if",
"(",
"propertyName",
"===",
"null",
")",
"{",
"return",
";",
"}",
"const",
"matchedObject",
"=",
"restrictedProperties",
".",
"get",
"(",
"objectName",
")",... | Checks to see whether a property access is restricted, and reports it if so.
@param {ASTNode} node The node to report
@param {string} objectName The name of the object
@param {string} propertyName The name of the property
@returns {undefined} | [
"Checks",
"to",
"see",
"whether",
"a",
"property",
"access",
"is",
"restricted",
"and",
"reports",
"it",
"if",
"so",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-restricted-properties.js#L104-L138 |
3,097 | eslint/eslint | lib/rules/no-extra-label.js | enterBreakableStatement | function enterBreakableStatement(node) {
scopeInfo = {
label: node.parent.type === "LabeledStatement" ? node.parent.label : null,
breakable: true,
upper: scopeInfo
};
} | javascript | function enterBreakableStatement(node) {
scopeInfo = {
label: node.parent.type === "LabeledStatement" ? node.parent.label : null,
breakable: true,
upper: scopeInfo
};
} | [
"function",
"enterBreakableStatement",
"(",
"node",
")",
"{",
"scopeInfo",
"=",
"{",
"label",
":",
"node",
".",
"parent",
".",
"type",
"===",
"\"LabeledStatement\"",
"?",
"node",
".",
"parent",
".",
"label",
":",
"null",
",",
"breakable",
":",
"true",
",",... | Creates a new scope with a breakable statement.
@param {ASTNode} node - A node to create. This is a BreakableStatement.
@returns {void} | [
"Creates",
"a",
"new",
"scope",
"with",
"a",
"breakable",
"statement",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-label.js#L47-L53 |
3,098 | eslint/eslint | lib/rules/no-extra-label.js | enterLabeledStatement | function enterLabeledStatement(node) {
if (!astUtils.isBreakableStatement(node.body)) {
scopeInfo = {
label: node.label,
breakable: false,
upper: scopeInfo
};
}
} | javascript | function enterLabeledStatement(node) {
if (!astUtils.isBreakableStatement(node.body)) {
scopeInfo = {
label: node.label,
breakable: false,
upper: scopeInfo
};
}
} | [
"function",
"enterLabeledStatement",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"astUtils",
".",
"isBreakableStatement",
"(",
"node",
".",
"body",
")",
")",
"{",
"scopeInfo",
"=",
"{",
"label",
":",
"node",
".",
"label",
",",
"breakable",
":",
"false",
",",
... | Creates a new scope with a labeled statement.
This ignores it if the body is a breakable statement.
In this case it's handled in the `enterBreakableStatement` function.
@param {ASTNode} node - A node to create. This is a LabeledStatement.
@returns {void} | [
"Creates",
"a",
"new",
"scope",
"with",
"a",
"labeled",
"statement",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-label.js#L73-L81 |
3,099 | eslint/eslint | lib/rules/no-extra-label.js | reportIfUnnecessary | function reportIfUnnecessary(node) {
if (!node.label) {
return;
}
const labelNode = node.label;
for (let info = scopeInfo; info !== null; info = info.upper) {
if (info.breakable || info.label && info.label.name === labelNode.name) {
... | javascript | function reportIfUnnecessary(node) {
if (!node.label) {
return;
}
const labelNode = node.label;
for (let info = scopeInfo; info !== null; info = info.upper) {
if (info.breakable || info.label && info.label.name === labelNode.name) {
... | [
"function",
"reportIfUnnecessary",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
".",
"label",
")",
"{",
"return",
";",
"}",
"const",
"labelNode",
"=",
"node",
".",
"label",
";",
"for",
"(",
"let",
"info",
"=",
"scopeInfo",
";",
"info",
"!==",
"null... | Reports a given control node if it's unnecessary.
@param {ASTNode} node - A node. This is a BreakStatement or a
ContinueStatement.
@returns {void} | [
"Reports",
"a",
"given",
"control",
"node",
"if",
"it",
"s",
"unnecessary",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-label.js#L105-L125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.