@@ -25,42 +25,40 @@ export async function getCssConflictDiagnostics(
2525 classNames . forEach ( ( className , index ) => {
2626 if ( state . jit ) {
2727 let { rules } = jit . generateRules ( state , [ className . className ] )
28- if ( rules . length !== 1 ) {
28+ if ( rules . length === 0 ) {
2929 return
3030 }
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 }
3639 } )
3740
3841 let otherClassNames = classNames . filter ( ( _className , i ) => i !== index )
3942
4043 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 ) {
4346 return false
4447 }
4548
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+ }
6462 }
6563
6664 return true
@@ -77,9 +75,7 @@ export async function getCssConflictDiagnostics(
7775 severity === 'error'
7876 ? 1 /* DiagnosticSeverity.Error */
7977 : 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 (
8379 conflictingClassNames . map (
8480 ( conflictingClassName ) => `'${ conflictingClassName . className } '`
8581 )
0 commit comments