pasika 0.10.27 → 0.10.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint/pasika/index.js +14 -4
- package/package.json +1 -1
|
@@ -1129,9 +1129,8 @@ function isColorToken(token, inventory) {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
function isKnown(className, inventory) {
|
|
1131
1131
|
if (className.includes("[") || className.includes("(")) return true;
|
|
1132
|
-
const
|
|
1133
|
-
const
|
|
1134
|
-
const utility = segments[segments.length - 1] ?? "";
|
|
1132
|
+
const segments = className.replace(/!+$/, "").split(":");
|
|
1133
|
+
const utility = (segments[segments.length - 1] ?? "").split("/")[0] ?? "";
|
|
1135
1134
|
if (!utility.includes("-")) return true;
|
|
1136
1135
|
const dash = utility.indexOf("-");
|
|
1137
1136
|
const firstTwo = utility.split("-").slice(0, 2).join("-");
|
|
@@ -3982,6 +3981,9 @@ function looksLikeLocaleKey(name) {
|
|
|
3982
3981
|
function looksLikeUserFacingString(value) {
|
|
3983
3982
|
return typeof value === "string" && /^\p{Lu}/u.test(value);
|
|
3984
3983
|
}
|
|
3984
|
+
function looksLikeUserFacingJsxText(value) {
|
|
3985
|
+
return typeof value === "string" && /\p{L}/u.test(value);
|
|
3986
|
+
}
|
|
3985
3987
|
var localesLocationRule = {
|
|
3986
3988
|
meta: {
|
|
3987
3989
|
schema: [],
|
|
@@ -3997,9 +3999,17 @@ var localesLocationRule = {
|
|
|
3997
3999
|
const srcIdx = segments.lastIndexOf("src");
|
|
3998
4000
|
if (srcIdx === -1) return {};
|
|
3999
4001
|
const folder = segments[srcIdx + 1];
|
|
4000
|
-
|
|
4002
|
+
const skipObjectLiteralCheck = folder === "app" || folder === "config";
|
|
4001
4003
|
return {
|
|
4004
|
+
JSXText(node) {
|
|
4005
|
+
if (!looksLikeUserFacingJsxText(node.value)) return;
|
|
4006
|
+
context.report({
|
|
4007
|
+
node,
|
|
4008
|
+
message: "User-facing JSX text must come from src/locales/index.ts, not be written inline."
|
|
4009
|
+
});
|
|
4010
|
+
},
|
|
4002
4011
|
VariableDeclarator(node) {
|
|
4012
|
+
if (skipObjectLiteralCheck) return;
|
|
4003
4013
|
if (node.id.type === "Identifier" && node.init?.type === "ObjectExpression" && node.init.properties.length > 0 && looksLikeLocaleKey(node.id.name)) {
|
|
4004
4014
|
const hasUserFacingStringValues = node.init.properties.some(
|
|
4005
4015
|
(p) => p.type === "Property" && p.value.type === "Literal" && looksLikeUserFacingString(p.value.value)
|