@@ -149,6 +149,7 @@ const KNOWN_NODES = new Set([
149
149
AST_NODE_TYPES . TSRestType ,
150
150
AST_NODE_TYPES . TSThisType ,
151
151
AST_NODE_TYPES . TSTupleType ,
152
+ AST_NODE_TYPES . TSTypeAliasDeclaration ,
152
153
AST_NODE_TYPES . TSTypeAnnotation ,
153
154
AST_NODE_TYPES . TSTypeLiteral ,
154
155
AST_NODE_TYPES . TSTypeOperator ,
@@ -1123,6 +1124,15 @@ export default createRule<RuleOptions, MessageIds>({
1123
1124
1124
1125
const ignoredNodeFirstTokens = new Set < Token > ( )
1125
1126
1127
+ function checkDeclarator ( node : Tree . VariableDeclarator | Tree . TSTypeAliasDeclaration , equalOperator : Token ) {
1128
+ const tokenAfterOperator = sourceCode . getTokenAfter ( equalOperator ) !
1129
+
1130
+ offsets . ignoreToken ( equalOperator )
1131
+ offsets . ignoreToken ( tokenAfterOperator )
1132
+ offsets . setDesiredOffsets ( [ tokenAfterOperator . range [ 0 ] , node . range [ 1 ] ] , equalOperator , 1 )
1133
+ offsets . setDesiredOffset ( equalOperator , sourceCode . getLastToken ( node . id ) , 0 )
1134
+ }
1135
+
1126
1136
function checkArrayLikeNode ( node : Tree . ArrayExpression | Tree . ArrayPattern | Tree . TSTupleType ) {
1127
1137
const elementList = node . type === AST_NODE_TYPES . TSTupleType ? node . elementTypes : node . elements
1128
1138
const openingBracket = sourceCode . getFirstToken ( node ) !
@@ -1815,12 +1825,8 @@ export default createRule<RuleOptions, MessageIds>({
1815
1825
VariableDeclarator ( node ) {
1816
1826
if ( node . init ) {
1817
1827
const equalOperator = sourceCode . getTokenBefore ( node . init , isNotOpeningParenToken ) !
1818
- const tokenAfterOperator = sourceCode . getTokenAfter ( equalOperator ) !
1819
1828
1820
- offsets . ignoreToken ( equalOperator )
1821
- offsets . ignoreToken ( tokenAfterOperator )
1822
- offsets . setDesiredOffsets ( [ tokenAfterOperator . range [ 0 ] , node . range [ 1 ] ] , equalOperator , 1 )
1823
- offsets . setDesiredOffset ( equalOperator , sourceCode . getLastToken ( node . id ) , 0 )
1829
+ checkDeclarator ( node , equalOperator )
1824
1830
}
1825
1831
} ,
1826
1832
@@ -1953,6 +1959,12 @@ export default createRule<RuleOptions, MessageIds>({
1953
1959
checkMemberExpression ( node , node . object , node . property )
1954
1960
} ,
1955
1961
1962
+ TSTypeAliasDeclaration ( node ) {
1963
+ const equalOperator = sourceCode . getTokenBefore ( node . typeAnnotation , isNotOpeningParenToken ) !
1964
+
1965
+ checkDeclarator ( node , equalOperator )
1966
+ } ,
1967
+
1956
1968
'TSTupleType' : checkArrayLikeNode ,
1957
1969
1958
1970
TSEnumDeclaration ( node ) {
0 commit comments