File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
packages/utilities/kit/src/JsxConfig Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,15 @@ export function getFromContext(context: RuleContext) {
4141 } ;
4242}
4343
44+ const cache = new WeakMap < RuleContext [ "sourceCode" ] , JsxConfig > ( ) ;
45+
4446/**
4547 * Get JsxConfig from annotation
4648 * @param context The RuleContext
4749 * @returns JsxConfig
4850 */
4951export function getFromAnnotation ( context : RuleContext ) {
52+ if ( cache . has ( context . sourceCode ) ) return cache . get ( context . sourceCode ) ;
5053 if ( ! context . sourceCode . text . includes ( "@jsx" ) ) return { } ;
5154 let jsx , jsxFrag , jsxRuntime , jsxImportSource ;
5255 for ( const comment of context . sourceCode . getAllComments ( ) . reverse ( ) ) {
@@ -61,5 +64,6 @@ export function getFromAnnotation(context: RuleContext) {
6164 if ( jsxFrag != null ) options . jsxFragmentFactory = jsxFrag ;
6265 if ( jsxRuntime != null ) options . jsx = jsxRuntime === "classic" ? JsxEmit . React : JsxEmit . ReactJSX ;
6366 if ( jsxImportSource != null ) options . jsxImportSource = jsxImportSource ;
67+ cache . set ( context . sourceCode , options ) ;
6468 return options ;
6569}
You can’t perform that action at this time.
0 commit comments