1- import { TSESTree , AST_NODE_TYPES } from '@typescript-eslint/typescript-estree' ;
1+ import { TSESTree } from '@typescript-eslint/typescript-estree' ;
22import { Scope } from 'eslint' ;
33
44export interface MessageDescriptor {
@@ -14,7 +14,7 @@ export interface MessageDescriptorNodeInfo {
1414}
1515
1616function isStringLiteral ( node : TSESTree . Node ) : node is TSESTree . StringLiteral {
17- return node . type === AST_NODE_TYPES . Literal && typeof node . value === 'string' ;
17+ return node . type === " Literal" && typeof node . value === 'string' ;
1818}
1919
2020function findReferenceImport (
@@ -28,22 +28,22 @@ function findReferenceImport(
2828
2929function isIntlFormatMessageCall ( node : TSESTree . Node ) {
3030 return (
31- node . type === AST_NODE_TYPES . CallExpression &&
32- node . callee . type === AST_NODE_TYPES . MemberExpression &&
33- node . callee . object . type === AST_NODE_TYPES . Identifier &&
31+ node . type === " CallExpression" &&
32+ node . callee . type === " MemberExpression" &&
33+ node . callee . object . type === " Identifier" &&
3434 node . callee . object . name === 'intl' &&
35- node . callee . property . type === AST_NODE_TYPES . Identifier &&
35+ node . callee . property . type === " Identifier" &&
3636 node . callee . property . name === 'formatMessage' &&
3737 node . arguments . length >= 1 &&
38- node . arguments [ 0 ] . type === AST_NODE_TYPES . ObjectExpression
38+ node . arguments [ 0 ] . type === " ObjectExpression"
3939 ) ;
4040}
4141
4242function isSingleMessageDescriptorDeclaration (
4343 id : TSESTree . LeftHandSideExpression ,
4444 importedVars : Scope . Variable [ ]
4545) {
46- if ( id . type !== AST_NODE_TYPES . Identifier ) {
46+ if ( id . type !== " Identifier" ) {
4747 return false ;
4848 }
4949 const importedVar = findReferenceImport ( id , importedVars ) ;
@@ -56,7 +56,7 @@ function isMultipleMessageDescriptorDeclaration(
5656 id : TSESTree . LeftHandSideExpression ,
5757 importedVars : Scope . Variable [ ]
5858) {
59- if ( id . type !== AST_NODE_TYPES . Identifier ) {
59+ if ( id . type !== " Identifier" ) {
6060 return false ;
6161 }
6262 const importedVar = findReferenceImport ( id , importedVars ) ;
@@ -69,7 +69,7 @@ function isMultipleMessageDescriptorDeclaration(
6969function extractMessageDescriptor (
7070 node ?: TSESTree . Expression
7171) : MessageDescriptorNodeInfo | undefined {
72- if ( ! node || node . type !== AST_NODE_TYPES . ObjectExpression ) {
72+ if ( ! node || node . type !== " ObjectExpression" ) {
7373 return ;
7474 }
7575 const result : MessageDescriptorNodeInfo = {
@@ -79,8 +79,8 @@ function extractMessageDescriptor(
7979 } ;
8080 for ( const prop of node . properties ) {
8181 if (
82- prop . type !== AST_NODE_TYPES . Property ||
83- prop . key . type !== AST_NODE_TYPES . Identifier
82+ prop . type !== " Property" ||
83+ prop . key . type !== " Identifier"
8484 ) {
8585 continue ;
8686 }
@@ -118,8 +118,8 @@ function extractMessageDescriptorFromJSXElement(
118118 } ;
119119 for ( const prop of node . attributes ) {
120120 if (
121- prop . type !== AST_NODE_TYPES . JSXAttribute ||
122- prop . name . type !== AST_NODE_TYPES . JSXIdentifier
121+ prop . type !== " JSXAttribute" ||
122+ prop . name . type !== " JSXIdentifier"
123123 ) {
124124 continue ;
125125 }
@@ -128,7 +128,7 @@ function extractMessageDescriptorFromJSXElement(
128128 case 'defaultMessage' :
129129 result . messageNode = prop . value ;
130130 if (
131- prop . value ?. type === AST_NODE_TYPES . Literal &&
131+ prop . value ?. type === " Literal" &&
132132 typeof prop . value . value === 'string'
133133 ) {
134134 result . message . defaultMessage = prop . value . value ;
@@ -137,24 +137,24 @@ function extractMessageDescriptorFromJSXElement(
137137 case 'description' :
138138 result . descriptionNode = prop . value ;
139139 if (
140- prop . value ?. type === AST_NODE_TYPES . Literal &&
140+ prop . value ?. type === " Literal" &&
141141 typeof prop . value . value === 'string'
142142 ) {
143143 result . message . description = prop . value . value ;
144144 }
145145 break ;
146146 case 'id' :
147147 if (
148- prop . value ?. type === AST_NODE_TYPES . Literal &&
148+ prop . value ?. type === " Literal" &&
149149 typeof prop . value . value === 'string'
150150 ) {
151151 result . message . id = prop . value . value ;
152152 }
153153 break ;
154154 case 'values' :
155155 if (
156- prop . value ?. type === AST_NODE_TYPES . JSXExpressionContainer &&
157- prop . value . expression . type === AST_NODE_TYPES . ObjectExpression
156+ prop . value ?. type === " JSXExpressionContainer" &&
157+ prop . value . expression . type === " ObjectExpression"
158158 ) {
159159 values = prop . value . expression ;
160160 }
@@ -170,18 +170,18 @@ function extractMessageDescriptorFromJSXElement(
170170function extractMessageDescriptors ( node ?: TSESTree . Expression ) {
171171 if (
172172 ! node ||
173- node . type !== AST_NODE_TYPES . ObjectExpression ||
173+ node . type !== " ObjectExpression" ||
174174 ! node . properties . length
175175 ) {
176176 return [ ] ;
177177 }
178178 const msgs = [ ] ;
179179 for ( const prop of node . properties ) {
180- if ( prop . type !== AST_NODE_TYPES . Property ) {
180+ if ( prop . type !== " Property" ) {
181181 continue ;
182182 }
183183 const msg = prop . value ;
184- if ( msg . type !== AST_NODE_TYPES . ObjectExpression ) {
184+ if ( msg . type !== " ObjectExpression" ) {
185185 continue ;
186186 }
187187 const nodeInfo = extractMessageDescriptor ( msg ) ;
@@ -197,7 +197,7 @@ export function extractMessages(
197197 importedMacroVars : Scope . Variable [ ] ,
198198 excludeMessageDeclCalls = false
199199) : Array < [ MessageDescriptorNodeInfo , TSESTree . Expression | undefined ] > {
200- if ( node . type === AST_NODE_TYPES . CallExpression ) {
200+ if ( node . type === " CallExpression" ) {
201201 const expr = node ;
202202 const fnId = expr . callee ;
203203 if (
@@ -219,9 +219,9 @@ export function extractMessages(
219219 ] ) ;
220220 }
221221 } else if (
222- node . type === AST_NODE_TYPES . JSXOpeningElement &&
222+ node . type === " JSXOpeningElement" &&
223223 node . name &&
224- node . name . type === AST_NODE_TYPES . JSXIdentifier &&
224+ node . name . type === " JSXIdentifier" &&
225225 node . name . name === 'FormattedMessage'
226226 ) {
227227 const msgDescriptorNodeInfo = extractMessageDescriptorFromJSXElement ( node ) ;
0 commit comments