Skip to content

Add option to allowVariableNamePattern in valid-define-options rule #2919

@FrontEndDog

Description

@FrontEndDog

**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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions