Skip to content

AI-native design editor. Open-source Figma alternative.

chore(vue): lint generated test id literals

Danila Poyarkov4a174e52ed70
diff --git a/lint/plugin.js b/lint/plugin.js
index d20956ba7..9b835059d 100644
--- a/lint/plugin.js
+++ b/lint/plugin.js
@@ -324,6 +324,35 @@ const noInvalidTestIdAttributes = {
}
}
+const noGeneratedTestIdLiterals = {
+ meta: {
+ docs: {
+ description: 'Disallow hand-written generated test-id literals — use shared helper functions'
+ }
+ },
+ create(context) {
+ const file = normalizedFilename(context)
+ if (file.endsWith('/packages/vue/src/testing/test-id.ts')) return {}
+ if (file.endsWith('/tests/helpers/test-ids.ts')) return {}
+ if (!file.includes('/src/') && !file.includes('/tests/')) return {}
+
+ return {
+ Program(node) {
+ const source = context.sourceCode.getText()
+ const match = source.match(
+ /["'`](?:mobile-)?toolbar-(?:tool|flyout|flyout-item)-|["'`]variables-add-(?:float|string|boolean)["'`]|["'`]acp-permission-option-/
+ )
+ if (!match) return
+ context.report({
+ node,
+ message:
+ 'Use shared generated test-id helpers instead of hand-written toolbar/variable/permission id literals.'
+ })
+ }
+ }
+ }
+}
+
const noDocumentQuerySelectorInVue = {
meta: {
docs: {
@@ -1413,6 +1442,7 @@ const plugin = {
'no-dynamic-data-test-id-in-vue': noDynamicDataTestIdInVue,
'no-test-id-helper-bind-in-vue': noTestIdHelperBindInVue,
'no-invalid-test-id-attributes': noInvalidTestIdAttributes,
+ 'no-generated-test-id-literals': noGeneratedTestIdLiterals,
'no-document-query-selector-in-vue': noDocumentQuerySelectorInVue,
'no-direct-selection-tool-state-mutation': noDirectSelectionToolStateMutation,
'no-math-random': noMathRandom,
diff --git a/oxlint.json b/oxlint.json
index 5182e38ea..85bda720e 100644
--- a/oxlint.json
+++ b/oxlint.json
@@ -116,6 +116,7 @@
"open-pencil/no-dynamic-data-test-id-in-vue": "error",
"open-pencil/no-test-id-helper-bind-in-vue": "error",
"open-pencil/no-invalid-test-id-attributes": "error",
+ "open-pencil/no-generated-test-id-literals": "error",
"open-pencil/no-document-query-selector-in-vue": "error",
"open-pencil/no-direct-selection-tool-state-mutation": "error",
"open-pencil/no-math-random": "error",