@@ -19,6 +19,9 @@ const PROPS_TO_REMOVE = [
1919 { key : "identifierName" , type : null } ,
2020 // For legacy estree AST
2121 { key : "attributes" , type : "ImportExpression" } ,
22+
23+ // Babel sets `computed: false`, while typescript-estree omits it
24+ { key : "computed" , value : false , type : "TSEnumMember" } ,
2225] ;
2326
2427// TODO: remove the ESLint token fixes after they are fixed in upstream
@@ -53,8 +56,9 @@ function deeplyRemoveProperties(obj, props) {
5356 for ( const [ k , v ] of Object . entries ( obj ) ) {
5457 if (
5558 props . some (
56- ( { key, type } ) =>
59+ ( { key, value , type } ) =>
5760 key === k &&
61+ ( value === undefined || value === v ) &&
5862 ( ( type === "Node" && obj . type ) || type === obj . type || type == null ) ,
5963 )
6064 ) {
@@ -78,6 +82,22 @@ function deeplyRemoveProperties(obj, props) {
7882 }
7983}
8084
85+ function deeplyMakePlainObject ( obj ) {
86+ if ( ! obj || typeof obj !== "object" ) return ;
87+
88+ if ( Array . isArray ( obj ) ) {
89+ for ( const el of obj ) {
90+ deeplyMakePlainObject ( el ) ;
91+ }
92+ return ;
93+ }
94+
95+ Object . setPrototypeOf ( obj , Object . prototype ) ;
96+ for ( const v of Object . values ( obj ) ) {
97+ deeplyMakePlainObject ( v ) ;
98+ }
99+ }
100+
81101// Only ESLint 9 or above will be tested
82102( isESLint9 ? describe : describe . skip ) (
83103 "Babel should output the same AST as TypeScript-Estree" ,
@@ -139,6 +159,10 @@ function deeplyRemoveProperties(obj, props) {
139159 } else {
140160 fixTSESLintTokens ( tsEstreeAST ) ;
141161 }
162+
163+ deeplyMakePlainObject ( babelAST ) ;
164+ deeplyMakePlainObject ( tsEstreeAST ) ;
165+
142166 expect ( babelAST ) . toEqual ( tsEstreeAST ) ;
143167 }
144168
@@ -304,7 +328,7 @@ function deeplyRemoveProperties(obj, props) {
304328 [ "function type" , "var v: (x: string) => string" ] ,
305329
306330 [ "conditional type" , "type M = T extends Q ? string : number" ] ,
307- [ "import type" , "var v: import('foo')" ] ,
331+ ... ( IS_BABEL_8 ? [ [ "import type" , "var v: import('foo')" ] ] : [ ] ) ,
308332 [ "instantiation expression optional chain" , "a?.b<c>" ] ,
309333 [ "type parameter" , "type Id<T> = T" ] ,
310334
@@ -341,9 +365,6 @@ function deeplyRemoveProperties(obj, props) {
341365 // Pending release https://github.com/microsoft/TypeScript/pull/61764
342366 "typescript/explicit-resource-management/valid-for-using-declaration-binding-of/input.js" ,
343367
344- // Pending https://github.com/typescript-eslint/typescript-eslint/issues/11474
345- "typescript/types/import-type-options-with-trailing-comma/input.ts" ,
346-
347368 // ts-eslint/tsc does not support arrow generic in tsx mode
348369 "typescript/arrow-function/async-await-null/input.ts" ,
349370 "typescript/arrow-function/async-generic-after-await/input.ts" ,
0 commit comments