@@ -914,6 +914,9 @@ test('Can find helper functions in CSS', async ({ expect }) => {
914
914
.a { color: from-config(theme(foo / 0.5, default)); }
915
915
.a { color: from-config(theme("foo" / 0.5)); }
916
916
.a { color: from-config(theme("foo" / 0.5, default)); }
917
+
918
+ /* nested helpers */
919
+ .a { color: config(theme(foo)); }
917
920
` ,
918
921
} )
919
922
@@ -962,89 +965,96 @@ test('Can find helper functions in CSS', async ({ expect }) => {
962
965
} ,
963
966
964
967
// Nested
965
- {
966
- helper : 'config' ,
967
- path : 'theme(foo)' ,
968
- ranges : { full : range ( 11 , 30 , 11 , 40 ) , path : range ( 11 , 30 , 11 , 40 ) } ,
969
- } ,
970
968
{
971
969
helper : 'theme' ,
972
970
path : 'foo' ,
973
971
ranges : { full : range ( 11 , 36 , 11 , 39 ) , path : range ( 11 , 36 , 11 , 39 ) } ,
974
972
} ,
975
- {
976
- helper : 'config' ,
977
- path : 'theme(foo, default)' ,
978
- ranges : { full : range ( 12 , 30 , 12 , 49 ) , path : range ( 12 , 30 , 12 , 49 ) } ,
979
- } ,
980
973
{
981
974
helper : 'theme' ,
982
975
path : 'foo' ,
983
976
ranges : { full : range ( 12 , 36 , 12 , 48 ) , path : range ( 12 , 36 , 12 , 39 ) } ,
984
977
} ,
985
- {
986
- helper : 'config' ,
987
- path : 'theme("foo")' ,
988
- ranges : { full : range ( 13 , 30 , 13 , 42 ) , path : range ( 13 , 30 , 13 , 42 ) } ,
989
- } ,
990
978
{
991
979
helper : 'theme' ,
992
980
path : 'foo' ,
993
981
ranges : { full : range ( 13 , 36 , 13 , 41 ) , path : range ( 13 , 37 , 13 , 40 ) } ,
994
982
} ,
995
- {
996
- helper : 'config' ,
997
- path : 'theme("foo", default)' ,
998
- ranges : { full : range ( 14 , 30 , 14 , 51 ) , path : range ( 14 , 30 , 14 , 51 ) } ,
999
- } ,
1000
983
{
1001
984
helper : 'theme' ,
1002
985
path : 'foo' ,
1003
986
ranges : { full : range ( 14 , 36 , 14 , 50 ) , path : range ( 14 , 37 , 14 , 40 ) } ,
1004
987
} ,
1005
- {
1006
- helper : 'config' ,
1007
- path : 'theme(foo / 0.5)' ,
1008
- ranges : { full : range ( 15 , 30 , 15 , 46 ) , path : range ( 15 , 30 , 15 , 46 ) } ,
1009
- } ,
1010
988
{
1011
989
helper : 'theme' ,
1012
990
path : 'foo' ,
1013
991
ranges : { full : range ( 15 , 36 , 15 , 45 ) , path : range ( 15 , 36 , 15 , 39 ) } ,
1014
992
} ,
1015
- {
1016
- helper : 'config' ,
1017
- path : 'theme(foo / 0.5, default)' ,
1018
- ranges : { full : range ( 16 , 30 , 16 , 55 ) , path : range ( 16 , 30 , 16 , 55 ) } ,
1019
- } ,
1020
993
{
1021
994
helper : 'theme' ,
1022
995
path : 'foo' ,
1023
996
ranges : { full : range ( 16 , 36 , 16 , 54 ) , path : range ( 16 , 36 , 16 , 39 ) } ,
1024
997
} ,
1025
998
{
1026
- helper : 'config ' ,
1027
- path : 'theme(" foo" / 0.5) ' ,
1028
- ranges : { full : range ( 17 , 30 , 17 , 48 ) , path : range ( 17 , 30 , 17 , 48 ) } ,
999
+ helper : 'theme ' ,
1000
+ path : 'foo' ,
1001
+ ranges : { full : range ( 17 , 36 , 17 , 47 ) , path : range ( 17 , 37 , 17 , 40 ) } ,
1029
1002
} ,
1030
1003
{
1031
1004
helper : 'theme' ,
1032
1005
path : 'foo' ,
1033
- ranges : { full : range ( 17 , 36 , 17 , 47 ) , path : range ( 17 , 37 , 17 , 40 ) } ,
1006
+ ranges : { full : range ( 18 , 36 , 18 , 56 ) , path : range ( 18 , 37 , 18 , 40 ) } ,
1034
1007
} ,
1008
+
1009
+ // Nested helpers
1035
1010
{
1036
1011
helper : 'config' ,
1037
- path : 'theme(" foo" / 0.5, default )' ,
1038
- ranges : { full : range ( 18 , 30 , 18 , 57 ) , path : range ( 18 , 30 , 18 , 57 ) } ,
1012
+ path : 'theme(foo)' ,
1013
+ ranges : { full : range ( 21 , 25 , 21 , 35 ) , path : range ( 21 , 25 , 21 , 35 ) } ,
1039
1014
} ,
1040
1015
{
1041
1016
helper : 'theme' ,
1042
1017
path : 'foo' ,
1043
- ranges : { full : range ( 18 , 36 , 18 , 56 ) , path : range ( 18 , 37 , 18 , 40 ) } ,
1018
+ ranges : { full : range ( 21 , 31 , 21 , 34 ) , path : range ( 21 , 31 , 21 , 34 ) } ,
1044
1019
} ,
1045
1020
] )
1046
1021
} )
1047
1022
1023
+ test ( 'Can find helper functions in SCSS' , async ( { expect } ) => {
1024
+ let file = createDocument ( {
1025
+ name : 'file.scss' ,
1026
+ lang : 'scss' ,
1027
+ settings : {
1028
+ tailwindCSS : {
1029
+ classFunctions : [ 'clsx' ] ,
1030
+ } ,
1031
+ } ,
1032
+ content : `
1033
+ .foo {
1034
+ color: config(foo);
1035
+ @include my-config($foo: bar);
1036
+ @include .my-config($foo: bar);
1037
+ @include $my-config($foo: bar);
1038
+ @include %my-config($foo: bar);
1039
+ @include #my-config($foo: bar);
1040
+ }
1041
+ ` ,
1042
+ } )
1043
+
1044
+ let fns = findHelperFunctionsInDocument ( file . state , file . doc )
1045
+
1046
+ expect ( fns ) . toEqual ( [
1047
+ // The first function matches
1048
+ {
1049
+ helper : 'config' ,
1050
+ path : 'foo' ,
1051
+ ranges : { full : range ( 2 , 22 , 2 , 25 ) , path : range ( 2 , 22 , 2 , 25 ) } ,
1052
+ } ,
1053
+
1054
+ // The rest don't
1055
+ ] )
1056
+ } )
1057
+
1048
1058
test ( 'class functions work inside astro code fences' , async ( { expect } ) => {
1049
1059
let file = createDocument ( {
1050
1060
name : 'file.astro' ,
@@ -1082,7 +1092,9 @@ test('class functions work inside astro code fences', async ({ expect }) => {
1082
1092
] )
1083
1093
} )
1084
1094
1085
- test ( 'classFunctions are detected inside of arrays in javascript just after opening bracket' , async ( { expect } ) => {
1095
+ test ( 'classFunctions are detected inside of arrays in javascript just after opening bracket' , async ( {
1096
+ expect,
1097
+ } ) => {
1086
1098
let file = createDocument ( {
1087
1099
name : 'file.js' ,
1088
1100
lang : 'javascript' ,
0 commit comments