Support literal constant references in `vue/valid-define-options` rule
Closed this issue · 4 comments
**What rule do you want to change?**valid-define-options
Does this change cause the rule to produce more or fewer warnings?
no
How will the change be implemented? (New option, new default behavior, etc.)?
Add option to ignoreVariables in valid-define-options
Please provide some example code that this change will affect:
before
const COMPONENT_NAME = 'ElForm'
defineOptions({
name: COMPONENT_NAME, // ❌ ESLint: referencing locally declared variables
})config:
{
"vue/valid-define-options": [
"error",
{ "allowVariableNamePattern": "^[A-Z_]+$" }
]
}after
const COMPONENT_NAME = 'ElForm'
defineOptions({
name: COMPONENT_NAME, // ✅ allowed
})“Because the COMPONENT_NAME variable will be used multiple times in the <script> block, but it will never change.”
What does the rule currently do for this code?
What will the rule do after it's changed?
Additional context
Literal constant references are now supported (see vuejs/core#5750).
In our next release, we can remove the report for this scenario without needing to add a new option to ignore it.
However, we should still keep the check for cases like this:
// ✗ BAD
const def = { name: 'custom' }
defineOptions(def)现在支持文字常量引用(参见vuejs/core#5750)。
在我们的下一个版本中,我们可以删除此场景的报告,而无需添加新选项来忽略它。
然而,我们仍然应该检查如下情况:
// ✗ BAD
const def = { name: 'custom' }
defineOptions(def)
Great! If the job of removing the report is not completed yet, can I help?
That would be great, go ahead!
That would be great, go ahead!
done!I’d appreciate it if you could review this PR when you have time.
Thanks! #2920