Skip to content

Commit fef5b53

Browse files
committed
Revert "feat: Add allowVariableNamePattern to valid-define-options"
This reverts commit d523648.
1 parent d523648 commit fef5b53

File tree

3 files changed

+3
-57
lines changed

3 files changed

+3
-57
lines changed

docs/rules/valid-define-options.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,7 @@ defineOptions({ props: { msg: String } })
108108

109109
## :wrench: Options
110110

111-
```json
112-
{
113-
"vue/valid-define-options": [
114-
"error",
115-
{
116-
"allowVariableNamePattern": "^[A-Z_]+$"
117-
}
118-
]
119-
}
120-
```
121-
122-
- `allowVariableNamePattern` Allow reference to declared variables if variable name matches patterns, default `null`.
111+
Nothing.
123112

124113
## :couple: Related Rules
125114

lib/rules/valid-define-options.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,7 @@ module.exports = {
1616
url: 'https://eslint.vuejs.org/rules/valid-define-options.html'
1717
},
1818
fixable: null,
19-
schema: [
20-
{
21-
type: 'object',
22-
properties: {
23-
allowVariableNamePattern: {
24-
type: 'string'
25-
}
26-
},
27-
additionalProperties: false
28-
}
29-
],
19+
schema: [],
3020
messages: {
3121
referencingLocally:
3222
'`defineOptions` is referencing locally declared variables.',
@@ -39,13 +29,6 @@ module.exports = {
3929
},
4030
/** @param {RuleContext} context */
4131
create(context) {
42-
const option = context.options[0] || {}
43-
const allowVariableNamePattern = option.allowVariableNamePattern
44-
/** @type {RegExp | null} */
45-
let allowVariableNamePatternRegEx = null
46-
if (allowVariableNamePattern) {
47-
allowVariableNamePatternRegEx = new RegExp(allowVariableNamePattern, 'u')
48-
}
4932
const scriptSetup = utils.getScriptSetupElement(context)
5033
if (!scriptSetup) {
5134
return {}
@@ -110,9 +93,7 @@ module.exports = {
11093
(def) =>
11194
def.type !== 'ImportBinding' &&
11295
utils.inRange(scriptSetup.range, def.name) &&
113-
!utils.inRange(defineOptions.range, def.name) &&
114-
(allowVariableNamePatternRegEx === null ||
115-
!allowVariableNamePatternRegEx.test(variable.name))
96+
!utils.inRange(defineOptions.range, def.name)
11697
)
11798
) {
11899
if (utils.withinTypeNode(node)) {

tests/lib/rules/valid-define-options.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,6 @@ tester.run('valid-define-options', rule, {
7474
7575
defineOptions(def);
7676
</script>`
77-
},
78-
{
79-
filename: 'test.vue',
80-
code: `
81-
<script setup>
82-
const COMPONENT_NAME = 'TestComponent'
83-
defineOptions({ name: COMPONENT_NAME })
84-
</script>`,
85-
options: [{ allowVariableNamePattern: '^[A-Z_]+$' }]
8677
}
8778
],
8879
invalid: [
@@ -214,21 +205,6 @@ tester.run('valid-define-options', rule, {
214205
line: 3
215206
}
216207
]
217-
},
218-
{
219-
filename: 'test.vue',
220-
code: `
221-
<script setup>
222-
const componentName = "TestComponent"
223-
defineOptions({ name: componentName });
224-
</script>`,
225-
options: [{ allowVariableNamePattern: '^[A-Z_]+$' }],
226-
errors: [
227-
{
228-
message: '`defineOptions` is referencing locally declared variables.',
229-
line: 4
230-
}
231-
]
232208
}
233209
]
234210
})

0 commit comments

Comments
 (0)