@stylistic/eslint-plugin-plus
Advanced tools
Comparing version 2.12.1 to 2.13.0
@@ -78,2 +78,11 @@ 'use strict'; | ||
} | ||
function isTypeKeywordOfNode(typeToken, node) { | ||
while (node.parent) { | ||
node = node.parent; | ||
if (node.type === "TSTypeAliasDeclaration" && context.sourceCode.getTokenBefore(node.id) === typeToken) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function handler(node, right) { | ||
@@ -97,3 +106,3 @@ if (node.loc.start.line === node.loc.end.line) | ||
const lastTokenOfLineLeft = lastTokenOfLine(tokenLeft.loc.start.line); | ||
const needAdditionIndent = firstTokenOfLineLeft?.type === "Keyword" && !["typeof", "instanceof", "this"].includes(firstTokenOfLineLeft.value) || firstTokenOfLineLeft?.type === "Identifier" && firstTokenOfLineLeft.value === "type" && node.parent?.type === "TSTypeAliasDeclaration" || [":", "[", "(", "<", "="].includes(lastTokenOfLineLeft?.value || "") || ["[", "(", "=>", ":"].includes(tokenBeforeAll?.value || "") && firstTokenOfLineLeft?.loc.start.line === tokenBeforeAll?.loc.start.line || ["||", "&&"].includes(lastTokenOfLineLeft?.value || "") && node.loc.start.line === tokenLeft.loc.start.line && node.loc.start.column !== getIndentOfLine(node.loc.start.line).length; | ||
const needAdditionIndent = firstTokenOfLineLeft?.type === "Keyword" && !["typeof", "instanceof", "this"].includes(firstTokenOfLineLeft.value) || firstTokenOfLineLeft?.type === "Identifier" && firstTokenOfLineLeft.value === "type" && isTypeKeywordOfNode(firstTokenOfLineLeft, node) || [":", "[", "(", "<"].concat(utils.ASSIGNMENT_OPERATOR).includes(lastTokenOfLineLeft?.value || "") || ["[", "(", "=>", ":"].concat(utils.ASSIGNMENT_OPERATOR).includes(tokenBeforeAll?.value || "") && firstTokenOfLineLeft?.loc.start.line === tokenBeforeAll?.loc.start.line || ["||", "&&"].includes(lastTokenOfLineLeft?.value || "") && node.loc.start.line === tokenLeft.loc.start.line && node.loc.start.column !== getIndentOfLine(node.loc.start.line).length; | ||
const needSubtractionIndent = lastTokenOfLineLeft?.value === ")" && isGreaterThanCloseBracketOfLine(tokenLeft.loc.start.line) && !["]", ")", "}"].includes(firstTokenOfLineLeft?.value || ""); | ||
@@ -100,0 +109,0 @@ const indentLeft = getIndentOfLine(tokenLeft.loc.start.line); |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const ASSIGNMENT_OPERATOR = ["=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=", "|=", "^=", "&=", "**=", "||=", "&&=", "??="]; | ||
function isCommentToken(token) { | ||
@@ -72,4 +73,5 @@ if (!token) | ||
exports.ASSIGNMENT_OPERATOR = ASSIGNMENT_OPERATOR; | ||
exports.createRule = createRule; | ||
exports.isCommentToken = isCommentToken; | ||
exports.isTokenOnSameLine = isTokenOnSameLine; |
{ | ||
"name": "@stylistic/eslint-plugin-plus", | ||
"type": "commonjs", | ||
"version": "2.12.1", | ||
"version": "2.13.0", | ||
"author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
546681
13164