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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2,800 | eslint/eslint | lib/rules/prefer-arrow-callback.js | checkMetaProperty | function checkMetaProperty(node, metaName, propertyName) {
return node.meta.name === metaName && node.property.name === propertyName;
} | javascript | function checkMetaProperty(node, metaName, propertyName) {
return node.meta.name === metaName && node.property.name === propertyName;
} | [
"function",
"checkMetaProperty",
"(",
"node",
",",
"metaName",
",",
"propertyName",
")",
"{",
"return",
"node",
".",
"meta",
".",
"name",
"===",
"metaName",
"&&",
"node",
".",
"property",
".",
"name",
"===",
"propertyName",
";",
"}"
] | Checks whether or not a given MetaProperty node equals to a given value.
@param {ASTNode} node - A MetaProperty node to check.
@param {string} metaName - The name of `MetaProperty.meta`.
@param {string} propertyName - The name of `MetaProperty.property`.
@returns {boolean} `true` if the node is the specific value. | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"MetaProperty",
"node",
"equals",
"to",
"a",
"given",
"value",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-arrow-callback.js#L28-L30 |
2,801 | eslint/eslint | lib/rules/prefer-arrow-callback.js | getVariableOfArguments | function getVariableOfArguments(scope) {
const variables = scope.variables;
for (let i = 0; i < variables.length; ++i) {
const variable = variables[i];
if (variable.name === "arguments") {
/*
* If there was a parameter which is named "arguments", the
* im... | javascript | function getVariableOfArguments(scope) {
const variables = scope.variables;
for (let i = 0; i < variables.length; ++i) {
const variable = variables[i];
if (variable.name === "arguments") {
/*
* If there was a parameter which is named "arguments", the
* im... | [
"function",
"getVariableOfArguments",
"(",
"scope",
")",
"{",
"const",
"variables",
"=",
"scope",
".",
"variables",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"variables",
".",
"length",
";",
"++",
"i",
")",
"{",
"const",
"variable",
"=",
... | Gets the variable object of `arguments` which is defined implicitly.
@param {eslint-scope.Scope} scope - A scope to get.
@returns {eslint-scope.Variable} The found variable object. | [
"Gets",
"the",
"variable",
"object",
"of",
"arguments",
"which",
"is",
"defined",
"implicitly",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-arrow-callback.js#L37-L56 |
2,802 | eslint/eslint | lib/rules/curly.js | isOneLiner | function isOneLiner(node) {
const first = sourceCode.getFirstToken(node),
last = sourceCode.getLastToken(node);
return first.loc.start.line === last.loc.end.line;
} | javascript | function isOneLiner(node) {
const first = sourceCode.getFirstToken(node),
last = sourceCode.getLastToken(node);
return first.loc.start.line === last.loc.end.line;
} | [
"function",
"isOneLiner",
"(",
"node",
")",
"{",
"const",
"first",
"=",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
")",
",",
"last",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
";",
"return",
"first",
".",
"loc",
".",
"start",
".",
... | Determines if a given node is a one-liner.
@param {ASTNode} node The node to check.
@returns {boolean} True if the node is a one-liner.
@private | [
"Determines",
"if",
"a",
"given",
"node",
"is",
"a",
"one",
"-",
"liner",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/curly.js#L99-L104 |
2,803 | eslint/eslint | lib/rules/curly.js | getElseKeyword | function getElseKeyword(node) {
return node.alternate && sourceCode.getFirstTokenBetween(node.consequent, node.alternate, isElseKeywordToken);
} | javascript | function getElseKeyword(node) {
return node.alternate && sourceCode.getFirstTokenBetween(node.consequent, node.alternate, isElseKeywordToken);
} | [
"function",
"getElseKeyword",
"(",
"node",
")",
"{",
"return",
"node",
".",
"alternate",
"&&",
"sourceCode",
".",
"getFirstTokenBetween",
"(",
"node",
".",
"consequent",
",",
"node",
".",
"alternate",
",",
"isElseKeywordToken",
")",
";",
"}"
] | Gets the `else` keyword token of a given `IfStatement` node.
@param {ASTNode} node - A `IfStatement` node to get.
@returns {Token} The `else` keyword token. | [
"Gets",
"the",
"else",
"keyword",
"token",
"of",
"a",
"given",
"IfStatement",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/curly.js#L121-L123 |
2,804 | eslint/eslint | lib/rules/curly.js | needsSemicolon | function needsSemicolon(closingBracket) {
const tokenBefore = sourceCode.getTokenBefore(closingBracket);
const tokenAfter = sourceCode.getTokenAfter(closingBracket);
const lastBlockNode = sourceCode.getNodeByRangeIndex(tokenBefore.range[0]);
if (astUtils.isSemicolonToken... | javascript | function needsSemicolon(closingBracket) {
const tokenBefore = sourceCode.getTokenBefore(closingBracket);
const tokenAfter = sourceCode.getTokenAfter(closingBracket);
const lastBlockNode = sourceCode.getNodeByRangeIndex(tokenBefore.range[0]);
if (astUtils.isSemicolonToken... | [
"function",
"needsSemicolon",
"(",
"closingBracket",
")",
"{",
"const",
"tokenBefore",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"closingBracket",
")",
";",
"const",
"tokenAfter",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"closingBracket",
")",
";",
"cons... | Determines if a semicolon needs to be inserted after removing a set of curly brackets, in order to avoid a SyntaxError.
@param {Token} closingBracket The } token
@returns {boolean} `true` if a semicolon needs to be inserted after the last statement in the block. | [
"Determines",
"if",
"a",
"semicolon",
"needs",
"to",
"be",
"inserted",
"after",
"removing",
"a",
"set",
"of",
"curly",
"brackets",
"in",
"order",
"to",
"avoid",
"a",
"SyntaxError",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/curly.js#L161-L208 |
2,805 | eslint/eslint | lib/rules/curly.js | prepareCheck | function prepareCheck(node, body, name, opts) {
const hasBlock = (body.type === "BlockStatement");
let expected = null;
if (node.type === "IfStatement" && node.consequent === body && requiresBraceOfConsequent(node)) {
expected = true;
} else if (multiOnly... | javascript | function prepareCheck(node, body, name, opts) {
const hasBlock = (body.type === "BlockStatement");
let expected = null;
if (node.type === "IfStatement" && node.consequent === body && requiresBraceOfConsequent(node)) {
expected = true;
} else if (multiOnly... | [
"function",
"prepareCheck",
"(",
"node",
",",
"body",
",",
"name",
",",
"opts",
")",
"{",
"const",
"hasBlock",
"=",
"(",
"body",
".",
"type",
"===",
"\"BlockStatement\"",
")",
";",
"let",
"expected",
"=",
"null",
";",
"if",
"(",
"node",
".",
"type",
... | Prepares to check the body of a node to see if it's a block statement.
@param {ASTNode} node The node to report if there's a problem.
@param {ASTNode} body The body node to check for blocks.
@param {string} name The name to report if there's a problem.
@param {{ condition: boolean }} opts Options to pass to the report ... | [
"Prepares",
"to",
"check",
"the",
"body",
"of",
"a",
"node",
"to",
"see",
"if",
"it",
"s",
"a",
"block",
"statement",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/curly.js#L224-L307 |
2,806 | eslint/eslint | lib/rules/curly.js | prepareIfChecks | function prepareIfChecks(node) {
const preparedChecks = [];
for (let currentNode = node; currentNode; currentNode = currentNode.alternate) {
preparedChecks.push(prepareCheck(currentNode, currentNode.consequent, "if", { condition: true }));
if (currentNode.alterna... | javascript | function prepareIfChecks(node) {
const preparedChecks = [];
for (let currentNode = node; currentNode; currentNode = currentNode.alternate) {
preparedChecks.push(prepareCheck(currentNode, currentNode.consequent, "if", { condition: true }));
if (currentNode.alterna... | [
"function",
"prepareIfChecks",
"(",
"node",
")",
"{",
"const",
"preparedChecks",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"currentNode",
"=",
"node",
";",
"currentNode",
";",
"currentNode",
"=",
"currentNode",
".",
"alternate",
")",
"{",
"preparedChecks",
".",... | Prepares to check the bodies of a "if", "else if" and "else" chain.
@param {ASTNode} node The first IfStatement node of the chain.
@returns {Object[]} prepared checks for each body of the chain. See `prepareCheck` for more
information. | [
"Prepares",
"to",
"check",
"the",
"bodies",
"of",
"a",
"if",
"else",
"if",
"and",
"else",
"chain",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/curly.js#L315-L346 |
2,807 | eslint/eslint | lib/rules/lines-around-comment.js | getCommentLineNums | function getCommentLineNums(comments) {
const lines = [];
comments.forEach(token => {
const start = token.loc.start.line;
const end = token.loc.end.line;
lines.push(start, end);
});
return lines;
} | javascript | function getCommentLineNums(comments) {
const lines = [];
comments.forEach(token => {
const start = token.loc.start.line;
const end = token.loc.end.line;
lines.push(start, end);
});
return lines;
} | [
"function",
"getCommentLineNums",
"(",
"comments",
")",
"{",
"const",
"lines",
"=",
"[",
"]",
";",
"comments",
".",
"forEach",
"(",
"token",
"=>",
"{",
"const",
"start",
"=",
"token",
".",
"loc",
".",
"start",
".",
"line",
";",
"const",
"end",
"=",
"... | Return an array with with any line numbers that contain comments.
@param {Array} comments An array of comment tokens.
@returns {Array} An array of line numbers. | [
"Return",
"an",
"array",
"with",
"with",
"any",
"line",
"numbers",
"that",
"contain",
"comments",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-comment.js#L37-L47 |
2,808 | eslint/eslint | lib/rules/lines-around-comment.js | codeAroundComment | function codeAroundComment(token) {
let currentToken = token;
do {
currentToken = sourceCode.getTokenBefore(currentToken, { includeComments: true });
} while (currentToken && astUtils.isCommentToken(currentToken));
if (currentToken && astUtils.isTokenOnS... | javascript | function codeAroundComment(token) {
let currentToken = token;
do {
currentToken = sourceCode.getTokenBefore(currentToken, { includeComments: true });
} while (currentToken && astUtils.isCommentToken(currentToken));
if (currentToken && astUtils.isTokenOnS... | [
"function",
"codeAroundComment",
"(",
"token",
")",
"{",
"let",
"currentToken",
"=",
"token",
";",
"do",
"{",
"currentToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"currentToken",
",",
"{",
"includeComments",
":",
"true",
"}",
")",
";",
"}",
"while"... | Returns whether or not comments are on lines starting with or ending with code
@param {token} token The comment token to check.
@returns {boolean} True if the comment is not alone. | [
"Returns",
"whether",
"or",
"not",
"comments",
"are",
"on",
"lines",
"starting",
"with",
"or",
"ending",
"with",
"code"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-comment.js#L152-L173 |
2,809 | eslint/eslint | lib/rules/lines-around-comment.js | isParentNodeType | function isParentNodeType(parent, nodeType) {
return parent.type === nodeType ||
(parent.body && parent.body.type === nodeType) ||
(parent.consequent && parent.consequent.type === nodeType);
} | javascript | function isParentNodeType(parent, nodeType) {
return parent.type === nodeType ||
(parent.body && parent.body.type === nodeType) ||
(parent.consequent && parent.consequent.type === nodeType);
} | [
"function",
"isParentNodeType",
"(",
"parent",
",",
"nodeType",
")",
"{",
"return",
"parent",
".",
"type",
"===",
"nodeType",
"||",
"(",
"parent",
".",
"body",
"&&",
"parent",
".",
"body",
".",
"type",
"===",
"nodeType",
")",
"||",
"(",
"parent",
".",
... | Returns whether or not comments are inside a node type or not.
@param {ASTNode} parent The Comment parent node.
@param {string} nodeType The parent type to check against.
@returns {boolean} True if the comment is inside nodeType. | [
"Returns",
"whether",
"or",
"not",
"comments",
"are",
"inside",
"a",
"node",
"type",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-comment.js#L181-L185 |
2,810 | eslint/eslint | lib/rules/lines-around-comment.js | isCommentAtParentStart | function isCommentAtParentStart(token, nodeType) {
const parent = getParentNodeOfToken(token);
return parent && isParentNodeType(parent, nodeType) &&
token.loc.start.line - parent.loc.start.line === 1;
} | javascript | function isCommentAtParentStart(token, nodeType) {
const parent = getParentNodeOfToken(token);
return parent && isParentNodeType(parent, nodeType) &&
token.loc.start.line - parent.loc.start.line === 1;
} | [
"function",
"isCommentAtParentStart",
"(",
"token",
",",
"nodeType",
")",
"{",
"const",
"parent",
"=",
"getParentNodeOfToken",
"(",
"token",
")",
";",
"return",
"parent",
"&&",
"isParentNodeType",
"(",
"parent",
",",
"nodeType",
")",
"&&",
"token",
".",
"loc",... | Returns whether or not comments are at the parent start or not.
@param {token} token The Comment token.
@param {string} nodeType The parent type to check against.
@returns {boolean} True if the comment is at parent start. | [
"Returns",
"whether",
"or",
"not",
"comments",
"are",
"at",
"the",
"parent",
"start",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-comment.js#L202-L207 |
2,811 | eslint/eslint | lib/rules/lines-around-comment.js | isCommentAtParentEnd | function isCommentAtParentEnd(token, nodeType) {
const parent = getParentNodeOfToken(token);
return parent && isParentNodeType(parent, nodeType) &&
parent.loc.end.line - token.loc.end.line === 1;
} | javascript | function isCommentAtParentEnd(token, nodeType) {
const parent = getParentNodeOfToken(token);
return parent && isParentNodeType(parent, nodeType) &&
parent.loc.end.line - token.loc.end.line === 1;
} | [
"function",
"isCommentAtParentEnd",
"(",
"token",
",",
"nodeType",
")",
"{",
"const",
"parent",
"=",
"getParentNodeOfToken",
"(",
"token",
")",
";",
"return",
"parent",
"&&",
"isParentNodeType",
"(",
"parent",
",",
"nodeType",
")",
"&&",
"parent",
".",
"loc",
... | Returns whether or not comments are at the parent end or not.
@param {token} token The Comment token.
@param {string} nodeType The parent type to check against.
@returns {boolean} True if the comment is at parent end. | [
"Returns",
"whether",
"or",
"not",
"comments",
"are",
"at",
"the",
"parent",
"end",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-comment.js#L215-L220 |
2,812 | eslint/eslint | lib/rules/lines-around-comment.js | isCommentAtBlockEnd | function isCommentAtBlockEnd(token) {
return isCommentAtParentEnd(token, "ClassBody") || isCommentAtParentEnd(token, "BlockStatement") || isCommentAtParentEnd(token, "SwitchCase") || isCommentAtParentEnd(token, "SwitchStatement");
} | javascript | function isCommentAtBlockEnd(token) {
return isCommentAtParentEnd(token, "ClassBody") || isCommentAtParentEnd(token, "BlockStatement") || isCommentAtParentEnd(token, "SwitchCase") || isCommentAtParentEnd(token, "SwitchStatement");
} | [
"function",
"isCommentAtBlockEnd",
"(",
"token",
")",
"{",
"return",
"isCommentAtParentEnd",
"(",
"token",
",",
"\"ClassBody\"",
")",
"||",
"isCommentAtParentEnd",
"(",
"token",
",",
"\"BlockStatement\"",
")",
"||",
"isCommentAtParentEnd",
"(",
"token",
",",
"\"Swit... | Returns whether or not comments are at the block end or not.
@param {token} token The Comment token.
@returns {boolean} True if the comment is at block end. | [
"Returns",
"whether",
"or",
"not",
"comments",
"are",
"at",
"the",
"block",
"end",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-comment.js#L236-L238 |
2,813 | eslint/eslint | lib/rules/no-extra-semi.js | report | function report(nodeOrToken) {
context.report({
node: nodeOrToken,
messageId: "unexpected",
fix(fixer) {
/*
* Expand the replacement range to include the surrounding
* tokens to avoid conflicting w... | javascript | function report(nodeOrToken) {
context.report({
node: nodeOrToken,
messageId: "unexpected",
fix(fixer) {
/*
* Expand the replacement range to include the surrounding
* tokens to avoid conflicting w... | [
"function",
"report",
"(",
"nodeOrToken",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
":",
"nodeOrToken",
",",
"messageId",
":",
"\"unexpected\"",
",",
"fix",
"(",
"fixer",
")",
"{",
"/*\n * Expand the replacement range to include the sur... | Reports an unnecessary semicolon error.
@param {Node|Token} nodeOrToken - A node or a token to be reported.
@returns {void} | [
"Reports",
"an",
"unnecessary",
"semicolon",
"error",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-semi.js#L46-L62 |
2,814 | eslint/eslint | lib/rules/no-extra-semi.js | checkForPartOfClassBody | function checkForPartOfClassBody(firstToken) {
for (let token = firstToken;
token.type === "Punctuator" && !astUtils.isClosingBraceToken(token);
token = sourceCode.getTokenAfter(token)
) {
if (astUtils.isSemicolonToken(token)) {
... | javascript | function checkForPartOfClassBody(firstToken) {
for (let token = firstToken;
token.type === "Punctuator" && !astUtils.isClosingBraceToken(token);
token = sourceCode.getTokenAfter(token)
) {
if (astUtils.isSemicolonToken(token)) {
... | [
"function",
"checkForPartOfClassBody",
"(",
"firstToken",
")",
"{",
"for",
"(",
"let",
"token",
"=",
"firstToken",
";",
"token",
".",
"type",
"===",
"\"Punctuator\"",
"&&",
"!",
"astUtils",
".",
"isClosingBraceToken",
"(",
"token",
")",
";",
"token",
"=",
"s... | Checks for a part of a class body.
This checks tokens from a specified token to a next MethodDefinition or the end of class body.
@param {Token} firstToken - The first token to check.
@returns {void} | [
"Checks",
"for",
"a",
"part",
"of",
"a",
"class",
"body",
".",
"This",
"checks",
"tokens",
"from",
"a",
"specified",
"token",
"to",
"a",
"next",
"MethodDefinition",
"or",
"the",
"end",
"of",
"class",
"body",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-semi.js#L71-L80 |
2,815 | eslint/eslint | lib/rules/sort-imports.js | usedMemberSyntax | function usedMemberSyntax(node) {
if (node.specifiers.length === 0) {
return "none";
}
if (node.specifiers[0].type === "ImportNamespaceSpecifier") {
return "all";
}
if (node.specifiers.length === 1) {
return "sin... | javascript | function usedMemberSyntax(node) {
if (node.specifiers.length === 0) {
return "none";
}
if (node.specifiers[0].type === "ImportNamespaceSpecifier") {
return "all";
}
if (node.specifiers.length === 1) {
return "sin... | [
"function",
"usedMemberSyntax",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"specifiers",
".",
"length",
"===",
"0",
")",
"{",
"return",
"\"none\"",
";",
"}",
"if",
"(",
"node",
".",
"specifiers",
"[",
"0",
"]",
".",
"type",
"===",
"\"ImportNamespac... | Gets the used member syntax style.
import "my-module.js" --> none
import * as myModule from "my-module.js" --> all
import {myMember} from "my-module.js" --> single
import {foo, bar} from "my-module.js" --> multiple
@param {ASTNode} node - the ImportDeclaration node.
@returns {string} used member parameter style, ["a... | [
"Gets",
"the",
"used",
"member",
"syntax",
"style",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/sort-imports.js#L77-L89 |
2,816 | eslint/eslint | lib/rules/newline-after-var.js | isLastNode | function isLastNode(node) {
const token = sourceCode.getTokenAfter(node);
return !token || (token.type === "Punctuator" && token.value === "}");
} | javascript | function isLastNode(node) {
const token = sourceCode.getTokenAfter(node);
return !token || (token.type === "Punctuator" && token.value === "}");
} | [
"function",
"isLastNode",
"(",
"node",
")",
"{",
"const",
"token",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"node",
")",
";",
"return",
"!",
"token",
"||",
"(",
"token",
".",
"type",
"===",
"\"Punctuator\"",
"&&",
"token",
".",
"value",
"===",
"\"}\... | Determine if provided node is the last of their parent block.
@private
@param {ASTNode} node - node to test
@returns {boolean} True if `node` is last of their parent block. | [
"Determine",
"if",
"provided",
"node",
"is",
"the",
"last",
"of",
"their",
"parent",
"block",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/newline-after-var.js#L130-L134 |
2,817 | eslint/eslint | lib/rules/newline-after-var.js | getLastCommentLineOfBlock | function getLastCommentLineOfBlock(commentStartLine) {
const currentCommentEnd = commentEndLine[commentStartLine];
return commentEndLine[currentCommentEnd + 1] ? getLastCommentLineOfBlock(currentCommentEnd + 1) : currentCommentEnd;
} | javascript | function getLastCommentLineOfBlock(commentStartLine) {
const currentCommentEnd = commentEndLine[commentStartLine];
return commentEndLine[currentCommentEnd + 1] ? getLastCommentLineOfBlock(currentCommentEnd + 1) : currentCommentEnd;
} | [
"function",
"getLastCommentLineOfBlock",
"(",
"commentStartLine",
")",
"{",
"const",
"currentCommentEnd",
"=",
"commentEndLine",
"[",
"commentStartLine",
"]",
";",
"return",
"commentEndLine",
"[",
"currentCommentEnd",
"+",
"1",
"]",
"?",
"getLastCommentLineOfBlock",
"("... | Gets the last line of a group of consecutive comments
@param {number} commentStartLine The starting line of the group
@returns {number} The number of the last comment line of the group | [
"Gets",
"the",
"last",
"line",
"of",
"a",
"group",
"of",
"consecutive",
"comments"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/newline-after-var.js#L141-L145 |
2,818 | eslint/eslint | lib/rules/newline-after-var.js | checkForBlankLine | function checkForBlankLine(node) {
/*
* lastToken is the last token on the node's line. It will usually also be the last token of the node, but it will
* sometimes be second-last if there is a semicolon on a different line.
*/
const lastToken = getLastToke... | javascript | function checkForBlankLine(node) {
/*
* lastToken is the last token on the node's line. It will usually also be the last token of the node, but it will
* sometimes be second-last if there is a semicolon on a different line.
*/
const lastToken = getLastToke... | [
"function",
"checkForBlankLine",
"(",
"node",
")",
"{",
"/*\n * lastToken is the last token on the node's line. It will usually also be the last token of the node, but it will\n * sometimes be second-last if there is a semicolon on a different line.\n */",
"const",
... | Checks that a blank line exists after a variable declaration when mode is
set to "always", or checks that there is no blank line when mode is set
to "never"
@private
@param {ASTNode} node - `VariableDeclaration` node to test
@returns {void} | [
"Checks",
"that",
"a",
"blank",
"line",
"exists",
"after",
"a",
"variable",
"declaration",
"when",
"mode",
"is",
"set",
"to",
"always",
"or",
"checks",
"that",
"there",
"is",
"no",
"blank",
"line",
"when",
"mode",
"is",
"set",
"to",
"never"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/newline-after-var.js#L165-L245 |
2,819 | eslint/eslint | tools/internal-rules/no-invalid-meta.js | hasMetaDocsDescription | function hasMetaDocsDescription(metaPropertyNode) {
const metaDocs = getPropertyFromObject("docs", metaPropertyNode.value);
return metaDocs && getPropertyFromObject("description", metaDocs.value);
} | javascript | function hasMetaDocsDescription(metaPropertyNode) {
const metaDocs = getPropertyFromObject("docs", metaPropertyNode.value);
return metaDocs && getPropertyFromObject("description", metaDocs.value);
} | [
"function",
"hasMetaDocsDescription",
"(",
"metaPropertyNode",
")",
"{",
"const",
"metaDocs",
"=",
"getPropertyFromObject",
"(",
"\"docs\"",
",",
"metaPropertyNode",
".",
"value",
")",
";",
"return",
"metaDocs",
"&&",
"getPropertyFromObject",
"(",
"\"description\"",
"... | Whether this `meta` ObjectExpression has a `docs.description` property defined or not.
@param {ASTNode} metaPropertyNode The `meta` ObjectExpression for this rule.
@returns {boolean} `true` if a `docs.description` property exists. | [
"Whether",
"this",
"meta",
"ObjectExpression",
"has",
"a",
"docs",
".",
"description",
"property",
"defined",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/tools/internal-rules/no-invalid-meta.js#L62-L66 |
2,820 | eslint/eslint | tools/internal-rules/no-invalid-meta.js | hasMetaDocsCategory | function hasMetaDocsCategory(metaPropertyNode) {
const metaDocs = getPropertyFromObject("docs", metaPropertyNode.value);
return metaDocs && getPropertyFromObject("category", metaDocs.value);
} | javascript | function hasMetaDocsCategory(metaPropertyNode) {
const metaDocs = getPropertyFromObject("docs", metaPropertyNode.value);
return metaDocs && getPropertyFromObject("category", metaDocs.value);
} | [
"function",
"hasMetaDocsCategory",
"(",
"metaPropertyNode",
")",
"{",
"const",
"metaDocs",
"=",
"getPropertyFromObject",
"(",
"\"docs\"",
",",
"metaPropertyNode",
".",
"value",
")",
";",
"return",
"metaDocs",
"&&",
"getPropertyFromObject",
"(",
"\"category\"",
",",
... | Whether this `meta` ObjectExpression has a `docs.category` property defined or not.
@param {ASTNode} metaPropertyNode The `meta` ObjectExpression for this rule.
@returns {boolean} `true` if a `docs.category` property exists. | [
"Whether",
"this",
"meta",
"ObjectExpression",
"has",
"a",
"docs",
".",
"category",
"property",
"defined",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/tools/internal-rules/no-invalid-meta.js#L74-L78 |
2,821 | eslint/eslint | tools/internal-rules/no-invalid-meta.js | hasMetaDocsRecommended | function hasMetaDocsRecommended(metaPropertyNode) {
const metaDocs = getPropertyFromObject("docs", metaPropertyNode.value);
return metaDocs && getPropertyFromObject("recommended", metaDocs.value);
} | javascript | function hasMetaDocsRecommended(metaPropertyNode) {
const metaDocs = getPropertyFromObject("docs", metaPropertyNode.value);
return metaDocs && getPropertyFromObject("recommended", metaDocs.value);
} | [
"function",
"hasMetaDocsRecommended",
"(",
"metaPropertyNode",
")",
"{",
"const",
"metaDocs",
"=",
"getPropertyFromObject",
"(",
"\"docs\"",
",",
"metaPropertyNode",
".",
"value",
")",
";",
"return",
"metaDocs",
"&&",
"getPropertyFromObject",
"(",
"\"recommended\"",
"... | Whether this `meta` ObjectExpression has a `docs.recommended` property defined or not.
@param {ASTNode} metaPropertyNode The `meta` ObjectExpression for this rule.
@returns {boolean} `true` if a `docs.recommended` property exists. | [
"Whether",
"this",
"meta",
"ObjectExpression",
"has",
"a",
"docs",
".",
"recommended",
"property",
"defined",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/tools/internal-rules/no-invalid-meta.js#L86-L90 |
2,822 | eslint/eslint | lib/rules/space-infix-ops.js | getFirstNonSpacedToken | function getFirstNonSpacedToken(left, right, op) {
const operator = sourceCode.getFirstTokenBetween(left, right, token => token.value === op);
const prev = sourceCode.getTokenBefore(operator);
const next = sourceCode.getTokenAfter(operator);
if (!sourceCode.isSpaceBetwee... | javascript | function getFirstNonSpacedToken(left, right, op) {
const operator = sourceCode.getFirstTokenBetween(left, right, token => token.value === op);
const prev = sourceCode.getTokenBefore(operator);
const next = sourceCode.getTokenAfter(operator);
if (!sourceCode.isSpaceBetwee... | [
"function",
"getFirstNonSpacedToken",
"(",
"left",
",",
"right",
",",
"op",
")",
"{",
"const",
"operator",
"=",
"sourceCode",
".",
"getFirstTokenBetween",
"(",
"left",
",",
"right",
",",
"token",
"=>",
"token",
".",
"value",
"===",
"op",
")",
";",
"const",... | Returns the first token which violates the rule
@param {ASTNode} left - The left node of the main node
@param {ASTNode} right - The right node of the main node
@param {string} op - The operator of the main node
@returns {Object} The violator token or null
@private | [
"Returns",
"the",
"first",
"token",
"which",
"violates",
"the",
"rule"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-infix-ops.js#L50-L60 |
2,823 | eslint/eslint | lib/rules/space-infix-ops.js | checkBinary | function checkBinary(node) {
const leftNode = (node.left.typeAnnotation) ? node.left.typeAnnotation : node.left;
const rightNode = node.right;
// search for = in AssignmentPattern nodes
const operator = node.operator || "=";
const nonSpacedNode = getFirstNon... | javascript | function checkBinary(node) {
const leftNode = (node.left.typeAnnotation) ? node.left.typeAnnotation : node.left;
const rightNode = node.right;
// search for = in AssignmentPattern nodes
const operator = node.operator || "=";
const nonSpacedNode = getFirstNon... | [
"function",
"checkBinary",
"(",
"node",
")",
"{",
"const",
"leftNode",
"=",
"(",
"node",
".",
"left",
".",
"typeAnnotation",
")",
"?",
"node",
".",
"left",
".",
"typeAnnotation",
":",
"node",
".",
"left",
";",
"const",
"rightNode",
"=",
"node",
".",
"r... | Check if the node is binary then report
@param {ASTNode} node node to evaluate
@returns {void}
@private | [
"Check",
"if",
"the",
"node",
"is",
"binary",
"then",
"report"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-infix-ops.js#L103-L117 |
2,824 | eslint/eslint | lib/rules/space-infix-ops.js | checkConditional | function checkConditional(node) {
const nonSpacedConsequesntNode = getFirstNonSpacedToken(node.test, node.consequent, "?");
const nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":");
if (nonSpacedConsequesntNode) {
report(node, nonSp... | javascript | function checkConditional(node) {
const nonSpacedConsequesntNode = getFirstNonSpacedToken(node.test, node.consequent, "?");
const nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":");
if (nonSpacedConsequesntNode) {
report(node, nonSp... | [
"function",
"checkConditional",
"(",
"node",
")",
"{",
"const",
"nonSpacedConsequesntNode",
"=",
"getFirstNonSpacedToken",
"(",
"node",
".",
"test",
",",
"node",
".",
"consequent",
",",
"\"?\"",
")",
";",
"const",
"nonSpacedAlternateNode",
"=",
"getFirstNonSpacedTok... | Check if the node is conditional
@param {ASTNode} node node to evaluate
@returns {void}
@private | [
"Check",
"if",
"the",
"node",
"is",
"conditional"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-infix-ops.js#L125-L134 |
2,825 | eslint/eslint | lib/rules/space-infix-ops.js | checkVar | function checkVar(node) {
const leftNode = (node.id.typeAnnotation) ? node.id.typeAnnotation : node.id;
const rightNode = node.init;
if (rightNode) {
const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, "=");
if (nonSpacedNode) {
... | javascript | function checkVar(node) {
const leftNode = (node.id.typeAnnotation) ? node.id.typeAnnotation : node.id;
const rightNode = node.init;
if (rightNode) {
const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, "=");
if (nonSpacedNode) {
... | [
"function",
"checkVar",
"(",
"node",
")",
"{",
"const",
"leftNode",
"=",
"(",
"node",
".",
"id",
".",
"typeAnnotation",
")",
"?",
"node",
".",
"id",
".",
"typeAnnotation",
":",
"node",
".",
"id",
";",
"const",
"rightNode",
"=",
"node",
".",
"init",
"... | Check if the node is a variable
@param {ASTNode} node node to evaluate
@returns {void}
@private | [
"Check",
"if",
"the",
"node",
"is",
"a",
"variable"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-infix-ops.js#L142-L153 |
2,826 | eslint/eslint | lib/rules/no-unmodified-loop-condition.js | isInRange | function isInRange(node, reference) {
const or = node.range;
const ir = reference.identifier.range;
return or[0] <= ir[0] && ir[1] <= or[1];
} | javascript | function isInRange(node, reference) {
const or = node.range;
const ir = reference.identifier.range;
return or[0] <= ir[0] && ir[1] <= or[1];
} | [
"function",
"isInRange",
"(",
"node",
",",
"reference",
")",
"{",
"const",
"or",
"=",
"node",
".",
"range",
";",
"const",
"ir",
"=",
"reference",
".",
"identifier",
".",
"range",
";",
"return",
"or",
"[",
"0",
"]",
"<=",
"ir",
"[",
"0",
"]",
"&&",
... | Checks whether or not a given reference is inside of a given node.
@param {ASTNode} node - A node to check.
@param {eslint-scope.Reference} reference - A reference to check.
@returns {boolean} `true` if the reference is inside of the node. | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"reference",
"is",
"inside",
"of",
"a",
"given",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unmodified-loop-condition.js#L82-L87 |
2,827 | eslint/eslint | lib/rules/no-unmodified-loop-condition.js | getEncloseFunctionDeclaration | function getEncloseFunctionDeclaration(reference) {
let node = reference.identifier;
while (node) {
if (node.type === "FunctionDeclaration") {
return node.id ? node : null;
}
node = node.parent;
}
return null;
} | javascript | function getEncloseFunctionDeclaration(reference) {
let node = reference.identifier;
while (node) {
if (node.type === "FunctionDeclaration") {
return node.id ? node : null;
}
node = node.parent;
}
return null;
} | [
"function",
"getEncloseFunctionDeclaration",
"(",
"reference",
")",
"{",
"let",
"node",
"=",
"reference",
".",
"identifier",
";",
"while",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"\"FunctionDeclaration\"",
")",
"{",
"return",
"node",
".... | Gets the function which encloses a given reference.
This supports only FunctionDeclaration.
@param {eslint-scope.Reference} reference - A reference to get.
@returns {ASTNode|null} The function node or null. | [
"Gets",
"the",
"function",
"which",
"encloses",
"a",
"given",
"reference",
".",
"This",
"supports",
"only",
"FunctionDeclaration",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unmodified-loop-condition.js#L115-L127 |
2,828 | eslint/eslint | lib/rules/no-unmodified-loop-condition.js | updateModifiedFlag | function updateModifiedFlag(conditions, modifiers) {
for (let i = 0; i < conditions.length; ++i) {
const condition = conditions[i];
for (let j = 0; !condition.modified && j < modifiers.length; ++j) {
const modifier = modifiers[j];
let funcNode, funcVar;
/*
... | javascript | function updateModifiedFlag(conditions, modifiers) {
for (let i = 0; i < conditions.length; ++i) {
const condition = conditions[i];
for (let j = 0; !condition.modified && j < modifiers.length; ++j) {
const modifier = modifiers[j];
let funcNode, funcVar;
/*
... | [
"function",
"updateModifiedFlag",
"(",
"conditions",
",",
"modifiers",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"conditions",
".",
"length",
";",
"++",
"i",
")",
"{",
"const",
"condition",
"=",
"conditions",
"[",
"i",
"]",
";",
"for... | Updates the "modified" flags of given loop conditions with given modifiers.
@param {LoopConditionInfo[]} conditions - The loop conditions to be updated.
@param {eslint-scope.Reference[]} modifiers - The references to update.
@returns {void} | [
"Updates",
"the",
"modified",
"flags",
"of",
"given",
"loop",
"conditions",
"with",
"given",
"modifiers",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unmodified-loop-condition.js#L136-L160 |
2,829 | eslint/eslint | lib/rules/no-unmodified-loop-condition.js | report | function report(condition) {
const node = condition.reference.identifier;
context.report({
node,
message: "'{{name}}' is not modified in this loop.",
data: node
});
} | javascript | function report(condition) {
const node = condition.reference.identifier;
context.report({
node,
message: "'{{name}}' is not modified in this loop.",
data: node
});
} | [
"function",
"report",
"(",
"condition",
")",
"{",
"const",
"node",
"=",
"condition",
".",
"reference",
".",
"identifier",
";",
"context",
".",
"report",
"(",
"{",
"node",
",",
"message",
":",
"\"'{{name}}' is not modified in this loop.\"",
",",
"data",
":",
"n... | Reports a given condition info.
@param {LoopConditionInfo} condition - A loop condition info to report.
@returns {void} | [
"Reports",
"a",
"given",
"condition",
"info",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unmodified-loop-condition.js#L190-L198 |
2,830 | eslint/eslint | lib/rules/no-unmodified-loop-condition.js | registerConditionsToGroup | function registerConditionsToGroup(conditions) {
for (let i = 0; i < conditions.length; ++i) {
const condition = conditions[i];
if (condition.group) {
let group = groupMap.get(condition.group);
if (!group) {
gr... | javascript | function registerConditionsToGroup(conditions) {
for (let i = 0; i < conditions.length; ++i) {
const condition = conditions[i];
if (condition.group) {
let group = groupMap.get(condition.group);
if (!group) {
gr... | [
"function",
"registerConditionsToGroup",
"(",
"conditions",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"conditions",
".",
"length",
";",
"++",
"i",
")",
"{",
"const",
"condition",
"=",
"conditions",
"[",
"i",
"]",
";",
"if",
"(",
"con... | Registers given conditions to the group the condition belongs to.
@param {LoopConditionInfo[]} conditions - A loop condition info to
register.
@returns {void} | [
"Registers",
"given",
"conditions",
"to",
"the",
"group",
"the",
"condition",
"belongs",
"to",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unmodified-loop-condition.js#L207-L221 |
2,831 | eslint/eslint | lib/rules/no-unmodified-loop-condition.js | hasDynamicExpressions | function hasDynamicExpressions(root) {
let retv = false;
Traverser.traverse(root, {
visitorKeys: sourceCode.visitorKeys,
enter(node) {
if (DYNAMIC_PATTERN.test(node.type)) {
retv = true;
this.bre... | javascript | function hasDynamicExpressions(root) {
let retv = false;
Traverser.traverse(root, {
visitorKeys: sourceCode.visitorKeys,
enter(node) {
if (DYNAMIC_PATTERN.test(node.type)) {
retv = true;
this.bre... | [
"function",
"hasDynamicExpressions",
"(",
"root",
")",
"{",
"let",
"retv",
"=",
"false",
";",
"Traverser",
".",
"traverse",
"(",
"root",
",",
"{",
"visitorKeys",
":",
"sourceCode",
".",
"visitorKeys",
",",
"enter",
"(",
"node",
")",
"{",
"if",
"(",
"DYNA... | Checks whether or not a given group node has any dynamic elements.
@param {ASTNode} root - A node to check.
This node is one of BinaryExpression or ConditionalExpression.
@returns {boolean} `true` if the node is dynamic. | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"group",
"node",
"has",
"any",
"dynamic",
"elements",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unmodified-loop-condition.js#L242-L258 |
2,832 | eslint/eslint | lib/rules/no-unmodified-loop-condition.js | toLoopCondition | function toLoopCondition(reference) {
if (reference.init) {
return null;
}
let group = null;
let child = reference.identifier;
let node = child.parent;
while (node) {
if (SENTINEL_PATTERN.test(node.type)) {
... | javascript | function toLoopCondition(reference) {
if (reference.init) {
return null;
}
let group = null;
let child = reference.identifier;
let node = child.parent;
while (node) {
if (SENTINEL_PATTERN.test(node.type)) {
... | [
"function",
"toLoopCondition",
"(",
"reference",
")",
"{",
"if",
"(",
"reference",
".",
"init",
")",
"{",
"return",
"null",
";",
"}",
"let",
"group",
"=",
"null",
";",
"let",
"child",
"=",
"reference",
".",
"identifier",
";",
"let",
"node",
"=",
"child... | Creates the loop condition information from a given reference.
@param {eslint-scope.Reference} reference - A reference to create.
@returns {LoopConditionInfo|null} Created loop condition info, or null. | [
"Creates",
"the",
"loop",
"condition",
"information",
"from",
"a",
"given",
"reference",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unmodified-loop-condition.js#L266-L311 |
2,833 | eslint/eslint | lib/rules/no-unmodified-loop-condition.js | checkReferences | function checkReferences(variable) {
// Gets references that exist in loop conditions.
const conditions = variable
.references
.map(toLoopCondition)
.filter(Boolean);
if (conditions.length === 0) {
return;
... | javascript | function checkReferences(variable) {
// Gets references that exist in loop conditions.
const conditions = variable
.references
.map(toLoopCondition)
.filter(Boolean);
if (conditions.length === 0) {
return;
... | [
"function",
"checkReferences",
"(",
"variable",
")",
"{",
"// Gets references that exist in loop conditions.",
"const",
"conditions",
"=",
"variable",
".",
"references",
".",
"map",
"(",
"toLoopCondition",
")",
".",
"filter",
"(",
"Boolean",
")",
";",
"if",
"(",
"... | Finds unmodified references which are inside of a loop condition.
Then reports the references which are outside of groups.
@param {eslint-scope.Variable} variable - A variable to report.
@returns {void} | [
"Finds",
"unmodified",
"references",
"which",
"are",
"inside",
"of",
"a",
"loop",
"condition",
".",
"Then",
"reports",
"the",
"references",
"which",
"are",
"outside",
"of",
"groups",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unmodified-loop-condition.js#L320-L349 |
2,834 | eslint/eslint | lib/util/timing.js | time | function time(key, fn) {
if (typeof data[key] === "undefined") {
data[key] = 0;
}
return function(...args) {
let t = process.hrtime();
fn(...args);
t = process.hrtime(t);
data[key] += t[0] * 1e3 + t[1] / 1e6;
};
} | javascript | function time(key, fn) {
if (typeof data[key] === "undefined") {
data[key] = 0;
}
return function(...args) {
let t = process.hrtime();
fn(...args);
t = process.hrtime(t);
data[key] += t[0] * 1e3 + t[1] / 1e6;
};
} | [
"function",
"time",
"(",
"key",
",",
"fn",
")",
"{",
"if",
"(",
"typeof",
"data",
"[",
"key",
"]",
"===",
"\"undefined\"",
")",
"{",
"data",
"[",
"key",
"]",
"=",
"0",
";",
"}",
"return",
"function",
"(",
"...",
"args",
")",
"{",
"let",
"t",
"=... | Time the run
@param {*} key key from the data object
@param {Function} fn function to be called
@returns {Function} function to be executed
@private | [
"Time",
"the",
"run"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/timing.js#L114-L126 |
2,835 | eslint/eslint | lib/rules/func-names.js | getConfigForNode | function getConfigForNode(node) {
if (
node.generator &&
context.options.length > 1 &&
context.options[1].generators
) {
return context.options[1].generators;
}
return context.options[0] || "always";
... | javascript | function getConfigForNode(node) {
if (
node.generator &&
context.options.length > 1 &&
context.options[1].generators
) {
return context.options[1].generators;
}
return context.options[0] || "always";
... | [
"function",
"getConfigForNode",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"generator",
"&&",
"context",
".",
"options",
".",
"length",
">",
"1",
"&&",
"context",
".",
"options",
"[",
"1",
"]",
".",
"generators",
")",
"{",
"return",
"context",
".",... | Returns the config option for the given node.
@param {ASTNode} node - A node to get the config for.
@returns {string} The config option. | [
"Returns",
"the",
"config",
"option",
"for",
"the",
"given",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/func-names.js#L77-L87 |
2,836 | eslint/eslint | lib/rules/func-names.js | isObjectOrClassMethod | function isObjectOrClassMethod(node) {
const parent = node.parent;
return (parent.type === "MethodDefinition" || (
parent.type === "Property" && (
parent.method ||
parent.kind === "get" ||
parent.kind === "set"
... | javascript | function isObjectOrClassMethod(node) {
const parent = node.parent;
return (parent.type === "MethodDefinition" || (
parent.type === "Property" && (
parent.method ||
parent.kind === "get" ||
parent.kind === "set"
... | [
"function",
"isObjectOrClassMethod",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"return",
"(",
"parent",
".",
"type",
"===",
"\"MethodDefinition\"",
"||",
"(",
"parent",
".",
"type",
"===",
"\"Property\"",
"&&",
"(",
"parent",... | Determines whether the current FunctionExpression node is a get, set, or
shorthand method in an object literal or a class.
@param {ASTNode} node - A node to check.
@returns {boolean} True if the node is a get, set, or shorthand method. | [
"Determines",
"whether",
"the",
"current",
"FunctionExpression",
"node",
"is",
"a",
"get",
"set",
"or",
"shorthand",
"method",
"in",
"an",
"object",
"literal",
"or",
"a",
"class",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/func-names.js#L95-L105 |
2,837 | eslint/eslint | lib/rules/func-names.js | hasInferredName | function hasInferredName(node) {
const parent = node.parent;
return isObjectOrClassMethod(node) ||
(parent.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.init === node) ||
(parent.type === "Property" && parent.value === node) ||
... | javascript | function hasInferredName(node) {
const parent = node.parent;
return isObjectOrClassMethod(node) ||
(parent.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.init === node) ||
(parent.type === "Property" && parent.value === node) ||
... | [
"function",
"hasInferredName",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"return",
"isObjectOrClassMethod",
"(",
"node",
")",
"||",
"(",
"parent",
".",
"type",
"===",
"\"VariableDeclarator\"",
"&&",
"parent",
".",
"id",
".",
... | Determines whether the current FunctionExpression node has a name that would be
inferred from context in a conforming ES6 environment.
@param {ASTNode} node - A node to check.
@returns {boolean} True if the node would have a name assigned automatically. | [
"Determines",
"whether",
"the",
"current",
"FunctionExpression",
"node",
"has",
"a",
"name",
"that",
"would",
"be",
"inferred",
"from",
"context",
"in",
"a",
"conforming",
"ES6",
"environment",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/func-names.js#L113-L122 |
2,838 | eslint/eslint | lib/rules/func-names.js | reportUnexpectedUnnamedFunction | function reportUnexpectedUnnamedFunction(node) {
context.report({
node,
messageId: "unnamed",
data: { name: astUtils.getFunctionNameWithKind(node) }
});
} | javascript | function reportUnexpectedUnnamedFunction(node) {
context.report({
node,
messageId: "unnamed",
data: { name: astUtils.getFunctionNameWithKind(node) }
});
} | [
"function",
"reportUnexpectedUnnamedFunction",
"(",
"node",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"messageId",
":",
"\"unnamed\"",
",",
"data",
":",
"{",
"name",
":",
"astUtils",
".",
"getFunctionNameWithKind",
"(",
"node",
")",
"}",
"}"... | Reports that an unnamed function should be named
@param {ASTNode} node - The node to report in the event of an error.
@returns {void} | [
"Reports",
"that",
"an",
"unnamed",
"function",
"should",
"be",
"named"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/func-names.js#L129-L135 |
2,839 | eslint/eslint | Makefile.js | generateBlogPost | function generateBlogPost(releaseInfo, prereleaseMajorVersion) {
const ruleList = ls("lib/rules")
// Strip the .js extension
.map(ruleFileName => ruleFileName.replace(/\.js$/u, ""))
/*
* Sort by length descending. This ensures that rule names which are substrings of other rule nam... | javascript | function generateBlogPost(releaseInfo, prereleaseMajorVersion) {
const ruleList = ls("lib/rules")
// Strip the .js extension
.map(ruleFileName => ruleFileName.replace(/\.js$/u, ""))
/*
* Sort by length descending. This ensures that rule names which are substrings of other rule nam... | [
"function",
"generateBlogPost",
"(",
"releaseInfo",
",",
"prereleaseMajorVersion",
")",
"{",
"const",
"ruleList",
"=",
"ls",
"(",
"\"lib/rules\"",
")",
"// Strip the .js extension",
".",
"map",
"(",
"ruleFileName",
"=>",
"ruleFileName",
".",
"replace",
"(",
"/",
"... | Generates a release blog post for eslint.org
@param {Object} releaseInfo The release metadata.
@param {string} [prereleaseMajorVersion] If this is a prerelease, the next major version after this prerelease
@returns {void}
@private | [
"Generates",
"a",
"release",
"blog",
"post",
"for",
"eslint",
".",
"org"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L121-L146 |
2,840 | eslint/eslint | Makefile.js | generateFormatterExamples | function generateFormatterExamples(formatterInfo, prereleaseVersion) {
const output = ejs.render(cat("./templates/formatter-examples.md.ejs"), formatterInfo);
let filename = "../eslint.github.io/docs/user-guide/formatters/index.md",
htmlFilename = "../eslint.github.io/docs/user-guide/formatters/html-for... | javascript | function generateFormatterExamples(formatterInfo, prereleaseVersion) {
const output = ejs.render(cat("./templates/formatter-examples.md.ejs"), formatterInfo);
let filename = "../eslint.github.io/docs/user-guide/formatters/index.md",
htmlFilename = "../eslint.github.io/docs/user-guide/formatters/html-for... | [
"function",
"generateFormatterExamples",
"(",
"formatterInfo",
",",
"prereleaseVersion",
")",
"{",
"const",
"output",
"=",
"ejs",
".",
"render",
"(",
"cat",
"(",
"\"./templates/formatter-examples.md.ejs\"",
")",
",",
"formatterInfo",
")",
";",
"let",
"filename",
"="... | Generates a doc page with formatter result examples
@param {Object} formatterInfo Linting results from each formatter
@param {string} [prereleaseVersion] The version used for a prerelease. This
changes where the output is stored.
@returns {void} | [
"Generates",
"a",
"doc",
"page",
"with",
"formatter",
"result",
"examples"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L155-L170 |
2,841 | eslint/eslint | Makefile.js | generateRuleIndexPage | function generateRuleIndexPage(basedir) {
const outputFile = "../eslint.github.io/_data/rules.yml",
categoryList = "conf/category-list.json",
categoriesData = JSON.parse(cat(path.resolve(categoryList)));
find(path.join(basedir, "/lib/rules/")).filter(fileType("js"))
.map(filename => [fi... | javascript | function generateRuleIndexPage(basedir) {
const outputFile = "../eslint.github.io/_data/rules.yml",
categoryList = "conf/category-list.json",
categoriesData = JSON.parse(cat(path.resolve(categoryList)));
find(path.join(basedir, "/lib/rules/")).filter(fileType("js"))
.map(filename => [fi... | [
"function",
"generateRuleIndexPage",
"(",
"basedir",
")",
"{",
"const",
"outputFile",
"=",
"\"../eslint.github.io/_data/rules.yml\"",
",",
"categoryList",
"=",
"\"conf/category-list.json\"",
",",
"categoriesData",
"=",
"JSON",
".",
"parse",
"(",
"cat",
"(",
"path",
".... | Generate a doc page that lists all of the rules and links to them
@param {string} basedir The directory in which to look for code.
@returns {void} | [
"Generate",
"a",
"doc",
"page",
"that",
"lists",
"all",
"of",
"the",
"rules",
"and",
"links",
"to",
"them"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L177-L215 |
2,842 | eslint/eslint | Makefile.js | getFirstCommitOfFile | function getFirstCommitOfFile(filePath) {
let commits = execSilent(`git rev-list HEAD -- ${filePath}`);
commits = splitCommandResultToLines(commits);
return commits[commits.length - 1].trim();
} | javascript | function getFirstCommitOfFile(filePath) {
let commits = execSilent(`git rev-list HEAD -- ${filePath}`);
commits = splitCommandResultToLines(commits);
return commits[commits.length - 1].trim();
} | [
"function",
"getFirstCommitOfFile",
"(",
"filePath",
")",
"{",
"let",
"commits",
"=",
"execSilent",
"(",
"`",
"${",
"filePath",
"}",
"`",
")",
";",
"commits",
"=",
"splitCommandResultToLines",
"(",
"commits",
")",
";",
"return",
"commits",
"[",
"commits",
".... | Gets the first commit sha of the given file.
@param {string} filePath The file path which should be checked.
@returns {string} The commit sha. | [
"Gets",
"the",
"first",
"commit",
"sha",
"of",
"the",
"given",
"file",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L328-L333 |
2,843 | eslint/eslint | Makefile.js | getFirstVersionOfFile | function getFirstVersionOfFile(filePath) {
const firstCommit = getFirstCommitOfFile(filePath);
let tags = execSilent(`git tag --contains ${firstCommit}`);
tags = splitCommandResultToLines(tags);
return tags.reduce((list, version) => {
const validatedVersion = semver.valid(version.trim());
... | javascript | function getFirstVersionOfFile(filePath) {
const firstCommit = getFirstCommitOfFile(filePath);
let tags = execSilent(`git tag --contains ${firstCommit}`);
tags = splitCommandResultToLines(tags);
return tags.reduce((list, version) => {
const validatedVersion = semver.valid(version.trim());
... | [
"function",
"getFirstVersionOfFile",
"(",
"filePath",
")",
"{",
"const",
"firstCommit",
"=",
"getFirstCommitOfFile",
"(",
"filePath",
")",
";",
"let",
"tags",
"=",
"execSilent",
"(",
"`",
"${",
"firstCommit",
"}",
"`",
")",
";",
"tags",
"=",
"splitCommandResul... | Gets the tag name where a given file was introduced first.
@param {string} filePath The file path to check.
@returns {string} The tag name. | [
"Gets",
"the",
"tag",
"name",
"where",
"a",
"given",
"file",
"was",
"introduced",
"first",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L340-L353 |
2,844 | eslint/eslint | Makefile.js | getFirstVersionOfDeletion | function getFirstVersionOfDeletion(filePath) {
const deletionCommit = getCommitDeletingFile(filePath),
tags = execSilent(`git tag --contains ${deletionCommit}`);
return splitCommandResultToLines(tags)
.map(version => semver.valid(version.trim()))
.filter(version => version)
.sor... | javascript | function getFirstVersionOfDeletion(filePath) {
const deletionCommit = getCommitDeletingFile(filePath),
tags = execSilent(`git tag --contains ${deletionCommit}`);
return splitCommandResultToLines(tags)
.map(version => semver.valid(version.trim()))
.filter(version => version)
.sor... | [
"function",
"getFirstVersionOfDeletion",
"(",
"filePath",
")",
"{",
"const",
"deletionCommit",
"=",
"getCommitDeletingFile",
"(",
"filePath",
")",
",",
"tags",
"=",
"execSilent",
"(",
"`",
"${",
"deletionCommit",
"}",
"`",
")",
";",
"return",
"splitCommandResultTo... | Gets the first version number where a given file is no longer present.
@param {string} filePath The path to the deleted file.
@returns {string} The version number. | [
"Gets",
"the",
"first",
"version",
"number",
"where",
"a",
"given",
"file",
"is",
"no",
"longer",
"present",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L371-L379 |
2,845 | eslint/eslint | Makefile.js | lintMarkdown | function lintMarkdown(files) {
const config = yaml.safeLoad(fs.readFileSync(path.join(__dirname, "./.markdownlint.yml"), "utf8")),
result = markdownlint.sync({
files,
config,
resultVersion: 1
}),
resultString = result.toString(),
returnCode = resul... | javascript | function lintMarkdown(files) {
const config = yaml.safeLoad(fs.readFileSync(path.join(__dirname, "./.markdownlint.yml"), "utf8")),
result = markdownlint.sync({
files,
config,
resultVersion: 1
}),
resultString = result.toString(),
returnCode = resul... | [
"function",
"lintMarkdown",
"(",
"files",
")",
"{",
"const",
"config",
"=",
"yaml",
".",
"safeLoad",
"(",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"\"./.markdownlint.yml\"",
")",
",",
"\"utf8\"",
")",
")",
",",
"result",
... | Lints Markdown files.
@param {Array} files Array of file names to lint.
@returns {Object} exec-style exit code object.
@private | [
"Lints",
"Markdown",
"files",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L387-L401 |
2,846 | eslint/eslint | Makefile.js | getFormatterResults | function getFormatterResults() {
const stripAnsi = require("strip-ansi");
const formatterFiles = fs.readdirSync("./lib/formatters/"),
rules = {
"no-else-return": "warn",
indent: ["warn", 4],
"space-unary-ops": "error",
semi: ["warn", "always"],
... | javascript | function getFormatterResults() {
const stripAnsi = require("strip-ansi");
const formatterFiles = fs.readdirSync("./lib/formatters/"),
rules = {
"no-else-return": "warn",
indent: ["warn", 4],
"space-unary-ops": "error",
semi: ["warn", "always"],
... | [
"function",
"getFormatterResults",
"(",
")",
"{",
"const",
"stripAnsi",
"=",
"require",
"(",
"\"strip-ansi\"",
")",
";",
"const",
"formatterFiles",
"=",
"fs",
".",
"readdirSync",
"(",
"\"./lib/formatters/\"",
")",
",",
"rules",
"=",
"{",
"\"no-else-return\"",
":... | Gets linting results from every formatter, based on a hard-coded snippet and config
@returns {Object} Output from each formatter | [
"Gets",
"linting",
"results",
"from",
"every",
"formatter",
"based",
"on",
"a",
"hard",
"-",
"coded",
"snippet",
"and",
"config"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L407-L456 |
2,847 | eslint/eslint | Makefile.js | hasIdInTitle | function hasIdInTitle(id) {
const docText = cat(docFilename);
const idOldAtEndOfTitleRegExp = new RegExp(`^# (.*?) \\(${id}\\)`, "u"); // original format
const idNewAtBeginningOfTitleRegExp = new RegExp(`^# ${id}: `, "u"); // new format is same as rules index
/*
... | javascript | function hasIdInTitle(id) {
const docText = cat(docFilename);
const idOldAtEndOfTitleRegExp = new RegExp(`^# (.*?) \\(${id}\\)`, "u"); // original format
const idNewAtBeginningOfTitleRegExp = new RegExp(`^# ${id}: `, "u"); // new format is same as rules index
/*
... | [
"function",
"hasIdInTitle",
"(",
"id",
")",
"{",
"const",
"docText",
"=",
"cat",
"(",
"docFilename",
")",
";",
"const",
"idOldAtEndOfTitleRegExp",
"=",
"new",
"RegExp",
"(",
"`",
"\\\\",
"${",
"id",
"}",
"\\\\",
"`",
",",
"\"u\"",
")",
";",
"// original ... | Check if id is present in title
@param {string} id id to check for
@returns {boolean} true if present
@private | [
"Check",
"if",
"id",
"is",
"present",
"in",
"title"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L817-L828 |
2,848 | eslint/eslint | Makefile.js | isPermissible | function isPermissible(dependency) {
const licenses = dependency.licenses;
if (Array.isArray(licenses)) {
return licenses.some(license => isPermissible({
name: dependency.name,
licenses: license
}));
}
return OPEN_SOURCE_LICENSES.... | javascript | function isPermissible(dependency) {
const licenses = dependency.licenses;
if (Array.isArray(licenses)) {
return licenses.some(license => isPermissible({
name: dependency.name,
licenses: license
}));
}
return OPEN_SOURCE_LICENSES.... | [
"function",
"isPermissible",
"(",
"dependency",
")",
"{",
"const",
"licenses",
"=",
"dependency",
".",
"licenses",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"licenses",
")",
")",
"{",
"return",
"licenses",
".",
"some",
"(",
"license",
"=>",
"isPermissi... | Check if a dependency is eligible to be used by us
@param {Object} dependency dependency to check
@returns {boolean} true if we have permission
@private | [
"Check",
"if",
"a",
"dependency",
"is",
"eligible",
"to",
"be",
"used",
"by",
"us"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L882-L893 |
2,849 | eslint/eslint | Makefile.js | loadPerformance | function loadPerformance() {
echo("");
echo("Loading:");
const results = [];
for (let cnt = 0; cnt < 5; cnt++) {
const loadPerfData = loadPerf({
checkDependencies: false
});
echo(` Load performance Run #${cnt + 1}: %dms`, loadPerfData.loadTime);
results.p... | javascript | function loadPerformance() {
echo("");
echo("Loading:");
const results = [];
for (let cnt = 0; cnt < 5; cnt++) {
const loadPerfData = loadPerf({
checkDependencies: false
});
echo(` Load performance Run #${cnt + 1}: %dms`, loadPerfData.loadTime);
results.p... | [
"function",
"loadPerformance",
"(",
")",
"{",
"echo",
"(",
"\"\"",
")",
";",
"echo",
"(",
"\"Loading:\"",
")",
";",
"const",
"results",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"cnt",
"=",
"0",
";",
"cnt",
"<",
"5",
";",
"cnt",
"++",
")",
"{",
"c... | Run the load performance for eslint
@returns {void}
@private | [
"Run",
"the",
"load",
"performance",
"for",
"eslint"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L1036-L1057 |
2,850 | eslint/eslint | lib/rules/template-tag-spacing.js | checkSpacing | function checkSpacing(node) {
const tagToken = sourceCode.getTokenBefore(node.quasi);
const literalToken = sourceCode.getFirstToken(node.quasi);
const hasWhitespace = sourceCode.isSpaceBetweenTokens(tagToken, literalToken);
if (never && hasWhitespace) {
c... | javascript | function checkSpacing(node) {
const tagToken = sourceCode.getTokenBefore(node.quasi);
const literalToken = sourceCode.getFirstToken(node.quasi);
const hasWhitespace = sourceCode.isSpaceBetweenTokens(tagToken, literalToken);
if (never && hasWhitespace) {
c... | [
"function",
"checkSpacing",
"(",
"node",
")",
"{",
"const",
"tagToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"node",
".",
"quasi",
")",
";",
"const",
"literalToken",
"=",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
".",
"quasi",
")",
";",
"c... | Check if a space is present between a template tag and its literal
@param {ASTNode} node node to evaluate
@returns {void}
@private | [
"Check",
"if",
"a",
"space",
"is",
"present",
"between",
"a",
"template",
"tag",
"and",
"its",
"literal"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/template-tag-spacing.js#L44-L78 |
2,851 | eslint/eslint | lib/rules/jsx-quotes.js | usesExpectedQuotes | function usesExpectedQuotes(node) {
return node.value.indexOf(setting.quote) !== -1 || astUtils.isSurroundedBy(node.raw, setting.quote);
} | javascript | function usesExpectedQuotes(node) {
return node.value.indexOf(setting.quote) !== -1 || astUtils.isSurroundedBy(node.raw, setting.quote);
} | [
"function",
"usesExpectedQuotes",
"(",
"node",
")",
"{",
"return",
"node",
".",
"value",
".",
"indexOf",
"(",
"setting",
".",
"quote",
")",
"!==",
"-",
"1",
"||",
"astUtils",
".",
"isSurroundedBy",
"(",
"node",
".",
"raw",
",",
"setting",
".",
"quote",
... | Checks if the given string literal node uses the expected quotes
@param {ASTNode} node - A string literal node.
@returns {boolean} Whether or not the string literal used the expected quotes.
@public | [
"Checks",
"if",
"the",
"given",
"string",
"literal",
"node",
"uses",
"the",
"expected",
"quotes"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/jsx-quotes.js#L72-L74 |
2,852 | eslint/eslint | lib/rules/strict.js | reportSlice | function reportSlice(nodes, start, end, messageId, fix) {
nodes.slice(start, end).forEach(node => {
context.report({ node, messageId, fix: fix ? getFixFunction(node) : null });
});
} | javascript | function reportSlice(nodes, start, end, messageId, fix) {
nodes.slice(start, end).forEach(node => {
context.report({ node, messageId, fix: fix ? getFixFunction(node) : null });
});
} | [
"function",
"reportSlice",
"(",
"nodes",
",",
"start",
",",
"end",
",",
"messageId",
",",
"fix",
")",
"{",
"nodes",
".",
"slice",
"(",
"start",
",",
"end",
")",
".",
"forEach",
"(",
"node",
"=>",
"{",
"context",
".",
"report",
"(",
"{",
"node",
","... | Report a slice of an array of nodes with a given message.
@param {ASTNode[]} nodes Nodes.
@param {string} start Index to start from.
@param {string} end Index to end before.
@param {string} messageId Message to display.
@param {boolean} fix `true` if the directive should be fixed (i.e. removed)
@returns {void} | [
"Report",
"a",
"slice",
"of",
"an",
"array",
"of",
"nodes",
"with",
"a",
"given",
"message",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/strict.js#L140-L144 |
2,853 | eslint/eslint | lib/rules/strict.js | reportAll | function reportAll(nodes, messageId, fix) {
reportSlice(nodes, 0, nodes.length, messageId, fix);
} | javascript | function reportAll(nodes, messageId, fix) {
reportSlice(nodes, 0, nodes.length, messageId, fix);
} | [
"function",
"reportAll",
"(",
"nodes",
",",
"messageId",
",",
"fix",
")",
"{",
"reportSlice",
"(",
"nodes",
",",
"0",
",",
"nodes",
".",
"length",
",",
"messageId",
",",
"fix",
")",
";",
"}"
] | Report all nodes in an array with a given message.
@param {ASTNode[]} nodes Nodes.
@param {string} messageId Message id to display.
@param {boolean} fix `true` if the directive should be fixed (i.e. removed)
@returns {void} | [
"Report",
"all",
"nodes",
"in",
"an",
"array",
"with",
"a",
"given",
"message",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/strict.js#L153-L155 |
2,854 | eslint/eslint | lib/rules/strict.js | reportAllExceptFirst | function reportAllExceptFirst(nodes, messageId, fix) {
reportSlice(nodes, 1, nodes.length, messageId, fix);
} | javascript | function reportAllExceptFirst(nodes, messageId, fix) {
reportSlice(nodes, 1, nodes.length, messageId, fix);
} | [
"function",
"reportAllExceptFirst",
"(",
"nodes",
",",
"messageId",
",",
"fix",
")",
"{",
"reportSlice",
"(",
"nodes",
",",
"1",
",",
"nodes",
".",
"length",
",",
"messageId",
",",
"fix",
")",
";",
"}"
] | Report all nodes in an array, except the first, with a given message.
@param {ASTNode[]} nodes Nodes.
@param {string} messageId Message id to display.
@param {boolean} fix `true` if the directive should be fixed (i.e. removed)
@returns {void} | [
"Report",
"all",
"nodes",
"in",
"an",
"array",
"except",
"the",
"first",
"with",
"a",
"given",
"message",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/strict.js#L164-L166 |
2,855 | eslint/eslint | lib/rules/strict.js | enterFunctionInFunctionMode | function enterFunctionInFunctionMode(node, useStrictDirectives) {
const isInClass = classScopes.length > 0,
isParentGlobal = scopes.length === 0 && classScopes.length === 0,
isParentStrict = scopes.length > 0 && scopes[scopes.length - 1],
isStrict = useStrictD... | javascript | function enterFunctionInFunctionMode(node, useStrictDirectives) {
const isInClass = classScopes.length > 0,
isParentGlobal = scopes.length === 0 && classScopes.length === 0,
isParentStrict = scopes.length > 0 && scopes[scopes.length - 1],
isStrict = useStrictD... | [
"function",
"enterFunctionInFunctionMode",
"(",
"node",
",",
"useStrictDirectives",
")",
"{",
"const",
"isInClass",
"=",
"classScopes",
".",
"length",
">",
"0",
",",
"isParentGlobal",
"=",
"scopes",
".",
"length",
"===",
"0",
"&&",
"classScopes",
".",
"length",
... | Entering a function in 'function' mode pushes a new nested scope onto the
stack. The new scope is true if the nested function is strict mode code.
@param {ASTNode} node The function declaration or expression.
@param {ASTNode[]} useStrictDirectives The Use Strict Directives of the node.
@returns {void} | [
"Entering",
"a",
"function",
"in",
"function",
"mode",
"pushes",
"a",
"new",
"nested",
"scope",
"onto",
"the",
"stack",
".",
"The",
"new",
"scope",
"is",
"true",
"if",
"the",
"nested",
"function",
"is",
"strict",
"mode",
"code",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/strict.js#L175-L204 |
2,856 | eslint/eslint | lib/formatters/codeframe.js | formatMessage | function formatMessage(message, parentResult) {
const type = (message.fatal || message.severity === 2) ? chalk.red("error") : chalk.yellow("warning");
const msg = `${chalk.bold(message.message.replace(/([^ ])\.$/u, "$1"))}`;
const ruleId = message.fatal ? "" : chalk.dim(`(${message.ruleId})`);
const fil... | javascript | function formatMessage(message, parentResult) {
const type = (message.fatal || message.severity === 2) ? chalk.red("error") : chalk.yellow("warning");
const msg = `${chalk.bold(message.message.replace(/([^ ])\.$/u, "$1"))}`;
const ruleId = message.fatal ? "" : chalk.dim(`(${message.ruleId})`);
const fil... | [
"function",
"formatMessage",
"(",
"message",
",",
"parentResult",
")",
"{",
"const",
"type",
"=",
"(",
"message",
".",
"fatal",
"||",
"message",
".",
"severity",
"===",
"2",
")",
"?",
"chalk",
".",
"red",
"(",
"\"error\"",
")",
":",
"chalk",
".",
"yell... | Gets the formatted output for a given message.
@param {Object} message The object that represents this message.
@param {Object} parentResult The result object that this message belongs to.
@returns {string} The formatted output. | [
"Gets",
"the",
"formatted",
"output",
"for",
"a",
"given",
"message",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/formatters/codeframe.js#L48-L71 |
2,857 | eslint/eslint | lib/formatters/codeframe.js | formatSummary | function formatSummary(errors, warnings, fixableErrors, fixableWarnings) {
const summaryColor = errors > 0 ? "red" : "yellow";
const summary = [];
const fixablesSummary = [];
if (errors > 0) {
summary.push(`${errors} ${pluralize("error", errors)}`);
}
if (warnings > 0) {
summar... | javascript | function formatSummary(errors, warnings, fixableErrors, fixableWarnings) {
const summaryColor = errors > 0 ? "red" : "yellow";
const summary = [];
const fixablesSummary = [];
if (errors > 0) {
summary.push(`${errors} ${pluralize("error", errors)}`);
}
if (warnings > 0) {
summar... | [
"function",
"formatSummary",
"(",
"errors",
",",
"warnings",
",",
"fixableErrors",
",",
"fixableWarnings",
")",
"{",
"const",
"summaryColor",
"=",
"errors",
">",
"0",
"?",
"\"red\"",
":",
"\"yellow\"",
";",
"const",
"summary",
"=",
"[",
"]",
";",
"const",
... | Gets the formatted output summary for a given number of errors and warnings.
@param {number} errors The number of errors.
@param {number} warnings The number of warnings.
@param {number} fixableErrors The number of fixable errors.
@param {number} fixableWarnings The number of fixable warnings.
@returns {strin... | [
"Gets",
"the",
"formatted",
"output",
"summary",
"for",
"a",
"given",
"number",
"of",
"errors",
"and",
"warnings",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/formatters/codeframe.js#L81-L109 |
2,858 | eslint/eslint | lib/rules/no-native-reassign.js | checkVariable | function checkVariable(variable) {
if (variable.writeable === false && exceptions.indexOf(variable.name) === -1) {
variable.references.forEach(checkReference);
}
} | javascript | function checkVariable(variable) {
if (variable.writeable === false && exceptions.indexOf(variable.name) === -1) {
variable.references.forEach(checkReference);
}
} | [
"function",
"checkVariable",
"(",
"variable",
")",
"{",
"if",
"(",
"variable",
".",
"writeable",
"===",
"false",
"&&",
"exceptions",
".",
"indexOf",
"(",
"variable",
".",
"name",
")",
"===",
"-",
"1",
")",
"{",
"variable",
".",
"references",
".",
"forEac... | Reports write references if a given variable is read-only builtin.
@param {Variable} variable - A variable to check.
@returns {void} | [
"Reports",
"write",
"references",
"if",
"a",
"given",
"variable",
"is",
"read",
"-",
"only",
"builtin",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-native-reassign.js#L79-L83 |
2,859 | eslint/eslint | lib/rules/space-unary-ops.js | overrideExistsForOperator | function overrideExistsForOperator(operator) {
return options.overrides && Object.prototype.hasOwnProperty.call(options.overrides, operator);
} | javascript | function overrideExistsForOperator(operator) {
return options.overrides && Object.prototype.hasOwnProperty.call(options.overrides, operator);
} | [
"function",
"overrideExistsForOperator",
"(",
"operator",
")",
"{",
"return",
"options",
".",
"overrides",
"&&",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"options",
".",
"overrides",
",",
"operator",
")",
";",
"}"
] | Checks if an override exists for a given operator.
@param {string} operator Operator
@returns {boolean} Whether or not an override has been provided for the operator | [
"Checks",
"if",
"an",
"override",
"exists",
"for",
"a",
"given",
"operator",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L86-L88 |
2,860 | eslint/eslint | lib/rules/space-unary-ops.js | verifyWordHasSpaces | function verifyWordHasSpaces(node, firstToken, secondToken, word) {
if (secondToken.range[0] === firstToken.range[1]) {
context.report({
node,
messageId: "wordOperator",
data: {
word
},
... | javascript | function verifyWordHasSpaces(node, firstToken, secondToken, word) {
if (secondToken.range[0] === firstToken.range[1]) {
context.report({
node,
messageId: "wordOperator",
data: {
word
},
... | [
"function",
"verifyWordHasSpaces",
"(",
"node",
",",
"firstToken",
",",
"secondToken",
",",
"word",
")",
"{",
"if",
"(",
"secondToken",
".",
"range",
"[",
"0",
"]",
"===",
"firstToken",
".",
"range",
"[",
"1",
"]",
")",
"{",
"context",
".",
"report",
"... | Verify Unary Word Operator has spaces after the word operator
@param {ASTnode} node AST node
@param {Object} firstToken first token from the AST node
@param {Object} secondToken second token from the AST node
@param {string} word The word to be used for reporting
@returns {void} | [
"Verify",
"Unary",
"Word",
"Operator",
"has",
"spaces",
"after",
"the",
"word",
"operator"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L107-L120 |
2,861 | eslint/eslint | lib/rules/space-unary-ops.js | verifyWordDoesntHaveSpaces | function verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word) {
if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) {
if (secondToken.range[0] > firstToken.range[1]) {
context.report({
node,
messageId: "une... | javascript | function verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word) {
if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) {
if (secondToken.range[0] > firstToken.range[1]) {
context.report({
node,
messageId: "une... | [
"function",
"verifyWordDoesntHaveSpaces",
"(",
"node",
",",
"firstToken",
",",
"secondToken",
",",
"word",
")",
"{",
"if",
"(",
"astUtils",
".",
"canTokensBeAdjacent",
"(",
"firstToken",
",",
"secondToken",
")",
")",
"{",
"if",
"(",
"secondToken",
".",
"range"... | Verify Unary Word Operator doesn't have spaces after the word operator
@param {ASTnode} node AST node
@param {Object} firstToken first token from the AST node
@param {Object} secondToken second token from the AST node
@param {string} word The word to be used for reporting
@returns {void} | [
"Verify",
"Unary",
"Word",
"Operator",
"doesn",
"t",
"have",
"spaces",
"after",
"the",
"word",
"operator"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L130-L145 |
2,862 | eslint/eslint | lib/rules/space-unary-ops.js | checkUnaryWordOperatorForSpaces | function checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, word) {
if (overrideExistsForOperator(word)) {
if (overrideEnforcesSpaces(word)) {
verifyWordHasSpaces(node, firstToken, secondToken, word);
} else {
verifyWordDoes... | javascript | function checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, word) {
if (overrideExistsForOperator(word)) {
if (overrideEnforcesSpaces(word)) {
verifyWordHasSpaces(node, firstToken, secondToken, word);
} else {
verifyWordDoes... | [
"function",
"checkUnaryWordOperatorForSpaces",
"(",
"node",
",",
"firstToken",
",",
"secondToken",
",",
"word",
")",
"{",
"if",
"(",
"overrideExistsForOperator",
"(",
"word",
")",
")",
"{",
"if",
"(",
"overrideEnforcesSpaces",
"(",
"word",
")",
")",
"{",
"veri... | Check Unary Word Operators for spaces after the word operator
@param {ASTnode} node AST node
@param {Object} firstToken first token from the AST node
@param {Object} secondToken second token from the AST node
@param {string} word The word to be used for reporting
@returns {void} | [
"Check",
"Unary",
"Word",
"Operators",
"for",
"spaces",
"after",
"the",
"word",
"operator"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L155-L167 |
2,863 | eslint/eslint | lib/rules/space-unary-ops.js | checkForSpacesAfterYield | function checkForSpacesAfterYield(node) {
const tokens = sourceCode.getFirstTokens(node, 3),
word = "yield";
if (!node.argument || node.delegate) {
return;
}
checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], word);
} | javascript | function checkForSpacesAfterYield(node) {
const tokens = sourceCode.getFirstTokens(node, 3),
word = "yield";
if (!node.argument || node.delegate) {
return;
}
checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], word);
} | [
"function",
"checkForSpacesAfterYield",
"(",
"node",
")",
"{",
"const",
"tokens",
"=",
"sourceCode",
".",
"getFirstTokens",
"(",
"node",
",",
"3",
")",
",",
"word",
"=",
"\"yield\"",
";",
"if",
"(",
"!",
"node",
".",
"argument",
"||",
"node",
".",
"deleg... | Verifies YieldExpressions satisfy spacing requirements
@param {ASTnode} node AST node
@returns {void} | [
"Verifies",
"YieldExpressions",
"satisfy",
"spacing",
"requirements"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L174-L183 |
2,864 | eslint/eslint | lib/rules/space-unary-ops.js | checkForSpacesAfterAwait | function checkForSpacesAfterAwait(node) {
const tokens = sourceCode.getFirstTokens(node, 3);
checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], "await");
} | javascript | function checkForSpacesAfterAwait(node) {
const tokens = sourceCode.getFirstTokens(node, 3);
checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], "await");
} | [
"function",
"checkForSpacesAfterAwait",
"(",
"node",
")",
"{",
"const",
"tokens",
"=",
"sourceCode",
".",
"getFirstTokens",
"(",
"node",
",",
"3",
")",
";",
"checkUnaryWordOperatorForSpaces",
"(",
"node",
",",
"tokens",
"[",
"0",
"]",
",",
"tokens",
"[",
"1"... | Verifies AwaitExpressions satisfy spacing requirements
@param {ASTNode} node AwaitExpression AST node
@returns {void} | [
"Verifies",
"AwaitExpressions",
"satisfy",
"spacing",
"requirements"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L190-L194 |
2,865 | eslint/eslint | lib/rules/space-unary-ops.js | verifyNonWordsHaveSpaces | function verifyNonWordsHaveSpaces(node, firstToken, secondToken) {
if (node.prefix) {
if (isFirstBangInBangBangExpression(node)) {
return;
}
if (firstToken.range[1] === secondToken.range[0]) {
context.report({
... | javascript | function verifyNonWordsHaveSpaces(node, firstToken, secondToken) {
if (node.prefix) {
if (isFirstBangInBangBangExpression(node)) {
return;
}
if (firstToken.range[1] === secondToken.range[0]) {
context.report({
... | [
"function",
"verifyNonWordsHaveSpaces",
"(",
"node",
",",
"firstToken",
",",
"secondToken",
")",
"{",
"if",
"(",
"node",
".",
"prefix",
")",
"{",
"if",
"(",
"isFirstBangInBangBangExpression",
"(",
"node",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"firs... | Verifies UnaryExpression, UpdateExpression and NewExpression have spaces before or after the operator
@param {ASTnode} node AST node
@param {Object} firstToken First token in the expression
@param {Object} secondToken Second token in the expression
@returns {void} | [
"Verifies",
"UnaryExpression",
"UpdateExpression",
"and",
"NewExpression",
"have",
"spaces",
"before",
"or",
"after",
"the",
"operator"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L203-L234 |
2,866 | eslint/eslint | lib/rules/space-unary-ops.js | verifyNonWordsDontHaveSpaces | function verifyNonWordsDontHaveSpaces(node, firstToken, secondToken) {
if (node.prefix) {
if (secondToken.range[0] > firstToken.range[1]) {
context.report({
node,
messageId: "unexpectedAfter",
data: {... | javascript | function verifyNonWordsDontHaveSpaces(node, firstToken, secondToken) {
if (node.prefix) {
if (secondToken.range[0] > firstToken.range[1]) {
context.report({
node,
messageId: "unexpectedAfter",
data: {... | [
"function",
"verifyNonWordsDontHaveSpaces",
"(",
"node",
",",
"firstToken",
",",
"secondToken",
")",
"{",
"if",
"(",
"node",
".",
"prefix",
")",
"{",
"if",
"(",
"secondToken",
".",
"range",
"[",
"0",
"]",
">",
"firstToken",
".",
"range",
"[",
"1",
"]",
... | Verifies UnaryExpression, UpdateExpression and NewExpression don't have spaces before or after the operator
@param {ASTnode} node AST node
@param {Object} firstToken First token in the expression
@param {Object} secondToken Second token in the expression
@returns {void} | [
"Verifies",
"UnaryExpression",
"UpdateExpression",
"and",
"NewExpression",
"don",
"t",
"have",
"spaces",
"before",
"or",
"after",
"the",
"operator"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L243-L274 |
2,867 | eslint/eslint | lib/rules/space-unary-ops.js | checkForSpaces | function checkForSpaces(node) {
const tokens = node.type === "UpdateExpression" && !node.prefix
? sourceCode.getLastTokens(node, 2)
: sourceCode.getFirstTokens(node, 2);
const firstToken = tokens[0];
const secondToken = tokens[1];
if ((nod... | javascript | function checkForSpaces(node) {
const tokens = node.type === "UpdateExpression" && !node.prefix
? sourceCode.getLastTokens(node, 2)
: sourceCode.getFirstTokens(node, 2);
const firstToken = tokens[0];
const secondToken = tokens[1];
if ((nod... | [
"function",
"checkForSpaces",
"(",
"node",
")",
"{",
"const",
"tokens",
"=",
"node",
".",
"type",
"===",
"\"UpdateExpression\"",
"&&",
"!",
"node",
".",
"prefix",
"?",
"sourceCode",
".",
"getLastTokens",
"(",
"node",
",",
"2",
")",
":",
"sourceCode",
".",
... | Verifies UnaryExpression, UpdateExpression and NewExpression satisfy spacing requirements
@param {ASTnode} node AST node
@returns {void} | [
"Verifies",
"UnaryExpression",
"UpdateExpression",
"and",
"NewExpression",
"satisfy",
"spacing",
"requirements"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L281-L306 |
2,868 | eslint/eslint | lib/rules/no-irregular-whitespace.js | removeWhitespaceError | function removeWhitespaceError(node) {
const locStart = node.loc.start;
const locEnd = node.loc.end;
errors = errors.filter(({ loc: errorLoc }) => {
if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) {
if (errorLoc.column >= locSt... | javascript | function removeWhitespaceError(node) {
const locStart = node.loc.start;
const locEnd = node.loc.end;
errors = errors.filter(({ loc: errorLoc }) => {
if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) {
if (errorLoc.column >= locSt... | [
"function",
"removeWhitespaceError",
"(",
"node",
")",
"{",
"const",
"locStart",
"=",
"node",
".",
"loc",
".",
"start",
";",
"const",
"locEnd",
"=",
"node",
".",
"loc",
".",
"end",
";",
"errors",
"=",
"errors",
".",
"filter",
"(",
"(",
"{",
"loc",
":... | Removes errors that occur inside a string node
@param {ASTNode} node to check for matching errors.
@returns {void}
@private | [
"Removes",
"errors",
"that",
"occur",
"inside",
"a",
"string",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-irregular-whitespace.js#L86-L98 |
2,869 | eslint/eslint | lib/rules/no-irregular-whitespace.js | removeInvalidNodeErrorsInTemplateLiteral | function removeInvalidNodeErrorsInTemplateLiteral(node) {
if (typeof node.value.raw === "string") {
if (ALL_IRREGULARS.test(node.value.raw)) {
removeWhitespaceError(node);
}
}
} | javascript | function removeInvalidNodeErrorsInTemplateLiteral(node) {
if (typeof node.value.raw === "string") {
if (ALL_IRREGULARS.test(node.value.raw)) {
removeWhitespaceError(node);
}
}
} | [
"function",
"removeInvalidNodeErrorsInTemplateLiteral",
"(",
"node",
")",
"{",
"if",
"(",
"typeof",
"node",
".",
"value",
".",
"raw",
"===",
"\"string\"",
")",
"{",
"if",
"(",
"ALL_IRREGULARS",
".",
"test",
"(",
"node",
".",
"value",
".",
"raw",
")",
")",
... | Checks template string literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
@param {ASTNode} node to check for matching errors.
@returns {void}
@private | [
"Checks",
"template",
"string",
"literal",
"nodes",
"for",
"errors",
"that",
"we",
"are",
"choosing",
"to",
"ignore",
"and",
"calls",
"the",
"relevant",
"methods",
"to",
"remove",
"the",
"errors"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-irregular-whitespace.js#L125-L131 |
2,870 | eslint/eslint | lib/rules/no-irregular-whitespace.js | checkForIrregularWhitespace | function checkForIrregularWhitespace(node) {
const sourceLines = sourceCode.lines;
sourceLines.forEach((sourceLine, lineIndex) => {
const lineNumber = lineIndex + 1;
let match;
while ((match = IRREGULAR_WHITESPACE.exec(sourceLine)) !== null) {
... | javascript | function checkForIrregularWhitespace(node) {
const sourceLines = sourceCode.lines;
sourceLines.forEach((sourceLine, lineIndex) => {
const lineNumber = lineIndex + 1;
let match;
while ((match = IRREGULAR_WHITESPACE.exec(sourceLine)) !== null) {
... | [
"function",
"checkForIrregularWhitespace",
"(",
"node",
")",
"{",
"const",
"sourceLines",
"=",
"sourceCode",
".",
"lines",
";",
"sourceLines",
".",
"forEach",
"(",
"(",
"sourceLine",
",",
"lineIndex",
")",
"=>",
"{",
"const",
"lineNumber",
"=",
"lineIndex",
"+... | Checks the program source for irregular whitespace
@param {ASTNode} node The program node
@returns {void}
@private | [
"Checks",
"the",
"program",
"source",
"for",
"irregular",
"whitespace"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-irregular-whitespace.js#L151-L167 |
2,871 | eslint/eslint | lib/rules/no-irregular-whitespace.js | checkForIrregularLineTerminators | function checkForIrregularLineTerminators(node) {
const source = sourceCode.getText(),
sourceLines = sourceCode.lines,
linebreaks = source.match(LINE_BREAK);
let lastLineIndex = -1,
match;
while ((match = IRREGULAR_LINE_TERMINATORS.exe... | javascript | function checkForIrregularLineTerminators(node) {
const source = sourceCode.getText(),
sourceLines = sourceCode.lines,
linebreaks = source.match(LINE_BREAK);
let lastLineIndex = -1,
match;
while ((match = IRREGULAR_LINE_TERMINATORS.exe... | [
"function",
"checkForIrregularLineTerminators",
"(",
"node",
")",
"{",
"const",
"source",
"=",
"sourceCode",
".",
"getText",
"(",
")",
",",
"sourceLines",
"=",
"sourceCode",
".",
"lines",
",",
"linebreaks",
"=",
"source",
".",
"match",
"(",
"LINE_BREAK",
")",
... | Checks the program source for irregular line terminators
@param {ASTNode} node The program node
@returns {void}
@private | [
"Checks",
"the",
"program",
"source",
"for",
"irregular",
"line",
"terminators"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-irregular-whitespace.js#L175-L192 |
2,872 | eslint/eslint | lib/rules/indent-legacy.js | getNodeIndent | function getNodeIndent(node, byLastLine) {
const token = byLastLine ? sourceCode.getLastToken(node) : sourceCode.getFirstToken(node);
const srcCharsBeforeNode = sourceCode.getText(token, token.loc.start.column).split("");
const indentChars = srcCharsBeforeNode.slice(0, srcCharsBefore... | javascript | function getNodeIndent(node, byLastLine) {
const token = byLastLine ? sourceCode.getLastToken(node) : sourceCode.getFirstToken(node);
const srcCharsBeforeNode = sourceCode.getText(token, token.loc.start.column).split("");
const indentChars = srcCharsBeforeNode.slice(0, srcCharsBefore... | [
"function",
"getNodeIndent",
"(",
"node",
",",
"byLastLine",
")",
"{",
"const",
"token",
"=",
"byLastLine",
"?",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
":",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
")",
";",
"const",
"srcCharsBeforeNode",... | Get the actual indent of node
@param {ASTNode|Token} node Node to examine
@param {boolean} [byLastLine=false] get indent of node's last line
@returns {Object} The node's indent. Contains keys `space` and `tab`, representing the indent of each character. Also
contains keys `goodChar` and `badChar`, where `goodChar` is t... | [
"Get",
"the",
"actual",
"indent",
"of",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L340-L353 |
2,873 | eslint/eslint | lib/rules/indent-legacy.js | checkNodeIndent | function checkNodeIndent(node, neededIndent) {
const actualIndent = getNodeIndent(node, false);
if (
node.type !== "ArrayExpression" &&
node.type !== "ObjectExpression" &&
(actualIndent.goodChar !== neededIndent || actualIndent.badChar !== 0) &&
... | javascript | function checkNodeIndent(node, neededIndent) {
const actualIndent = getNodeIndent(node, false);
if (
node.type !== "ArrayExpression" &&
node.type !== "ObjectExpression" &&
(actualIndent.goodChar !== neededIndent || actualIndent.badChar !== 0) &&
... | [
"function",
"checkNodeIndent",
"(",
"node",
",",
"neededIndent",
")",
"{",
"const",
"actualIndent",
"=",
"getNodeIndent",
"(",
"node",
",",
"false",
")",
";",
"if",
"(",
"node",
".",
"type",
"!==",
"\"ArrayExpression\"",
"&&",
"node",
".",
"type",
"!==",
"... | Check indent for node
@param {ASTNode} node Node to check
@param {int} neededIndent needed indent
@returns {void} | [
"Check",
"indent",
"for",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L375-L414 |
2,874 | eslint/eslint | lib/rules/indent-legacy.js | checkLastNodeLineIndent | function checkLastNodeLineIndent(node, lastLineIndent) {
const lastToken = sourceCode.getLastToken(node);
const endIndent = getNodeIndent(lastToken, true);
if ((endIndent.goodChar !== lastLineIndent || endIndent.badChar !== 0) && isNodeFirstInLine(node, true)) {
repo... | javascript | function checkLastNodeLineIndent(node, lastLineIndent) {
const lastToken = sourceCode.getLastToken(node);
const endIndent = getNodeIndent(lastToken, true);
if ((endIndent.goodChar !== lastLineIndent || endIndent.badChar !== 0) && isNodeFirstInLine(node, true)) {
repo... | [
"function",
"checkLastNodeLineIndent",
"(",
"node",
",",
"lastLineIndent",
")",
"{",
"const",
"lastToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
";",
"const",
"endIndent",
"=",
"getNodeIndent",
"(",
"lastToken",
",",
"true",
")",
";",
"if",... | Check last node line indent this detects, that block closed correctly
@param {ASTNode} node Node to examine
@param {int} lastLineIndent needed indent
@returns {void} | [
"Check",
"last",
"node",
"line",
"indent",
"this",
"detects",
"that",
"block",
"closed",
"correctly"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L432-L446 |
2,875 | eslint/eslint | lib/rules/indent-legacy.js | checkLastReturnStatementLineIndent | function checkLastReturnStatementLineIndent(node, firstLineIndent) {
/*
* in case if return statement ends with ');' we have traverse back to ')'
* otherwise we'll measure indent for ';' and replace ')'
*/
const lastToken = sourceCode.getLastToken(node, as... | javascript | function checkLastReturnStatementLineIndent(node, firstLineIndent) {
/*
* in case if return statement ends with ');' we have traverse back to ')'
* otherwise we'll measure indent for ';' and replace ')'
*/
const lastToken = sourceCode.getLastToken(node, as... | [
"function",
"checkLastReturnStatementLineIndent",
"(",
"node",
",",
"firstLineIndent",
")",
"{",
"/*\n * in case if return statement ends with ');' we have traverse back to ')'\n * otherwise we'll measure indent for ';' and replace ')'\n */",
"const",
"lastTok... | Check last node line indent this detects, that block closed correctly
This function for more complicated return statement case, where closing parenthesis may be followed by ';'
@param {ASTNode} node Node to examine
@param {int} firstLineIndent first line needed indent
@returns {void} | [
"Check",
"last",
"node",
"line",
"indent",
"this",
"detects",
"that",
"block",
"closed",
"correctly",
"This",
"function",
"for",
"more",
"complicated",
"return",
"statement",
"case",
"where",
"closing",
"parenthesis",
"may",
"be",
"followed",
"by",
";"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L455-L482 |
2,876 | eslint/eslint | lib/rules/indent-legacy.js | checkFirstNodeLineIndent | function checkFirstNodeLineIndent(node, firstLineIndent) {
const startIndent = getNodeIndent(node, false);
if ((startIndent.goodChar !== firstLineIndent || startIndent.badChar !== 0) && isNodeFirstInLine(node)) {
report(
node,
firstLineInd... | javascript | function checkFirstNodeLineIndent(node, firstLineIndent) {
const startIndent = getNodeIndent(node, false);
if ((startIndent.goodChar !== firstLineIndent || startIndent.badChar !== 0) && isNodeFirstInLine(node)) {
report(
node,
firstLineInd... | [
"function",
"checkFirstNodeLineIndent",
"(",
"node",
",",
"firstLineIndent",
")",
"{",
"const",
"startIndent",
"=",
"getNodeIndent",
"(",
"node",
",",
"false",
")",
";",
"if",
"(",
"(",
"startIndent",
".",
"goodChar",
"!==",
"firstLineIndent",
"||",
"startIndent... | Check first node line indent is correct
@param {ASTNode} node Node to examine
@param {int} firstLineIndent needed indent
@returns {void} | [
"Check",
"first",
"node",
"line",
"indent",
"is",
"correct"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L490-L502 |
2,877 | eslint/eslint | lib/rules/indent-legacy.js | getParentNodeByType | function getParentNodeByType(node, type, stopAtList) {
let parent = node.parent;
const stopAtSet = new Set(stopAtList || ["Program"]);
while (parent.type !== type && !stopAtSet.has(parent.type) && parent.type !== "Program") {
parent = parent.parent;
}
... | javascript | function getParentNodeByType(node, type, stopAtList) {
let parent = node.parent;
const stopAtSet = new Set(stopAtList || ["Program"]);
while (parent.type !== type && !stopAtSet.has(parent.type) && parent.type !== "Program") {
parent = parent.parent;
}
... | [
"function",
"getParentNodeByType",
"(",
"node",
",",
"type",
",",
"stopAtList",
")",
"{",
"let",
"parent",
"=",
"node",
".",
"parent",
";",
"const",
"stopAtSet",
"=",
"new",
"Set",
"(",
"stopAtList",
"||",
"[",
"\"Program\"",
"]",
")",
";",
"while",
"(",... | Returns a parent node of given node based on a specified type
if not present then return null
@param {ASTNode} node node to examine
@param {string} type type that is being looked for
@param {string} stopAtList end points for the evaluating code
@returns {ASTNode|void} if found then node otherwise null | [
"Returns",
"a",
"parent",
"node",
"of",
"given",
"node",
"based",
"on",
"a",
"specified",
"type",
"if",
"not",
"present",
"then",
"return",
"null"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L512-L521 |
2,878 | eslint/eslint | lib/rules/indent-legacy.js | isNodeInVarOnTop | function isNodeInVarOnTop(node, varNode) {
return varNode &&
varNode.parent.loc.start.line === node.loc.start.line &&
varNode.parent.declarations.length > 1;
} | javascript | function isNodeInVarOnTop(node, varNode) {
return varNode &&
varNode.parent.loc.start.line === node.loc.start.line &&
varNode.parent.declarations.length > 1;
} | [
"function",
"isNodeInVarOnTop",
"(",
"node",
",",
"varNode",
")",
"{",
"return",
"varNode",
"&&",
"varNode",
".",
"parent",
".",
"loc",
".",
"start",
".",
"line",
"===",
"node",
".",
"loc",
".",
"start",
".",
"line",
"&&",
"varNode",
".",
"parent",
"."... | Check to see if the node is part of the multi-line variable declaration.
Also if its on the same line as the varNode
@param {ASTNode} node node to check
@param {ASTNode} varNode variable declaration node to check against
@returns {boolean} True if all the above condition satisfy | [
"Check",
"to",
"see",
"if",
"the",
"node",
"is",
"part",
"of",
"the",
"multi",
"-",
"line",
"variable",
"declaration",
".",
"Also",
"if",
"its",
"on",
"the",
"same",
"line",
"as",
"the",
"varNode"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L540-L544 |
2,879 | eslint/eslint | lib/rules/indent-legacy.js | isArgBeforeCalleeNodeMultiline | function isArgBeforeCalleeNodeMultiline(node) {
const parent = node.parent;
if (parent.arguments.length >= 2 && parent.arguments[1] === node) {
return parent.arguments[0].loc.end.line > parent.arguments[0].loc.start.line;
}
return false;
} | javascript | function isArgBeforeCalleeNodeMultiline(node) {
const parent = node.parent;
if (parent.arguments.length >= 2 && parent.arguments[1] === node) {
return parent.arguments[0].loc.end.line > parent.arguments[0].loc.start.line;
}
return false;
} | [
"function",
"isArgBeforeCalleeNodeMultiline",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"if",
"(",
"parent",
".",
"arguments",
".",
"length",
">=",
"2",
"&&",
"parent",
".",
"arguments",
"[",
"1",
"]",
"===",
"node",
")",... | Check to see if the argument before the callee node is multi-line and
there should only be 1 argument before the callee node
@param {ASTNode} node node to check
@returns {boolean} True if arguments are multi-line | [
"Check",
"to",
"see",
"if",
"the",
"argument",
"before",
"the",
"callee",
"node",
"is",
"multi",
"-",
"line",
"and",
"there",
"should",
"only",
"be",
"1",
"argument",
"before",
"the",
"callee",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L552-L560 |
2,880 | eslint/eslint | lib/rules/indent-legacy.js | filterOutSameLineVars | function filterOutSameLineVars(node) {
return node.declarations.reduce((finalCollection, elem) => {
const lastElem = finalCollection[finalCollection.length - 1];
if ((elem.loc.start.line !== node.loc.start.line && !lastElem) ||
(lastElem && lastElem.loc.s... | javascript | function filterOutSameLineVars(node) {
return node.declarations.reduce((finalCollection, elem) => {
const lastElem = finalCollection[finalCollection.length - 1];
if ((elem.loc.start.line !== node.loc.start.line && !lastElem) ||
(lastElem && lastElem.loc.s... | [
"function",
"filterOutSameLineVars",
"(",
"node",
")",
"{",
"return",
"node",
".",
"declarations",
".",
"reduce",
"(",
"(",
"finalCollection",
",",
"elem",
")",
"=>",
"{",
"const",
"lastElem",
"=",
"finalCollection",
"[",
"finalCollection",
".",
"length",
"-",... | Filter out the elements which are on the same line of each other or the node.
basically have only 1 elements from each line except the variable declaration line.
@param {ASTNode} node Variable declaration node
@returns {ASTNode[]} Filtered elements | [
"Filter",
"out",
"the",
"elements",
"which",
"are",
"on",
"the",
"same",
"line",
"of",
"each",
"other",
"or",
"the",
"node",
".",
"basically",
"have",
"only",
"1",
"elements",
"from",
"each",
"line",
"except",
"the",
"variable",
"declaration",
"line",
"."
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L889-L900 |
2,881 | eslint/eslint | lib/rules/prefer-template.js | getTopConcatBinaryExpression | function getTopConcatBinaryExpression(node) {
let currentNode = node;
while (isConcatenation(currentNode.parent)) {
currentNode = currentNode.parent;
}
return currentNode;
} | javascript | function getTopConcatBinaryExpression(node) {
let currentNode = node;
while (isConcatenation(currentNode.parent)) {
currentNode = currentNode.parent;
}
return currentNode;
} | [
"function",
"getTopConcatBinaryExpression",
"(",
"node",
")",
"{",
"let",
"currentNode",
"=",
"node",
";",
"while",
"(",
"isConcatenation",
"(",
"currentNode",
".",
"parent",
")",
")",
"{",
"currentNode",
"=",
"currentNode",
".",
"parent",
";",
"}",
"return",
... | Gets the top binary expression node for concatenation in parents of a given node.
@param {ASTNode} node - A node to get.
@returns {ASTNode} the top binary expression node in parents of a given node. | [
"Gets",
"the",
"top",
"binary",
"expression",
"node",
"for",
"concatenation",
"in",
"parents",
"of",
"a",
"given",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-template.js#L32-L39 |
2,882 | eslint/eslint | lib/rules/prefer-template.js | isOctalEscapeSequence | function isOctalEscapeSequence(node) {
// No need to check TemplateLiterals – would throw error with octal escape
const isStringLiteral = node.type === "Literal" && typeof node.value === "string";
if (!isStringLiteral) {
return false;
}
const match = node.raw.match(/^([^\\]|\\[^0-7])*\\([... | javascript | function isOctalEscapeSequence(node) {
// No need to check TemplateLiterals – would throw error with octal escape
const isStringLiteral = node.type === "Literal" && typeof node.value === "string";
if (!isStringLiteral) {
return false;
}
const match = node.raw.match(/^([^\\]|\\[^0-7])*\\([... | [
"function",
"isOctalEscapeSequence",
"(",
"node",
")",
"{",
"// No need to check TemplateLiterals – would throw error with octal escape",
"const",
"isStringLiteral",
"=",
"node",
".",
"type",
"===",
"\"Literal\"",
"&&",
"typeof",
"node",
".",
"value",
"===",
"\"string\"",
... | Determines whether a given node is a octal escape sequence
@param {ASTNode} node A node to check
@returns {boolean} `true` if the node is an octal escape sequence | [
"Determines",
"whether",
"a",
"given",
"node",
"is",
"a",
"octal",
"escape",
"sequence"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-template.js#L46-L65 |
2,883 | eslint/eslint | lib/rules/prefer-template.js | hasOctalEscapeSequence | function hasOctalEscapeSequence(node) {
if (isConcatenation(node)) {
return hasOctalEscapeSequence(node.left) || hasOctalEscapeSequence(node.right);
}
return isOctalEscapeSequence(node);
} | javascript | function hasOctalEscapeSequence(node) {
if (isConcatenation(node)) {
return hasOctalEscapeSequence(node.left) || hasOctalEscapeSequence(node.right);
}
return isOctalEscapeSequence(node);
} | [
"function",
"hasOctalEscapeSequence",
"(",
"node",
")",
"{",
"if",
"(",
"isConcatenation",
"(",
"node",
")",
")",
"{",
"return",
"hasOctalEscapeSequence",
"(",
"node",
".",
"left",
")",
"||",
"hasOctalEscapeSequence",
"(",
"node",
".",
"right",
")",
";",
"}"... | Checks whether or not a node contains a octal escape sequence
@param {ASTNode} node A node to check
@returns {boolean} `true` if the node contains an octal escape sequence | [
"Checks",
"whether",
"or",
"not",
"a",
"node",
"contains",
"a",
"octal",
"escape",
"sequence"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-template.js#L72-L78 |
2,884 | eslint/eslint | lib/rules/prefer-template.js | hasStringLiteral | function hasStringLiteral(node) {
if (isConcatenation(node)) {
// `left` is deeper than `right` normally.
return hasStringLiteral(node.right) || hasStringLiteral(node.left);
}
return astUtils.isStringLiteral(node);
} | javascript | function hasStringLiteral(node) {
if (isConcatenation(node)) {
// `left` is deeper than `right` normally.
return hasStringLiteral(node.right) || hasStringLiteral(node.left);
}
return astUtils.isStringLiteral(node);
} | [
"function",
"hasStringLiteral",
"(",
"node",
")",
"{",
"if",
"(",
"isConcatenation",
"(",
"node",
")",
")",
"{",
"// `left` is deeper than `right` normally.",
"return",
"hasStringLiteral",
"(",
"node",
".",
"right",
")",
"||",
"hasStringLiteral",
"(",
"node",
".",... | Checks whether or not a given binary expression has string literals.
@param {ASTNode} node - A node to check.
@returns {boolean} `true` if the node has string literals. | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"binary",
"expression",
"has",
"string",
"literals",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-template.js#L85-L92 |
2,885 | eslint/eslint | lib/rules/prefer-template.js | hasNonStringLiteral | function hasNonStringLiteral(node) {
if (isConcatenation(node)) {
// `left` is deeper than `right` normally.
return hasNonStringLiteral(node.right) || hasNonStringLiteral(node.left);
}
return !astUtils.isStringLiteral(node);
} | javascript | function hasNonStringLiteral(node) {
if (isConcatenation(node)) {
// `left` is deeper than `right` normally.
return hasNonStringLiteral(node.right) || hasNonStringLiteral(node.left);
}
return !astUtils.isStringLiteral(node);
} | [
"function",
"hasNonStringLiteral",
"(",
"node",
")",
"{",
"if",
"(",
"isConcatenation",
"(",
"node",
")",
")",
"{",
"// `left` is deeper than `right` normally.",
"return",
"hasNonStringLiteral",
"(",
"node",
".",
"right",
")",
"||",
"hasNonStringLiteral",
"(",
"node... | Checks whether or not a given binary expression has non string literals.
@param {ASTNode} node - A node to check.
@returns {boolean} `true` if the node has non string literals. | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"binary",
"expression",
"has",
"non",
"string",
"literals",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-template.js#L99-L106 |
2,886 | eslint/eslint | lib/rules/prefer-template.js | getTextBetween | function getTextBetween(node1, node2) {
const allTokens = [node1].concat(sourceCode.getTokensBetween(node1, node2)).concat(node2);
const sourceText = sourceCode.getText();
return allTokens.slice(0, -1).reduce((accumulator, token, index) => accumulator + sourceText.slice(token.range[... | javascript | function getTextBetween(node1, node2) {
const allTokens = [node1].concat(sourceCode.getTokensBetween(node1, node2)).concat(node2);
const sourceText = sourceCode.getText();
return allTokens.slice(0, -1).reduce((accumulator, token, index) => accumulator + sourceText.slice(token.range[... | [
"function",
"getTextBetween",
"(",
"node1",
",",
"node2",
")",
"{",
"const",
"allTokens",
"=",
"[",
"node1",
"]",
".",
"concat",
"(",
"sourceCode",
".",
"getTokensBetween",
"(",
"node1",
",",
"node2",
")",
")",
".",
"concat",
"(",
"node2",
")",
";",
"c... | Gets the non-token text between two nodes, ignoring any other tokens that appear between the two tokens.
@param {ASTNode} node1 The first node
@param {ASTNode} node2 The second node
@returns {string} The text between the nodes, excluding other tokens | [
"Gets",
"the",
"non",
"-",
"token",
"text",
"between",
"two",
"nodes",
"ignoring",
"any",
"other",
"tokens",
"that",
"appear",
"between",
"the",
"two",
"tokens",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-template.js#L167-L172 |
2,887 | eslint/eslint | lib/rules/prefer-template.js | getTemplateLiteral | function getTemplateLiteral(currentNode, textBeforeNode, textAfterNode) {
if (currentNode.type === "Literal" && typeof currentNode.value === "string") {
/*
* If the current node is a string literal, escape any instances of ${ or ` to prevent them from being interpreted
... | javascript | function getTemplateLiteral(currentNode, textBeforeNode, textAfterNode) {
if (currentNode.type === "Literal" && typeof currentNode.value === "string") {
/*
* If the current node is a string literal, escape any instances of ${ or ` to prevent them from being interpreted
... | [
"function",
"getTemplateLiteral",
"(",
"currentNode",
",",
"textBeforeNode",
",",
"textAfterNode",
")",
"{",
"if",
"(",
"currentNode",
".",
"type",
"===",
"\"Literal\"",
"&&",
"typeof",
"currentNode",
".",
"value",
"===",
"\"string\"",
")",
"{",
"/*\n ... | Returns a template literal form of the given node.
@param {ASTNode} currentNode A node that should be converted to a template literal
@param {string} textBeforeNode Text that should appear before the node
@param {string} textAfterNode Text that should appear after the node
@returns {string} A string form of this node, ... | [
"Returns",
"a",
"template",
"literal",
"form",
"of",
"the",
"given",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-template.js#L181-L234 |
2,888 | eslint/eslint | lib/rules/prefer-template.js | fixNonStringBinaryExpression | function fixNonStringBinaryExpression(fixer, node) {
const topBinaryExpr = getTopConcatBinaryExpression(node.parent);
if (hasOctalEscapeSequence(topBinaryExpr)) {
return null;
}
return fixer.replaceText(topBinaryExpr, getTemplateLiteral(topBinaryExpr, nu... | javascript | function fixNonStringBinaryExpression(fixer, node) {
const topBinaryExpr = getTopConcatBinaryExpression(node.parent);
if (hasOctalEscapeSequence(topBinaryExpr)) {
return null;
}
return fixer.replaceText(topBinaryExpr, getTemplateLiteral(topBinaryExpr, nu... | [
"function",
"fixNonStringBinaryExpression",
"(",
"fixer",
",",
"node",
")",
"{",
"const",
"topBinaryExpr",
"=",
"getTopConcatBinaryExpression",
"(",
"node",
".",
"parent",
")",
";",
"if",
"(",
"hasOctalEscapeSequence",
"(",
"topBinaryExpr",
")",
")",
"{",
"return"... | Returns a fixer object that converts a non-string binary expression to a template literal
@param {SourceCodeFixer} fixer The fixer object
@param {ASTNode} node A node that should be converted to a template literal
@returns {Object} A fix for this binary expression | [
"Returns",
"a",
"fixer",
"object",
"that",
"converts",
"a",
"non",
"-",
"string",
"binary",
"expression",
"to",
"a",
"template",
"literal"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-template.js#L242-L250 |
2,889 | eslint/eslint | lib/rules/prefer-template.js | checkForStringConcat | function checkForStringConcat(node) {
if (!astUtils.isStringLiteral(node) || !isConcatenation(node.parent)) {
return;
}
const topBinaryExpr = getTopConcatBinaryExpression(node.parent);
// Checks whether or not this node had been checked already.
... | javascript | function checkForStringConcat(node) {
if (!astUtils.isStringLiteral(node) || !isConcatenation(node.parent)) {
return;
}
const topBinaryExpr = getTopConcatBinaryExpression(node.parent);
// Checks whether or not this node had been checked already.
... | [
"function",
"checkForStringConcat",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"astUtils",
".",
"isStringLiteral",
"(",
"node",
")",
"||",
"!",
"isConcatenation",
"(",
"node",
".",
"parent",
")",
")",
"{",
"return",
";",
"}",
"const",
"topBinaryExpr",
"=",
"... | Reports if a given node is string concatenation with non string literals.
@param {ASTNode} node - A node to check.
@returns {void} | [
"Reports",
"if",
"a",
"given",
"node",
"is",
"string",
"concatenation",
"with",
"non",
"string",
"literals",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-template.js#L258-L278 |
2,890 | eslint/eslint | lib/rules/no-return-await.js | reportUnnecessaryAwait | function reportUnnecessaryAwait(node) {
context.report({
node: context.getSourceCode().getFirstToken(node),
loc: node.loc,
message
});
} | javascript | function reportUnnecessaryAwait(node) {
context.report({
node: context.getSourceCode().getFirstToken(node),
loc: node.loc,
message
});
} | [
"function",
"reportUnnecessaryAwait",
"(",
"node",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
":",
"context",
".",
"getSourceCode",
"(",
")",
".",
"getFirstToken",
"(",
"node",
")",
",",
"loc",
":",
"node",
".",
"loc",
",",
"message",
"}",
"... | Reports a found unnecessary `await` expression.
@param {ASTNode} node The node representing the `await` expression to report
@returns {void} | [
"Reports",
"a",
"found",
"unnecessary",
"await",
"expression",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-return-await.js#L41-L47 |
2,891 | eslint/eslint | lib/rules/no-self-compare.js | hasSameTokens | function hasSameTokens(nodeA, nodeB) {
const tokensA = sourceCode.getTokens(nodeA);
const tokensB = sourceCode.getTokens(nodeB);
return tokensA.length === tokensB.length &&
tokensA.every((token, index) => token.type === tokensB[index].type && token.value === tokensB[... | javascript | function hasSameTokens(nodeA, nodeB) {
const tokensA = sourceCode.getTokens(nodeA);
const tokensB = sourceCode.getTokens(nodeB);
return tokensA.length === tokensB.length &&
tokensA.every((token, index) => token.type === tokensB[index].type && token.value === tokensB[... | [
"function",
"hasSameTokens",
"(",
"nodeA",
",",
"nodeB",
")",
"{",
"const",
"tokensA",
"=",
"sourceCode",
".",
"getTokens",
"(",
"nodeA",
")",
";",
"const",
"tokensB",
"=",
"sourceCode",
".",
"getTokens",
"(",
"nodeB",
")",
";",
"return",
"tokensA",
".",
... | Determines whether two nodes are composed of the same tokens.
@param {ASTNode} nodeA The first node
@param {ASTNode} nodeB The second node
@returns {boolean} true if the nodes have identical token representations | [
"Determines",
"whether",
"two",
"nodes",
"are",
"composed",
"of",
"the",
"same",
"tokens",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-self-compare.js#L36-L42 |
2,892 | eslint/eslint | lib/rules/no-constant-condition.js | isConstant | function isConstant(node, inBooleanPosition) {
switch (node.type) {
case "Literal":
case "ArrowFunctionExpression":
case "FunctionExpression":
case "ObjectExpression":
case "ArrayExpression":
return true;
... | javascript | function isConstant(node, inBooleanPosition) {
switch (node.type) {
case "Literal":
case "ArrowFunctionExpression":
case "FunctionExpression":
case "ObjectExpression":
case "ArrayExpression":
return true;
... | [
"function",
"isConstant",
"(",
"node",
",",
"inBooleanPosition",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"\"Literal\"",
":",
"case",
"\"ArrowFunctionExpression\"",
":",
"case",
"\"FunctionExpression\"",
":",
"case",
"\"ObjectExpression\"",
... | Checks if a node has a constant truthiness value.
@param {ASTNode} node The AST node to check.
@param {boolean} inBooleanPosition `false` if checking branch of a condition.
`true` in all other cases
@returns {Bool} true when node's truthiness is constant
@private | [
"Checks",
"if",
"a",
"node",
"has",
"a",
"constant",
"truthiness",
"value",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-constant-condition.js#L92-L146 |
2,893 | eslint/eslint | lib/rules/no-constant-condition.js | trackConstantConditionLoop | function trackConstantConditionLoop(node) {
if (node.test && isConstant(node.test, true)) {
loopsInCurrentScope.add(node);
}
} | javascript | function trackConstantConditionLoop(node) {
if (node.test && isConstant(node.test, true)) {
loopsInCurrentScope.add(node);
}
} | [
"function",
"trackConstantConditionLoop",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"test",
"&&",
"isConstant",
"(",
"node",
".",
"test",
",",
"true",
")",
")",
"{",
"loopsInCurrentScope",
".",
"add",
"(",
"node",
")",
";",
"}",
"}"
] | Tracks when the given node contains a constant condition.
@param {ASTNode} node The AST node to check.
@returns {void}
@private | [
"Tracks",
"when",
"the",
"given",
"node",
"contains",
"a",
"constant",
"condition",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-constant-condition.js#L154-L158 |
2,894 | eslint/eslint | lib/rules/no-constant-condition.js | checkConstantConditionLoopInSet | function checkConstantConditionLoopInSet(node) {
if (loopsInCurrentScope.has(node)) {
loopsInCurrentScope.delete(node);
context.report({ node: node.test, messageId: "unexpected" });
}
} | javascript | function checkConstantConditionLoopInSet(node) {
if (loopsInCurrentScope.has(node)) {
loopsInCurrentScope.delete(node);
context.report({ node: node.test, messageId: "unexpected" });
}
} | [
"function",
"checkConstantConditionLoopInSet",
"(",
"node",
")",
"{",
"if",
"(",
"loopsInCurrentScope",
".",
"has",
"(",
"node",
")",
")",
"{",
"loopsInCurrentScope",
".",
"delete",
"(",
"node",
")",
";",
"context",
".",
"report",
"(",
"{",
"node",
":",
"n... | Reports when the set contains the given constant condition node
@param {ASTNode} node The AST node to check.
@returns {void}
@private | [
"Reports",
"when",
"the",
"set",
"contains",
"the",
"given",
"constant",
"condition",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-constant-condition.js#L166-L171 |
2,895 | eslint/eslint | lib/rules/no-constant-condition.js | reportIfConstant | function reportIfConstant(node) {
if (node.test && isConstant(node.test, true)) {
context.report({ node: node.test, messageId: "unexpected" });
}
} | javascript | function reportIfConstant(node) {
if (node.test && isConstant(node.test, true)) {
context.report({ node: node.test, messageId: "unexpected" });
}
} | [
"function",
"reportIfConstant",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"test",
"&&",
"isConstant",
"(",
"node",
".",
"test",
",",
"true",
")",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
":",
"node",
".",
"test",
",",
"messageId",
... | Reports when the given node contains a constant condition.
@param {ASTNode} node The AST node to check.
@returns {void}
@private | [
"Reports",
"when",
"the",
"given",
"node",
"contains",
"a",
"constant",
"condition",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-constant-condition.js#L179-L183 |
2,896 | eslint/eslint | lib/rules/generator-star-spacing.js | optionToDefinition | function optionToDefinition(option, defaults) {
if (!option) {
return defaults;
}
return typeof option === "string"
? optionDefinitions[option]
: Object.assign({}, defaults, option);
} | javascript | function optionToDefinition(option, defaults) {
if (!option) {
return defaults;
}
return typeof option === "string"
? optionDefinitions[option]
: Object.assign({}, defaults, option);
} | [
"function",
"optionToDefinition",
"(",
"option",
",",
"defaults",
")",
"{",
"if",
"(",
"!",
"option",
")",
"{",
"return",
"defaults",
";",
"}",
"return",
"typeof",
"option",
"===",
"\"string\"",
"?",
"optionDefinitions",
"[",
"option",
"]",
":",
"Object",
... | Returns resolved option definitions based on an option and defaults
@param {any} option - The option object or string value
@param {Object} defaults - The defaults to use if options are not present
@returns {Object} the resolved object definition | [
"Returns",
"resolved",
"option",
"definitions",
"based",
"on",
"an",
"option",
"and",
"defaults"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/generator-star-spacing.js#L86-L94 |
2,897 | eslint/eslint | lib/rules/generator-star-spacing.js | getStarToken | function getStarToken(node) {
return sourceCode.getFirstToken(
(node.parent.method || node.parent.type === "MethodDefinition") ? node.parent : node,
isStarToken
);
} | javascript | function getStarToken(node) {
return sourceCode.getFirstToken(
(node.parent.method || node.parent.type === "MethodDefinition") ? node.parent : node,
isStarToken
);
} | [
"function",
"getStarToken",
"(",
"node",
")",
"{",
"return",
"sourceCode",
".",
"getFirstToken",
"(",
"(",
"node",
".",
"parent",
".",
"method",
"||",
"node",
".",
"parent",
".",
"type",
"===",
"\"MethodDefinition\"",
")",
"?",
"node",
".",
"parent",
":",
... | Gets the generator star token of the given function node.
@param {ASTNode} node - The function node to get.
@returns {Token} Found star token. | [
"Gets",
"the",
"generator",
"star",
"token",
"of",
"the",
"given",
"function",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/generator-star-spacing.js#L124-L129 |
2,898 | eslint/eslint | lib/rules/generator-star-spacing.js | checkFunction | function checkFunction(node) {
if (!node.generator) {
return;
}
const starToken = getStarToken(node);
const prevToken = sourceCode.getTokenBefore(starToken);
const nextToken = sourceCode.getTokenAfter(starToken);
let kind = "named... | javascript | function checkFunction(node) {
if (!node.generator) {
return;
}
const starToken = getStarToken(node);
const prevToken = sourceCode.getTokenBefore(starToken);
const nextToken = sourceCode.getTokenAfter(starToken);
let kind = "named... | [
"function",
"checkFunction",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
".",
"generator",
")",
"{",
"return",
";",
"}",
"const",
"starToken",
"=",
"getStarToken",
"(",
"node",
")",
";",
"const",
"prevToken",
"=",
"sourceCode",
".",
"getTokenBefore",
... | Enforces the spacing around the star if node is a generator function.
@param {ASTNode} node A function expression or declaration node.
@returns {void} | [
"Enforces",
"the",
"spacing",
"around",
"the",
"star",
"if",
"node",
"is",
"a",
"generator",
"function",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/generator-star-spacing.js#L180-L203 |
2,899 | eslint/eslint | lib/rules/switch-colon-spacing.js | getColonToken | function getColonToken(node) {
if (node.test) {
return sourceCode.getTokenAfter(node.test, astUtils.isColonToken);
}
return sourceCode.getFirstToken(node, 1);
} | javascript | function getColonToken(node) {
if (node.test) {
return sourceCode.getTokenAfter(node.test, astUtils.isColonToken);
}
return sourceCode.getFirstToken(node, 1);
} | [
"function",
"getColonToken",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"test",
")",
"{",
"return",
"sourceCode",
".",
"getTokenAfter",
"(",
"node",
".",
"test",
",",
"astUtils",
".",
"isColonToken",
")",
";",
"}",
"return",
"sourceCode",
".",
"getFi... | true by default
Get the colon token of the given SwitchCase node.
@param {ASTNode} node The SwitchCase node to get.
@returns {Token} The colon token of the node. | [
"true",
"by",
"default",
"Get",
"the",
"colon",
"token",
"of",
"the",
"given",
"SwitchCase",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/switch-colon-spacing.js#L59-L64 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.