noVueRestrictedComponentOptions (JavaScript)
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noVueRestrictedComponentOptions - This rule doesn’t have a fix.
- The default severity of this rule is error.
- This rule belongs to the following domains:
- Sources:
- Inspired from
vue/no-restricted-component-options
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noVueRestrictedComponentOptions": "error" } } }}Description
Section titled “Description”Disallow configured options in Vue components.
A Vue component is described by an object of options, such as props, data or
mounted. Some projects want to avoid certain options, for example options that a
library no longer supports, or options the team decided to stop using.
This rule reports the options listed in the componentOptions
option. It checks the object passed to defineComponent() or createApp(), the object
exported by default from the <script> block of a .vue file, and the object passed to
defineOptions() in <script setup>. It does nothing until you list at least one option.
Examples
Section titled “Examples”The examples below use the following configuration:
{ "linter": { "rules": { "nursery": { "noVueRestrictedComponentOptions": { "level": "on", "options": { "componentOptions": [ "init", [ "props", "*", "twoWay" ] ] } } } } }}Invalid
Section titled “Invalid”<script>export default { init() {},};</script>code-block.vue:3:3 lint/nursery/noVueRestrictedComponentOptions ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The component option init is not allowed.
1 │ <script>
2 │ export default {
> 3 │ init() {},
│ ^^^^
4 │ };
5 │ </script>
ℹ Your project lists this component option under componentOptions in the configuration of this rule, so it isn't allowed.
ℹ Remove this option, or replace it with the alternative your project recommends.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
<script>export default { props: { name: { type: String, twoWay: true }, },};</script>code-block.vue:4:27 lint/nursery/noVueRestrictedComponentOptions ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The component option props.*.twoWay is not allowed.
2 │ export default {
3 │ props: {
> 4 │ name: { type: String, twoWay: true },
│ ^^^^^^
5 │ },
6 │ };
ℹ Your project lists this component option under componentOptions in the configuration of this rule, so it isn't allowed.
ℹ Remove this option, or replace it with the alternative your project recommends.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
<script setup>defineOptions({ init() {},});</script>code-block.vue:3:3 lint/nursery/noVueRestrictedComponentOptions ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The component option init is not allowed.
1 │ <script setup>
2 │ defineOptions({
> 3 │ init() {},
│ ^^^^
4 │ });
5 │ </script>
ℹ Your project lists this component option under componentOptions in the configuration of this rule, so it isn't allowed.
ℹ Remove this option, or replace it with the alternative your project recommends.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
<script>export default { beforeCreate() {}, props: { name: { type: String, required: true }, },};</script>Options
Section titled “Options”componentOptions
Section titled “componentOptions”Default: []
The component options that must not be used. Each entry is one of the following:
- The name of an option, such as
"init". - A list of names that leads to an option inside other options. For example,
["props", "name", "twoWay"]matchestwoWayinprops: { name: { twoWay: true } }. The name"*"matches any property, including spread properties such as...otherand properties whose name is computed, such as[key]. - An object with these properties:
name: The name of the option, or a list of names as described above. This property is required.message: A custom message to show in place of the default message.
Names must match the property names exactly.
{ "linter": { "rules": { "nursery": { "noVueRestrictedComponentOptions": { "level": "on", "options": { "componentOptions": [ { "name": "init", "message": "Use beforeCreate() instead." }, { "name": [ "props", "*", "twoWay" ], "message": "Two-way props are not supported." } ] } } } } }}<script>export default { init() {},};</script>code-block.vue:3:3 lint/nursery/noVueRestrictedComponentOptions ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Use beforeCreate() instead.
1 │ <script>
2 │ export default {
> 3 │ init() {},
│ ^^^^
4 │ };
5 │ </script>
ℹ Your project lists this component option under componentOptions in the configuration of this rule, so it isn't allowed.
ℹ Remove this option, or replace it with the alternative your project recommends.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
<script>export default { beforeCreate() {}, props: { name: { type: String }, },};</script>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.