File tree 2 files changed +20
-0
lines changed
lib/styles/context/vue-components
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(
55
55
return null ;
56
56
}
57
57
58
+ const vueComponentCache = new WeakMap <
59
+ RuleContext ,
60
+ { component : AST . ESLintObjectExpression | null ; cachedAt : number }
61
+ > ( ) ;
62
+
58
63
/**
59
64
* Find Vue component of the current file.
60
65
* @param {RuleContext } context The ESLint rule context object.
@@ -63,6 +68,11 @@ function getVueComponentObject(
63
68
function findVueComponent (
64
69
context : RuleContext
65
70
) : AST . ESLintObjectExpression | null {
71
+ const cached = vueComponentCache . get ( context ) ;
72
+ if ( cached !== undefined && cached . cachedAt > Date . now ( ) - 1000 ) {
73
+ return cached . component ;
74
+ }
75
+
66
76
const sourceCode = context . getSourceCode ( ) ;
67
77
const componentComments = sourceCode
68
78
. getAllComments ( )
@@ -118,6 +128,11 @@ function findVueComponent(
118
128
// noop
119
129
} ,
120
130
} ) ;
131
+
132
+ vueComponentCache . set ( context , {
133
+ component : result ,
134
+ cachedAt : Date . now ( ) ,
135
+ } ) ;
121
136
return result ;
122
137
}
123
138
You can’t perform that action at this time.
0 commit comments