You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/pigment-react/src/utils/sxObjectExtractor.ts
+18-13Lines changed: 18 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,9 @@ function validateObjectKey(
23
23
return;
24
24
}
25
25
if(!parentCall){
26
-
throwkeyPath.buildCodeFrameError('Expressions in css object keys are not supported.');
26
+
throwkeyPath.buildCodeFrameError(
27
+
`${process.env.PACKAGE_NAME}: Expressions in css object keys are not supported.`,
28
+
);
27
29
}
28
30
if(
29
31
!identifiers.every((item)=>{
@@ -41,7 +43,7 @@ function validateObjectKey(
41
43
})
42
44
){
43
45
throwkeyPath.buildCodeFrameError(
44
-
'Variables in css object keys should only use the passed theme(s) object or variables that are defined in the root scope.',
46
+
`${process.env.PACKAGE_NAME}: Variables in css object keys should only use the passed theme(s) object or variables that are defined in the root scope.`,
45
47
);
46
48
}
47
49
}
@@ -59,14 +61,14 @@ function traverseObjectExpression(
59
61
constvalue=property.get('value');
60
62
if(!value.isExpression()){
61
63
throwvalue.buildCodeFrameError(
62
-
'This value is not supported. It can only be static values or local variables.',
64
+
`${process.env.PACKAGE_NAME}: This value is not supported. It can only be static values or local variables.`,
63
65
);
64
66
}
65
67
if(value.isObjectExpression()){
66
68
traverseObjectExpression(value,parentCall);
67
69
}elseif(value.isArrowFunctionExpression()){
68
70
throwvalue.buildCodeFrameError(
69
-
'Arrow functions are not supported as values of sx object.',
71
+
`${process.env.PACKAGE_NAME}: Arrow functions are not supported as values of sx object.`,
'You can only use variables that are defined in the root scope of the file.',
114
+
`${process.env.PACKAGE_NAME}: You can only use variables in the spread that are defined in the root scope of the file.`,
114
115
);
115
116
}
116
117
}elseif(property.isObjectMethod()){
117
-
throwproperty.buildCodeFrameError('sx prop object does not support ObjectMethods.');
118
+
throwproperty.buildCodeFrameError(
119
+
`${process.env.PACKAGE_NAME}: sx prop object does not support ObjectMethods.`,
120
+
);
118
121
}else{
119
-
throwproperty.buildCodeFrameError('Unknown property in object.');
122
+
throwproperty.buildCodeFrameError(
123
+
`${process.env.PACKAGE_NAME}: Unknown property in object.`,
124
+
);
120
125
}
121
126
});
122
127
}
@@ -128,7 +133,7 @@ export function sxObjectExtractor(nodePath: NodePath<ObjectExpression | ArrowFun
128
133
constbody=nodePath.get('body');
129
134
if(!body.isObjectExpression()){
130
135
throwbody.buildCodeFrameError(
131
-
"sx prop only supports arrow functions that directly return an object, e.g. () => ({color: 'red'}). You can accept theme object in the params if required.",
136
+
`${process.env.PACKAGE_NAME}: sx prop only supports arrow functions directly returning an object, e.g. () => ({color: 'red'}). You can accept theme object in the params if required.`,
0 commit comments