1
1
import prettier from '@prettier/sync'
2
2
import type { MessageIds , RuleOptions } from './types'
3
+ import type { TSESTree } from '@typescript-eslint/utils'
3
4
import type { RuleModule } from '@typescript-eslint/utils/ts-eslint'
4
5
5
6
const rule : RuleModule < MessageIds , RuleOptions > = {
@@ -39,7 +40,6 @@ const rule: RuleModule<MessageIds, RuleOptions> = {
39
40
node . callee . type === 'MemberExpression'
40
41
? node . callee . object
41
42
: node . callee
42
- const offset = callee . loc . start . column
43
43
const parser =
44
44
node . callee . type === 'MemberExpression' &&
45
45
node . callee . property . type === 'Identifier'
@@ -61,8 +61,18 @@ const rule: RuleModule<MessageIds, RuleOptions> = {
61
61
} )
62
62
}
63
63
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 ) } `
66
76
if ( result !== cssRaw ) {
67
77
context . report ( {
68
78
node : arg ,
0 commit comments