File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
lib/styles/context/vue-components Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " eslint-plugin-vue-scoped-css " : patch
3+ ---
4+
5+ Improve ` no-unused-selector ` performance
Original file line number Diff line number Diff line change @@ -55,6 +55,11 @@ function getVueComponentObject(
5555 return null ;
5656}
5757
58+ const vueComponentCache = new WeakMap <
59+ RuleContext ,
60+ { component : AST . ESLintObjectExpression | null ; cachedAt : number }
61+ > ( ) ;
62+
5863/**
5964 * Find Vue component of the current file.
6065 * @param {RuleContext } context The ESLint rule context object.
@@ -63,6 +68,11 @@ function getVueComponentObject(
6368function findVueComponent (
6469 context : RuleContext
6570) : AST . ESLintObjectExpression | null {
71+ const cached = vueComponentCache . get ( context ) ;
72+ if ( cached !== undefined && cached . cachedAt > Date . now ( ) - 1000 ) {
73+ return cached . component ;
74+ }
75+
6676 const sourceCode = context . getSourceCode ( ) ;
6777 const componentComments = sourceCode
6878 . getAllComments ( )
@@ -118,6 +128,11 @@ function findVueComponent(
118128 // noop
119129 } ,
120130 } ) ;
131+
132+ vueComponentCache . set ( context , {
133+ component : result ,
134+ cachedAt : Date . now ( ) ,
135+ } ) ;
121136 return result ;
122137}
123138
You can’t perform that action at this time.
0 commit comments