repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isFixable | function isFixable(nodeOrToken: Token) {
const nextToken = sourceCode.getTokenAfter(nodeOrToken)
if (!nextToken || nextToken.type !== 'String')
return true
const stringNode = sourceCode.getNodeByRangeIndex(nextToken.range[0])
return !isTopLevelExpressionStatement(stringNode!.parent!)
... | /**
* Checks if a node or token is fixable.
* A node is fixable if it can be removed without turning a subsequent statement into a directive after fixing other nodes.
* @param nodeOrToken The node or token to check.
* @returns Whether or not the node is fixable.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-extra-semi/no-extra-semi._js_.ts#L39-L48 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | report | function report(nodeOrToken: Token | ASTNode) {
context.report({
node: nodeOrToken,
messageId: 'unexpected',
fix: isFixable(nodeOrToken as Token)
/**
* Expand the replacement range to include the surrounding
* tokens to avoid conflicting with semi.
... | /**
* Reports an unnecessary semicolon error.
* @param nodeOrToken A node or a token to be reported.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-extra-semi/no-extra-semi._js_.ts#L54-L69 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | checkForPartOfClassBody | function checkForPartOfClassBody(firstToken: Token) {
for (let token = firstToken;
token.type === 'Punctuator' && !isClosingBraceToken(token);
token = sourceCode.getTokenAfter(token)!
) {
if (isSemicolonToken(token))
report(token)
}
} | /**
* 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 firstToken The first token to check.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-extra-semi/no-extra-semi._js_.ts#L76-L84 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | normalizeOptions | function normalizeOptions(options: RuleOptions[0] = {}) {
const hasGroups = options.groups && options.groups.length > 0
const groups = hasGroups ? options.groups : DEFAULT_GROUPS
const allowSamePrecedence = options.allowSamePrecedence !== false
return {
groups,
allowSamePrecedence,
}
} | /**
* Normalizes options.
* @param options A options object to normalize.
* @returns Normalized option object.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-mixed-operators/no-mixed-operators._js_.ts#L41-L50 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | includesBothInAGroup | function includesBothInAGroup(groups: string[][], left: string, right: string): boolean {
return groups.some(group => group.includes(left) && group.includes(right))
} | /**
* Checks whether any group which includes both given operator exists or not.
* @param groups A list of groups to check.
* @param left An operator.
* @param right Another operator.
* @returns if such group existed.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-mixed-operators/no-mixed-operators._js_.ts#L59-L61 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getChildNode | function getChildNode(node: NodeType | Tree.ConditionalExpression): ASTNode {
return node.type === 'ConditionalExpression' ? node.test : node.left
} | /**
* Checks whether the given node is a conditional expression and returns the test node else the left node.
* @param node A node which can be a BinaryExpression or a LogicalExpression node.
* This parent node can be BinaryExpression, LogicalExpression
* , or a ConditionalExpression node
* @returns node the ... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-mixed-operators/no-mixed-operators._js_.ts#L70-L72 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | shouldIgnore | function shouldIgnore(node: NodeType): boolean {
const a = node
const b = node.parent as (NodeType | Tree.ConditionalExpression)
return (
!includesBothInAGroup(
options.groups ?? [],
a.operator,
b.type === 'ConditionalExpression' ? '?:' : b.operator,
)
... | /**
* Checks whether a given node should be ignored by options or not.
* @param node A node to check. This is a BinaryExpression
* node or a LogicalExpression node. This parent node is one of
* them, too.
* @returns `true` if the node should be ignored.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-mixed-operators/no-mixed-operators._js_.ts#L128-L143 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isMixedWithParent | function isMixedWithParent(node: NodeType): boolean {
return (
node.operator !== (node.parent as NodeType).operator
&& !isParenthesised(sourceCode, node)
)
} | /**
* Checks whether the operator of a given node is mixed with parent
* node's operator or not.
* @param node A node to check. This is a BinaryExpression
* node or a LogicalExpression node. This parent node is one of
* them, too.
* @returns `true` if the node was mixed.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-mixed-operators/no-mixed-operators._js_.ts#L153-L158 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getOperatorToken | function getOperatorToken(node: NodeType): Tree.Token {
return sourceCode.getTokenAfter(getChildNode(node), isNotClosingParenToken)!
} | /**
* Gets the operator token of a given node.
* @param node A node to check. This is a BinaryExpression
* node or a LogicalExpression node.
* @returns The operator token of the node.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-mixed-operators/no-mixed-operators._js_.ts#L166-L168 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | reportBothOperators | function reportBothOperators(node: NodeType) {
const parent = node.parent as NodeType
const left = (getChildNode(parent) === node) ? node : parent
const right = (getChildNode(parent) !== node) ? node : parent
const data = {
leftOperator: left.operator || '?:',
rightOperator: righ... | /**
* Reports both the operator of a given node and the operator of the
* parent node.
* @param node A node to check. This is a BinaryExpression
* node or a LogicalExpression node. This parent node is one of
* them, too.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-mixed-operators/no-mixed-operators._js_.ts#L177-L198 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | check | function check(node: NodeType) {
if (
TARGET_NODE_TYPE.test(node.parent.type)
&& isMixedWithParent(node)
&& !shouldIgnore(node)
) {
reportBothOperators(node)
}
} | /**
* Checks between the operator of this node and the operator of the
* parent node.
* @param node A node to check.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-mixed-operators/no-mixed-operators._js_.ts#L205-L213 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | formatReportedCommentValue | function formatReportedCommentValue(token: Token): string {
const valueLines = token.value.split('\n')
const value = valueLines[0]
const formattedValue = `${value.slice(0, 12)}...`
return valueLines.length === 1 && value.length <= 12 ? value : formattedValue
} | /**
* Formats value of given comment token for error message by truncating its length.
* @param token comment token
* @returns formatted value
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-multi-spaces/no-multi-spaces._js_.ts#L69-L75 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getExpectedError | function getExpectedError(lines: number) {
return {
messageId: 'consecutiveBlank',
data: {
max: lines,
pluralizedLines: lines === 1 ? 'line' : 'lines',
},
type: 'Program',
column: 1,
}
} | /**
* Creates the expected error message object for the specified number of lines
* @param lines The number of lines expected.
* @returns the expected error message object
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-multiple-empty-lines/no-multiple-empty-lines._js_.test.ts#L15-L25 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getExpectedErrorEOF | function getExpectedErrorEOF(lines: number) {
return {
messageId: 'blankEndOfFile',
data: {
max: lines,
},
type: 'Program',
column: 1,
}
} | /**
* Creates the expected error message object for the specified number of lines
* @param lines The number of lines expected.
* @returns the expected error message object
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-multiple-empty-lines/no-multiple-empty-lines._js_.test.ts#L33-L42 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getExpectedErrorBOF | function getExpectedErrorBOF(lines: number) {
return {
messageId: 'blankBeginningOfFile',
data: {
max: lines,
},
type: 'Program',
column: 1,
}
} | /**
* Creates the expected error message object for the specified number of lines
* @param lines The number of lines expected.
* @returns the expected error message object
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-multiple-empty-lines/no-multiple-empty-lines._js_.test.ts#L50-L59 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | report | function report(node: ASTNode, location: Tree.Position | Tree.SourceLocation, fixRange: Readonly<Tree.Range>) {
/**
* Passing node is a bit dirty, because message data will contain big
* text in `source`. But... who cares :) ?
* One more kludge will not make worse the bloody wizardry of this
... | /**
* Report the error message
* @param node node to report
* @param location range information
* @param fixRange Range based on the whole program
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-trailing-spaces/no-trailing-spaces._js_.ts#L64-L79 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getCommentLineNumbers | function getCommentLineNumbers(comments: Tree.Comment[]) {
const lines = new Set()
comments.forEach((comment) => {
const endLine = comment.type === 'Block'
? comment.loc.end.line - 1
: comment.loc.end.line
for (let i = comment.loc.start.line; i <= endLine; i++)
... | /**
* Given a list of comment nodes, return the line numbers for those comments.
* @param comments An array of comment nodes.
* @returns An array of line numbers containing comments.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-trailing-spaces/no-trailing-spaces._js_.ts#L86-L99 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | reportError | function reportError(node: Tree.MemberExpression, leftToken: Token, rightToken: Token) {
context.report({
node,
messageId: 'unexpectedWhitespace',
data: {
propName: sourceCode.getText(node.property),
},
fix(fixer) {
let replacementText = ''
if... | /**
* Reports whitespace before property token
* @param node the node to report in the event of an error
* @param leftToken the left token
* @param rightToken the right token
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/no-whitespace-before-property/no-whitespace-before-property._js_.ts#L39-L69 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getOption | function getOption(keywordName: KeywordName) {
return context.options[1] && context.options[1].overrides && context.options[1].overrides[keywordName]
|| context.options[0]
|| 'beside'
} | /**
* Gets the applicable preference for a particular keyword
* @param keywordName The name of a keyword, e.g. 'if'
* @returns The applicable option for the keyword, e.g. 'beside'
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/nonblock-statement-body-position/nonblock-statement-body-position._js_.ts#L64-L68 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | validateStatement | function validateStatement(node: Tree.Statement, keywordName: KeywordName) {
const option = getOption(keywordName)
if (node.type === 'BlockStatement' || option === 'any')
return
const tokenBefore = sourceCode.getTokenBefore(node)!
if (tokenBefore.loc.end.line === node.loc.start.line &... | /**
* Validates the location of a single-line statement
* @param node The single-line statement
* @param keywordName The applicable keyword name for the single-line statement
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/nonblock-statement-body-position/nonblock-statement-body-position._js_.ts#L75-L102 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | normalizeOptionValue | function normalizeOptionValue(value: any) {
let multiline = false
let minProperties = Number.POSITIVE_INFINITY
let consistent = false
if (value) {
if (value === 'always') {
minProperties = 0
}
else if (value === 'never') {
minProperties = Number.POSITIVE_INFINITY
}
else {
... | /**
* Normalizes a given option value.
* @param value An option value to parse.
* @returns Normalized option object.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-newline/object-curly-newline._js_.ts#L43-L66 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isObject | function isObject(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null
} | /**
* Checks if a value is an object.
* @param value The value to check
* @returns `true` if the value is an object, otherwise `false`
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-newline/object-curly-newline._js_.ts#L73-L75 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isNodeSpecificOption | function isNodeSpecificOption(option: unknown) {
return isObject(option) || typeof option === 'string'
} | /**
* Checks if an option is a node-specific option
* @param option The option to check
* @returns `true` if the option is node-specific, otherwise `false`
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-newline/object-curly-newline._js_.ts#L82-L84 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | normalizeOptions | function normalizeOptions(options: any) {
if (isObject(options) && Object.values(options).some(isNodeSpecificOption)) {
return {
ObjectExpression: normalizeOptionValue(options.ObjectExpression),
ObjectPattern: normalizeOptionValue(options.ObjectPattern),
ImportDeclaration: normalizeOptionValue(o... | /**
* Normalizes a given option value.
* @param options An option value to parse.
* @returns {{
* ObjectExpression: {multiline: boolean, minProperties: number, consistent: boolean},
* ObjectPattern: {multiline: boolean, minProperties: number, consistent: boolean},
* ImportDeclaration: {multiline: boolean, m... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-newline/object-curly-newline._js_.ts#L98-L113 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | areLineBreaksRequired | function areLineBreaksRequired(
node:
| Tree.ObjectExpression
| Tree.ObjectPattern
| Tree.ImportDeclaration
| Tree.ExportNamedDeclaration
| Tree.TSTypeLiteral
| Tree.TSInterfaceBody,
options: { multiline: boolean, minProperties: number, consistent: boolean },
first: Token,
last: Token,
)... | /**
* Determines if ObjectExpression, ObjectPattern, ImportDeclaration, ExportNamedDeclaration, TSTypeLiteral or TSInterfaceBody
* node needs to be checked for missing line breaks
* @param node Node under inspection
* @param options option specific to node type
* @param first First object property
* @param last L... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-newline/object-curly-newline._js_.ts#L124-L159 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | check | function check(
node:
| Tree.ObjectExpression
| Tree.ObjectPattern
| Tree.ImportDeclaration
| Tree.ExportNamedDeclaration
| Tree.TSTypeLiteral
| Tree.TSInterfaceBody,
) {
const options = normalizedOptions[node.type]
if (
(node.type === 'Impo... | /**
* Reports a given node if it violated this rule.
* @param node A node to check. This is an ObjectExpression, ObjectPattern, ImportDeclaration, ExportNamedDeclaration, TSTypeLiteral or TSInterfaceBody node.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-newline/object-curly-newline._js_.ts#L210-L330 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isOptionSet | function isOptionSet(option: keyof NonNullable<RuleOptions[1]>): boolean {
return context.options[1] ? context.options[1][option] === !spaced : false
} | /**
* Determines whether an option is set, relative to the spacing option.
* If spaced is "always", then check whether option is set to false.
* If spaced is "never", then check whether option is set to true.
* @param option The option to exclude.
* @returns Whether or not the property is exclu... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._js_.ts#L60-L62 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | reportNoBeginningSpace | function reportNoBeginningSpace(node: ASTNode, token: Token) {
const nextToken = context.sourceCode.getTokenAfter(token, { includeComments: true })!
context.report({
node,
loc: { start: token.loc.end, end: nextToken.loc.start },
messageId: 'unexpectedSpaceAfter',
data: {
... | /**
* Reports that there shouldn't be a space after the first token
* @param node The node to report in the event of an error.
* @param token The token to use for the report.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._js_.ts#L75-L89 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | reportNoEndingSpace | function reportNoEndingSpace(node: ASTNode, token: Token) {
const previousToken = context.sourceCode.getTokenBefore(token, { includeComments: true })!
context.report({
node,
loc: { start: previousToken.loc.end, end: token.loc.start },
messageId: 'unexpectedSpaceBefore',
data... | /**
* Reports that there shouldn't be a space before the last token
* @param node The node to report in the event of an error.
* @param token The token to use for the report.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._js_.ts#L96-L110 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | reportRequiredBeginningSpace | function reportRequiredBeginningSpace(node: ASTNode, token: Token) {
context.report({
node,
loc: token.loc,
messageId: 'requireSpaceAfter',
data: {
token: token.value,
},
fix(fixer: RuleFixer) {
return fixer.insertTextAfter(token, ' ')
},... | /**
* Reports that there should be a space after the first token
* @param node The node to report in the event of an error.
* @param token The token to use for the report.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._js_.ts#L117-L129 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | reportRequiredEndingSpace | function reportRequiredEndingSpace(node: ASTNode, token: Token) {
context.report({
node,
loc: token.loc,
messageId: 'requireSpaceBefore',
data: {
token: token.value,
},
fix(fixer: RuleFixer) {
return fixer.insertTextBefore(token, ' ')
},
... | /**
* Reports that there should be a space before the last token
* @param node The node to report in the event of an error.
* @param token The token to use for the report.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._js_.ts#L136-L148 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | validateBraceSpacing | function validateBraceSpacing(node: ASTNode, first: Token, second: Token, penultimate: Token, last: Token) {
if (isTokenOnSameLine(first, second)) {
const firstSpaced = sourceCode.isSpaceBetween(first, second)
if (options.spaced && !firstSpaced)
reportRequiredBeginningSpace(node, first)... | /**
* Determines if spacing in curly braces is valid.
* @param node The AST node to check.
* @param first The first token to check (should be the opening brace)
* @param second The second token to check (should be first after the opening brace)
* @param penultimate The penultimate token to chec... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._js_.ts#L158-L189 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getClosingBraceOfObject | function getClosingBraceOfObject(
node:
| Tree.ObjectExpression
| Tree.ObjectPattern,
) {
const lastProperty = node.properties[node.properties.length - 1]
return sourceCode.getTokenAfter(lastProperty, isClosingBraceToken)
} | /**
* Gets '}' token of an object node.
*
* Because the last token of object patterns might be a type annotation,
* this traverses tokens preceded by the last property, then returns the
* first '}' token.
* @param node The node to get. This node is an
* ObjectExpression or an Obj... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._js_.ts#L202-L210 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | checkForObject | function checkForObject(node:
| Tree.ObjectExpression
| Tree.ObjectPattern) {
if (node.properties.length === 0)
return
const first = sourceCode.getFirstToken(node)!
const last = getClosingBraceOfObject(node)!
const second = sourceCode.getTokenAfter(first, { includeComments: ... | /**
* Reports a given object node if spacing in curly braces is invalid.
* @param node An ObjectExpression or ObjectPattern node to check.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._js_.ts#L216-L228 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | checkForImport | function checkForImport(node: Tree.ImportDeclaration) {
if (node.specifiers.length === 0)
return
let firstSpecifier = node.specifiers[0]
const lastSpecifier = node.specifiers[node.specifiers.length - 1]
if (lastSpecifier.type !== 'ImportSpecifier')
return
if (firstSpecif... | /**
* Reports a given import node if spacing in curly braces is invalid.
* @param node An ImportDeclaration node to check.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._js_.ts#L234-L253 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | checkForExport | function checkForExport(node: Tree.ExportNamedDeclaration) {
if (node.specifiers.length === 0)
return
const firstSpecifier = node.specifiers[0]
const lastSpecifier = node.specifiers[node.specifiers.length - 1]
const first = sourceCode.getTokenBefore(firstSpecifier)!
const last = s... | /**
* Reports a given export node if spacing in curly braces is invalid.
* @param node An ExportNamedDeclaration node to check.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._js_.ts#L259-L271 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isOptionSet | function isOptionSet(
option: 'arraysInObjects' | 'objectsInObjects',
): boolean {
return secondOption ? secondOption[option] === !spaced : false
} | /**
* Determines whether an option is set, relative to the spacing option.
* If spaced is "always", then check whether option is set to false.
* If spaced is "never", then check whether option is set to true.
* @param option The option to exclude.
* @returns Whether or not the property is exclu... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._ts_.ts#L36-L40 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | reportNoBeginningSpace | function reportNoBeginningSpace(
node: Tree.TSMappedType | Tree.TSTypeLiteral,
token: Tree.Token,
): void {
const nextToken = sourceCode.getTokenAfter(token, { includeComments: true })!
context.report({
node,
loc: { start: token.loc.end, end: nextToken.loc.start },
m... | /**
* Reports that there shouldn't be a space after the first token
* @param node The node to report in the event of an error.
* @param token The token to use for the report.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._ts_.ts#L53-L70 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | reportNoEndingSpace | function reportNoEndingSpace(
node: Tree.TSMappedType | Tree.TSTypeLiteral,
token: Tree.Token,
): void {
const previousToken = sourceCode.getTokenBefore(token, { includeComments: true })!
context.report({
node,
loc: { start: previousToken.loc.end, end: token.loc.start },
... | /**
* Reports that there shouldn't be a space before the last token
* @param node The node to report in the event of an error.
* @param token The token to use for the report.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._ts_.ts#L77-L94 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | reportRequiredBeginningSpace | function reportRequiredBeginningSpace(
node: Tree.TSMappedType | Tree.TSTypeLiteral,
token: Tree.Token,
): void {
context.report({
node,
loc: token.loc,
messageId: 'requireSpaceAfter',
data: {
token: token.value,
},
fix(fixer) {
r... | /**
* Reports that there should be a space after the first token
* @param node The node to report in the event of an error.
* @param token The token to use for the report.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._ts_.ts#L101-L116 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | reportRequiredEndingSpace | function reportRequiredEndingSpace(
node: Tree.TSMappedType | Tree.TSTypeLiteral,
token: Tree.Token,
): void {
context.report({
node,
loc: token.loc,
messageId: 'requireSpaceBefore',
data: {
token: token.value,
},
fix(fixer) {
ret... | /**
* Reports that there should be a space before the last token
* @param node The node to report in the event of an error.
* @param token The token to use for the report.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._ts_.ts#L123-L138 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | validateBraceSpacing | function validateBraceSpacing(
node: Tree.TSMappedType | Tree.TSTypeLiteral,
first: Tree.Token,
second: Tree.Token,
penultimate: Tree.Token,
last: Tree.Token,
): void {
if (isTokenOnSameLine(first, second)) {
const firstSpaced = sourceCode.isSpaceBetween!(first, second)
... | /**
* Determines if spacing in curly braces is valid.
* @param node The AST node to check.
* @param first The first token to check (should be the opening brace)
* @param second The second token to check (should be first after the opening brace)
* @param penultimate The penultimate token to chec... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._ts_.ts#L148-L212 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getClosingBraceOfObject | function getClosingBraceOfObject(
node: Tree.TSTypeLiteral,
): Tree.Token | null {
const lastProperty = node.members[node.members.length - 1]
return sourceCode.getTokenAfter(lastProperty, isClosingBraceToken)
} | /**
* Gets '}' token of an object node.
*
* Because the last token of object patterns might be a type annotation,
* this traverses tokens preceded by the last property, then returns the
* first '}' token.
* @param node The node to get. This node is an
* ObjectExpression or an Obj... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/object-curly-spacing/object-curly-spacing._ts_.ts#L225-L231 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | errorAt | function errorAt(line: number, column: number) {
return {
messageId: 'expectVarOnNewline',
type: 'VariableDeclaration',
line,
column,
}
} | // ------------------------------------------------------------------------------ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/one-var-declaration-per-line/one-var-declaration-per-line._js_.test.ts#L20-L27 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isForTypeSpecifier | function isForTypeSpecifier(keyword: NodeTypes) {
return keyword === 'ForStatement' || keyword === 'ForInStatement' || keyword === 'ForOfStatement'
} | /**
* Determine if provided keyword is a variant of for specifiers
* @private
* @param keyword keyword to test
* @returns True if `keyword` is a variant of for specifier
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/one-var-declaration-per-line/one-var-declaration-per-line._js_.ts#L43-L45 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | checkForNewLine | function checkForNewLine(node: Tree.VariableDeclaration) {
if (isForTypeSpecifier(node.parent.type))
return
const declarations = node.declarations
let prev: Tree.LetOrConstOrVarDeclarator
declarations.forEach((current) => {
if (prev && prev.loc.end.line === current.loc.start.li... | /**
* Checks newlines around variable declarations.
* @private
* @param node `VariableDeclaration` node to test
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/one-var-declaration-per-line/one-var-declaration-per-line._js_.ts#L52-L72 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getFixer | function getFixer(operatorToken: Token, desiredStyle: string): ReportFixFunction {
return (fixer) => {
const tokenBefore = sourceCode.getTokenBefore(operatorToken)!
const tokenAfter = sourceCode.getTokenAfter(operatorToken)!
const textBefore = sourceCode.text.slice(tokenBefore.range[1], op... | /**
* Gets a fixer function to fix rule issues
* @param operatorToken The operator token of an expression
* @param desiredStyle The style for the rule. One of 'before', 'after', 'none'
* @returns A fixer function
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/operator-linebreak/operator-linebreak._js_.ts#L78-L127 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | validateNode | function validateNode(node: ASTNode, rightSide: ASTNode, operator: string) {
/**
* Find the operator token by searching from the right side, because between the left side and the operator
* there could be additional tokens from type annotations. Search specifically for the token which
* value... | /**
* Checks the operator placement
* @param node The node to check
* @param rightSide The node that comes after the operator in `node`
* @param operator The operator
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/operator-linebreak/operator-linebreak._js_.ts#L136-L202 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | validateBinaryExpression | function validateBinaryExpression(node: Tree.BinaryExpression | Tree.LogicalExpression | Tree.AssignmentExpression) {
validateNode(node, node.right, node.operator)
} | /**
* Validates a binary expression using `validateNode`
* @param node node to be validated
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/operator-linebreak/operator-linebreak._js_.ts#L208-L210 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getOpenBrace | function getOpenBrace(node: Tree.BlockStatement | Tree.StaticBlock | Tree.SwitchStatement | Tree.ClassBody): Token {
if (node.type === 'SwitchStatement')
return sourceCode.getTokenBefore(node.cases[0])!
if (node.type === 'StaticBlock')
return sourceCode.getFirstToken(node, { skip: 1 })! // ... | /**
* Gets the open brace token from a given node.
* @param node A BlockStatement or SwitchStatement node from which to get the open brace.
* @returns The token of the open brace.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padded-blocks/padded-blocks._js_.ts#L89-L98 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isComment | function isComment(node: ASTNode | Token) {
return node.type === 'Line' || node.type === 'Block'
} | /**
* Checks if the given parameter is a comment node
* @param node An AST node or token
* @returns True if node is a comment
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padded-blocks/padded-blocks._js_.ts#L105-L107 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isPaddingBetweenTokens | function isPaddingBetweenTokens(first: Token, second: Token) {
return second.loc.start.line - first.loc.end.line >= 2
} | /**
* Checks if there is padding between two tokens
* @param first The first token
* @param second The second token
* @returns True if there is at least a line between the tokens
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padded-blocks/padded-blocks._js_.ts#L115-L117 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getFirstBlockToken | function getFirstBlockToken(token: Token) {
let prev
let first = token
do {
prev = first
first = sourceCode.getTokenAfter(first, { includeComments: true })!
} while (isComment(first) && first.loc.start.line === prev.loc.end.line)
return first
} | /**
* Checks if the given token has a blank line after it.
* @param token The token to check.
* @returns Whether or not the token is followed by a blank line.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padded-blocks/padded-blocks._js_.ts#L124-L134 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getLastBlockToken | function getLastBlockToken(token: Token) {
let last = token
let next
do {
next = last
last = sourceCode.getTokenBefore(last, { includeComments: true })!
} while (isComment(last) && last.loc.end.line === next.loc.start.line)
return last
} | /**
* Checks if the given token is preceded by a blank line.
* @param token The token to check
* @returns Whether or not the token is preceded by a blank line
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padded-blocks/padded-blocks._js_.ts#L141-L151 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | requirePaddingFor | function requirePaddingFor(node: ASTNode) {
switch (node.type) {
case 'BlockStatement':
case 'StaticBlock':
return options.blocks
case 'SwitchStatement':
return options.switches
case 'ClassBody':
return options.classes
/* c8 ignore next */
... | /**
* Checks if a node should be padded, according to the rule config.
* @param node The AST node to check.
* @throws {Error} (Unreachable)
* @returns True if the node should be padded, false otherwise.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padded-blocks/padded-blocks._js_.ts#L159-L173 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | checkPadding | function checkPadding(node: Tree.BlockStatement | Tree.SwitchStatement | Tree.ClassBody) {
const openBrace = getOpenBrace(node)
const firstBlockToken = getFirstBlockToken(openBrace)
const tokenBeforeFirst = sourceCode.getTokenBefore(firstBlockToken, { includeComments: true })!
const closeBrace =... | /**
* Checks the given BlockStatement node to be padded if the block is not empty.
* @param node The AST node of a BlockStatement.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padded-blocks/padded-blocks._js_.ts#L179-L255 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | newKeywordTester | function newKeywordTester(keyword: string): Tester {
return {
test: (node, sourceCode) => sourceCode.getFirstToken(node)?.value === keyword,
}
} | /**
* Creates tester which check if a node starts with specific keyword.
* @param keyword The keyword to test.
* @returns the created tester.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L32-L36 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | newSinglelineKeywordTester | function newSinglelineKeywordTester(keyword: string): Tester {
return {
test: (node, sourceCode) => node.loc.start.line === node.loc.end.line
&& sourceCode.getFirstToken(node)?.value === keyword,
}
} | /**
* Creates tester which check if a node starts with specific keyword and spans a single line.
* @param keyword The keyword to test.
* @returns the created tester.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L44-L49 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | newMultilineKeywordTester | function newMultilineKeywordTester(keyword: string): Tester {
return {
test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line
&& sourceCode.getFirstToken(node)?.value === keyword,
}
} | /**
* Creates tester which check if a node starts with specific keyword and spans multiple lines.
* @param keyword The keyword to test.
* @returns the created tester.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L57-L62 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | newNodeTypeTester | function newNodeTypeTester(type: string): Tester {
return {
test: (node: ASTNode) =>
node.type === type,
}
} | /**
* Creates tester which check if a node is specific type.
* @param type The node type to test.
* @returns the created tester.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L70-L75 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isIIFEStatement | function isIIFEStatement(node: ASTNode): boolean {
if (node.type === 'ExpressionStatement') {
let call = skipChainExpression(node.expression)
if (call.type === 'UnaryExpression')
call = skipChainExpression(call.argument)
return call.type === 'CallExpression' && isFunction(call.callee)
}
return... | /**
* Checks the given node is an expression statement of IIFE.
* @param node The node to check.
* @returns `true` if the node is an expression statement of IIFE.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L83-L93 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isBlockLikeStatement | function isBlockLikeStatement(sourceCode: SourceCode, node: ASTNode): boolean {
// do-while with a block is a block-like statement.
if (node.type === 'DoWhileStatement' && node.body.type === 'BlockStatement')
return true
/**
* IIFE is a block-like statement specially from
* JSCS#disallowPaddingNewLines... | /**
* Checks whether the given node is a block-like statement.
* This checks the last token of the node is the closing brace of a block.
* @param sourceCode The source code to get tokens.
* @param node The node to check.
* @returns `true` if the node is a block-like statement.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L103-L125 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getActualLastToken | function getActualLastToken(sourceCode: SourceCode, node: ASTNode): Tree.Token {
const semiToken = sourceCode.getLastToken(node)!
const prevToken = sourceCode.getTokenBefore(semiToken)!
const nextToken = sourceCode.getTokenAfter(semiToken)
const isSemicolonLessStyle = Boolean(
prevToken
&& nextToken
... | /**
* Gets the actual last token.
*
* If a semicolon is semicolon-less style's semicolon, this ignores it.
* For example:
*
* foo()
* ;[1, 2, 3].forEach(bar)
* @param sourceCode The source code to get tokens.
* @param node The node to get.
* @returns The actual last token.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L140-L154 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | replacerToRemovePaddingLines | function replacerToRemovePaddingLines(_: string, trailingSpaces: string, indentSpaces: string): string {
return trailingSpaces + indentSpaces
} | /**
* This returns the concatenation of the first 2 captured strings.
* @param _ Unused. Whole matched string.
* @param trailingSpaces The trailing spaces of the first line.
* @param indentSpaces The indentation spaces of the last line.
* @returns The concatenation of trailingSpaces and indentSpaces.
* @private
... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L164-L166 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | verifyForAny | function verifyForAny(): void {
} | /**
* Check and report statements for `any` configuration.
* It does nothing.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L173-L174 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | verifyForNever | function verifyForNever(context: Context, _: ASTNode, nextNode: ASTNode, paddingLines: [Tree.Token, Tree.Token][]): void {
if (paddingLines.length === 0)
return
context.report({
node: nextNode,
messageId: 'unexpectedBlankLine',
fix(fixer) {
if (paddingLines.length >= 2)
return null
... | /**
* Check and report statements for `never` configuration.
* This autofix removes blank lines between the given 2 statements.
* However, if comments exist between 2 blank lines, it does not remove those
* blank lines automatically.
* @param context The rule context to report.
* @param _ Unused. The previous nod... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L188-L208 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | verifyForAlways | function verifyForAlways(context: Context, prevNode: ASTNode, nextNode: ASTNode, paddingLines: [Tree.Token, Tree.Token][]): void {
if (paddingLines.length > 0)
return
context.report({
node: nextNode,
messageId: 'expectedBlankLine',
fix(fixer) {
const sourceCode = context.sourceCode
let ... | /**
* Check and report statements for `always` configuration.
* This autofix inserts a blank line between the given 2 statements.
* If the `prevNode` has trailing comments, it inserts a blank line after the
* trailing comments.
* @param context The rule context to report.
* @param prevNode The previous node to ch... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L222-L274 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | enterScope | function enterScope(): void {
scopeInfo = {
upper: scopeInfo,
prevNode: null,
}
} | /**
* Processes to enter to new scope.
* This manages the current previous statement.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L429-L434 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | exitScope | function exitScope(): void {
scopeInfo = scopeInfo?.upper
} | /**
* Processes to exit from the current scope.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L440-L442 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | match | function match(node: ASTNode, type: string | string[]): boolean {
let innerStatementNode = node
while (innerStatementNode.type === 'LabeledStatement')
innerStatementNode = innerStatementNode.body
if (Array.isArray(type))
return type.some(match.bind(null, innerStatementNode))
r... | /**
* Checks whether the given node matches the given type.
* @param node The statement node to check.
* @param type The statement type to check.
* @returns `true` if the statement node matched the type.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L451-L461 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getPaddingType | function getPaddingType(prevNode: ASTNode, nextNode: ASTNode) {
for (let i = configureList.length - 1; i >= 0; --i) {
const configure = configureList[i]
const matched
= match(prevNode, configure.prev)
&& match(nextNode, configure.next)
if (matched... | /**
* Finds the last matched configure from configureList.
* @param prevNode The previous statement to match.
* @param nextNode The current statement to match.
* @returns The tester of the last matched configure.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L470-L481 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getPaddingLineSequences | function getPaddingLineSequences(prevNode: ASTNode, nextNode: ASTNode): [Tree.Token, Tree.Token][] {
const pairs: [Tree.Token, Tree.Token][] = []
let prevToken = getActualLastToken(sourceCode, prevNode)
if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) {
do {
const token = ... | /**
* Gets padding line sequences between the given 2 statements.
* Comments are separators of the padding line sequences.
* @param prevNode The previous statement to count.
* @param nextNode The current statement to count.
* @returns The array of token pairs.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L491-L510 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | verify | function verify(node: ASTNode): void {
const parentType = node.parent!.type
const validParent
= STATEMENT_LIST_PARENTS.has(parentType)
|| parentType === 'SwitchStatement'
if (!validParent)
return
// Save this node as the current previous statement.
... | /**
* Verify padding lines between the given node and the previous node.
* @param node The node to verify.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L517-L538 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | verifyThenEnterScope | function verifyThenEnterScope(node: ASTNode): void {
verify(node)
enterScope()
} | /**
* Verify padding lines between the given node and the previous node.
* Then process to enter to new scope.
* @param node The node to verify.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._js_.ts#L546-L549 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | newKeywordTester | function newKeywordTester(
type: AST_NODE_TYPES | AST_NODE_TYPES[],
keyword: string,
): NodeTestObject {
return {
test(node, sourceCode): boolean {
const isSameKeyword = sourceCode.getFirstToken(node)?.value === keyword
const isSameType = Array.isArray(type)
? type.includes(node.type)
... | /**
* Creates tester which check if a node starts with specific keyword with the
* appropriate AST_NODE_TYPES.
* @param keyword The keyword to test.
* @returns the created tester.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L65-L79 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | newSinglelineKeywordTester | function newSinglelineKeywordTester(keyword: string): NodeTestObject {
return {
test(node, sourceCode): boolean {
return (
node.loc.start.line === node.loc.end.line
&& sourceCode.getFirstToken(node)!.value === keyword
)
},
}
} | /**
* Creates tester which check if a node starts with specific keyword and spans a single line.
* @param keyword The keyword to test.
* @returns the created tester.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L87-L96 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | newMultilineKeywordTester | function newMultilineKeywordTester(keyword: string): NodeTestObject {
return {
test(node, sourceCode): boolean {
return (
node.loc.start.line !== node.loc.end.line
&& sourceCode.getFirstToken(node)!.value === keyword
)
},
}
} | /**
* Creates tester which check if a node starts with specific keyword and spans multiple lines.
* @param keyword The keyword to test.
* @returns the created tester.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L104-L113 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | newNodeTypeTester | function newNodeTypeTester(type: AST_NODE_TYPES): NodeTestObject {
return {
test: (node): boolean => node.type === type,
}
} | /**
* Creates tester which check if a node is specific type.
* @param type The node type to test.
* @returns the created tester.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L121-L125 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | skipChainExpression | function skipChainExpression(node: ASTNode): ASTNode {
return node && node.type === AST_NODE_TYPES.ChainExpression
? node.expression
: node
} | /**
* Skips a chain expression node
* @param node The node to test
* @returnsA non-chain expression
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L133-L137 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isIIFEStatement | function isIIFEStatement(node: ASTNode): boolean {
if (node.type === AST_NODE_TYPES.ExpressionStatement) {
let expression = skipChainExpression(node.expression)
if (expression.type === AST_NODE_TYPES.UnaryExpression)
expression = skipChainExpression(expression.argument)
if (expression.type === AST_... | /**
* Checks the given node is an expression statement of IIFE.
* @param node The node to check.
* @returns `true` if the node is an expression statement of IIFE.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L145-L160 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isCJSRequire | function isCJSRequire(node: ASTNode): boolean {
if (node.type === AST_NODE_TYPES.VariableDeclaration) {
const declaration = node.declarations[0]
if (declaration?.init) {
let call = declaration?.init
while (call.type === AST_NODE_TYPES.MemberExpression)
call = call.object
if (
... | /**
* Checks the given node is a CommonJS require statement
* @param node The node to check.
* @returns `true` if the node is a CommonJS require statement.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L168-L185 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isBlockLikeStatement | function isBlockLikeStatement(
node: ASTNode,
sourceCode: TSESLint.SourceCode,
): boolean {
// do-while with a block is a block-like statement.
if (
node.type === AST_NODE_TYPES.DoWhileStatement
&& node.body.type === AST_NODE_TYPES.BlockStatement
) {
return true
}
/**
* IIFE is a block-lik... | /**
* Checks whether the given node is a block-like statement.
* This checks the last token of the node is the closing brace of a block.
* @param sourceCode The source code to get tokens.
* @param node The node to check.
* @returns `true` if the node is a block-like statement.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L195-L226 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isDirective | function isDirective(
node: ASTNode,
sourceCode: TSESLint.SourceCode,
): boolean {
return (
node.type === AST_NODE_TYPES.ExpressionStatement
&& (node.parent?.type === AST_NODE_TYPES.Program
|| (node.parent?.type === AST_NODE_TYPES.BlockStatement
&& isFunction(node.parent.parent)))
&& n... | /**
* Check whether the given node is a directive or not.
* @param node The node to check.
* @param sourceCode The source code object to get tokens.
* @returns `true` if the node is a directive.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L234-L247 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isDirectivePrologue | function isDirectivePrologue(
node: ASTNode,
sourceCode: TSESLint.SourceCode,
): boolean {
if (
isDirective(node, sourceCode)
&& node.parent
&& 'body' in node.parent
&& Array.isArray(node.parent.body)
) {
for (const sibling of node.parent.body) {
if (sibling === node)
break
... | /**
* Check whether the given node is a part of directive prologue or not.
* @param node The node to check.
* @param sourceCode The source code object to get tokens.
* @returns `true` if the node is a part of directive prologue.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L255-L275 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isCJSExport | function isCJSExport(node: ASTNode): boolean {
if (node.type === AST_NODE_TYPES.ExpressionStatement) {
const expression = node.expression
if (expression.type === AST_NODE_TYPES.AssignmentExpression) {
let left = expression.left
if (left.type === AST_NODE_TYPES.MemberExpression) {
while (le... | /**
* Checks the given node is a CommonJS export statement
* @param node The node to check.
* @returns `true` if the node is a CommonJS export statement.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L283-L303 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isExpression | function isExpression(
node: ASTNode,
sourceCode: TSESLint.SourceCode,
): boolean {
return (
node.type === AST_NODE_TYPES.ExpressionStatement
&& !isDirectivePrologue(node, sourceCode)
)
} | /**
* Check whether the given node is an expression
* @param node The node to check.
* @param sourceCode The source code object to get tokens.
* @returns `true` if the node is an expression
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L311-L319 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getActualLastToken | function getActualLastToken(
node: ASTNode,
sourceCode: TSESLint.SourceCode,
): Tree.Token | null {
const semiToken = sourceCode.getLastToken(node)!
const prevToken = sourceCode.getTokenBefore(semiToken)
const nextToken = sourceCode.getTokenAfter(semiToken)
const isSemicolonLessStyle
= prevToken
&... | /**
* Gets the actual last token.
*
* If a semicolon is semicolon-less style's semicolon, this ignores it.
* For example:
*
* foo()
* ;[1, 2, 3].forEach(bar)
* @param sourceCode The source code to get tokens.
* @param node The node to get.
* @returns The actual last token.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L334-L350 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | replacerToRemovePaddingLines | function replacerToRemovePaddingLines(
_: string,
trailingSpaces: string,
indentSpaces: string,
): string {
return trailingSpaces + indentSpaces
} | /**
* This returns the concatenation of the first 2 captured strings.
* @param _ Unused. Whole matched string.
* @param trailingSpaces The trailing spaces of the first line.
* @param indentSpaces The indentation spaces of the last line.
* @returns The concatenation of trailingSpaces and indentSpaces.
* @private
... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L360-L366 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | verifyForAny | function verifyForAny(): void {
// Empty
} | /**
* Check and report statements for `any` configuration.
* It does nothing.
*
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L374-L376 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | verifyForNever | function verifyForNever(
context: TSESLint.RuleContext<MessageIds, Options>,
_: ASTNode,
nextNode: ASTNode,
paddingLines: [Tree.Token, Tree.Token][],
): void {
if (paddingLines.length === 0)
return
context.report({
node: nextNode,
messageId: 'unexpectedBlankLine',
fix(fixer) {
if (pad... | /**
* Check and report statements for `never` configuration.
* This autofix removes blank lines between the given 2 statements.
* However, if comments exist between 2 blank lines, it does not remove those
* blank lines automatically.
* @param context The rule context to report.
* @param _ Unused. The previous nod... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L391-L420 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | verifyForAlways | function verifyForAlways(
context: TSESLint.RuleContext<MessageIds, Options>,
prevNode: ASTNode,
nextNode: ASTNode,
paddingLines: [Tree.Token, Tree.Token][],
): void {
if (paddingLines.length > 0)
return
context.report({
node: nextNode,
messageId: 'expectedBlankLine',
fix(fixer) {
con... | /**
* Check and report statements for `always` configuration.
* This autofix inserts a blank line between the given 2 statements.
* If the `prevNode` has trailing comments, it inserts a blank line after the
* trailing comments.
* @param context The rule context to report.
* @param prevNode The previous node to ch... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L435-L489 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | enterScope | function enterScope(): void {
scopeInfo = {
upper: scopeInfo,
prevNode: null,
}
} | /**
* Processes to enter to new scope.
* This manages the current previous statement.
*
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L685-L690 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | exitScope | function exitScope(): void {
if (scopeInfo)
scopeInfo = scopeInfo.upper
} | /**
* Processes to exit from the current scope.
*
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L697-L700 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | match | function match(node: ASTNode, type: string[] | string): boolean {
let innerStatementNode = node
while (innerStatementNode.type === AST_NODE_TYPES.LabeledStatement)
innerStatementNode = innerStatementNode.body
if (Array.isArray(type))
return type.some(match.bind(null, innerStatementNo... | /**
* Checks whether the given node matches the given type.
* @param node The statement node to check.
* @param type The statement type to check.
* @returns `true` if the statement node matched the type.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L709-L719 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getPaddingType | function getPaddingType(
prevNode: ASTNode,
nextNode: ASTNode,
): (typeof PaddingTypes)[keyof typeof PaddingTypes] {
for (let i = configureList.length - 1; i >= 0; --i) {
const configure = configureList[i]
if (
match(prevNode, configure.prev)
&& match(nextNode, ... | /**
* Finds the last matched configure from configureList.
* @paramprevNode The previous statement to match.
* @paramnextNode The current statement to match.
* @returns The tester of the last matched configure.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L728-L742 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | getPaddingLineSequences | function getPaddingLineSequences(
prevNode: ASTNode,
nextNode: ASTNode,
): [Tree.Token, Tree.Token][] {
const pairs: [Tree.Token, Tree.Token][] = []
let prevToken: Tree.Token = getActualLastToken(prevNode, sourceCode)!
if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) {
... | /**
* Gets padding line sequences between the given 2 statements.
* Comments are separators of the padding line sequences.
* @paramprevNode The previous statement to count.
* @paramnextNode The current statement to count.
* @returns The array of token pairs.
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L752-L773 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | verify | function verify(node: ASTNode): void {
if (
!node.parent
|| ![
AST_NODE_TYPES.BlockStatement,
AST_NODE_TYPES.Program,
AST_NODE_TYPES.StaticBlock,
AST_NODE_TYPES.SwitchCase,
AST_NODE_TYPES.SwitchStatement,
AST_NODE_TYPES.TSInterfaceBody,
... | /**
* Verify padding lines between the given node and the previous node.
* @param node The node to verify.
*
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L781-L810 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | verifyThenEnterScope | function verifyThenEnterScope(node: ASTNode): void {
verify(node)
enterScope()
} | /**
* Verify padding lines between the given node and the previous node.
* Then process to enter to new scope.
* @param node The node to verify.
*
* @private
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements._ts_.ts#L819-L822 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | isKeyword | function isKeyword(tokenStr: string): boolean {
return KEYWORDS_JS.includes(tokenStr)
} | /**
* Checks whether a certain string constitutes an ES3 token
* @param tokenStr The string to be checked.
* @returns `true` if it is an ES3 token.
*/ | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/quote-props/quote-props._js_.ts#L91-L93 | 481d54b6521b8705570132424c78d320dec57610 |
eslint-stylistic | github_2023 | eslint-stylistic | typescript | areQuotesRedundant | function areQuotesRedundant(rawKey: string, tokens: any, skipNumberLiterals: boolean = false): boolean {
return tokens.length === 1 && tokens[0].start === 0 && tokens[0].end === rawKey.length
&& (['Identifier', 'Keyword', 'Null', 'Boolean'].includes(tokens[0].type)
|| (tokens[0].type === 'Numeri... | /**
* Checks if an espree-tokenized key has redundant quotes (i.e. whether quotes are unnecessary)
* @param rawKey The raw key value from the source
* @param tokens The espree-tokenized node key
* @param [skipNumberLiterals] Indicates whether number literals should be checked
* @returns Whether... | https://github.com/eslint-stylistic/eslint-stylistic/blob/481d54b6521b8705570132424c78d320dec57610/packages/eslint-plugin/rules/quote-props/quote-props._js_.ts#L103-L107 | 481d54b6521b8705570132424c78d320dec57610 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.