@terrazzo/parser 2.0.0-beta.5 → 2.0.0-beta.6
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/index.js +18 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -309,20 +309,23 @@ async function build(tokens, { resolver, sources, logger = new Logger(), config
|
|
|
309
309
|
},
|
|
310
310
|
pluginName: plugin.name
|
|
311
311
|
});
|
|
312
|
-
if (!formats[params.format]) formats[params.format] = {};
|
|
312
|
+
if (!formats[params.format]) formats[params.format] = { [FALLBACK_PERMUTATION_ID]: [] };
|
|
313
313
|
if (!formats[params.format][permutationID]) formats[params.format][permutationID] = [];
|
|
314
314
|
const foundTokenI = formats[params.format][permutationID].findIndex((t) => id === t.id && (!params.localID || params.localID === t.localID) && (!mode || t.mode === mode));
|
|
315
|
-
if (foundTokenI === -1)
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
315
|
+
if (foundTokenI === -1) {
|
|
316
|
+
const transformedToken = {
|
|
317
|
+
...params,
|
|
318
|
+
id,
|
|
319
|
+
value: cleanValue,
|
|
320
|
+
type: typeof cleanValue === "string" ? SINGLE_VALUE : MULTI_VALUE,
|
|
321
|
+
mode: mode || ".",
|
|
322
|
+
token: makeReadOnlyToken(token),
|
|
323
|
+
permutationID,
|
|
324
|
+
input: JSON.parse(permutationID)
|
|
325
|
+
};
|
|
326
|
+
formats[params.format][permutationID].push(transformedToken);
|
|
327
|
+
if (params.input && !Object.keys(params.input).length && permutationID !== FALLBACK_PERMUTATION_ID) formats[params.format][FALLBACK_PERMUTATION_ID].push(transformedToken);
|
|
328
|
+
} else {
|
|
326
329
|
formats[params.format][permutationID][foundTokenI].value = cleanValue;
|
|
327
330
|
formats[params.format][permutationID][foundTokenI].type = typeof cleanValue === "string" ? SINGLE_VALUE : MULTI_VALUE;
|
|
328
331
|
}
|
|
@@ -2392,14 +2395,14 @@ async function lintRunner({ tokens, filename, config = {}, sources, logger }) {
|
|
|
2392
2395
|
let message = "";
|
|
2393
2396
|
if (!descriptor.message && !descriptor.messageId) logger.error({
|
|
2394
2397
|
group: "lint",
|
|
2395
|
-
label: `${plugin.name}
|
|
2398
|
+
label: `${plugin.name}:${id}`,
|
|
2396
2399
|
message: "Unable to report error: missing message or messageId"
|
|
2397
2400
|
});
|
|
2398
2401
|
if (descriptor.message) message = descriptor.message;
|
|
2399
2402
|
else {
|
|
2400
2403
|
if (!(descriptor.messageId in (rule.meta?.messages ?? {}))) logger.error({
|
|
2401
2404
|
group: "lint",
|
|
2402
|
-
label: `${plugin.name}
|
|
2405
|
+
label: `${plugin.name}:${id}`,
|
|
2403
2406
|
message: `messageId "${descriptor.messageId}" does not exist`
|
|
2404
2407
|
});
|
|
2405
2408
|
message = rule.meta?.messages?.[descriptor.messageId] ?? "";
|
|
@@ -3136,7 +3139,7 @@ function processTokens(rootSource, { config, logger, sourceByFilename, isResolve
|
|
|
3136
3139
|
const tokenIDs = [];
|
|
3137
3140
|
const groups = {};
|
|
3138
3141
|
traverse(rootSource.document, { enter(node, _parent, rawPath) {
|
|
3139
|
-
if (node.type !== "Object") return;
|
|
3142
|
+
if (node.type !== "Object" || rawPath.includes("$value") || rawPath.includes("$extensions")) return;
|
|
3140
3143
|
groupFromNode(node, {
|
|
3141
3144
|
path: isResolver ? filterResolverPaths(rawPath) : rawPath,
|
|
3142
3145
|
groups
|