@wix/origami-lint 1.34.44 → 1.34.45
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/page-model/utils.js +13 -5
- package/package.json +2 -2
package/dist/page-model/utils.js
CHANGED
|
@@ -50,13 +50,21 @@ export function attributeName(attr) {
|
|
|
50
50
|
export const isIdAttribute = (attr) => attributeName(attr) === 'id';
|
|
51
51
|
/** id="comp-x" → 'comp-x'; no id, or id={variable} → null. */
|
|
52
52
|
export const getLiteralId = (node) => getLiteralAttribute(node, 'id');
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
/**
|
|
54
|
+
* className="comp-x card" → ['comp-x', 'card']; className={['comp-x', 'open', {…}]} → ['comp-x'], as the import reads it: the
|
|
55
|
+
* array's first item is the class, the rest are states (parseJsx.ts splitClassName). No className, or className={variable} → [].
|
|
56
|
+
*/
|
|
57
|
+
export function getLiteralClassNames(node) {
|
|
58
|
+
const value = getAttributeValue(node, 'className');
|
|
59
|
+
const classes = value?.type === 'JSXExpressionContainer' && value.expression.type === 'ArrayExpression' ? getStringLiteral(value.expression.elements[0]) : getStringLiteral(value);
|
|
60
|
+
return classes?.split(/\s+/).filter(Boolean) ?? [];
|
|
61
|
+
}
|
|
62
|
+
const getLiteralAttribute = (node, name) => getStringLiteral(getAttributeValue(node, name));
|
|
63
|
+
function getAttributeValue(node, name) {
|
|
56
64
|
const attr = node.openingElement.attributes.find((attribute) => attributeName(attribute) === name);
|
|
57
|
-
|
|
58
|
-
return value?.type === 'Literal' && typeof value.value === 'string' ? value.value : null;
|
|
65
|
+
return attr?.type === 'JSXAttribute' ? attr.value : null;
|
|
59
66
|
}
|
|
67
|
+
const getStringLiteral = (node) => node?.type === 'Literal' && typeof node.value === 'string' ? node.value : null;
|
|
60
68
|
export function createSourceReader(text) {
|
|
61
69
|
const lineStarts = [0];
|
|
62
70
|
for (let i = 0; i < text.length; i++)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/origami-lint",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.45",
|
|
4
4
|
"description": "Offline lint for an exported Origami site: lints the pages that changed since the last passing run",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
]
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
-
"falconPackageHash": "
|
|
57
|
+
"falconPackageHash": "2074e22ab967a850d77f7b1a49eb1862edcfa2d6716aead0795088c5"
|
|
58
58
|
}
|