11import prettier from '@prettier/sync'
22import type { MessageIds , RuleOptions } from './types'
3+ import type { TSESTree } from '@typescript-eslint/utils'
34import type { RuleModule } from '@typescript-eslint/utils/ts-eslint'
45
56const rule : RuleModule < MessageIds , RuleOptions > = {
@@ -39,7 +40,6 @@ const rule: RuleModule<MessageIds, RuleOptions> = {
3940 node . callee . type === 'MemberExpression'
4041 ? node . callee . object
4142 : node . callee
42- const offset = callee . loc . start . column
4343 const parser =
4444 node . callee . type === 'MemberExpression' &&
4545 node . callee . property . type === 'Identifier'
@@ -61,8 +61,18 @@ const rule: RuleModule<MessageIds, RuleOptions> = {
6161 } )
6262 }
6363
64- const placeholder = ' ' . repeat ( offset + tabWidth )
65- const result = `\n${ placeholder } ${ formattedCss . slice ( 0 , - 1 ) . replaceAll ( '\n' , `\n${ placeholder } ` ) } \n${ ' ' . repeat ( offset ) } `
64+ const line = callee . loc . start . line
65+ function getOffset ( node : TSESTree . Node ) {
66+ if ( node . parent ?. loc . start . line === line ) {
67+ return getOffset ( node . parent )
68+ }
69+ return node . loc . start . column
70+ }
71+ const column = getOffset ( callee )
72+ const placeholder = ' ' . repeat ( column + tabWidth )
73+ const result = `\n${ placeholder } ${ formattedCss
74+ . slice ( 0 , - 1 )
75+ . replaceAll ( '\n' , `\n${ placeholder } ` ) } \n${ ' ' . repeat ( column ) } `
6676 if ( result !== cssRaw ) {
6777 context . report ( {
6878 node : arg ,
0 commit comments