attio 0.0.1-experimental.20250212 → 0.0.1-experimental.20250212.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/lint.cjs
CHANGED
|
@@ -75,5 +75,57 @@ module.exports = {
|
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
},
|
|
78
|
+
"form-submit-button": {
|
|
79
|
+
meta: {
|
|
80
|
+
type: "problem",
|
|
81
|
+
docs: {
|
|
82
|
+
description: "Ensure <Form/> components have exactly one <SubmitButton/> as a direct child, and <SubmitButton/> components only appear as direct children of <Form/> components",
|
|
83
|
+
category: "Possible Errors",
|
|
84
|
+
recommended: true,
|
|
85
|
+
},
|
|
86
|
+
fixable: null,
|
|
87
|
+
},
|
|
88
|
+
create(context) {
|
|
89
|
+
return {
|
|
90
|
+
JSXElement(node) {
|
|
91
|
+
// Check if this is a Form component
|
|
92
|
+
if (node.openingElement.name.name === "Form") {
|
|
93
|
+
let submitButtonCount = 0
|
|
94
|
+
|
|
95
|
+
// Check direct children only
|
|
96
|
+
node.children.forEach(child => {
|
|
97
|
+
if (child.type === "JSXElement") {
|
|
98
|
+
if (child.openingElement.name.name === "SubmitButton") {
|
|
99
|
+
submitButtonCount++
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
if (submitButtonCount === 0) {
|
|
105
|
+
context.report({
|
|
106
|
+
node,
|
|
107
|
+
message: "<Form/> component must have exactly one <SubmitButton/> as a direct child",
|
|
108
|
+
})
|
|
109
|
+
} else if (submitButtonCount > 1) {
|
|
110
|
+
context.report({
|
|
111
|
+
node,
|
|
112
|
+
message: "<Form/> component must not have multiple <SubmitButton/> children",
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Check if this is a SubmitButton that's not a direct child of Form
|
|
117
|
+
else if (node.openingElement.name.name === "SubmitButton") {
|
|
118
|
+
const parent = node.parent
|
|
119
|
+
if (!parent || parent.type !== "JSXElement" || parent.openingElement.name.name !== "Form") {
|
|
120
|
+
context.report({
|
|
121
|
+
node,
|
|
122
|
+
message: "<SubmitButton/> must be a direct child of a <Form/> component",
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
},
|
|
78
130
|
},
|
|
79
131
|
}
|