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,100 | eslint/eslint | lib/rules/no-dupe-class-members.js | getState | function getState(name, isStatic) {
const stateMap = stack[stack.length - 1];
const key = `$${name}`; // to avoid "__proto__".
if (!stateMap[key]) {
stateMap[key] = {
nonStatic: { init: false, get: false, set: false },
static: ... | javascript | function getState(name, isStatic) {
const stateMap = stack[stack.length - 1];
const key = `$${name}`; // to avoid "__proto__".
if (!stateMap[key]) {
stateMap[key] = {
nonStatic: { init: false, get: false, set: false },
static: ... | [
"function",
"getState",
"(",
"name",
",",
"isStatic",
")",
"{",
"const",
"stateMap",
"=",
"stack",
"[",
"stack",
".",
"length",
"-",
"1",
"]",
";",
"const",
"key",
"=",
"`",
"${",
"name",
"}",
"`",
";",
"// to avoid \"__proto__\".",
"if",
"(",
"!",
"... | Gets state of a given member name.
@param {string} name - A name of a member.
@param {boolean} isStatic - A flag which specifies that is a static member.
@returns {Object} A state of a given member name.
- retv.init {boolean} A flag which shows the name is declared as normal member.
- retv.get {boolean} A flag which sh... | [
"Gets",
"state",
"of",
"a",
"given",
"member",
"name",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-dupe-class-members.js#L42-L54 |
3,101 | eslint/eslint | lib/rules/prefer-object-spread.js | needsParens | function needsParens(node, sourceCode) {
const parent = node.parent;
switch (parent.type) {
case "VariableDeclarator":
case "ArrayExpression":
case "ReturnStatement":
case "CallExpression":
case "Property":
return false;
case "AssignmentExpression":
... | javascript | function needsParens(node, sourceCode) {
const parent = node.parent;
switch (parent.type) {
case "VariableDeclarator":
case "ArrayExpression":
case "ReturnStatement":
case "CallExpression":
case "Property":
return false;
case "AssignmentExpression":
... | [
"function",
"needsParens",
"(",
"node",
",",
"sourceCode",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"switch",
"(",
"parent",
".",
"type",
")",
"{",
"case",
"\"VariableDeclarator\"",
":",
"case",
"\"ArrayExpression\"",
":",
"case",
"\"Ret... | Helper that checks if the node needs parentheses to be valid JS.
The default is to wrap the node in parentheses to avoid parsing errors.
@param {ASTNode} node - The node that the rule warns on
@param {Object} sourceCode - in context sourcecode object
@returns {boolean} - Returns true if the node needs parentheses | [
"Helper",
"that",
"checks",
"if",
"the",
"node",
"needs",
"parentheses",
"to",
"be",
"valid",
"JS",
".",
"The",
"default",
"is",
"to",
"wrap",
"the",
"node",
"in",
"parentheses",
"to",
"avoid",
"parsing",
"errors",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-object-spread.js#L35-L50 |
3,102 | eslint/eslint | lib/rules/prefer-object-spread.js | getParenTokens | function getParenTokens(node, leftArgumentListParen, sourceCode) {
const parens = [sourceCode.getFirstToken(node), sourceCode.getLastToken(node)];
let leftNext = sourceCode.getTokenBefore(node);
let rightNext = sourceCode.getTokenAfter(node);
// Note: don't include the parens of the argument list.
... | javascript | function getParenTokens(node, leftArgumentListParen, sourceCode) {
const parens = [sourceCode.getFirstToken(node), sourceCode.getLastToken(node)];
let leftNext = sourceCode.getTokenBefore(node);
let rightNext = sourceCode.getTokenAfter(node);
// Note: don't include the parens of the argument list.
... | [
"function",
"getParenTokens",
"(",
"node",
",",
"leftArgumentListParen",
",",
"sourceCode",
")",
"{",
"const",
"parens",
"=",
"[",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
")",
",",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
"]",
";",
"let"... | Get the parenthesis tokens of a given ObjectExpression node.
This incldues the braces of the object literal and enclosing parentheses.
@param {ASTNode} node The node to get.
@param {Token} leftArgumentListParen The opening paren token of the argument list.
@param {SourceCode} sourceCode The source code object to get to... | [
"Get",
"the",
"parenthesis",
"tokens",
"of",
"a",
"given",
"ObjectExpression",
"node",
".",
"This",
"incldues",
"the",
"braces",
"of",
"the",
"object",
"literal",
"and",
"enclosing",
"parentheses",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-object-spread.js#L77-L96 |
3,103 | eslint/eslint | lib/rules/prefer-object-spread.js | defineFixer | function defineFixer(node, sourceCode) {
return function *(fixer) {
const leftParen = sourceCode.getTokenAfter(node.callee, isOpeningParenToken);
const rightParen = sourceCode.getLastToken(node);
// Remove the callee `Object.assign`
yield fixer.remove(node.callee);
// Repla... | javascript | function defineFixer(node, sourceCode) {
return function *(fixer) {
const leftParen = sourceCode.getTokenAfter(node.callee, isOpeningParenToken);
const rightParen = sourceCode.getLastToken(node);
// Remove the callee `Object.assign`
yield fixer.remove(node.callee);
// Repla... | [
"function",
"defineFixer",
"(",
"node",
",",
"sourceCode",
")",
"{",
"return",
"function",
"*",
"(",
"fixer",
")",
"{",
"const",
"leftParen",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"node",
".",
"callee",
",",
"isOpeningParenToken",
")",
";",
"const",
... | Autofixes the Object.assign call to use an object spread instead.
@param {ASTNode|null} node - The node that the rule warns on, i.e. the Object.assign call
@param {string} sourceCode - sourceCode of the Object.assign call
@returns {Function} autofixer - replaces the Object.assign with a spread object. | [
"Autofixes",
"the",
"Object",
".",
"assign",
"call",
"to",
"use",
"an",
"object",
"spread",
"instead",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-object-spread.js#L149-L211 |
3,104 | eslint/eslint | lib/rules/space-before-function-paren.js | getConfigForFunction | function getConfigForFunction(node) {
if (node.type === "ArrowFunctionExpression") {
// Always ignore non-async functions and arrow functions without parens, e.g. async foo => bar
if (node.async && astUtils.isOpeningParenToken(sourceCode.getFirstToken(node, { skip: 1 }))) {
... | javascript | function getConfigForFunction(node) {
if (node.type === "ArrowFunctionExpression") {
// Always ignore non-async functions and arrow functions without parens, e.g. async foo => bar
if (node.async && astUtils.isOpeningParenToken(sourceCode.getFirstToken(node, { skip: 1 }))) {
... | [
"function",
"getConfigForFunction",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"\"ArrowFunctionExpression\"",
")",
"{",
"// Always ignore non-async functions and arrow functions without parens, e.g. async foo => bar",
"if",
"(",
"node",
".",
"async",
"&&"... | Gets the config for a given function
@param {ASTNode} node The function node
@returns {string} "always", "never", or "ignore" | [
"Gets",
"the",
"config",
"for",
"a",
"given",
"function"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-before-function-paren.js#L88-L104 |
3,105 | eslint/eslint | lib/rules/space-before-function-paren.js | checkFunction | function checkFunction(node) {
const functionConfig = getConfigForFunction(node);
if (functionConfig === "ignore") {
return;
}
const rightToken = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
const leftToken = sourceCode.getTo... | javascript | function checkFunction(node) {
const functionConfig = getConfigForFunction(node);
if (functionConfig === "ignore") {
return;
}
const rightToken = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
const leftToken = sourceCode.getTo... | [
"function",
"checkFunction",
"(",
"node",
")",
"{",
"const",
"functionConfig",
"=",
"getConfigForFunction",
"(",
"node",
")",
";",
"if",
"(",
"functionConfig",
"===",
"\"ignore\"",
")",
"{",
"return",
";",
"}",
"const",
"rightToken",
"=",
"sourceCode",
".",
... | Checks the parens of a function node
@param {ASTNode} node A function node
@returns {void} | [
"Checks",
"the",
"parens",
"of",
"a",
"function",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-before-function-paren.js#L111-L137 |
3,106 | eslint/eslint | lib/rules/capitalized-comments.js | createRegExpForIgnorePatterns | function createRegExpForIgnorePatterns(normalizedOptions) {
Object.keys(normalizedOptions).forEach(key => {
const ignorePatternStr = normalizedOptions[key].ignorePattern;
if (ignorePatternStr) {
const regExp = RegExp(`^\\s*(?:${ignorePatternStr})`, "u");
normalizedOptions[k... | javascript | function createRegExpForIgnorePatterns(normalizedOptions) {
Object.keys(normalizedOptions).forEach(key => {
const ignorePatternStr = normalizedOptions[key].ignorePattern;
if (ignorePatternStr) {
const regExp = RegExp(`^\\s*(?:${ignorePatternStr})`, "u");
normalizedOptions[k... | [
"function",
"createRegExpForIgnorePatterns",
"(",
"normalizedOptions",
")",
"{",
"Object",
".",
"keys",
"(",
"normalizedOptions",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"const",
"ignorePatternStr",
"=",
"normalizedOptions",
"[",
"key",
"]",
".",
"ignorePatter... | Creates a regular expression for each ignorePattern defined in the rule
options.
This is done in order to avoid invoking the RegExp constructor repeatedly.
@param {Object} normalizedOptions The normalized rule options.
@returns {void} | [
"Creates",
"a",
"regular",
"expression",
"for",
"each",
"ignorePattern",
"defined",
"in",
"the",
"rule",
"options",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/capitalized-comments.js#L89-L99 |
3,107 | eslint/eslint | lib/rules/capitalized-comments.js | isConsecutiveComment | function isConsecutiveComment(comment) {
const previousTokenOrComment = sourceCode.getTokenBefore(comment, { includeComments: true });
return Boolean(
previousTokenOrComment &&
["Block", "Line"].indexOf(previousTokenOrComment.type) !== -1
);
} | javascript | function isConsecutiveComment(comment) {
const previousTokenOrComment = sourceCode.getTokenBefore(comment, { includeComments: true });
return Boolean(
previousTokenOrComment &&
["Block", "Line"].indexOf(previousTokenOrComment.type) !== -1
);
} | [
"function",
"isConsecutiveComment",
"(",
"comment",
")",
"{",
"const",
"previousTokenOrComment",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"comment",
",",
"{",
"includeComments",
":",
"true",
"}",
")",
";",
"return",
"Boolean",
"(",
"previousTokenOrComment",
... | Determine if a comment follows another comment.
@param {ASTNode} comment The comment to check.
@returns {boolean} True if the comment follows a valid comment. | [
"Determine",
"if",
"a",
"comment",
"follows",
"another",
"comment",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/capitalized-comments.js#L188-L195 |
3,108 | eslint/eslint | lib/rules/capitalized-comments.js | isCommentValid | function isCommentValid(comment, options) {
// 1. Check for default ignore pattern.
if (DEFAULT_IGNORE_PATTERN.test(comment.value)) {
return true;
}
// 2. Check for custom ignore pattern.
const commentWithoutAsterisks = comment.value
... | javascript | function isCommentValid(comment, options) {
// 1. Check for default ignore pattern.
if (DEFAULT_IGNORE_PATTERN.test(comment.value)) {
return true;
}
// 2. Check for custom ignore pattern.
const commentWithoutAsterisks = comment.value
... | [
"function",
"isCommentValid",
"(",
"comment",
",",
"options",
")",
"{",
"// 1. Check for default ignore pattern.",
"if",
"(",
"DEFAULT_IGNORE_PATTERN",
".",
"test",
"(",
"comment",
".",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"// 2. Check for custom igno... | Check a comment to determine if it is valid for this rule.
@param {ASTNode} comment The comment node to process.
@param {Object} options The options for checking this comment.
@returns {boolean} True if the comment is valid, false otherwise. | [
"Check",
"a",
"comment",
"to",
"determine",
"if",
"it",
"is",
"valid",
"for",
"this",
"rule",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/capitalized-comments.js#L204-L260 |
3,109 | eslint/eslint | lib/rules/capitalized-comments.js | processComment | function processComment(comment) {
const options = normalizedOptions[comment.type],
commentValid = isCommentValid(comment, options);
if (!commentValid) {
const messageId = capitalize === "always"
? "unexpectedLowercaseComment"
... | javascript | function processComment(comment) {
const options = normalizedOptions[comment.type],
commentValid = isCommentValid(comment, options);
if (!commentValid) {
const messageId = capitalize === "always"
? "unexpectedLowercaseComment"
... | [
"function",
"processComment",
"(",
"comment",
")",
"{",
"const",
"options",
"=",
"normalizedOptions",
"[",
"comment",
".",
"type",
"]",
",",
"commentValid",
"=",
"isCommentValid",
"(",
"comment",
",",
"options",
")",
";",
"if",
"(",
"!",
"commentValid",
")",... | Process a comment to determine if it needs to be reported.
@param {ASTNode} comment The comment node to process.
@returns {void} | [
"Process",
"a",
"comment",
"to",
"determine",
"if",
"it",
"needs",
"to",
"be",
"reported",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/capitalized-comments.js#L268-L293 |
3,110 | eslint/eslint | lib/rules/consistent-return.js | isClassConstructor | function isClassConstructor(node) {
return node.type === "FunctionExpression" &&
node.parent &&
node.parent.type === "MethodDefinition" &&
node.parent.kind === "constructor";
} | javascript | function isClassConstructor(node) {
return node.type === "FunctionExpression" &&
node.parent &&
node.parent.type === "MethodDefinition" &&
node.parent.kind === "constructor";
} | [
"function",
"isClassConstructor",
"(",
"node",
")",
"{",
"return",
"node",
".",
"type",
"===",
"\"FunctionExpression\"",
"&&",
"node",
".",
"parent",
"&&",
"node",
".",
"parent",
".",
"type",
"===",
"\"MethodDefinition\"",
"&&",
"node",
".",
"parent",
".",
"... | Checks whether a given node is a `constructor` method in an ES6 class
@param {ASTNode} node A node to check
@returns {boolean} `true` if the node is a `constructor` method | [
"Checks",
"whether",
"a",
"given",
"node",
"is",
"a",
"constructor",
"method",
"in",
"an",
"ES6",
"class"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/consistent-return.js#L43-L48 |
3,111 | eslint/eslint | lib/rules/consistent-return.js | checkLastSegment | function checkLastSegment(node) {
let loc, name;
/*
* Skip if it expected no return value or unreachable.
* When unreachable, all paths are returned or thrown.
*/
if (!funcInfo.hasReturnValue ||
funcInfo.codePath.currentSegments... | javascript | function checkLastSegment(node) {
let loc, name;
/*
* Skip if it expected no return value or unreachable.
* When unreachable, all paths are returned or thrown.
*/
if (!funcInfo.hasReturnValue ||
funcInfo.codePath.currentSegments... | [
"function",
"checkLastSegment",
"(",
"node",
")",
"{",
"let",
"loc",
",",
"name",
";",
"/*\n * Skip if it expected no return value or unreachable.\n * When unreachable, all paths are returned or thrown.\n */",
"if",
"(",
"!",
"funcInfo",
".",
"ha... | Checks whether of not the implicit returning is consistent if the last
code path segment is reachable.
@param {ASTNode} node - A program/function node to check.
@returns {void} | [
"Checks",
"whether",
"of",
"not",
"the",
"implicit",
"returning",
"is",
"consistent",
"if",
"the",
"last",
"code",
"path",
"segment",
"is",
"reachable",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/consistent-return.js#L95-L144 |
3,112 | eslint/eslint | lib/util/node-event-generator.js | countClassAttributes | function countClassAttributes(parsedSelector) {
switch (parsedSelector.type) {
case "child":
case "descendant":
case "sibling":
case "adjacent":
return countClassAttributes(parsedSelector.left) + countClassAttributes(parsedSelector.right);
case "compound":
... | javascript | function countClassAttributes(parsedSelector) {
switch (parsedSelector.type) {
case "child":
case "descendant":
case "sibling":
case "adjacent":
return countClassAttributes(parsedSelector.left) + countClassAttributes(parsedSelector.right);
case "compound":
... | [
"function",
"countClassAttributes",
"(",
"parsedSelector",
")",
"{",
"switch",
"(",
"parsedSelector",
".",
"type",
")",
"{",
"case",
"\"child\"",
":",
"case",
"\"descendant\"",
":",
"case",
"\"sibling\"",
":",
"case",
"\"adjacent\"",
":",
"return",
"countClassAttr... | Counts the number of class, pseudo-class, and attribute queries in this selector
@param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior
@returns {number} The number of class, pseudo-class, and attribute queries in this selector | [
"Counts",
"the",
"number",
"of",
"class",
"pseudo",
"-",
"class",
"and",
"attribute",
"queries",
"in",
"this",
"selector"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/node-event-generator.js#L86-L108 |
3,113 | eslint/eslint | lib/util/node-event-generator.js | countIdentifiers | function countIdentifiers(parsedSelector) {
switch (parsedSelector.type) {
case "child":
case "descendant":
case "sibling":
case "adjacent":
return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right);
case "compound":
case "not"... | javascript | function countIdentifiers(parsedSelector) {
switch (parsedSelector.type) {
case "child":
case "descendant":
case "sibling":
case "adjacent":
return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right);
case "compound":
case "not"... | [
"function",
"countIdentifiers",
"(",
"parsedSelector",
")",
"{",
"switch",
"(",
"parsedSelector",
".",
"type",
")",
"{",
"case",
"\"child\"",
":",
"case",
"\"descendant\"",
":",
"case",
"\"sibling\"",
":",
"case",
"\"adjacent\"",
":",
"return",
"countIdentifiers",... | Counts the number of identifier queries in this selector
@param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior
@returns {number} The number of identifier queries | [
"Counts",
"the",
"number",
"of",
"identifier",
"queries",
"in",
"this",
"selector"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/node-event-generator.js#L115-L134 |
3,114 | eslint/eslint | lib/util/node-event-generator.js | compareSpecificity | function compareSpecificity(selectorA, selectorB) {
return selectorA.attributeCount - selectorB.attributeCount ||
selectorA.identifierCount - selectorB.identifierCount ||
(selectorA.rawSelector <= selectorB.rawSelector ? -1 : 1);
} | javascript | function compareSpecificity(selectorA, selectorB) {
return selectorA.attributeCount - selectorB.attributeCount ||
selectorA.identifierCount - selectorB.identifierCount ||
(selectorA.rawSelector <= selectorB.rawSelector ? -1 : 1);
} | [
"function",
"compareSpecificity",
"(",
"selectorA",
",",
"selectorB",
")",
"{",
"return",
"selectorA",
".",
"attributeCount",
"-",
"selectorB",
".",
"attributeCount",
"||",
"selectorA",
".",
"identifierCount",
"-",
"selectorB",
".",
"identifierCount",
"||",
"(",
"... | Compares the specificity of two selector objects, with CSS-like rules.
@param {ASTSelector} selectorA An AST selector descriptor
@param {ASTSelector} selectorB Another AST selector descriptor
@returns {number}
a value less than 0 if selectorA is less specific than selectorB
a value greater than 0 if selectorA is more s... | [
"Compares",
"the",
"specificity",
"of",
"two",
"selector",
"objects",
"with",
"CSS",
"-",
"like",
"rules",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/node-event-generator.js#L146-L150 |
3,115 | eslint/eslint | lib/rules/max-statements-per-line.js | reportFirstExtraStatementAndClear | function reportFirstExtraStatementAndClear() {
if (firstExtraStatement) {
context.report({
node: firstExtraStatement,
messageId: "exceed",
data: {
numberOfStatementsOnThisLine,
maxStat... | javascript | function reportFirstExtraStatementAndClear() {
if (firstExtraStatement) {
context.report({
node: firstExtraStatement,
messageId: "exceed",
data: {
numberOfStatementsOnThisLine,
maxStat... | [
"function",
"reportFirstExtraStatementAndClear",
"(",
")",
"{",
"if",
"(",
"firstExtraStatement",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
":",
"firstExtraStatement",
",",
"messageId",
":",
"\"exceed\"",
",",
"data",
":",
"{",
"numberOfStatementsOnThi... | Reports with the first extra statement, and clears it.
@returns {void} | [
"Reports",
"with",
"the",
"first",
"extra",
"statement",
"and",
"clears",
"it",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/max-statements-per-line.js#L67-L80 |
3,116 | eslint/eslint | lib/rules/max-statements-per-line.js | enterStatement | function enterStatement(node) {
const line = node.loc.start.line;
/*
* Skip to allow non-block statements if this is direct child of control statements.
* `if (a) foo();` is counted as 1.
* But `if (a) foo(); else foo();` should be counted as 2.
... | javascript | function enterStatement(node) {
const line = node.loc.start.line;
/*
* Skip to allow non-block statements if this is direct child of control statements.
* `if (a) foo();` is counted as 1.
* But `if (a) foo(); else foo();` should be counted as 2.
... | [
"function",
"enterStatement",
"(",
"node",
")",
"{",
"const",
"line",
"=",
"node",
".",
"loc",
".",
"start",
".",
"line",
";",
"/*\n * Skip to allow non-block statements if this is direct child of control statements.\n * `if (a) foo();` is counted as 1.\n ... | Addresses a given node.
It updates the state of this rule, then reports the node if the node violated this rule.
@param {ASTNode} node - A node to check.
@returns {void} | [
"Addresses",
"a",
"given",
"node",
".",
"It",
"updates",
"the",
"state",
"of",
"this",
"rule",
"then",
"reports",
"the",
"node",
"if",
"the",
"node",
"violated",
"this",
"rule",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/max-statements-per-line.js#L99-L126 |
3,117 | eslint/eslint | lib/rules/max-statements-per-line.js | leaveStatement | function leaveStatement(node) {
const line = getActualLastToken(node).loc.end.line;
// Update state.
if (line !== lastStatementLine) {
reportFirstExtraStatementAndClear();
numberOfStatementsOnThisLine = 1;
lastStatementLine = line;
... | javascript | function leaveStatement(node) {
const line = getActualLastToken(node).loc.end.line;
// Update state.
if (line !== lastStatementLine) {
reportFirstExtraStatementAndClear();
numberOfStatementsOnThisLine = 1;
lastStatementLine = line;
... | [
"function",
"leaveStatement",
"(",
"node",
")",
"{",
"const",
"line",
"=",
"getActualLastToken",
"(",
"node",
")",
".",
"loc",
".",
"end",
".",
"line",
";",
"// Update state.",
"if",
"(",
"line",
"!==",
"lastStatementLine",
")",
"{",
"reportFirstExtraStatement... | Updates the state of this rule with the end line of leaving node to check with the next statement.
@param {ASTNode} node - A node to check.
@returns {void} | [
"Updates",
"the",
"state",
"of",
"this",
"rule",
"with",
"the",
"end",
"line",
"of",
"leaving",
"node",
"to",
"check",
"with",
"the",
"next",
"statement",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/max-statements-per-line.js#L134-L143 |
3,118 | eslint/eslint | lib/rules/block-spacing.js | checkSpacingInsideBraces | function checkSpacingInsideBraces(node) {
// Gets braces and the first/last token of content.
const openBrace = getOpenBrace(node);
const closeBrace = sourceCode.getLastToken(node);
const firstToken = sourceCode.getTokenAfter(openBrace, { includeComments: true });
... | javascript | function checkSpacingInsideBraces(node) {
// Gets braces and the first/last token of content.
const openBrace = getOpenBrace(node);
const closeBrace = sourceCode.getLastToken(node);
const firstToken = sourceCode.getTokenAfter(openBrace, { includeComments: true });
... | [
"function",
"checkSpacingInsideBraces",
"(",
"node",
")",
"{",
"// Gets braces and the first/last token of content.",
"const",
"openBrace",
"=",
"getOpenBrace",
"(",
"node",
")",
";",
"const",
"closeBrace",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
";"... | Reports invalid spacing style inside braces.
@param {ASTNode} node - A BlockStatement/SwitchStatement node to get.
@returns {void} | [
"Reports",
"invalid",
"spacing",
"style",
"inside",
"braces",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/block-spacing.js#L80-L140 |
3,119 | eslint/eslint | lib/rules/multiline-comment-style.js | convertToStarredBlock | function convertToStarredBlock(firstComment, commentLinesList) {
const initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
const starredLines = commentLinesList.map(line => `${initialOffset} *${line}`);
return `\n${sta... | javascript | function convertToStarredBlock(firstComment, commentLinesList) {
const initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
const starredLines = commentLinesList.map(line => `${initialOffset} *${line}`);
return `\n${sta... | [
"function",
"convertToStarredBlock",
"(",
"firstComment",
",",
"commentLinesList",
")",
"{",
"const",
"initialOffset",
"=",
"sourceCode",
".",
"text",
".",
"slice",
"(",
"firstComment",
".",
"range",
"[",
"0",
"]",
"-",
"firstComment",
".",
"loc",
".",
"start"... | Converts a comment into starred-block form
@param {Token} firstComment The first comment of the group being converted
@param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
@returns {string} A representation of the comment value in starred-block form, excluding start and end marke... | [
"Converts",
"a",
"comment",
"into",
"starred",
"-",
"block",
"form"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/multiline-comment-style.js#L64-L69 |
3,120 | eslint/eslint | lib/rules/multiline-comment-style.js | convertToSeparateLines | function convertToSeparateLines(firstComment, commentLinesList) {
const initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
const separateLines = commentLinesList.map(line => `// ${line.trim()}`);
return separateLines.... | javascript | function convertToSeparateLines(firstComment, commentLinesList) {
const initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
const separateLines = commentLinesList.map(line => `// ${line.trim()}`);
return separateLines.... | [
"function",
"convertToSeparateLines",
"(",
"firstComment",
",",
"commentLinesList",
")",
"{",
"const",
"initialOffset",
"=",
"sourceCode",
".",
"text",
".",
"slice",
"(",
"firstComment",
".",
"range",
"[",
"0",
"]",
"-",
"firstComment",
".",
"loc",
".",
"start... | Converts a comment into separate-line form
@param {Token} firstComment The first comment of the group being converted
@param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
@returns {string} A representation of the comment value in separate-line form | [
"Converts",
"a",
"comment",
"into",
"separate",
"-",
"line",
"form"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/multiline-comment-style.js#L77-L82 |
3,121 | eslint/eslint | lib/rules/multiline-comment-style.js | convertToBlock | function convertToBlock(firstComment, commentLinesList) {
const initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
const blockLines = commentLinesList.map(line => line.trim());
return `/* ${blockLines.join(`\n${initia... | javascript | function convertToBlock(firstComment, commentLinesList) {
const initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
const blockLines = commentLinesList.map(line => line.trim());
return `/* ${blockLines.join(`\n${initia... | [
"function",
"convertToBlock",
"(",
"firstComment",
",",
"commentLinesList",
")",
"{",
"const",
"initialOffset",
"=",
"sourceCode",
".",
"text",
".",
"slice",
"(",
"firstComment",
".",
"range",
"[",
"0",
"]",
"-",
"firstComment",
".",
"loc",
".",
"start",
"."... | Converts a comment into bare-block form
@param {Token} firstComment The first comment of the group being converted
@param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
@returns {string} A representation of the comment value in bare-block form | [
"Converts",
"a",
"comment",
"into",
"bare",
"-",
"block",
"form"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/multiline-comment-style.js#L90-L95 |
3,122 | eslint/eslint | lib/rules/multiline-comment-style.js | isJSDoc | function isJSDoc(commentGroup) {
const lines = commentGroup[0].value.split(astUtils.LINEBREAK_MATCHER);
return commentGroup[0].type === "Block" &&
/^\*\s*$/u.test(lines[0]) &&
lines.slice(1, -1).every(line => /^\s* /u.test(line)) &&
/^\s*$/u.test(... | javascript | function isJSDoc(commentGroup) {
const lines = commentGroup[0].value.split(astUtils.LINEBREAK_MATCHER);
return commentGroup[0].type === "Block" &&
/^\*\s*$/u.test(lines[0]) &&
lines.slice(1, -1).every(line => /^\s* /u.test(line)) &&
/^\s*$/u.test(... | [
"function",
"isJSDoc",
"(",
"commentGroup",
")",
"{",
"const",
"lines",
"=",
"commentGroup",
"[",
"0",
"]",
".",
"value",
".",
"split",
"(",
"astUtils",
".",
"LINEBREAK_MATCHER",
")",
";",
"return",
"commentGroup",
"[",
"0",
"]",
".",
"type",
"===",
"\"B... | Check a comment is JSDoc form
@param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment
@returns {boolean} if commentGroup is JSDoc form, return true | [
"Check",
"a",
"comment",
"is",
"JSDoc",
"form"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/multiline-comment-style.js#L102-L109 |
3,123 | eslint/eslint | lib/code-path-analysis/code-path-analyzer.js | isIdentifierReference | function isIdentifierReference(node) {
const parent = node.parent;
switch (parent.type) {
case "LabeledStatement":
case "BreakStatement":
case "ContinueStatement":
case "ArrayPattern":
case "RestElement":
case "ImportSpecifier":
case "ImportDefaultSpecifi... | javascript | function isIdentifierReference(node) {
const parent = node.parent;
switch (parent.type) {
case "LabeledStatement":
case "BreakStatement":
case "ContinueStatement":
case "ArrayPattern":
case "RestElement":
case "ImportSpecifier":
case "ImportDefaultSpecifi... | [
"function",
"isIdentifierReference",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"switch",
"(",
"parent",
".",
"type",
")",
"{",
"case",
"\"LabeledStatement\"",
":",
"case",
"\"BreakStatement\"",
":",
"case",
"\"ContinueStatement\"... | Checks that a given identifier node is a reference or not.
This is used to detect the first throwable node in a `try` block.
@param {ASTNode} node - An Identifier node to check.
@returns {boolean} `true` if the node is a reference. | [
"Checks",
"that",
"a",
"given",
"identifier",
"node",
"is",
"a",
"reference",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/code-path-analysis/code-path-analyzer.js#L96-L133 |
3,124 | eslint/eslint | lib/code-path-analysis/code-path-analyzer.js | leaveFromCurrentSegment | function leaveFromCurrentSegment(analyzer, node) {
const state = CodePath.getState(analyzer.codePath);
const currentSegments = state.currentSegments;
for (let i = 0; i < currentSegments.length; ++i) {
const currentSegment = currentSegments[i];
debug.dump(`onCodePathSegmentEnd ${currentSegm... | javascript | function leaveFromCurrentSegment(analyzer, node) {
const state = CodePath.getState(analyzer.codePath);
const currentSegments = state.currentSegments;
for (let i = 0; i < currentSegments.length; ++i) {
const currentSegment = currentSegments[i];
debug.dump(`onCodePathSegmentEnd ${currentSegm... | [
"function",
"leaveFromCurrentSegment",
"(",
"analyzer",
",",
"node",
")",
"{",
"const",
"state",
"=",
"CodePath",
".",
"getState",
"(",
"analyzer",
".",
"codePath",
")",
";",
"const",
"currentSegments",
"=",
"state",
".",
"currentSegments",
";",
"for",
"(",
... | Updates the current segment with empty.
This is called at the last of functions or the program.
@param {CodePathAnalyzer} analyzer - The instance.
@param {ASTNode} node - The current AST node.
@returns {void} | [
"Updates",
"the",
"current",
"segment",
"with",
"empty",
".",
"This",
"is",
"called",
"at",
"the",
"last",
"of",
"functions",
"or",
"the",
"program",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/code-path-analysis/code-path-analyzer.js#L206-L224 |
3,125 | eslint/eslint | lib/code-path-analysis/code-path-analyzer.js | preprocess | function preprocess(analyzer, node) {
const codePath = analyzer.codePath;
const state = CodePath.getState(codePath);
const parent = node.parent;
switch (parent.type) {
case "LogicalExpression":
if (
parent.right === node &&
isHandledLogicalOperator(pa... | javascript | function preprocess(analyzer, node) {
const codePath = analyzer.codePath;
const state = CodePath.getState(codePath);
const parent = node.parent;
switch (parent.type) {
case "LogicalExpression":
if (
parent.right === node &&
isHandledLogicalOperator(pa... | [
"function",
"preprocess",
"(",
"analyzer",
",",
"node",
")",
"{",
"const",
"codePath",
"=",
"analyzer",
".",
"codePath",
";",
"const",
"state",
"=",
"CodePath",
".",
"getState",
"(",
"codePath",
")",
";",
"const",
"parent",
"=",
"node",
".",
"parent",
";... | Updates the code path due to the position of a given node in the parent node
thereof.
For example, if the node is `parent.consequent`, this creates a fork from the
current path.
@param {CodePathAnalyzer} analyzer - The instance.
@param {ASTNode} node - The current AST node.
@returns {void} | [
"Updates",
"the",
"code",
"path",
"due",
"to",
"the",
"position",
"of",
"a",
"given",
"node",
"in",
"the",
"parent",
"node",
"thereof",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/code-path-analysis/code-path-analyzer.js#L237-L338 |
3,126 | eslint/eslint | lib/code-path-analysis/code-path-analyzer.js | processCodePathToEnter | function processCodePathToEnter(analyzer, node) {
let codePath = analyzer.codePath;
let state = codePath && CodePath.getState(codePath);
const parent = node.parent;
switch (node.type) {
case "Program":
case "FunctionDeclaration":
case "FunctionExpression":
case "ArrowFun... | javascript | function processCodePathToEnter(analyzer, node) {
let codePath = analyzer.codePath;
let state = codePath && CodePath.getState(codePath);
const parent = node.parent;
switch (node.type) {
case "Program":
case "FunctionDeclaration":
case "FunctionExpression":
case "ArrowFun... | [
"function",
"processCodePathToEnter",
"(",
"analyzer",
",",
"node",
")",
"{",
"let",
"codePath",
"=",
"analyzer",
".",
"codePath",
";",
"let",
"state",
"=",
"codePath",
"&&",
"CodePath",
".",
"getState",
"(",
"codePath",
")",
";",
"const",
"parent",
"=",
"... | Updates the code path due to the type of a given node in entering.
@param {CodePathAnalyzer} analyzer - The instance.
@param {ASTNode} node - The current AST node.
@returns {void} | [
"Updates",
"the",
"code",
"path",
"due",
"to",
"the",
"type",
"of",
"a",
"given",
"node",
"in",
"entering",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/code-path-analysis/code-path-analyzer.js#L347-L435 |
3,127 | eslint/eslint | lib/code-path-analysis/code-path-analyzer.js | processCodePathToExit | function processCodePathToExit(analyzer, node) {
const codePath = analyzer.codePath;
const state = CodePath.getState(codePath);
let dontForward = false;
switch (node.type) {
case "IfStatement":
case "ConditionalExpression":
state.popChoiceContext();
break;
... | javascript | function processCodePathToExit(analyzer, node) {
const codePath = analyzer.codePath;
const state = CodePath.getState(codePath);
let dontForward = false;
switch (node.type) {
case "IfStatement":
case "ConditionalExpression":
state.popChoiceContext();
break;
... | [
"function",
"processCodePathToExit",
"(",
"analyzer",
",",
"node",
")",
"{",
"const",
"codePath",
"=",
"analyzer",
".",
"codePath",
";",
"const",
"state",
"=",
"CodePath",
".",
"getState",
"(",
"codePath",
")",
";",
"let",
"dontForward",
"=",
"false",
";",
... | Updates the code path due to the type of a given node in leaving.
@param {CodePathAnalyzer} analyzer - The instance.
@param {ASTNode} node - The current AST node.
@returns {void} | [
"Updates",
"the",
"code",
"path",
"due",
"to",
"the",
"type",
"of",
"a",
"given",
"node",
"in",
"leaving",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/code-path-analysis/code-path-analyzer.js#L444-L548 |
3,128 | eslint/eslint | lib/rules/operator-assignment.js | getOperatorToken | function getOperatorToken(node) {
return sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
} | javascript | function getOperatorToken(node) {
return sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
} | [
"function",
"getOperatorToken",
"(",
"node",
")",
"{",
"return",
"sourceCode",
".",
"getFirstTokenBetween",
"(",
"node",
".",
"left",
",",
"node",
".",
"right",
",",
"token",
"=>",
"token",
".",
"value",
"===",
"node",
".",
"operator",
")",
";",
"}"
] | Returns the operator token of an AssignmentExpression or BinaryExpression
@param {ASTNode} node An AssignmentExpression or BinaryExpression node
@returns {Token} The operator token in the node | [
"Returns",
"the",
"operator",
"token",
"of",
"an",
"AssignmentExpression",
"or",
"BinaryExpression"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/operator-assignment.js#L123-L125 |
3,129 | eslint/eslint | lib/rules/operator-assignment.js | verify | function verify(node) {
if (node.operator !== "=" || node.right.type !== "BinaryExpression") {
return;
}
const left = node.left;
const expr = node.right;
const operator = expr.operator;
if (isCommutativeOperatorWithShorthand(opera... | javascript | function verify(node) {
if (node.operator !== "=" || node.right.type !== "BinaryExpression") {
return;
}
const left = node.left;
const expr = node.right;
const operator = expr.operator;
if (isCommutativeOperatorWithShorthand(opera... | [
"function",
"verify",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"operator",
"!==",
"\"=\"",
"||",
"node",
".",
"right",
".",
"type",
"!==",
"\"BinaryExpression\"",
")",
"{",
"return",
";",
"}",
"const",
"left",
"=",
"node",
".",
"left",
";",
"co... | Ensures that an assignment uses the shorthand form where possible.
@param {ASTNode} node An AssignmentExpression node.
@returns {void} | [
"Ensures",
"that",
"an",
"assignment",
"uses",
"the",
"shorthand",
"form",
"where",
"possible",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/operator-assignment.js#L132-L171 |
3,130 | eslint/eslint | lib/rules/operator-assignment.js | prohibit | function prohibit(node) {
if (node.operator !== "=") {
context.report({
node,
messageId: "unexpected",
fix(fixer) {
if (canBeFixed(node.left)) {
const operatorToken = getOperatorTo... | javascript | function prohibit(node) {
if (node.operator !== "=") {
context.report({
node,
messageId: "unexpected",
fix(fixer) {
if (canBeFixed(node.left)) {
const operatorToken = getOperatorTo... | [
"function",
"prohibit",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"operator",
"!==",
"\"=\"",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"messageId",
":",
"\"unexpected\"",
",",
"fix",
"(",
"fixer",
")",
"{",
"if",
"(",
"canBeFix... | Warns if an assignment expression uses operator assignment shorthand.
@param {ASTNode} node An AssignmentExpression node.
@returns {void} | [
"Warns",
"if",
"an",
"assignment",
"expression",
"uses",
"operator",
"assignment",
"shorthand",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/operator-assignment.js#L178-L206 |
3,131 | eslint/eslint | lib/rules/function-paren-newline.js | validateArguments | function validateArguments(parens, elements) {
const leftParen = parens.leftParen;
const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen);
const hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen);
const needsNewlines = shouldHaveNewlines... | javascript | function validateArguments(parens, elements) {
const leftParen = parens.leftParen;
const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen);
const hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen);
const needsNewlines = shouldHaveNewlines... | [
"function",
"validateArguments",
"(",
"parens",
",",
"elements",
")",
"{",
"const",
"leftParen",
"=",
"parens",
".",
"leftParen",
";",
"const",
"tokenAfterLeftParen",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"leftParen",
")",
";",
"const",
"hasLeftNewline",
... | Validates a list of arguments or parameters
@param {Object} parens An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token
@param {ASTNode[]} elements The arguments or parameters in the list
@returns {void} | [
"Validates",
"a",
"list",
"of",
"arguments",
"or",
"parameters"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/function-paren-newline.js#L162-L181 |
3,132 | eslint/eslint | lib/rules/function-paren-newline.js | getParenTokens | function getParenTokens(node) {
switch (node.type) {
case "NewExpression":
if (!node.arguments.length && !(
astUtils.isOpeningParenToken(sourceCode.getLastToken(node, { skip: 1 })) &&
astUtils.isClosingParenToken(sourceCode.... | javascript | function getParenTokens(node) {
switch (node.type) {
case "NewExpression":
if (!node.arguments.length && !(
astUtils.isOpeningParenToken(sourceCode.getLastToken(node, { skip: 1 })) &&
astUtils.isClosingParenToken(sourceCode.... | [
"function",
"getParenTokens",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"\"NewExpression\"",
":",
"if",
"(",
"!",
"node",
".",
"arguments",
".",
"length",
"&&",
"!",
"(",
"astUtils",
".",
"isOpeningParenToken",
"(",
"so... | Gets the left paren and right paren tokens of a node.
@param {ASTNode} node The node with parens
@returns {Object} An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token.
Can also return `null` if an expression has no parens (e.g. a NewExpression with no arguments, or an Ar... | [
"Gets",
"the",
"left",
"paren",
"and",
"right",
"paren",
"tokens",
"of",
"a",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/function-paren-newline.js#L190-L238 |
3,133 | eslint/eslint | lib/rules/function-paren-newline.js | validateNode | function validateNode(node) {
const parens = getParenTokens(node);
if (parens) {
validateParens(parens, astUtils.isFunction(node) ? node.params : node.arguments);
if (multilineArgumentsOption) {
validateArguments(parens, astUtils.isFunction(n... | javascript | function validateNode(node) {
const parens = getParenTokens(node);
if (parens) {
validateParens(parens, astUtils.isFunction(node) ? node.params : node.arguments);
if (multilineArgumentsOption) {
validateArguments(parens, astUtils.isFunction(n... | [
"function",
"validateNode",
"(",
"node",
")",
"{",
"const",
"parens",
"=",
"getParenTokens",
"(",
"node",
")",
";",
"if",
"(",
"parens",
")",
"{",
"validateParens",
"(",
"parens",
",",
"astUtils",
".",
"isFunction",
"(",
"node",
")",
"?",
"node",
".",
... | Validates the parentheses for a node
@param {ASTNode} node The node with parens
@returns {void} | [
"Validates",
"the",
"parentheses",
"for",
"a",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/function-paren-newline.js#L245-L255 |
3,134 | eslint/eslint | lib/rules/no-unused-vars.js | getDefinedMessage | function getDefinedMessage(unusedVar) {
const defType = unusedVar.defs && unusedVar.defs[0] && unusedVar.defs[0].type;
let type;
let pattern;
if (defType === "CatchClause" && config.caughtErrorsIgnorePattern) {
type = "args";
pattern = con... | javascript | function getDefinedMessage(unusedVar) {
const defType = unusedVar.defs && unusedVar.defs[0] && unusedVar.defs[0].type;
let type;
let pattern;
if (defType === "CatchClause" && config.caughtErrorsIgnorePattern) {
type = "args";
pattern = con... | [
"function",
"getDefinedMessage",
"(",
"unusedVar",
")",
"{",
"const",
"defType",
"=",
"unusedVar",
".",
"defs",
"&&",
"unusedVar",
".",
"defs",
"[",
"0",
"]",
"&&",
"unusedVar",
".",
"defs",
"[",
"0",
"]",
".",
"type",
";",
"let",
"type",
";",
"let",
... | Generate the warning message about the variable being
defined and unused, including the ignore pattern if configured.
@param {Variable} unusedVar - eslint-scope variable object.
@returns {string} The warning message to be used with this unused variable. | [
"Generate",
"the",
"warning",
"message",
"about",
"the",
"variable",
"being",
"defined",
"and",
"unused",
"including",
"the",
"ignore",
"pattern",
"if",
"configured",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L109-L128 |
3,135 | eslint/eslint | lib/rules/no-unused-vars.js | hasRestSpreadSibling | function hasRestSpreadSibling(variable) {
if (config.ignoreRestSiblings) {
return variable.defs.some(def => {
const propertyNode = def.name.parent;
const patternNode = propertyNode.parent;
return (
propertyN... | javascript | function hasRestSpreadSibling(variable) {
if (config.ignoreRestSiblings) {
return variable.defs.some(def => {
const propertyNode = def.name.parent;
const patternNode = propertyNode.parent;
return (
propertyN... | [
"function",
"hasRestSpreadSibling",
"(",
"variable",
")",
"{",
"if",
"(",
"config",
".",
"ignoreRestSiblings",
")",
"{",
"return",
"variable",
".",
"defs",
".",
"some",
"(",
"def",
"=>",
"{",
"const",
"propertyNode",
"=",
"def",
".",
"name",
".",
"parent",... | Determines if a variable has a sibling rest property
@param {Variable} variable - eslint-scope variable object.
@returns {boolean} True if the variable is exported, false if not.
@private | [
"Determines",
"if",
"a",
"variable",
"has",
"a",
"sibling",
"rest",
"property"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L179-L194 |
3,136 | eslint/eslint | lib/rules/no-unused-vars.js | isSelfReference | function isSelfReference(ref, nodes) {
let scope = ref.from;
while (scope) {
if (nodes.indexOf(scope.block) >= 0) {
return true;
}
scope = scope.upper;
}
return false;
} | javascript | function isSelfReference(ref, nodes) {
let scope = ref.from;
while (scope) {
if (nodes.indexOf(scope.block) >= 0) {
return true;
}
scope = scope.upper;
}
return false;
} | [
"function",
"isSelfReference",
"(",
"ref",
",",
"nodes",
")",
"{",
"let",
"scope",
"=",
"ref",
".",
"from",
";",
"while",
"(",
"scope",
")",
"{",
"if",
"(",
"nodes",
".",
"indexOf",
"(",
"scope",
".",
"block",
")",
">=",
"0",
")",
"{",
"return",
... | Determine if an identifier is referencing an enclosing function name.
@param {Reference} ref - The reference to check.
@param {ASTNode[]} nodes - The candidate function nodes.
@returns {boolean} True if it's a self-reference, false if not.
@private | [
"Determine",
"if",
"an",
"identifier",
"is",
"referencing",
"an",
"enclosing",
"function",
"name",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L213-L225 |
3,137 | eslint/eslint | lib/rules/no-unused-vars.js | getFunctionDefinitions | function getFunctionDefinitions(variable) {
const functionDefinitions = [];
variable.defs.forEach(def => {
const { type, node } = def;
// FunctionDeclarations
if (type === "FunctionName") {
functionDefinitions.push(node);
... | javascript | function getFunctionDefinitions(variable) {
const functionDefinitions = [];
variable.defs.forEach(def => {
const { type, node } = def;
// FunctionDeclarations
if (type === "FunctionName") {
functionDefinitions.push(node);
... | [
"function",
"getFunctionDefinitions",
"(",
"variable",
")",
"{",
"const",
"functionDefinitions",
"=",
"[",
"]",
";",
"variable",
".",
"defs",
".",
"forEach",
"(",
"def",
"=>",
"{",
"const",
"{",
"type",
",",
"node",
"}",
"=",
"def",
";",
"// FunctionDeclar... | Gets a list of function definitions for a specified variable.
@param {Variable} variable - eslint-scope variable object.
@returns {ASTNode[]} Function nodes.
@private | [
"Gets",
"a",
"list",
"of",
"function",
"definitions",
"for",
"a",
"specified",
"variable",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L233-L251 |
3,138 | eslint/eslint | lib/rules/no-unused-vars.js | isInside | function isInside(inner, outer) {
return (
inner.range[0] >= outer.range[0] &&
inner.range[1] <= outer.range[1]
);
} | javascript | function isInside(inner, outer) {
return (
inner.range[0] >= outer.range[0] &&
inner.range[1] <= outer.range[1]
);
} | [
"function",
"isInside",
"(",
"inner",
",",
"outer",
")",
"{",
"return",
"(",
"inner",
".",
"range",
"[",
"0",
"]",
">=",
"outer",
".",
"range",
"[",
"0",
"]",
"&&",
"inner",
".",
"range",
"[",
"1",
"]",
"<=",
"outer",
".",
"range",
"[",
"1",
"]... | Checks the position of given nodes.
@param {ASTNode} inner - A node which is expected as inside.
@param {ASTNode} outer - A node which is expected as outside.
@returns {boolean} `true` if the `inner` node exists in the `outer` node.
@private | [
"Checks",
"the",
"position",
"of",
"given",
"nodes",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L261-L266 |
3,139 | eslint/eslint | lib/rules/no-unused-vars.js | getRhsNode | function getRhsNode(ref, prevRhsNode) {
const id = ref.identifier;
const parent = id.parent;
const granpa = parent.parent;
const refScope = ref.from.variableScope;
const varScope = ref.resolved.scope.variableScope;
const canBeUsedLater = refScope !... | javascript | function getRhsNode(ref, prevRhsNode) {
const id = ref.identifier;
const parent = id.parent;
const granpa = parent.parent;
const refScope = ref.from.variableScope;
const varScope = ref.resolved.scope.variableScope;
const canBeUsedLater = refScope !... | [
"function",
"getRhsNode",
"(",
"ref",
",",
"prevRhsNode",
")",
"{",
"const",
"id",
"=",
"ref",
".",
"identifier",
";",
"const",
"parent",
"=",
"id",
".",
"parent",
";",
"const",
"granpa",
"=",
"parent",
".",
"parent",
";",
"const",
"refScope",
"=",
"re... | If a given reference is left-hand side of an assignment, this gets
the right-hand side node of the assignment.
In the following cases, this returns null.
- The reference is not the LHS of an assignment expression.
- The reference is inside of a loop.
- The reference is inside of a function scope which is different fr... | [
"If",
"a",
"given",
"reference",
"is",
"left",
"-",
"hand",
"side",
"of",
"an",
"assignment",
"this",
"gets",
"the",
"right",
"-",
"hand",
"side",
"node",
"of",
"the",
"assignment",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L284-L308 |
3,140 | eslint/eslint | lib/rules/no-unused-vars.js | isReadForItself | function isReadForItself(ref, rhsNode) {
const id = ref.identifier;
const parent = id.parent;
const granpa = parent.parent;
return ref.isRead() && (
// self update. e.g. `a += 1`, `a++`
(// in RHS of an assignment for itself. e.g. `a = a ... | javascript | function isReadForItself(ref, rhsNode) {
const id = ref.identifier;
const parent = id.parent;
const granpa = parent.parent;
return ref.isRead() && (
// self update. e.g. `a += 1`, `a++`
(// in RHS of an assignment for itself. e.g. `a = a ... | [
"function",
"isReadForItself",
"(",
"ref",
",",
"rhsNode",
")",
"{",
"const",
"id",
"=",
"ref",
".",
"identifier",
";",
"const",
"parent",
"=",
"id",
".",
"parent",
";",
"const",
"granpa",
"=",
"parent",
".",
"parent",
";",
"return",
"ref",
".",
"isRea... | Checks whether a given reference is a read to update itself or not.
@param {eslint-scope.Reference} ref - A reference to check.
@param {ASTNode} rhsNode - The RHS node of the previous assignment.
@returns {boolean} The reference is a read to update itself.
@private | [
"Checks",
"whether",
"a",
"given",
"reference",
"is",
"a",
"read",
"to",
"update",
"itself",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L394-L415 |
3,141 | eslint/eslint | lib/rules/no-unused-vars.js | isForInRef | function isForInRef(ref) {
let target = ref.identifier.parent;
// "for (var ...) { return; }"
if (target.type === "VariableDeclarator") {
target = target.parent.parent;
}
if (target.type !== "ForInStatement") {
return false;
... | javascript | function isForInRef(ref) {
let target = ref.identifier.parent;
// "for (var ...) { return; }"
if (target.type === "VariableDeclarator") {
target = target.parent.parent;
}
if (target.type !== "ForInStatement") {
return false;
... | [
"function",
"isForInRef",
"(",
"ref",
")",
"{",
"let",
"target",
"=",
"ref",
".",
"identifier",
".",
"parent",
";",
"// \"for (var ...) { return; }\"",
"if",
"(",
"target",
".",
"type",
"===",
"\"VariableDeclarator\"",
")",
"{",
"target",
"=",
"target",
".",
... | Determine if an identifier is used either in for-in loops.
@param {Reference} ref - The reference to check.
@returns {boolean} whether reference is used in the for-in loops
@private | [
"Determine",
"if",
"an",
"identifier",
"is",
"used",
"either",
"in",
"for",
"-",
"in",
"loops",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L424-L452 |
3,142 | eslint/eslint | lib/rules/no-unused-vars.js | isAfterLastUsedArg | function isAfterLastUsedArg(variable) {
const def = variable.defs[0];
const params = context.getDeclaredVariables(def.node);
const posteriorParams = params.slice(params.indexOf(variable) + 1);
// If any used parameters occur after this parameter, do not report.
... | javascript | function isAfterLastUsedArg(variable) {
const def = variable.defs[0];
const params = context.getDeclaredVariables(def.node);
const posteriorParams = params.slice(params.indexOf(variable) + 1);
// If any used parameters occur after this parameter, do not report.
... | [
"function",
"isAfterLastUsedArg",
"(",
"variable",
")",
"{",
"const",
"def",
"=",
"variable",
".",
"defs",
"[",
"0",
"]",
";",
"const",
"params",
"=",
"context",
".",
"getDeclaredVariables",
"(",
"def",
".",
"node",
")",
";",
"const",
"posteriorParams",
"=... | Checks whether the given variable is after the last used parameter.
@param {eslint-scope.Variable} variable - The variable to check.
@returns {boolean} `true` if the variable is defined after the last
used parameter. | [
"Checks",
"whether",
"the",
"given",
"variable",
"is",
"after",
"the",
"last",
"used",
"parameter",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L489-L496 |
3,143 | eslint/eslint | lib/rules/comma-spacing.js | report | function report(node, loc, otherNode) {
context.report({
node,
fix(fixer) {
if (options[loc]) {
if (loc === "before") {
return fixer.insertTextBefore(node, " ");
}
... | javascript | function report(node, loc, otherNode) {
context.report({
node,
fix(fixer) {
if (options[loc]) {
if (loc === "before") {
return fixer.insertTextBefore(node, " ");
}
... | [
"function",
"report",
"(",
"node",
",",
"loc",
",",
"otherNode",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"fix",
"(",
"fixer",
")",
"{",
"if",
"(",
"options",
"[",
"loc",
"]",
")",
"{",
"if",
"(",
"loc",
"===",
"\"before\"",
")"... | Reports a spacing error with an appropriate message.
@param {ASTNode} node The binary expression node to report.
@param {string} loc Is the error "before" or "after" the comma?
@param {ASTNode} otherNode The node at the left or right of `node`
@returns {void}
@private | [
"Reports",
"a",
"spacing",
"error",
"with",
"an",
"appropriate",
"message",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/comma-spacing.js#L74-L104 |
3,144 | eslint/eslint | lib/rules/comma-spacing.js | validateCommaItemSpacing | function validateCommaItemSpacing(tokens, reportItem) {
if (tokens.left && astUtils.isTokenOnSameLine(tokens.left, tokens.comma) &&
(options.before !== sourceCode.isSpaceBetweenTokens(tokens.left, tokens.comma))
) {
report(reportItem, "before", tokens.left);
... | javascript | function validateCommaItemSpacing(tokens, reportItem) {
if (tokens.left && astUtils.isTokenOnSameLine(tokens.left, tokens.comma) &&
(options.before !== sourceCode.isSpaceBetweenTokens(tokens.left, tokens.comma))
) {
report(reportItem, "before", tokens.left);
... | [
"function",
"validateCommaItemSpacing",
"(",
"tokens",
",",
"reportItem",
")",
"{",
"if",
"(",
"tokens",
".",
"left",
"&&",
"astUtils",
".",
"isTokenOnSameLine",
"(",
"tokens",
".",
"left",
",",
"tokens",
".",
"comma",
")",
"&&",
"(",
"options",
".",
"befo... | Validates the spacing around a comma token.
@param {Object} tokens - The tokens to be validated.
@param {Token} tokens.comma The token representing the comma.
@param {Token} [tokens.left] The last token before the comma.
@param {Token} [tokens.right] The first token after the comma.
@param {Token|ASTNode} reportItem Th... | [
"Validates",
"the",
"spacing",
"around",
"a",
"comma",
"token",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/comma-spacing.js#L116-L136 |
3,145 | eslint/eslint | lib/rules/comma-spacing.js | addNullElementsToIgnoreList | function addNullElementsToIgnoreList(node) {
let previousToken = sourceCode.getFirstToken(node);
node.elements.forEach(element => {
let token;
if (element === null) {
token = sourceCode.getTokenAfter(previousToken);
if (a... | javascript | function addNullElementsToIgnoreList(node) {
let previousToken = sourceCode.getFirstToken(node);
node.elements.forEach(element => {
let token;
if (element === null) {
token = sourceCode.getTokenAfter(previousToken);
if (a... | [
"function",
"addNullElementsToIgnoreList",
"(",
"node",
")",
"{",
"let",
"previousToken",
"=",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
")",
";",
"node",
".",
"elements",
".",
"forEach",
"(",
"element",
"=>",
"{",
"let",
"token",
";",
"if",
"(",
"e... | Adds null elements of the given ArrayExpression or ArrayPattern node to the ignore list.
@param {ASTNode} node An ArrayExpression or ArrayPattern node.
@returns {void} | [
"Adds",
"null",
"elements",
"of",
"the",
"given",
"ArrayExpression",
"or",
"ArrayPattern",
"node",
"to",
"the",
"ignore",
"list",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/comma-spacing.js#L143-L161 |
3,146 | eslint/eslint | lib/rules/no-var.js | getEnclosingFunctionScope | function getEnclosingFunctionScope(scope) {
let currentScope = scope;
while (currentScope.type !== "function" && currentScope.type !== "global") {
currentScope = currentScope.upper;
}
return currentScope;
} | javascript | function getEnclosingFunctionScope(scope) {
let currentScope = scope;
while (currentScope.type !== "function" && currentScope.type !== "global") {
currentScope = currentScope.upper;
}
return currentScope;
} | [
"function",
"getEnclosingFunctionScope",
"(",
"scope",
")",
"{",
"let",
"currentScope",
"=",
"scope",
";",
"while",
"(",
"currentScope",
".",
"type",
"!==",
"\"function\"",
"&&",
"currentScope",
".",
"type",
"!==",
"\"global\"",
")",
"{",
"currentScope",
"=",
... | Finds the nearest function scope or global scope walking up the scope
hierarchy.
@param {eslint-scope.Scope} scope - The scope to traverse.
@returns {eslint-scope.Scope} a function scope or global scope containing the given
scope. | [
"Finds",
"the",
"nearest",
"function",
"scope",
"or",
"global",
"scope",
"walking",
"up",
"the",
"scope",
"hierarchy",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-var.js#L35-L42 |
3,147 | eslint/eslint | lib/rules/no-var.js | isLoopAssignee | function isLoopAssignee(node) {
return (node.parent.type === "ForOfStatement" || node.parent.type === "ForInStatement") &&
node === node.parent.left;
} | javascript | function isLoopAssignee(node) {
return (node.parent.type === "ForOfStatement" || node.parent.type === "ForInStatement") &&
node === node.parent.left;
} | [
"function",
"isLoopAssignee",
"(",
"node",
")",
"{",
"return",
"(",
"node",
".",
"parent",
".",
"type",
"===",
"\"ForOfStatement\"",
"||",
"node",
".",
"parent",
".",
"type",
"===",
"\"ForInStatement\"",
")",
"&&",
"node",
"===",
"node",
".",
"parent",
"."... | Checks whether the given node is the assignee of a loop.
@param {ASTNode} node - A VariableDeclaration node to check.
@returns {boolean} `true` if the declaration is assigned as part of loop
iteration. | [
"Checks",
"whether",
"the",
"given",
"node",
"is",
"the",
"assignee",
"of",
"a",
"loop",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-var.js#L65-L68 |
3,148 | eslint/eslint | lib/rules/no-var.js | getScopeNode | function getScopeNode(node) {
for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
if (SCOPE_NODE_TYPE.test(currentNode.type)) {
return currentNode;
}
}
/* istanbul ignore next : unreachable */
return null;
} | javascript | function getScopeNode(node) {
for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
if (SCOPE_NODE_TYPE.test(currentNode.type)) {
return currentNode;
}
}
/* istanbul ignore next : unreachable */
return null;
} | [
"function",
"getScopeNode",
"(",
"node",
")",
"{",
"for",
"(",
"let",
"currentNode",
"=",
"node",
";",
"currentNode",
";",
"currentNode",
"=",
"currentNode",
".",
"parent",
")",
"{",
"if",
"(",
"SCOPE_NODE_TYPE",
".",
"test",
"(",
"currentNode",
".",
"type... | Gets the scope node which directly contains a given node.
@param {ASTNode} node - A node to get. This is a `VariableDeclaration` or
an `Identifier`.
@returns {ASTNode} A scope node. This is one of `Program`, `BlockStatement`,
`SwitchStatement`, `ForStatement`, `ForInStatement`, and
`ForOfStatement`. | [
"Gets",
"the",
"scope",
"node",
"which",
"directly",
"contains",
"a",
"given",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-var.js#L91-L100 |
3,149 | eslint/eslint | lib/rules/no-var.js | isUsedFromOutsideOf | function isUsedFromOutsideOf(scopeNode) {
/**
* Checks whether a given reference is inside of the specified scope or not.
*
* @param {eslint-scope.Reference} reference - A reference to check.
* @returns {boolean} `true` if the reference is inside of the specified
* scope.
*/
... | javascript | function isUsedFromOutsideOf(scopeNode) {
/**
* Checks whether a given reference is inside of the specified scope or not.
*
* @param {eslint-scope.Reference} reference - A reference to check.
* @returns {boolean} `true` if the reference is inside of the specified
* scope.
*/
... | [
"function",
"isUsedFromOutsideOf",
"(",
"scopeNode",
")",
"{",
"/**\n * Checks whether a given reference is inside of the specified scope or not.\n *\n * @param {eslint-scope.Reference} reference - A reference to check.\n * @returns {boolean} `true` if the reference is inside of the spec... | Checks whether a given variable is used from outside of the specified scope.
@param {ASTNode} scopeNode - A scope node to check.
@returns {Function} The predicate function which checks whether a given
variable is used from outside of the specified scope. | [
"Checks",
"whether",
"a",
"given",
"variable",
"is",
"used",
"from",
"outside",
"of",
"the",
"specified",
"scope",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-var.js#L119-L138 |
3,150 | eslint/eslint | lib/rules/no-var.js | isOutsideOfScope | function isOutsideOfScope(reference) {
const scope = scopeNode.range;
const id = reference.identifier.range;
return id[0] < scope[0] || id[1] > scope[1];
} | javascript | function isOutsideOfScope(reference) {
const scope = scopeNode.range;
const id = reference.identifier.range;
return id[0] < scope[0] || id[1] > scope[1];
} | [
"function",
"isOutsideOfScope",
"(",
"reference",
")",
"{",
"const",
"scope",
"=",
"scopeNode",
".",
"range",
";",
"const",
"id",
"=",
"reference",
".",
"identifier",
".",
"range",
";",
"return",
"id",
"[",
"0",
"]",
"<",
"scope",
"[",
"0",
"]",
"||",
... | Checks whether a given reference is inside of the specified scope or not.
@param {eslint-scope.Reference} reference - A reference to check.
@returns {boolean} `true` if the reference is inside of the specified
scope. | [
"Checks",
"whether",
"a",
"given",
"reference",
"is",
"inside",
"of",
"the",
"specified",
"scope",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-var.js#L128-L133 |
3,151 | eslint/eslint | lib/rules/no-var.js | hasReferenceInTDZ | function hasReferenceInTDZ(node) {
const initStart = node.range[0];
const initEnd = node.range[1];
return variable => {
const id = variable.defs[0].name;
const idStart = id.range[0];
const defaultValue = (id.parent.type === "AssignmentPattern" ? id.parent.right : null);
cons... | javascript | function hasReferenceInTDZ(node) {
const initStart = node.range[0];
const initEnd = node.range[1];
return variable => {
const id = variable.defs[0].name;
const idStart = id.range[0];
const defaultValue = (id.parent.type === "AssignmentPattern" ? id.parent.right : null);
cons... | [
"function",
"hasReferenceInTDZ",
"(",
"node",
")",
"{",
"const",
"initStart",
"=",
"node",
".",
"range",
"[",
"0",
"]",
";",
"const",
"initEnd",
"=",
"node",
".",
"range",
"[",
"1",
"]",
";",
"return",
"variable",
"=>",
"{",
"const",
"id",
"=",
"vari... | Creates the predicate function which checks whether a variable has their references in TDZ.
The predicate function would return `true`:
- if a reference is before the declarator. E.g. (var a = b, b = 1;)(var {a = b, b} = {};)
- if a reference is in the expression of their default value. E.g. (var {a = a} = {};)
- if... | [
"Creates",
"the",
"predicate",
"function",
"which",
"checks",
"whether",
"a",
"variable",
"has",
"their",
"references",
"in",
"TDZ",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-var.js#L153-L175 |
3,152 | eslint/eslint | lib/rules/no-var.js | hasSelfReferenceInTDZ | function hasSelfReferenceInTDZ(declarator) {
if (!declarator.init) {
return false;
}
const variables = context.getDeclaredVariables(declarator);
return variables.some(hasReferenceInTDZ(declarator.init));
} | javascript | function hasSelfReferenceInTDZ(declarator) {
if (!declarator.init) {
return false;
}
const variables = context.getDeclaredVariables(declarator);
return variables.some(hasReferenceInTDZ(declarator.init));
} | [
"function",
"hasSelfReferenceInTDZ",
"(",
"declarator",
")",
"{",
"if",
"(",
"!",
"declarator",
".",
"init",
")",
"{",
"return",
"false",
";",
"}",
"const",
"variables",
"=",
"context",
".",
"getDeclaredVariables",
"(",
"declarator",
")",
";",
"return",
"var... | Checks whether the variables which are defined by the given declarator node have their references in TDZ.
@param {ASTNode} declarator - The VariableDeclarator node to check.
@returns {boolean} `true` if one of the variables which are defined by the given declarator node have their references in TDZ. | [
"Checks",
"whether",
"the",
"variables",
"which",
"are",
"defined",
"by",
"the",
"given",
"declarator",
"node",
"have",
"their",
"references",
"in",
"TDZ",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-var.js#L205-L212 |
3,153 | eslint/eslint | lib/rules/no-var.js | report | function report(node) {
context.report({
node,
message: "Unexpected var, use let or const instead.",
fix(fixer) {
const varToken = sourceCode.getFirstToken(node, { filter: t => t.value === "var" });
return canFix(node)... | javascript | function report(node) {
context.report({
node,
message: "Unexpected var, use let or const instead.",
fix(fixer) {
const varToken = sourceCode.getFirstToken(node, { filter: t => t.value === "var" });
return canFix(node)... | [
"function",
"report",
"(",
"node",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"message",
":",
"\"Unexpected var, use let or const instead.\"",
",",
"fix",
"(",
"fixer",
")",
"{",
"const",
"varToken",
"=",
"sourceCode",
".",
"getFirstToken",
"("... | Reports a given variable declaration node.
@param {ASTNode} node - A variable declaration node to report.
@returns {void} | [
"Reports",
"a",
"given",
"variable",
"declaration",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-var.js#L307-L320 |
3,154 | eslint/eslint | lib/rules/no-confusing-arrow.js | checkArrowFunc | function checkArrowFunc(node) {
const body = node.body;
if (isConditional(body) && !(allowParens && astUtils.isParenthesised(sourceCode, body))) {
context.report({
node,
messageId: "confusing",
fix(fixer) {
... | javascript | function checkArrowFunc(node) {
const body = node.body;
if (isConditional(body) && !(allowParens && astUtils.isParenthesised(sourceCode, body))) {
context.report({
node,
messageId: "confusing",
fix(fixer) {
... | [
"function",
"checkArrowFunc",
"(",
"node",
")",
"{",
"const",
"body",
"=",
"node",
".",
"body",
";",
"if",
"(",
"isConditional",
"(",
"body",
")",
"&&",
"!",
"(",
"allowParens",
"&&",
"astUtils",
".",
"isParenthesised",
"(",
"sourceCode",
",",
"body",
")... | Reports if an arrow function contains an ambiguous conditional.
@param {ASTNode} node - A node to check and report.
@returns {void} | [
"Reports",
"if",
"an",
"arrow",
"function",
"contains",
"an",
"ambiguous",
"conditional",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-confusing-arrow.js#L65-L79 |
3,155 | eslint/eslint | lib/rules/max-nested-callbacks.js | checkFunction | function checkFunction(node) {
const parent = node.parent;
if (parent.type === "CallExpression") {
callbackStack.push(node);
}
if (callbackStack.length > THRESHOLD) {
const opts = { num: callbackStack.length, max: THRESHOLD };
... | javascript | function checkFunction(node) {
const parent = node.parent;
if (parent.type === "CallExpression") {
callbackStack.push(node);
}
if (callbackStack.length > THRESHOLD) {
const opts = { num: callbackStack.length, max: THRESHOLD };
... | [
"function",
"checkFunction",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"if",
"(",
"parent",
".",
"type",
"===",
"\"CallExpression\"",
")",
"{",
"callbackStack",
".",
"push",
"(",
"node",
")",
";",
"}",
"if",
"(",
"callb... | Checks a given function node for too many callbacks.
@param {ASTNode} node The node to check.
@returns {void}
@private | [
"Checks",
"a",
"given",
"function",
"node",
"for",
"too",
"many",
"callbacks",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/max-nested-callbacks.js#L81-L93 |
3,156 | eslint/eslint | lib/rules/init-declarations.js | isInitialized | function isInitialized(node) {
const declaration = node.parent;
const block = declaration.parent;
if (isForLoop(block)) {
if (block.type === "ForStatement") {
return block.init === declaration;
}
return block.left === declaration;
}
return Boolean(node.init);
} | javascript | function isInitialized(node) {
const declaration = node.parent;
const block = declaration.parent;
if (isForLoop(block)) {
if (block.type === "ForStatement") {
return block.init === declaration;
}
return block.left === declaration;
}
return Boolean(node.init);
} | [
"function",
"isInitialized",
"(",
"node",
")",
"{",
"const",
"declaration",
"=",
"node",
".",
"parent",
";",
"const",
"block",
"=",
"declaration",
".",
"parent",
";",
"if",
"(",
"isForLoop",
"(",
"block",
")",
")",
"{",
"if",
"(",
"block",
".",
"type",... | Checks whether or not a given declarator node has its initializer.
@param {ASTNode} node - A declarator node to check.
@returns {boolean} `true` when the node has its initializer. | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"declarator",
"node",
"has",
"its",
"initializer",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/init-declarations.js#L28-L39 |
3,157 | eslint/eslint | lib/rules/new-cap.js | checkArray | function checkArray(obj, key, fallback) {
/* istanbul ignore if */
if (Object.prototype.hasOwnProperty.call(obj, key) && !Array.isArray(obj[key])) {
throw new TypeError(`${key}, if provided, must be an Array`);
}
return obj[key] || fallback;
} | javascript | function checkArray(obj, key, fallback) {
/* istanbul ignore if */
if (Object.prototype.hasOwnProperty.call(obj, key) && !Array.isArray(obj[key])) {
throw new TypeError(`${key}, if provided, must be an Array`);
}
return obj[key] || fallback;
} | [
"function",
"checkArray",
"(",
"obj",
",",
"key",
",",
"fallback",
")",
"{",
"/* istanbul ignore if */",
"if",
"(",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"obj",
",",
"key",
")",
"&&",
"!",
"Array",
".",
"isArray",
"(",
"obj... | Ensure that if the key is provided, it must be an array.
@param {Object} obj Object to check with `key`.
@param {string} key Object key to check on `obj`.
@param {*} fallback If obj[key] is not present, this will be returned.
@returns {string[]} Returns obj[key] if it's an Array, otherwise `fallback` | [
"Ensure",
"that",
"if",
"the",
"key",
"is",
"provided",
"it",
"must",
"be",
"an",
"array",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/new-cap.js#L36-L43 |
3,158 | eslint/eslint | lib/rules/new-cap.js | calculateCapIsNewExceptions | function calculateCapIsNewExceptions(config) {
let capIsNewExceptions = checkArray(config, "capIsNewExceptions", CAPS_ALLOWED);
if (capIsNewExceptions !== CAPS_ALLOWED) {
capIsNewExceptions = capIsNewExceptions.concat(CAPS_ALLOWED);
}
return capIsNewExceptions.reduce(invert, {});
} | javascript | function calculateCapIsNewExceptions(config) {
let capIsNewExceptions = checkArray(config, "capIsNewExceptions", CAPS_ALLOWED);
if (capIsNewExceptions !== CAPS_ALLOWED) {
capIsNewExceptions = capIsNewExceptions.concat(CAPS_ALLOWED);
}
return capIsNewExceptions.reduce(invert, {});
} | [
"function",
"calculateCapIsNewExceptions",
"(",
"config",
")",
"{",
"let",
"capIsNewExceptions",
"=",
"checkArray",
"(",
"config",
",",
"\"capIsNewExceptions\"",
",",
"CAPS_ALLOWED",
")",
";",
"if",
"(",
"capIsNewExceptions",
"!==",
"CAPS_ALLOWED",
")",
"{",
"capIsN... | Creates an object with the cap is new exceptions as its keys and true as their values.
@param {Object} config Rule configuration
@returns {Object} Object with cap is new exceptions. | [
"Creates",
"an",
"object",
"with",
"the",
"cap",
"is",
"new",
"exceptions",
"as",
"its",
"keys",
"and",
"true",
"as",
"their",
"values",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/new-cap.js#L61-L69 |
3,159 | eslint/eslint | lib/rules/new-cap.js | getCap | function getCap(str) {
const firstChar = str.charAt(0);
const firstCharLower = firstChar.toLowerCase();
const firstCharUpper = firstChar.toUpperCase();
if (firstCharLower === firstCharUpper) {
// char has no uppercase variant, so it's non-alphabetic
... | javascript | function getCap(str) {
const firstChar = str.charAt(0);
const firstCharLower = firstChar.toLowerCase();
const firstCharUpper = firstChar.toUpperCase();
if (firstCharLower === firstCharUpper) {
// char has no uppercase variant, so it's non-alphabetic
... | [
"function",
"getCap",
"(",
"str",
")",
"{",
"const",
"firstChar",
"=",
"str",
".",
"charAt",
"(",
"0",
")",
";",
"const",
"firstCharLower",
"=",
"firstChar",
".",
"toLowerCase",
"(",
")",
";",
"const",
"firstCharUpper",
"=",
"firstChar",
".",
"toUpperCase"... | Returns the capitalization state of the string -
Whether the first character is uppercase, lowercase, or non-alphabetic
@param {string} str String
@returns {string} capitalization state: "non-alpha", "lower", or "upper" | [
"Returns",
"the",
"capitalization",
"state",
"of",
"the",
"string",
"-",
"Whether",
"the",
"first",
"character",
"is",
"uppercase",
"lowercase",
"or",
"non",
"-",
"alphabetic"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/new-cap.js#L181-L197 |
3,160 | eslint/eslint | lib/rules/new-cap.js | isCapAllowed | function isCapAllowed(allowedMap, node, calleeName, pattern) {
const sourceText = sourceCode.getText(node.callee);
if (allowedMap[calleeName] || allowedMap[sourceText]) {
return true;
}
if (pattern && pattern.test(sourceText)) {
return tr... | javascript | function isCapAllowed(allowedMap, node, calleeName, pattern) {
const sourceText = sourceCode.getText(node.callee);
if (allowedMap[calleeName] || allowedMap[sourceText]) {
return true;
}
if (pattern && pattern.test(sourceText)) {
return tr... | [
"function",
"isCapAllowed",
"(",
"allowedMap",
",",
"node",
",",
"calleeName",
",",
"pattern",
")",
"{",
"const",
"sourceText",
"=",
"sourceCode",
".",
"getText",
"(",
"node",
".",
"callee",
")",
";",
"if",
"(",
"allowedMap",
"[",
"calleeName",
"]",
"||",
... | Check if capitalization is allowed for a CallExpression
@param {Object} allowedMap Object mapping calleeName to a Boolean
@param {ASTNode} node CallExpression node
@param {string} calleeName Capitalized callee name from a CallExpression
@param {Object} pattern RegExp object from options pattern
@returns {boolean} Retur... | [
"Check",
"if",
"capitalization",
"is",
"allowed",
"for",
"a",
"CallExpression"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/new-cap.js#L207-L226 |
3,161 | eslint/eslint | lib/rules/new-cap.js | report | function report(node, messageId) {
let callee = node.callee;
if (callee.type === "MemberExpression") {
callee = callee.property;
}
context.report({ node, loc: callee.loc.start, messageId });
} | javascript | function report(node, messageId) {
let callee = node.callee;
if (callee.type === "MemberExpression") {
callee = callee.property;
}
context.report({ node, loc: callee.loc.start, messageId });
} | [
"function",
"report",
"(",
"node",
",",
"messageId",
")",
"{",
"let",
"callee",
"=",
"node",
".",
"callee",
";",
"if",
"(",
"callee",
".",
"type",
"===",
"\"MemberExpression\"",
")",
"{",
"callee",
"=",
"callee",
".",
"property",
";",
"}",
"context",
"... | Reports the given messageId for the given node. The location will be the start of the property or the callee.
@param {ASTNode} node CallExpression or NewExpression node.
@param {string} messageId The messageId to report.
@returns {void} | [
"Reports",
"the",
"given",
"messageId",
"for",
"the",
"given",
"node",
".",
"The",
"location",
"will",
"be",
"the",
"start",
"of",
"the",
"property",
"or",
"the",
"callee",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/new-cap.js#L234-L242 |
3,162 | eslint/eslint | lib/util/traverser.js | getVisitorKeys | function getVisitorKeys(visitorKeys, node) {
let keys = visitorKeys[node.type];
if (!keys) {
keys = vk.getKeys(node);
debug("Unknown node type \"%s\": Estimated visitor keys %j", node.type, keys);
}
return keys;
} | javascript | function getVisitorKeys(visitorKeys, node) {
let keys = visitorKeys[node.type];
if (!keys) {
keys = vk.getKeys(node);
debug("Unknown node type \"%s\": Estimated visitor keys %j", node.type, keys);
}
return keys;
} | [
"function",
"getVisitorKeys",
"(",
"visitorKeys",
",",
"node",
")",
"{",
"let",
"keys",
"=",
"visitorKeys",
"[",
"node",
".",
"type",
"]",
";",
"if",
"(",
"!",
"keys",
")",
"{",
"keys",
"=",
"vk",
".",
"getKeys",
"(",
"node",
")",
";",
"debug",
"("... | Get the visitor keys of a given node.
@param {Object} visitorKeys The map of visitor keys.
@param {ASTNode} node The node to get their visitor keys.
@returns {string[]} The visitor keys of the node. | [
"Get",
"the",
"visitor",
"keys",
"of",
"a",
"given",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/traverser.js#L43-L52 |
3,163 | eslint/eslint | lib/rules/yoda.js | looksLikeLiteral | function looksLikeLiteral(node) {
return (node.type === "UnaryExpression" &&
node.operator === "-" &&
node.prefix &&
node.argument.type === "Literal" &&
typeof node.argument.value === "number");
} | javascript | function looksLikeLiteral(node) {
return (node.type === "UnaryExpression" &&
node.operator === "-" &&
node.prefix &&
node.argument.type === "Literal" &&
typeof node.argument.value === "number");
} | [
"function",
"looksLikeLiteral",
"(",
"node",
")",
"{",
"return",
"(",
"node",
".",
"type",
"===",
"\"UnaryExpression\"",
"&&",
"node",
".",
"operator",
"===",
"\"-\"",
"&&",
"node",
".",
"prefix",
"&&",
"node",
".",
"argument",
".",
"type",
"===",
"\"Liter... | Determines whether a non-Literal node is a negative number that should be
treated as if it were a single Literal node.
@param {ASTNode} node Node to test.
@returns {boolean} True if the node is a negative number that looks like a
real literal and should be treated as such. | [
"Determines",
"whether",
"a",
"non",
"-",
"Literal",
"node",
"is",
"a",
"negative",
"number",
"that",
"should",
"be",
"treated",
"as",
"if",
"it",
"were",
"a",
"single",
"Literal",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/yoda.js#L52-L58 |
3,164 | eslint/eslint | lib/rules/prefer-reflect.js | report | function report(node, existing, substitute) {
context.report({
node,
message: "Avoid using {{existing}}, instead use {{substitute}}.",
data: {
existing,
substitute
}
});
} | javascript | function report(node, existing, substitute) {
context.report({
node,
message: "Avoid using {{existing}}, instead use {{substitute}}.",
data: {
existing,
substitute
}
});
} | [
"function",
"report",
"(",
"node",
",",
"existing",
",",
"substitute",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"message",
":",
"\"Avoid using {{existing}}, instead use {{substitute}}.\"",
",",
"data",
":",
"{",
"existing",
",",
"substitute",
"... | Reports the Reflect violation based on the `existing` and `substitute`
@param {Object} node The node that violates the rule.
@param {string} existing The existing method name that has been used.
@param {string} substitute The Reflect substitute that should be used.
@returns {void} | [
"Reports",
"the",
"Reflect",
"violation",
"based",
"on",
"the",
"existing",
"and",
"substitute"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-reflect.js#L89-L98 |
3,165 | eslint/eslint | lib/rules/prefer-named-capture-group.js | checkRegex | function checkRegex(regex, node, uFlag) {
let ast;
try {
ast = parser.parsePattern(regex, 0, regex.length, uFlag);
} catch (_) {
// ignore regex syntax errors
return;
}
regexpp.visitRegExpAST(ast, {
... | javascript | function checkRegex(regex, node, uFlag) {
let ast;
try {
ast = parser.parsePattern(regex, 0, regex.length, uFlag);
} catch (_) {
// ignore regex syntax errors
return;
}
regexpp.visitRegExpAST(ast, {
... | [
"function",
"checkRegex",
"(",
"regex",
",",
"node",
",",
"uFlag",
")",
"{",
"let",
"ast",
";",
"try",
"{",
"ast",
"=",
"parser",
".",
"parsePattern",
"(",
"regex",
",",
"0",
",",
"regex",
".",
"length",
",",
"uFlag",
")",
";",
"}",
"catch",
"(",
... | Function to check regular expression.
@param {string} regex The regular expression to be check.
@param {ASTNode} node AST node which contains regular expression.
@param {boolean} uFlag Flag indicates whether unicode mode is enabled or not.
@returns {void} | [
"Function",
"to",
"check",
"regular",
"expression",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-named-capture-group.js#L58-L94 |
3,166 | eslint/eslint | lib/util/file-finder.js | normalizeDirectoryEntries | function normalizeDirectoryEntries(entries, directory, supportedConfigs) {
const fileHash = {};
entries.forEach(entry => {
if (supportedConfigs.indexOf(entry) >= 0) {
const resolvedEntry = path.resolve(directory, entry);
if (fs.statSync(resolvedEntry).isFile()) {
... | javascript | function normalizeDirectoryEntries(entries, directory, supportedConfigs) {
const fileHash = {};
entries.forEach(entry => {
if (supportedConfigs.indexOf(entry) >= 0) {
const resolvedEntry = path.resolve(directory, entry);
if (fs.statSync(resolvedEntry).isFile()) {
... | [
"function",
"normalizeDirectoryEntries",
"(",
"entries",
",",
"directory",
",",
"supportedConfigs",
")",
"{",
"const",
"fileHash",
"=",
"{",
"}",
";",
"entries",
".",
"forEach",
"(",
"entry",
"=>",
"{",
"if",
"(",
"supportedConfigs",
".",
"indexOf",
"(",
"en... | Create a hash of filenames from a directory listing
@param {string[]} entries Array of directory entries.
@param {string} directory Path to a current directory.
@param {string[]} supportedConfigs List of support filenames.
@returns {Object} Hashmap of filenames | [
"Create",
"a",
"hash",
"of",
"filenames",
"from",
"a",
"directory",
"listing"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/file-finder.js#L42-L55 |
3,167 | eslint/eslint | lib/rules/no-empty-function.js | getKind | function getKind(node) {
const parent = node.parent;
let kind = "";
if (node.type === "ArrowFunctionExpression") {
return "arrowFunctions";
}
// Detects main kind.
if (parent.type === "Property") {
if (parent.kind === "get") {
return "getters";
}
if ... | javascript | function getKind(node) {
const parent = node.parent;
let kind = "";
if (node.type === "ArrowFunctionExpression") {
return "arrowFunctions";
}
// Detects main kind.
if (parent.type === "Property") {
if (parent.kind === "get") {
return "getters";
}
if ... | [
"function",
"getKind",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"let",
"kind",
"=",
"\"\"",
";",
"if",
"(",
"node",
".",
"type",
"===",
"\"ArrowFunctionExpression\"",
")",
"{",
"return",
"\"arrowFunctions\"",
";",
"}",
"... | Gets the kind of a given function node.
@param {ASTNode} node - A function node to get. This is one of
an ArrowFunctionExpression, a FunctionDeclaration, or a
FunctionExpression.
@returns {string} The kind of the function. This is one of "functions",
"arrowFunctions", "generatorFunctions", "asyncFunctions", "methods",... | [
"Gets",
"the",
"kind",
"of",
"a",
"given",
"function",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-empty-function.js#L40-L85 |
3,168 | eslint/eslint | lib/rules/no-empty-function.js | reportIfEmpty | function reportIfEmpty(node) {
const kind = getKind(node);
const name = astUtils.getFunctionNameWithKind(node);
const innerComments = sourceCode.getTokens(node.body, {
includeComments: true,
filter: astUtils.isCommentToken
});
... | javascript | function reportIfEmpty(node) {
const kind = getKind(node);
const name = astUtils.getFunctionNameWithKind(node);
const innerComments = sourceCode.getTokens(node.body, {
includeComments: true,
filter: astUtils.isCommentToken
});
... | [
"function",
"reportIfEmpty",
"(",
"node",
")",
"{",
"const",
"kind",
"=",
"getKind",
"(",
"node",
")",
";",
"const",
"name",
"=",
"astUtils",
".",
"getFunctionNameWithKind",
"(",
"node",
")",
";",
"const",
"innerComments",
"=",
"sourceCode",
".",
"getTokens"... | Reports a given function node if the node matches the following patterns.
- Not allowed by options.
- The body is empty.
- The body doesn't have any comments.
@param {ASTNode} node - A function node to report. This is one of
an ArrowFunctionExpression, a FunctionDeclaration, or a
FunctionExpression.
@returns {void} | [
"Reports",
"a",
"given",
"function",
"node",
"if",
"the",
"node",
"matches",
"the",
"following",
"patterns",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-empty-function.js#L139-L159 |
3,169 | eslint/eslint | lib/rules/no-unused-labels.js | enterLabeledScope | function enterLabeledScope(node) {
scopeInfo = {
label: node.label.name,
used: false,
upper: scopeInfo
};
} | javascript | function enterLabeledScope(node) {
scopeInfo = {
label: node.label.name,
used: false,
upper: scopeInfo
};
} | [
"function",
"enterLabeledScope",
"(",
"node",
")",
"{",
"scopeInfo",
"=",
"{",
"label",
":",
"node",
".",
"label",
".",
"name",
",",
"used",
":",
"false",
",",
"upper",
":",
"scopeInfo",
"}",
";",
"}"
] | Adds a scope info to the stack.
@param {ASTNode} node - A node to add. This is a LabeledStatement.
@returns {void} | [
"Adds",
"a",
"scope",
"info",
"to",
"the",
"stack",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-labels.js#L42-L48 |
3,170 | eslint/eslint | lib/rules/no-unused-labels.js | exitLabeledScope | function exitLabeledScope(node) {
if (!scopeInfo.used) {
context.report({
node: node.label,
messageId: "unused",
data: node.label,
fix(fixer) {
/*
* Only perform ... | javascript | function exitLabeledScope(node) {
if (!scopeInfo.used) {
context.report({
node: node.label,
messageId: "unused",
data: node.label,
fix(fixer) {
/*
* Only perform ... | [
"function",
"exitLabeledScope",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"scopeInfo",
".",
"used",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
":",
"node",
".",
"label",
",",
"messageId",
":",
"\"unused\"",
",",
"data",
":",
"node",
".",
"lab... | Removes the top of the stack.
At the same time, this reports the label if it's never used.
@param {ASTNode} node - A node to report. This is a LabeledStatement.
@returns {void} | [
"Removes",
"the",
"top",
"of",
"the",
"stack",
".",
"At",
"the",
"same",
"time",
"this",
"reports",
"the",
"label",
"if",
"it",
"s",
"never",
"used",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-labels.js#L57-L80 |
3,171 | eslint/eslint | lib/rules/no-unused-labels.js | markAsUsed | function markAsUsed(node) {
if (!node.label) {
return;
}
const label = node.label.name;
let info = scopeInfo;
while (info) {
if (info.label === label) {
info.used = true;
break;
... | javascript | function markAsUsed(node) {
if (!node.label) {
return;
}
const label = node.label.name;
let info = scopeInfo;
while (info) {
if (info.label === label) {
info.used = true;
break;
... | [
"function",
"markAsUsed",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
".",
"label",
")",
"{",
"return",
";",
"}",
"const",
"label",
"=",
"node",
".",
"label",
".",
"name",
";",
"let",
"info",
"=",
"scopeInfo",
";",
"while",
"(",
"info",
")",
"... | Marks the label of a given node as used.
@param {ASTNode} node - A node to mark. This is a BreakStatement or
ContinueStatement.
@returns {void} | [
"Marks",
"the",
"label",
"of",
"a",
"given",
"node",
"as",
"used",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-labels.js#L89-L104 |
3,172 | eslint/eslint | lib/rules/padding-line-between-statements.js | isIIFEStatement | function isIIFEStatement(node) {
if (node.type === "ExpressionStatement") {
let call = node.expression;
if (call.type === "UnaryExpression") {
call = call.argument;
}
return call.type === "CallExpression" && astUtils.isFunction(call.callee);
}
return false;
} | javascript | function isIIFEStatement(node) {
if (node.type === "ExpressionStatement") {
let call = node.expression;
if (call.type === "UnaryExpression") {
call = call.argument;
}
return call.type === "CallExpression" && astUtils.isFunction(call.callee);
}
return false;
} | [
"function",
"isIIFEStatement",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"\"ExpressionStatement\"",
")",
"{",
"let",
"call",
"=",
"node",
".",
"expression",
";",
"if",
"(",
"call",
".",
"type",
"===",
"\"UnaryExpression\"",
")",
"{",
... | Checks the given node is an expression statement of IIFE.
@param {ASTNode} node The node to check.
@returns {boolean} `true` if the node is an expression statement of IIFE.
@private | [
"Checks",
"the",
"given",
"node",
"is",
"an",
"expression",
"statement",
"of",
"IIFE",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L91-L101 |
3,173 | eslint/eslint | lib/rules/padding-line-between-statements.js | isBlockLikeStatement | function isBlockLikeStatement(sourceCode, node) {
// do-while with a block is a block-like statement.
if (node.type === "DoWhileStatement" && node.body.type === "BlockStatement") {
return true;
}
/*
* IIFE is a block-like statement specially from
* JSCS#disallowPaddingNewLinesAfterBl... | javascript | function isBlockLikeStatement(sourceCode, node) {
// do-while with a block is a block-like statement.
if (node.type === "DoWhileStatement" && node.body.type === "BlockStatement") {
return true;
}
/*
* IIFE is a block-like statement specially from
* JSCS#disallowPaddingNewLinesAfterBl... | [
"function",
"isBlockLikeStatement",
"(",
"sourceCode",
",",
"node",
")",
"{",
"// do-while with a block is a block-like statement.",
"if",
"(",
"node",
".",
"type",
"===",
"\"DoWhileStatement\"",
"&&",
"node",
".",
"body",
".",
"type",
"===",
"\"BlockStatement\"",
")"... | Checks whether the given node is a block-like statement.
This checks the last token of the node is the closing brace of a block.
@param {SourceCode} sourceCode The source code to get tokens.
@param {ASTNode} node The node to check.
@returns {boolean} `true` if the node is a block-like statement.
@private | [
"Checks",
"whether",
"the",
"given",
"node",
"is",
"a",
"block",
"-",
"like",
"statement",
".",
"This",
"checks",
"the",
"last",
"token",
"of",
"the",
"node",
"is",
"the",
"closing",
"brace",
"of",
"a",
"block",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L112-L137 |
3,174 | eslint/eslint | lib/rules/padding-line-between-statements.js | isDirective | function isDirective(node, sourceCode) {
return (
node.type === "ExpressionStatement" &&
(
node.parent.type === "Program" ||
(
node.parent.type === "BlockStatement" &&
astUtils.isFunction(node.parent.parent)
)
) &&
n... | javascript | function isDirective(node, sourceCode) {
return (
node.type === "ExpressionStatement" &&
(
node.parent.type === "Program" ||
(
node.parent.type === "BlockStatement" &&
astUtils.isFunction(node.parent.parent)
)
) &&
n... | [
"function",
"isDirective",
"(",
"node",
",",
"sourceCode",
")",
"{",
"return",
"(",
"node",
".",
"type",
"===",
"\"ExpressionStatement\"",
"&&",
"(",
"node",
".",
"parent",
".",
"type",
"===",
"\"Program\"",
"||",
"(",
"node",
".",
"parent",
".",
"type",
... | Check whether the given node is a directive or not.
@param {ASTNode} node The node to check.
@param {SourceCode} sourceCode The source code object to get tokens.
@returns {boolean} `true` if the node is a directive. | [
"Check",
"whether",
"the",
"given",
"node",
"is",
"a",
"directive",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L145-L159 |
3,175 | eslint/eslint | lib/rules/padding-line-between-statements.js | isDirectivePrologue | function isDirectivePrologue(node, sourceCode) {
if (isDirective(node, sourceCode)) {
for (const sibling of node.parent.body) {
if (sibling === node) {
break;
}
if (!isDirective(sibling, sourceCode)) {
return false;
}
}
... | javascript | function isDirectivePrologue(node, sourceCode) {
if (isDirective(node, sourceCode)) {
for (const sibling of node.parent.body) {
if (sibling === node) {
break;
}
if (!isDirective(sibling, sourceCode)) {
return false;
}
}
... | [
"function",
"isDirectivePrologue",
"(",
"node",
",",
"sourceCode",
")",
"{",
"if",
"(",
"isDirective",
"(",
"node",
",",
"sourceCode",
")",
")",
"{",
"for",
"(",
"const",
"sibling",
"of",
"node",
".",
"parent",
".",
"body",
")",
"{",
"if",
"(",
"siblin... | Check whether the given node is a part of directive prologue or not.
@param {ASTNode} node The node to check.
@param {SourceCode} sourceCode The source code object to get tokens.
@returns {boolean} `true` if the node is a part of directive prologue. | [
"Check",
"whether",
"the",
"given",
"node",
"is",
"a",
"part",
"of",
"directive",
"prologue",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L167-L180 |
3,176 | eslint/eslint | lib/rules/padding-line-between-statements.js | getActualLastToken | function getActualLastToken(sourceCode, node) {
const semiToken = sourceCode.getLastToken(node);
const prevToken = sourceCode.getTokenBefore(semiToken);
const nextToken = sourceCode.getTokenAfter(semiToken);
const isSemicolonLessStyle = Boolean(
prevToken &&
nextToken &&
prevToke... | javascript | function getActualLastToken(sourceCode, node) {
const semiToken = sourceCode.getLastToken(node);
const prevToken = sourceCode.getTokenBefore(semiToken);
const nextToken = sourceCode.getTokenAfter(semiToken);
const isSemicolonLessStyle = Boolean(
prevToken &&
nextToken &&
prevToke... | [
"function",
"getActualLastToken",
"(",
"sourceCode",
",",
"node",
")",
"{",
"const",
"semiToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
";",
"const",
"prevToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"semiToken",
")",
";",
"const"... | Gets the actual last token.
If a semicolon is semicolon-less style's semicolon, this ignores it.
For example:
foo()
;[1, 2, 3].forEach(bar)
@param {SourceCode} sourceCode The source code to get tokens.
@param {ASTNode} node The node to get.
@returns {Token} The actual last token.
@private | [
"Gets",
"the",
"actual",
"last",
"token",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L196-L210 |
3,177 | eslint/eslint | lib/rules/padding-line-between-statements.js | verifyForNever | function verifyForNever(context, _, nextNode, paddingLines) {
if (paddingLines.length === 0) {
return;
}
context.report({
node: nextNode,
message: "Unexpected blank line before this statement.",
fix(fixer) {
if (paddingLines.length >= 2) {
return ... | javascript | function verifyForNever(context, _, nextNode, paddingLines) {
if (paddingLines.length === 0) {
return;
}
context.report({
node: nextNode,
message: "Unexpected blank line before this statement.",
fix(fixer) {
if (paddingLines.length >= 2) {
return ... | [
"function",
"verifyForNever",
"(",
"context",
",",
"_",
",",
"nextNode",
",",
"paddingLines",
")",
"{",
"if",
"(",
"paddingLines",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"context",
".",
"report",
"(",
"{",
"node",
":",
"nextNode",
","... | Check and report statements for `never` configuration.
This autofix removes blank lines between the given 2 statements.
However, if comments exist between 2 blank lines, it does not remove those
blank lines automatically.
@param {RuleContext} context The rule context to report.
@param {ASTNode} _ Unused. The previous ... | [
"Check",
"and",
"report",
"statements",
"for",
"never",
"configuration",
".",
"This",
"autofix",
"removes",
"blank",
"lines",
"between",
"the",
"given",
"2",
"statements",
".",
"However",
"if",
"comments",
"exist",
"between",
"2",
"blank",
"lines",
"it",
"does... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L248-L272 |
3,178 | eslint/eslint | lib/rules/padding-line-between-statements.js | verifyForAlways | function verifyForAlways(context, prevNode, nextNode, paddingLines) {
if (paddingLines.length > 0) {
return;
}
context.report({
node: nextNode,
message: "Expected blank line before this statement.",
fix(fixer) {
const sourceCode = context.getSourceCode();
... | javascript | function verifyForAlways(context, prevNode, nextNode, paddingLines) {
if (paddingLines.length > 0) {
return;
}
context.report({
node: nextNode,
message: "Expected blank line before this statement.",
fix(fixer) {
const sourceCode = context.getSourceCode();
... | [
"function",
"verifyForAlways",
"(",
"context",
",",
"prevNode",
",",
"nextNode",
",",
"paddingLines",
")",
"{",
"if",
"(",
"paddingLines",
".",
"length",
">",
"0",
")",
"{",
"return",
";",
"}",
"context",
".",
"report",
"(",
"{",
"node",
":",
"nextNode",... | Check and report statements for `always` configuration.
This autofix inserts a blank line between the given 2 statements.
If the `prevNode` has trailing comments, it inserts a blank line after the
trailing comments.
@param {RuleContext} context The rule context to report.
@param {ASTNode} prevNode The previous node to... | [
"Check",
"and",
"report",
"statements",
"for",
"always",
"configuration",
".",
"This",
"autofix",
"inserts",
"a",
"blank",
"line",
"between",
"the",
"given",
"2",
"statements",
".",
"If",
"the",
"prevNode",
"has",
"trailing",
"comments",
"it",
"inserts",
"a",
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L288-L342 |
3,179 | eslint/eslint | lib/rules/padding-line-between-statements.js | match | function match(node, type) {
let innerStatementNode = node;
while (innerStatementNode.type === "LabeledStatement") {
innerStatementNode = innerStatementNode.body;
}
if (Array.isArray(type)) {
return type.some(match.bind(null, innerStatemen... | javascript | function match(node, type) {
let innerStatementNode = node;
while (innerStatementNode.type === "LabeledStatement") {
innerStatementNode = innerStatementNode.body;
}
if (Array.isArray(type)) {
return type.some(match.bind(null, innerStatemen... | [
"function",
"match",
"(",
"node",
",",
"type",
")",
"{",
"let",
"innerStatementNode",
"=",
"node",
";",
"while",
"(",
"innerStatementNode",
".",
"type",
"===",
"\"LabeledStatement\"",
")",
"{",
"innerStatementNode",
"=",
"innerStatementNode",
".",
"body",
";",
... | Checks whether the given node matches the given type.
@param {ASTNode} node The statement node to check.
@param {string|string[]} type The statement type to check.
@returns {boolean} `true` if the statement node matched the type.
@private | [
"Checks",
"whether",
"the",
"given",
"node",
"matches",
"the",
"given",
"type",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L520-L530 |
3,180 | eslint/eslint | lib/rules/padding-line-between-statements.js | getPaddingType | function getPaddingType(prevNode, nextNode) {
for (let i = configureList.length - 1; i >= 0; --i) {
const configure = configureList[i];
const matched =
match(prevNode, configure.prev) &&
match(nextNode, configure.next);
... | javascript | function getPaddingType(prevNode, nextNode) {
for (let i = configureList.length - 1; i >= 0; --i) {
const configure = configureList[i];
const matched =
match(prevNode, configure.prev) &&
match(nextNode, configure.next);
... | [
"function",
"getPaddingType",
"(",
"prevNode",
",",
"nextNode",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"configureList",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"--",
"i",
")",
"{",
"const",
"configure",
"=",
"configureList",
"[",
"i",
"]",... | Finds the last matched configure from configureList.
@param {ASTNode} prevNode The previous statement to match.
@param {ASTNode} nextNode The current statement to match.
@returns {Object} The tester of the last matched configure.
@private | [
"Finds",
"the",
"last",
"matched",
"configure",
"from",
"configureList",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L540-L552 |
3,181 | eslint/eslint | lib/rules/padding-line-between-statements.js | getPaddingLineSequences | function getPaddingLineSequences(prevNode, nextNode) {
const pairs = [];
let prevToken = getActualLastToken(sourceCode, prevNode);
if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) {
do {
const token = sourceCode.getTokenAfter(
... | javascript | function getPaddingLineSequences(prevNode, nextNode) {
const pairs = [];
let prevToken = getActualLastToken(sourceCode, prevNode);
if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) {
do {
const token = sourceCode.getTokenAfter(
... | [
"function",
"getPaddingLineSequences",
"(",
"prevNode",
",",
"nextNode",
")",
"{",
"const",
"pairs",
"=",
"[",
"]",
";",
"let",
"prevToken",
"=",
"getActualLastToken",
"(",
"sourceCode",
",",
"prevNode",
")",
";",
"if",
"(",
"nextNode",
".",
"loc",
".",
"s... | Gets padding line sequences between the given 2 statements.
Comments are separators of the padding line sequences.
@param {ASTNode} prevNode The previous statement to count.
@param {ASTNode} nextNode The current statement to count.
@returns {Array<Token[]>} The array of token pairs.
@private | [
"Gets",
"padding",
"line",
"sequences",
"between",
"the",
"given",
"2",
"statements",
".",
"Comments",
"are",
"separators",
"of",
"the",
"padding",
"line",
"sequences",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L563-L583 |
3,182 | eslint/eslint | lib/rules/padding-line-between-statements.js | verify | function verify(node) {
const parentType = node.parent.type;
const validParent =
astUtils.STATEMENT_LIST_PARENTS.has(parentType) ||
parentType === "SwitchStatement";
if (!validParent) {
return;
}
// Save this n... | javascript | function verify(node) {
const parentType = node.parent.type;
const validParent =
astUtils.STATEMENT_LIST_PARENTS.has(parentType) ||
parentType === "SwitchStatement";
if (!validParent) {
return;
}
// Save this n... | [
"function",
"verify",
"(",
"node",
")",
"{",
"const",
"parentType",
"=",
"node",
".",
"parent",
".",
"type",
";",
"const",
"validParent",
"=",
"astUtils",
".",
"STATEMENT_LIST_PARENTS",
".",
"has",
"(",
"parentType",
")",
"||",
"parentType",
"===",
"\"Switch... | Verify padding lines between the given node and the previous node.
@param {ASTNode} node The node to verify.
@returns {void}
@private | [
"Verify",
"padding",
"lines",
"between",
"the",
"given",
"node",
"and",
"the",
"previous",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L592-L614 |
3,183 | eslint/eslint | lib/rules/dot-location.js | checkDotLocation | function checkDotLocation(obj, prop, node) {
const dot = sourceCode.getTokenBefore(prop);
const textBeforeDot = sourceCode.getText().slice(obj.range[1], dot.range[0]);
const textAfterDot = sourceCode.getText().slice(dot.range[1], prop.range[0]);
if (dot.type === "Punctua... | javascript | function checkDotLocation(obj, prop, node) {
const dot = sourceCode.getTokenBefore(prop);
const textBeforeDot = sourceCode.getText().slice(obj.range[1], dot.range[0]);
const textAfterDot = sourceCode.getText().slice(dot.range[1], prop.range[0]);
if (dot.type === "Punctua... | [
"function",
"checkDotLocation",
"(",
"obj",
",",
"prop",
",",
"node",
")",
"{",
"const",
"dot",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"prop",
")",
";",
"const",
"textBeforeDot",
"=",
"sourceCode",
".",
"getText",
"(",
")",
".",
"slice",
"(",
"ob... | Reports if the dot between object and property is on the correct loccation.
@param {ASTNode} obj The object owning the property.
@param {ASTNode} prop The property of the object.
@param {ASTNode} node The corresponding node of the token.
@returns {void} | [
"Reports",
"if",
"the",
"dot",
"between",
"object",
"and",
"property",
"is",
"on",
"the",
"correct",
"loccation",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/dot-location.js#L55-L81 |
3,184 | eslint/eslint | lib/rules/nonblock-statement-body-position.js | validateStatement | function validateStatement(node, keywordName) {
const option = getOption(keywordName);
if (node.type === "BlockStatement" || option === "any") {
return;
}
const tokenBefore = sourceCode.getTokenBefore(node);
if (tokenBefore.loc.end.line === ... | javascript | function validateStatement(node, keywordName) {
const option = getOption(keywordName);
if (node.type === "BlockStatement" || option === "any") {
return;
}
const tokenBefore = sourceCode.getTokenBefore(node);
if (tokenBefore.loc.end.line === ... | [
"function",
"validateStatement",
"(",
"node",
",",
"keywordName",
")",
"{",
"const",
"option",
"=",
"getOption",
"(",
"keywordName",
")",
";",
"if",
"(",
"node",
".",
"type",
"===",
"\"BlockStatement\"",
"||",
"option",
"===",
"\"any\"",
")",
"{",
"return",
... | Validates the location of a single-line statement
@param {ASTNode} node The single-line statement
@param {string} keywordName The applicable keyword name for the single-line statement
@returns {void} | [
"Validates",
"the",
"location",
"of",
"a",
"single",
"-",
"line",
"statement"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/nonblock-statement-body-position.js#L70-L97 |
3,185 | eslint/eslint | lib/util/source-code-fixer.js | compareMessagesByFixRange | function compareMessagesByFixRange(a, b) {
return a.fix.range[0] - b.fix.range[0] || a.fix.range[1] - b.fix.range[1];
} | javascript | function compareMessagesByFixRange(a, b) {
return a.fix.range[0] - b.fix.range[0] || a.fix.range[1] - b.fix.range[1];
} | [
"function",
"compareMessagesByFixRange",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
".",
"fix",
".",
"range",
"[",
"0",
"]",
"-",
"b",
".",
"fix",
".",
"range",
"[",
"0",
"]",
"||",
"a",
".",
"fix",
".",
"range",
"[",
"1",
"]",
"-",
"b",
".... | Compares items in a messages array by range.
@param {Message} a The first message.
@param {Message} 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",
"messages",
"array",
"by",
"range",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/source-code-fixer.js#L26-L28 |
3,186 | eslint/eslint | lib/util/source-code-fixer.js | attemptFix | function attemptFix(problem) {
const fix = problem.fix;
const start = fix.range[0];
const end = fix.range[1];
// Remain it as a problem if it's overlapped or it's a negative range
if (lastPos >= start || start > end) {
remainingMessages.push(problem);
ret... | javascript | function attemptFix(problem) {
const fix = problem.fix;
const start = fix.range[0];
const end = fix.range[1];
// Remain it as a problem if it's overlapped or it's a negative range
if (lastPos >= start || start > end) {
remainingMessages.push(problem);
ret... | [
"function",
"attemptFix",
"(",
"problem",
")",
"{",
"const",
"fix",
"=",
"problem",
".",
"fix",
";",
"const",
"start",
"=",
"fix",
".",
"range",
"[",
"0",
"]",
";",
"const",
"end",
"=",
"fix",
".",
"range",
"[",
"1",
"]",
";",
"// Remain it as a prob... | Try to use the 'fix' from a problem.
@param {Message} problem The message object to apply fixes from
@returns {boolean} Whether fix was successfully applied | [
"Try",
"to",
"use",
"the",
"fix",
"from",
"a",
"problem",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/source-code-fixer.js#L86-L107 |
3,187 | eslint/eslint | lib/util/source-code.js | looksLikeExport | function looksLikeExport(astNode) {
return astNode.type === "ExportDefaultDeclaration" || astNode.type === "ExportNamedDeclaration" ||
astNode.type === "ExportAllDeclaration" || astNode.type === "ExportSpecifier";
} | javascript | function looksLikeExport(astNode) {
return astNode.type === "ExportDefaultDeclaration" || astNode.type === "ExportNamedDeclaration" ||
astNode.type === "ExportAllDeclaration" || astNode.type === "ExportSpecifier";
} | [
"function",
"looksLikeExport",
"(",
"astNode",
")",
"{",
"return",
"astNode",
".",
"type",
"===",
"\"ExportDefaultDeclaration\"",
"||",
"astNode",
".",
"type",
"===",
"\"ExportNamedDeclaration\"",
"||",
"astNode",
".",
"type",
"===",
"\"ExportAllDeclaration\"",
"||",
... | Check to see if its a ES6 export declaration.
@param {ASTNode} astNode An AST node.
@returns {boolean} whether the given node represents an export declaration.
@private | [
"Check",
"to",
"see",
"if",
"its",
"a",
"ES6",
"export",
"declaration",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/source-code.js#L51-L54 |
3,188 | eslint/eslint | lib/rules/no-trailing-spaces.js | getCommentLineNumbers | function getCommentLineNumbers(comments) {
const lines = new Set();
comments.forEach(comment => {
for (let i = comment.loc.start.line; i <= comment.loc.end.line; i++) {
lines.add(i);
}
});
return lines;
} | javascript | function getCommentLineNumbers(comments) {
const lines = new Set();
comments.forEach(comment => {
for (let i = comment.loc.start.line; i <= comment.loc.end.line; i++) {
lines.add(i);
}
});
return lines;
} | [
"function",
"getCommentLineNumbers",
"(",
"comments",
")",
"{",
"const",
"lines",
"=",
"new",
"Set",
"(",
")",
";",
"comments",
".",
"forEach",
"(",
"comment",
"=>",
"{",
"for",
"(",
"let",
"i",
"=",
"comment",
".",
"loc",
".",
"start",
".",
"line",
... | Given a list of comment nodes, return the line numbers for those comments.
@param {Array} comments An array of comment nodes.
@returns {number[]} An array of line numbers containing comments. | [
"Given",
"a",
"list",
"of",
"comment",
"nodes",
"return",
"the",
"line",
"numbers",
"for",
"those",
"comments",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-trailing-spaces.js#L89-L99 |
3,189 | eslint/eslint | lib/rules/no-use-before-define.js | isOuterVariable | function isOuterVariable(variable, reference) {
return (
variable.defs[0].type === "Variable" &&
variable.scope.variableScope !== reference.from.variableScope
);
} | javascript | function isOuterVariable(variable, reference) {
return (
variable.defs[0].type === "Variable" &&
variable.scope.variableScope !== reference.from.variableScope
);
} | [
"function",
"isOuterVariable",
"(",
"variable",
",",
"reference",
")",
"{",
"return",
"(",
"variable",
".",
"defs",
"[",
"0",
"]",
".",
"type",
"===",
"\"Variable\"",
"&&",
"variable",
".",
"scope",
".",
"variableScope",
"!==",
"reference",
".",
"from",
".... | Checks whether or not a given variable is a variable declaration in an upper function scope.
@param {eslint-scope.Variable} variable - A variable to check.
@param {eslint-scope.Reference} reference - A reference to check.
@returns {boolean} `true` if the variable is a variable declaration. | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"variable",
"is",
"a",
"variable",
"declaration",
"in",
"an",
"upper",
"function",
"scope",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-use-before-define.js#L67-L72 |
3,190 | eslint/eslint | lib/rules/no-use-before-define.js | isInRange | function isInRange(node, location) {
return node && node.range[0] <= location && location <= node.range[1];
} | javascript | function isInRange(node, location) {
return node && node.range[0] <= location && location <= node.range[1];
} | [
"function",
"isInRange",
"(",
"node",
",",
"location",
")",
"{",
"return",
"node",
"&&",
"node",
".",
"range",
"[",
"0",
"]",
"<=",
"location",
"&&",
"location",
"<=",
"node",
".",
"range",
"[",
"1",
"]",
";",
"}"
] | Checks whether or not a given location is inside of the range of a given node.
@param {ASTNode} node - An node to check.
@param {number} location - A location to check.
@returns {boolean} `true` if the location is inside of the range of the node. | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"location",
"is",
"inside",
"of",
"the",
"range",
"of",
"a",
"given",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-use-before-define.js#L81-L83 |
3,191 | eslint/eslint | lib/rules/no-use-before-define.js | isInInitializer | function isInInitializer(variable, reference) {
if (variable.scope !== reference.from) {
return false;
}
let node = variable.identifiers[0].parent;
const location = reference.identifier.range[1];
while (node) {
if (node.type === "VariableDeclarator") {
if (isInRange(nod... | javascript | function isInInitializer(variable, reference) {
if (variable.scope !== reference.from) {
return false;
}
let node = variable.identifiers[0].parent;
const location = reference.identifier.range[1];
while (node) {
if (node.type === "VariableDeclarator") {
if (isInRange(nod... | [
"function",
"isInInitializer",
"(",
"variable",
",",
"reference",
")",
"{",
"if",
"(",
"variable",
".",
"scope",
"!==",
"reference",
".",
"from",
")",
"{",
"return",
"false",
";",
"}",
"let",
"node",
"=",
"variable",
".",
"identifiers",
"[",
"0",
"]",
... | Checks whether or not a given reference is inside of the initializers of a given variable.
This returns `true` in the following cases:
var a = a
var [a = a] = list
var {a = a} = obj
for (var a in a) {}
for (var a of a) {}
@param {Variable} variable - A variable to check.
@param {Reference} reference - A reference to... | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"reference",
"is",
"inside",
"of",
"the",
"initializers",
"of",
"a",
"given",
"variable",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-use-before-define.js#L100-L131 |
3,192 | eslint/eslint | lib/rules/no-use-before-define.js | findVariablesInScope | function findVariablesInScope(scope) {
scope.references.forEach(reference => {
const variable = reference.resolved;
/*
* Skips when the reference is:
* - initialization's.
* - referring to an undefined variable.
... | javascript | function findVariablesInScope(scope) {
scope.references.forEach(reference => {
const variable = reference.resolved;
/*
* Skips when the reference is:
* - initialization's.
* - referring to an undefined variable.
... | [
"function",
"findVariablesInScope",
"(",
"scope",
")",
"{",
"scope",
".",
"references",
".",
"forEach",
"(",
"reference",
"=>",
"{",
"const",
"variable",
"=",
"reference",
".",
"resolved",
";",
"/*\n * Skips when the reference is:\n * - ini... | Finds and validates all variables in a given scope.
@param {Scope} scope The scope object.
@returns {void}
@private | [
"Finds",
"and",
"validates",
"all",
"variables",
"in",
"a",
"given",
"scope",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-use-before-define.js#L196-L226 |
3,193 | eslint/eslint | lib/rules/semi-style.js | isLastChild | function isLastChild(node) {
const t = node.parent.type;
if (t === "IfStatement" && node.parent.consequent === node && node.parent.alternate) { // before `else` keyword.
return true;
}
if (t === "DoWhileStatement") { // before `while` keyword.
return true;
}
const nodeList = get... | javascript | function isLastChild(node) {
const t = node.parent.type;
if (t === "IfStatement" && node.parent.consequent === node && node.parent.alternate) { // before `else` keyword.
return true;
}
if (t === "DoWhileStatement") { // before `while` keyword.
return true;
}
const nodeList = get... | [
"function",
"isLastChild",
"(",
"node",
")",
"{",
"const",
"t",
"=",
"node",
".",
"parent",
".",
"type",
";",
"if",
"(",
"t",
"===",
"\"IfStatement\"",
"&&",
"node",
".",
"parent",
".",
"consequent",
"===",
"node",
"&&",
"node",
".",
"parent",
".",
"... | Check whether a given node is the last statement in the parent block.
@param {Node} node A node to check.
@returns {boolean} `true` if the node is the last statement in the parent block. | [
"Check",
"whether",
"a",
"given",
"node",
"is",
"the",
"last",
"statement",
"in",
"the",
"parent",
"block",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/semi-style.js#L52-L64 |
3,194 | eslint/eslint | lib/rules/semi-style.js | check | function check(semiToken, expected) {
const prevToken = sourceCode.getTokenBefore(semiToken);
const nextToken = sourceCode.getTokenAfter(semiToken);
const prevIsSameLine = !prevToken || astUtils.isTokenOnSameLine(prevToken, semiToken);
const nextIsSameLine = !nextToken ||... | javascript | function check(semiToken, expected) {
const prevToken = sourceCode.getTokenBefore(semiToken);
const nextToken = sourceCode.getTokenAfter(semiToken);
const prevIsSameLine = !prevToken || astUtils.isTokenOnSameLine(prevToken, semiToken);
const nextIsSameLine = !nextToken ||... | [
"function",
"check",
"(",
"semiToken",
",",
"expected",
")",
"{",
"const",
"prevToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"semiToken",
")",
";",
"const",
"nextToken",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"semiToken",
")",
";",
"const",
... | Check the given semicolon token.
@param {Token} semiToken The semicolon token to check.
@param {"first"|"last"} expected The expected location to check.
@returns {void} | [
"Check",
"the",
"given",
"semicolon",
"token",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/semi-style.js#L91-L119 |
3,195 | eslint/eslint | lib/rules/no-extra-parens.js | ruleApplies | function ruleApplies(node) {
if (node.type === "JSXElement" || node.type === "JSXFragment") {
const isSingleLine = node.loc.start.line === node.loc.end.line;
switch (IGNORE_JSX) {
// Exclude this JSX element from linting
case "all":
... | javascript | function ruleApplies(node) {
if (node.type === "JSXElement" || node.type === "JSXFragment") {
const isSingleLine = node.loc.start.line === node.loc.end.line;
switch (IGNORE_JSX) {
// Exclude this JSX element from linting
case "all":
... | [
"function",
"ruleApplies",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"\"JSXElement\"",
"||",
"node",
".",
"type",
"===",
"\"JSXFragment\"",
")",
"{",
"const",
"isSingleLine",
"=",
"node",
".",
"loc",
".",
"start",
".",
"line",
"===",
... | Determines if this rule should be enforced for a node given the current configuration.
@param {ASTNode} node - The node to be checked.
@returns {boolean} True if the rule should be enforced for this node.
@private | [
"Determines",
"if",
"this",
"rule",
"should",
"be",
"enforced",
"for",
"a",
"node",
"given",
"the",
"current",
"configuration",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-parens.js#L90-L117 |
3,196 | eslint/eslint | lib/rules/no-extra-parens.js | isNewExpressionWithParens | function isNewExpressionWithParens(newExpression) {
const lastToken = sourceCode.getLastToken(newExpression);
const penultimateToken = sourceCode.getTokenBefore(lastToken);
return newExpression.arguments.length > 0 || astUtils.isOpeningParenToken(penultimateToken) && astUtils.isClos... | javascript | function isNewExpressionWithParens(newExpression) {
const lastToken = sourceCode.getLastToken(newExpression);
const penultimateToken = sourceCode.getTokenBefore(lastToken);
return newExpression.arguments.length > 0 || astUtils.isOpeningParenToken(penultimateToken) && astUtils.isClos... | [
"function",
"isNewExpressionWithParens",
"(",
"newExpression",
")",
"{",
"const",
"lastToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"newExpression",
")",
";",
"const",
"penultimateToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"lastToken",
")",
";",
... | Determines if a constructor function is newed-up with parens
@param {ASTNode} newExpression - The NewExpression node to be checked.
@returns {boolean} True if the constructor is called with parens.
@private | [
"Determines",
"if",
"a",
"constructor",
"function",
"is",
"newed",
"-",
"up",
"with",
"parens"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-parens.js#L190-L195 |
3,197 | eslint/eslint | lib/rules/no-extra-parens.js | requiresLeadingSpace | function requiresLeadingSpace(node) {
const leftParenToken = sourceCode.getTokenBefore(node);
const tokenBeforeLeftParen = sourceCode.getTokenBefore(node, 1);
const firstToken = sourceCode.getFirstToken(node);
return tokenBeforeLeftParen &&
tokenBeforeLef... | javascript | function requiresLeadingSpace(node) {
const leftParenToken = sourceCode.getTokenBefore(node);
const tokenBeforeLeftParen = sourceCode.getTokenBefore(node, 1);
const firstToken = sourceCode.getFirstToken(node);
return tokenBeforeLeftParen &&
tokenBeforeLef... | [
"function",
"requiresLeadingSpace",
"(",
"node",
")",
"{",
"const",
"leftParenToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"node",
")",
";",
"const",
"tokenBeforeLeftParen",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"node",
",",
"1",
")",
";",
"... | Determines whether a node should be preceded by an additional space when removing parens
@param {ASTNode} node node to evaluate; must be surrounded by parentheses
@returns {boolean} `true` if a space should be inserted before the node
@private | [
"Determines",
"whether",
"a",
"node",
"should",
"be",
"preceded",
"by",
"an",
"additional",
"space",
"when",
"removing",
"parens"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-parens.js#L262-L271 |
3,198 | eslint/eslint | lib/rules/no-extra-parens.js | requiresTrailingSpace | function requiresTrailingSpace(node) {
const nextTwoTokens = sourceCode.getTokensAfter(node, { count: 2 });
const rightParenToken = nextTwoTokens[0];
const tokenAfterRightParen = nextTwoTokens[1];
const tokenBeforeRightParen = sourceCode.getLastToken(node);
r... | javascript | function requiresTrailingSpace(node) {
const nextTwoTokens = sourceCode.getTokensAfter(node, { count: 2 });
const rightParenToken = nextTwoTokens[0];
const tokenAfterRightParen = nextTwoTokens[1];
const tokenBeforeRightParen = sourceCode.getLastToken(node);
r... | [
"function",
"requiresTrailingSpace",
"(",
"node",
")",
"{",
"const",
"nextTwoTokens",
"=",
"sourceCode",
".",
"getTokensAfter",
"(",
"node",
",",
"{",
"count",
":",
"2",
"}",
")",
";",
"const",
"rightParenToken",
"=",
"nextTwoTokens",
"[",
"0",
"]",
";",
"... | Determines whether a node should be followed by an additional space when removing parens
@param {ASTNode} node node to evaluate; must be surrounded by parentheses
@returns {boolean} `true` if a space should be inserted after the node
@private | [
"Determines",
"whether",
"a",
"node",
"should",
"be",
"followed",
"by",
"an",
"additional",
"space",
"when",
"removing",
"parens"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-parens.js#L279-L288 |
3,199 | eslint/eslint | lib/rules/no-extra-parens.js | doesMemberExpressionContainCallExpression | function doesMemberExpressionContainCallExpression(node) {
let currentNode = node.object;
let currentNodeType = node.object.type;
while (currentNodeType === "MemberExpression") {
currentNode = currentNode.object;
currentNodeType = currentNode.type;
... | javascript | function doesMemberExpressionContainCallExpression(node) {
let currentNode = node.object;
let currentNodeType = node.object.type;
while (currentNodeType === "MemberExpression") {
currentNode = currentNode.object;
currentNodeType = currentNode.type;
... | [
"function",
"doesMemberExpressionContainCallExpression",
"(",
"node",
")",
"{",
"let",
"currentNode",
"=",
"node",
".",
"object",
";",
"let",
"currentNodeType",
"=",
"node",
".",
"object",
".",
"type",
";",
"while",
"(",
"currentNodeType",
"===",
"\"MemberExpressi... | Check if a member expression contains a call expression
@param {ASTNode} node MemberExpression node to evaluate
@returns {boolean} true if found, false if not | [
"Check",
"if",
"a",
"member",
"expression",
"contains",
"a",
"call",
"expression"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-parens.js#L355-L365 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.