Repository: vuejs/eslint-plugin-vue
Pull request #1892 (2022-05-17 10:54:47)

Rename `vue/no-invalid-attribute-name` rule to `vue/invalid-attribute-name` and add it to presets

FloEdelmann: Maybe before we release v9, should we rename `no-invalid-attribute-name` to `valid-attribute-name` for consistency?
ota-meshi: I think it's a good idea to rename the rule. I will rename in this PR.

Patch:
diff --git a/docs/rules/README.md b/docs/rules/README.md
index 869a0cee..b7292864 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -105,6 +105,7 @@ Rules in this category are enabled for all presets provided by eslint-plugin-vue
 | [vue/return-in-computed-property](./return-in-computed-property.md) | enforce that a return statement is present in computed property |  | :three::two::warning: |
 | [vue/return-in-emits-validator](./return-in-emits-validator.md) | enforce that a return statement is present in emits validator |  | :three::two::warning: |
 | [vue/use-v-on-exact](./use-v-on-exact.md) | enforce usage of `exact` modifier on `v-on` |  | :three::two::hammer: |
+| [vue/valid-attribute-name](./valid-attribute-name.md) | require valid attribute names |  | :three::two::warning: |
 | [vue/valid-define-emits](./valid-define-emits.md) | enforce valid `defineEmits` compiler macro |  | :three::two::warning: |
 | [vue/valid-define-props](./valid-define-props.md) | enforce valid `defineProps` compiler macro |  | :three::two::warning: |
 | [vue/valid-model-definition](./valid-model-definition.md) | require valid keys in model option |  | :two::warning: |
@@ -224,7 +225,6 @@ For example:
 | [vue/no-boolean-default](./no-boolean-default.md) | disallow boolean defaults | :wrench: | :hammer: |
 | [vue/no-duplicate-attr-inheritance](./no-duplicate-attr-inheritance.md) | enforce `inheritAttrs` to be set to `false` when using `v-bind="$attrs"` |  | :hammer: |
 | [vue/no-empty-component-block](./no-empty-component-block.md) | disallow the `<template>` `<script>` `<style>` block to be empty |  | :hammer: |
-| [vue/no-invalid-attribute-name](./no-invalid-attribute-name.md) | require valid attribute names |  | :warning: |
 | [vue/no-multiple-objects-in-class](./no-multiple-objects-in-class.md) | disallow to pass multiple objects into array to class |  | :hammer: |
 | [vue/no-potential-component-option-typo](./no-potential-component-option-typo.md) | disallow a potential typo in your component property | :bulb: | :hammer: |
 | [vue/no-restricted-block](./no-restricted-block.md) | disallow specific block |  | :hammer: |
diff --git a/docs/rules/no-invalid-attribute-name.md b/docs/rules/valid-attribute-name.md
similarity index 61%
rename from docs/rules/no-invalid-attribute-name.md
rename to docs/rules/valid-attribute-name.md
index 811d9232..f310cce6 100644
--- a/docs/rules/no-invalid-attribute-name.md
+++ b/docs/rules/valid-attribute-name.md
@@ -1,20 +1,21 @@
 ---
 pageClass: rule-details
 sidebarDepth: 0
-title: vue/no-invalid-attribute-name
+title: vue/valid-attribute-name
 description: require valid attribute names
 ---
-# vue/no-invalid-attribute-name
+# vue/valid-attribute-name
 
 > require valid attribute names
 
 - :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
+- :gear: This rule is included in all of `"plugin:vue/vue3-essential"`, `"plugin:vue/essential"`, `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
 
 ## :book: Rule Details
 
 This rule detects invalid HTML attributes.
 
-<eslint-code-block :rules="{'vue/no-invalid-attribute-name': ['error']}">
+<eslint-code-block :rules="{'vue/valid-attribute-name': ['error']}">
 
 ```vue
 <template>
@@ -39,5 +40,5 @@ Nothing.
 
 ## :mag: Implementation
 
-- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-invalid-attribute-name.js)
-- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/no-invalid-attribute-name.js)
+- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/valid-attribute-name.js)
+- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/valid-attribute-name.js)
diff --git a/lib/configs/essential.js b/lib/configs/essential.js
index 33cfe64e..944a162e 100644
--- a/lib/configs/essential.js
+++ b/lib/configs/essential.js
@@ -49,6 +49,7 @@ module.exports = {
     'vue/return-in-computed-property': 'error',
     'vue/return-in-emits-validator': 'error',
     'vue/use-v-on-exact': 'error',
+    'vue/valid-attribute-name': 'error',
     'vue/valid-define-emits': 'error',
     'vue/valid-define-props': 'error',
     'vue/valid-model-definition': 'error',
diff --git a/lib/configs/vue3-essential.js b/lib/configs/vue3-essential.js
index 1a150733..5fe530be 100644
--- a/lib/configs/vue3-essential.js
+++ b/lib/configs/vue3-essential.js
@@ -66,6 +66,7 @@ module.exports = {
     'vue/return-in-computed-property': 'error',
     'vue/return-in-emits-validator': 'error',
     'vue/use-v-on-exact': 'error',
+    'vue/valid-attribute-name': 'error',
     'vue/valid-define-emits': 'error',
     'vue/valid-define-props': 'error',
     'vue/valid-next-tick': 'error',
diff --git a/lib/index.js b/lib/index.js
index 7d30f4e5..c4979a98 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -91,7 +91,6 @@ module.exports = {
     'no-export-in-script-setup': require('./rules/no-export-in-script-setup'),
     'no-expose-after-await': require('./rules/no-expose-after-await'),
     'no-extra-parens': require('./rules/no-extra-parens'),
-    'no-invalid-attribute-name': require('./rules/no-invalid-attribute-name'),
     'no-invalid-model-keys': require('./rules/no-invalid-model-keys'),
     'no-irregular-whitespace': require('./rules/no-irregular-whitespace'),
     'no-lifecycle-after-await': require('./rules/no-lifecycle-after-await'),
@@ -197,6 +196,7 @@ module.exports = {
     'v-on-function-call': require('./rules/v-on-function-call'),
     'v-on-style': require('./rules/v-on-style'),
     'v-slot-style': require('./rules/v-slot-style'),
+    'valid-attribute-name': require('./rules/valid-attribute-name'),
     'valid-define-emits': require('./rules/valid-define-emits'),
     'valid-define-props': require('./rules/valid-define-props'),
     'valid-model-definition': require('./rules/valid-model-definition'),
diff --git a/lib/rules/no-invalid-attribute-name.js b/lib/rules/valid-attribute-name.js
similarity index 92%
rename from lib/rules/no-invalid-attribute-name.js
rename to lib/rules/valid-attribute-name.js
index 8fd3c713..6da399f3 100644
--- a/lib/rules/no-invalid-attribute-name.js
+++ b/lib/rules/valid-attribute-name.js
@@ -12,8 +12,8 @@ module.exports = {
     type: 'problem',
     docs: {
       description: 'require valid attribute names',
-      categories: undefined,
-      url: 'https://eslint.vuejs.org/rules/no-invalid-attribute-name.html'
+      categories: ['vue3-essential', 'essential'],
+      url: 'https://eslint.vuejs.org/rules/valid-attribute-name.html'
     },
     fixable: null,
     schema: [],


Test patch:
diff --git a/tests/lib/rules/no-invalid-attribute-name.js b/tests/lib/rules/valid-attribute-name.js
similarity index 95%
rename from tests/lib/rules/no-invalid-attribute-name.js
rename to tests/lib/rules/valid-attribute-name.js
index 09c07cc2..92023189 100644
--- a/tests/lib/rules/no-invalid-attribute-name.js
+++ b/tests/lib/rules/valid-attribute-name.js
@@ -1,11 +1,11 @@
 /**
- * @author *****your name*****
+ * @author Doug Wade <douglas.b.wade@gmail.com>
  * See LICENSE file in root directory for full license.
  */
 'use strict'
 
 const RuleTester = require('eslint').RuleTester
-const rule = require('../../../lib/rules/no-invalid-attribute-name')
+const rule = require('../../../lib/rules/valid-attribute-name')
 
 const tester = new RuleTester({
   parser: require.resolve('vue-eslint-parser'),
@@ -15,7 +15,7 @@ const tester = new RuleTester({
   }
 })
 
-tester.run('no-invalid-attribute-name', rule, {
+tester.run('valid-attribute-name', rule, {
   valid: [
     {
       filename: 'test.vue',