Skip to content

Commit

Permalink
fix(plus/indent-binary-ops): considring || and && (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
9romise authored Jun 19, 2024
1 parent 09ea5b0 commit 9627a10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ run({
this.overflow = true;
}
`,
$`
const woof = computed(() => keys.value.filter(
({ type }) => type === 'bark' ||
type === 'pooque' ||
type === 'srenque'
));
`,
],
invalid: [],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ASTNode } from '@shared/types'
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
import { createRule } from '../../utils/createRule'
import type { MessageIds, RuleOptions } from './types'

Expand Down Expand Up @@ -74,8 +75,9 @@ export default createRule<RuleOptions, MessageIds>({
const firstTokenOfLineLeft = firstTokenOfLine(tokenLeft.loc.start.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')
|| (firstTokenOfLineLeft?.type === 'Identifier' && firstTokenOfLineLeft.value === 'type' && node.parent?.type === AST_NODE_TYPES.TSTypeAliasDeclaration)
|| [':', '[', '(', '<', '='].includes(lastTokenOfLineLeft?.value || '')
|| (['||', '&&'].includes(lastTokenOfLineLeft?.value || '') && node.loc.start.line === tokenLeft.loc.start.line && node.loc.start.column !== getIndentOfLine(node.loc.start.line).length)

const indentTarget = getIndentOfLine(tokenLeft.loc.start.line) + (needAdditionIndent ? indentStr : '')
const indentRight = getIndentOfLine(tokenRight.loc.start.line)
Expand Down

0 comments on commit 9627a10

Please sign in to comment.