@starci/eslint-canon-fe 3.0.0 → 3.0.1
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/class-names.mjs +4 -1
- package/package.json +1 -1
- package/vendor-boundary.mjs +4 -3
package/class-names.mjs
CHANGED
|
@@ -58,7 +58,10 @@ const usesImportedClassName = (node, imported) => {
|
|
|
58
58
|
if (!node) return false
|
|
59
59
|
if (node.type === "Identifier") return imported.has(node.name) || node.name === "undefined"
|
|
60
60
|
if (isEmptyClassName(node)) return true
|
|
61
|
-
if (node.type === "CallExpression")
|
|
61
|
+
if (node.type === "CallExpression") {
|
|
62
|
+
if (node.callee.type === "Identifier") return imported.has(node.callee.name)
|
|
63
|
+
return node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && imported.has(node.callee.object.name)
|
|
64
|
+
}
|
|
62
65
|
if (node.type === "MemberExpression") return node.object.type === "Identifier" && imported.has(node.object.name)
|
|
63
66
|
if (node.type === "ConditionalExpression") return usesImportedClassName(node.consequent, imported) && usesImportedClassName(node.alternate, imported)
|
|
64
67
|
if (node.type === "LogicalExpression") {
|
package/package.json
CHANGED
package/vendor-boundary.mjs
CHANGED
|
@@ -9,6 +9,7 @@ const normalize = (filename) => String(filename || "").replace(/\\/g, "/")
|
|
|
9
9
|
const componentFile = (filename) => /\/src\/components\//.test(normalize(filename))
|
|
10
10
|
const leafFile = (filename) => /\/src\/components\/leaves\//.test(normalize(filename))
|
|
11
11
|
const mechanicsFile = (filename) => /\/src\/components\/(branches|overlays)\//.test(normalize(filename))
|
|
12
|
+
const classNamesFile = (filename) => /\/src\/components\/.*\/classNames\.tsx?$/.test(normalize(filename))
|
|
12
13
|
|
|
13
14
|
/** Keep direct Heroicons imports in the Icon leaf. */
|
|
14
15
|
export const noVendorIconOutsideIconLeaf = {
|
|
@@ -19,12 +20,12 @@ export const noVendorIconOutsideIconLeaf = {
|
|
|
19
20
|
},
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
/** Keep HeroUI mechanics inside leaves
|
|
23
|
+
/** Keep HeroUI mechanics inside leaves, named mechanics branches, and styling-owner modules. */
|
|
23
24
|
export const vendorPrimitiveHasNamedOwner = {
|
|
24
|
-
meta: { type: "problem", docs: { description: "HeroUI primitives have a named
|
|
25
|
+
meta: { type: "problem", docs: { description: "HeroUI primitives have a named component or styling owner." }, schema: [], messages: { owner: "Import HeroUI primitives from a named leaf, mechanics branch, or colocated classNames module." } },
|
|
25
26
|
create(context) {
|
|
26
27
|
const file = context.filename || context.getFilename()
|
|
27
|
-
if (!componentFile(file) || leafFile(file) || mechanicsFile(file)) return {}
|
|
28
|
+
if (!componentFile(file) || leafFile(file) || mechanicsFile(file) || classNamesFile(file)) return {}
|
|
28
29
|
return { ImportDeclaration(node) { if (String(node.source.value) === "@heroui/react") context.report({ node, messageId: "owner" }) } }
|
|
29
30
|
},
|
|
30
31
|
}
|