@@ -73,14 +73,17 @@ export default createRule('consistent-selector-style', {
73
73
74
74
const selections : {
75
75
class : Selections ;
76
- id : Map < string , AST . SvelteHTMLElement [ ] > ;
76
+ id : Selections ;
77
77
type : Map < string , AST . SvelteHTMLElement [ ] > ;
78
78
} = {
79
79
class : {
80
80
exact : new Map ( ) ,
81
81
prefixes : new Map ( )
82
82
} ,
83
- id : new Map ( ) ,
83
+ id : {
84
+ exact : new Map ( ) ,
85
+ prefixes : new Map ( )
86
+ } ,
84
87
type : new Map ( )
85
88
} ;
86
89
@@ -156,7 +159,7 @@ export default createRule('consistent-selector-style', {
156
159
* Checks an ID selector
157
160
*/
158
161
function checkIdSelector ( node : SelectorIdentifier ) : void {
159
- const selection = selections . id . get ( node . value ) ?? [ ] ;
162
+ const selection = matchSelection ( selections . id , node . value ) ;
160
163
for ( const styleValue of style ) {
161
164
if ( styleValue === 'class' ) {
162
165
context . report ( {
@@ -227,8 +230,15 @@ export default createRule('consistent-selector-style', {
227
230
addToArrayMap ( selections . class . prefixes , prefix , node ) ;
228
231
}
229
232
}
230
- if ( attribute . key . name === 'id' && value . type === 'SvelteLiteral' ) {
231
- addToArrayMap ( selections . id , value . value , node ) ;
233
+ if ( attribute . key . name === 'id' ) {
234
+ if ( value . type === 'SvelteLiteral' ) {
235
+ addToArrayMap ( selections . id . exact , value . value , node ) ;
236
+ } else if ( value . type === 'SvelteMustacheTag' ) {
237
+ const prefix = extractExpressionPrefixLiteral ( context , value . expression ) ;
238
+ if ( prefix !== null ) {
239
+ addToArrayMap ( selections . id . prefixes , prefix , node ) ;
240
+ }
241
+ }
232
242
}
233
243
}
234
244
}
0 commit comments