File tree Expand file tree Collapse file tree 2 files changed +53
-4
lines changed
Expand file tree Collapse file tree 2 files changed +53
-4
lines changed Original file line number Diff line number Diff line change @@ -2,17 +2,36 @@ export default function (_context) {
22 return ( root , result ) => {
33 let found = false
44
5+ root . walkAtRules ( 'tailwind' , ( node ) => {
6+ if ( found ) return false
7+
8+ if ( node . parent && node . parent . type !== 'root' ) {
9+ found = true
10+ node . warn (
11+ result ,
12+ [
13+ 'Nested @tailwind rules were detected, but are not supported.' ,
14+ "Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix" ,
15+ 'Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy' ,
16+ ] . join ( '\n' )
17+ )
18+ return false
19+ }
20+ } )
21+
522 root . walkRules ( ( rule ) => {
623 if ( found ) return false
724
825 rule . walkRules ( ( nestedRule ) => {
926 found = true
1027 nestedRule . warn (
1128 result ,
12- // TODO: Improve this warning message
13- 'Nested CSS detected, checkout the docs on how to support nesting: https://tailwindcss.com/docs/using-with-preprocessors#nesting'
29+ [
30+ 'Nested CSS was detected, but CSS nesting has not been configured correctly.' ,
31+ 'Please enable a CSS nesting plugin *before* Tailwind in your configuration.' ,
32+ 'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting' ,
33+ ] . join ( '\n' )
1434 )
15-
1635 return false
1736 } )
1837 } )
Original file line number Diff line number Diff line change @@ -19,7 +19,37 @@ it('should warn when we detect nested css', () => {
1919 expect ( result . messages ) . toMatchObject ( [
2020 {
2121 type : 'warning' ,
22- text : 'Nested CSS detected, checkout the docs on how to support nesting: https://tailwindcss.com/docs/using-with-preprocessors#nesting' ,
22+ text : [
23+ 'Nested CSS was detected, but CSS nesting has not been configured correctly.' ,
24+ 'Please enable a CSS nesting plugin *before* Tailwind in your configuration.' ,
25+ 'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting' ,
26+ ] . join ( '\n' ) ,
27+ } ,
28+ ] )
29+ } )
30+ } )
31+
32+ it ( 'should warn when we detect namespaced @tailwind at rules' , ( ) => {
33+ let config = {
34+ content : [ { raw : html `<div class= "text-center" > </ div> ` } ] ,
35+ }
36+
37+ let input = css `
38+ .namespace {
39+ @tailwind utilities;
40+ }
41+ `
42+
43+ return run ( input , config ) . then ( ( result ) => {
44+ expect ( result . messages ) . toHaveLength ( 1 )
45+ expect ( result . messages ) . toMatchObject ( [
46+ {
47+ type : 'warning' ,
48+ text : [
49+ 'Nested @tailwind rules were detected, but are not supported.' ,
50+ "Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix" ,
51+ 'Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy' ,
52+ ] . join ( '\n' ) ,
2353 } ,
2454 ] )
2555 } )
You can’t perform that action at this time.
0 commit comments