@@ -25,42 +25,40 @@ export async function getCssConflictDiagnostics(
25
25
classNames . forEach ( ( className , index ) => {
26
26
if ( state . jit ) {
27
27
let { rules } = jit . generateRules ( state , [ className . className ] )
28
- if ( rules . length !== 1 ) {
28
+ if ( rules . length === 0 ) {
29
29
return
30
30
}
31
- let rule = rules [ 0 ]
32
- let context : string [ ]
33
- let properties = [ ]
34
- rule . walkDecls ( ( { prop } ) => {
35
- properties . push ( prop )
31
+
32
+ let info : Array < { context : string [ ] ; properties : string [ ] } > = rules . map ( ( rule ) => {
33
+ let properties : string [ ] = [ ]
34
+ rule . walkDecls ( ( { prop } ) => {
35
+ properties . push ( prop )
36
+ } )
37
+ let context = jit . getRuleContext ( state , rule , className . className )
38
+ return { context, properties }
36
39
} )
37
40
38
41
let otherClassNames = classNames . filter ( ( _className , i ) => i !== index )
39
42
40
43
let conflictingClassNames = otherClassNames . filter ( ( otherClassName ) => {
41
- let { rules } = jit . generateRules ( state , [ otherClassName . className ] )
42
- if ( rules . length !== 1 ) {
44
+ let { rules : otherRules } = jit . generateRules ( state , [ otherClassName . className ] )
45
+ if ( otherRules . length !== rules . length ) {
43
46
return false
44
47
}
45
48
46
- let otherRule = rules [ 0 ]
47
-
48
- let otherProperties = [ ]
49
- otherRule . walkDecls ( ( { prop } ) => {
50
- otherProperties . push ( prop )
51
- } )
52
-
53
- if ( ! equal ( properties , otherProperties ) ) {
54
- return false
55
- }
56
-
57
- if ( ! context ) {
58
- context = jit . getRuleContext ( state , rule , className . className )
59
- }
60
- let otherContext = jit . getRuleContext ( state , otherRule , otherClassName . className )
61
-
62
- if ( ! equal ( context , otherContext ) ) {
63
- return false
49
+ for ( let i = 0 ; i < otherRules . length ; i ++ ) {
50
+ let rule = otherRules [ i ]
51
+ let properties : string [ ] = [ ]
52
+ rule . walkDecls ( ( { prop } ) => {
53
+ properties . push ( prop )
54
+ } )
55
+ if ( ! equal ( info [ i ] . properties , properties ) ) {
56
+ return false
57
+ }
58
+ let context = jit . getRuleContext ( state , rule , otherClassName . className )
59
+ if ( ! equal ( info [ i ] . context , context ) ) {
60
+ return false
61
+ }
64
62
}
65
63
66
64
return true
@@ -77,9 +75,7 @@ export async function getCssConflictDiagnostics(
77
75
severity === 'error'
78
76
? 1 /* DiagnosticSeverity.Error */
79
77
: 2 /* DiagnosticSeverity.Warning */ ,
80
- message : `'${ className . className } ' applies the same CSS ${
81
- properties . length === 1 ? 'property' : 'properties'
82
- } as ${ joinWithAnd (
78
+ message : `'${ className . className } ' applies the same CSS properties as ${ joinWithAnd (
83
79
conflictingClassNames . map (
84
80
( conflictingClassName ) => `'${ conflictingClassName . className } '`
85
81
)
0 commit comments