Appearance
vue/no-restricted-component-options
禁止特定组件选项
¥disallow specific component option
📖 规则详情
此规则允许你指定你不想在应用中使用的组件选项。
¥This rule allows you to specify component options that you don't want to use in your application.
🔧选项
¥🔧 Options
此规则采用字符串列表,其中每个字符串都是要限制的组件选项名称或模式:
¥This rule takes a list of strings, where each string is a component option name or pattern to be restricted:
json
{
"vue/no-restricted-component-options": ["error", "init", "beforeCompile", "compiled", "activate", "ready", "/^(?:at|de)tached$/"]
}
Now loading...
此外,你可以使用数组来指定对象属性的路径。
¥Also, you can use an array to specify the path of object properties.
例如 [ "error", ["props", "/.*/", "twoWay"] ]
¥e.g. [ "error", ["props", "/.*/", "twoWay"] ]
Now loading...
你可以使用 "*"
来匹配所有属性,包括计算键。
¥You can use "*"
to match all properties, including computed keys.
例如 [ "error", ["props", "*", "twoWay"] ]
¥e.g. [ "error", ["props", "*", "twoWay"] ]
Now loading...
或者,该规则也接受对象。
¥Alternatively, the rule also accepts objects.
json
{
"vue/no-restricted-component-options": ["error",
{
"name": "init",
"message": "Use \"beforeCreate\" instead."
},
{
"name": "/^(?:at|de)tached$/",
"message": "\"attached\" and \"detached\" is deprecated."
},
{
"name": ["props", "/.*/", "twoWay"],
"message": "\"props.*.twoWay\" cannot be used."
}
]
}
可以为对象指定以下属性。
¥The following properties can be specified for the object.
name
...指定组件选项名称或模式,或其数组的路径。¥
name
... Specify the component option name or pattern, or the path by its array.message
...指定可选的自定义消息。¥
message
... Specify an optional custom message.
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v7.0.0 中引入
¥This rule was introduced in eslint-plugin-vue v7.0.0
🔍代码实现
¥🔍 Implementation