Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
Detect conflicting multi-rule classes (#498)
Signature
-----BEGIN PGP SIGNATURE----- wsBcBAABCAAQBQJiGNeCCRBK7hj4Ov3rIwAArQcIAATbI6SjBmDG+c6SY8pRfJ6T ouv82eXv1Lg+qZWqm6PlBaC7ez3YUtNZppsL2IHIwPfdB6X7pJ/D0PqWXqDxF7xQ H8azTYOX5cUp7GOaCwbJ/maOtiZQuEaIKXBnRcNaqsacYc85J+uuJBBJArBRR+Uu 1xaMz5nduFFBxEnKtNZokXXG90JWR0Wia+/+ItMtM0xglFGahpksiW21bhbwatN/ lf9hd4s2zxT3+TTlSNWp9K1JDGb8/KP7arzctZ3LMYboxHLuazr0xBok2PYZo5Ju kq79NwT3JS3yG7VDABW8T8ghwzJzlJa1FJWHSDMWJJYVGGLlu8V64TT5cyJdzC8= =eIFP -----END PGP SIGNATURE-----
Brad Cornes <bradlc41@gmail.com>
2 years ago
1 changed files, 25 additions(+), 29 deletions(-)
M packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts -> packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts
diff --git a/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts
index c061ec4735282c4738456f4ddf331d0961e52435..4459d249bed274dee0a18fe58c3db84f9574acf2 100644
--- a/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts
+++ b/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts
@@ -25,42 +25,40 @@
     classNames.forEach((className, index) => {
       if (state.jit) {
         let { rules } = jit.generateRules(state, [className.className])
-        if (rules.length !== 1) {
+        if (rules.length === 0) {
           return
         }
-        let rule = rules[0]
-        let context: string[]
-        let properties = []
-        rule.walkDecls(({ prop }) => {
-          properties.push(prop)
+
+        let info: Array<{ context: string[]; properties: string[] }> = rules.map((rule) => {
+          let properties: string[] = []
+          rule.walkDecls(({ prop }) => {
+            properties.push(prop)
+          })
+          let context = jit.getRuleContext(state, rule, className.className)
+          return { context, properties }
         })
 
         let otherClassNames = classNames.filter((_className, i) => i !== index)
 
         let conflictingClassNames = otherClassNames.filter((otherClassName) => {
-          let { rules } = jit.generateRules(state, [otherClassName.className])
-          if (rules.length !== 1) {
-            return false
-          }
-
-          let otherRule = rules[0]
-
-          let otherProperties = []
-          otherRule.walkDecls(({ prop }) => {
-            otherProperties.push(prop)
-          })
-
-          if (!equal(properties, otherProperties)) {
+          let { rules: otherRules } = jit.generateRules(state, [otherClassName.className])
+          if (otherRules.length !== rules.length) {
             return false
           }
 
-          if (!context) {
-            context = jit.getRuleContext(state, rule, className.className)
-          }
-          let otherContext = jit.getRuleContext(state, otherRule, otherClassName.className)
-
-          if (!equal(context, otherContext)) {
-            return false
+          for (let i = 0; i < otherRules.length; i++) {
+            let rule = otherRules[i]
+            let properties: string[] = []
+            rule.walkDecls(({ prop }) => {
+              properties.push(prop)
+            })
+            if (!equal(info[i].properties, properties)) {
+              return false
+            }
+            let context = jit.getRuleContext(state, rule, otherClassName.className)
+            if (!equal(info[i].context, context)) {
+              return false
+            }
           }
 
           return true
@@ -77,9 +75,7 @@           severity:
             severity === 'error'
               ? 1 /* DiagnosticSeverity.Error */
               : 2 /* DiagnosticSeverity.Warning */,
-          message: `'${className.className}' applies the same CSS ${
-            properties.length === 1 ? 'property' : 'properties'
-          } as ${joinWithAnd(
+          message: `'${className.className}' applies the same CSS properties as ${joinWithAnd(
             conflictingClassNames.map(
               (conflictingClassName) => `'${conflictingClassName.className}'`
             )