Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5902957

Browse files
update order-in-components
1 parent fdfeb76 commit 5902957

File tree

1 file changed

+56
-50
lines changed

1 file changed

+56
-50
lines changed

‎docs/rules/order-in-components.md‎

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,76 +3,82 @@
33
- :gear: This rule is included in `"plugin:vue/recommended"`.
44
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
55

6-
This rule makes sure you keep declared order of properties in components.
7-
86
## :book: Rule Details
97

8+
This rule makes sure you keep declared order of properties in components.
109
Recommended order of properties can be [found here](https://vuejs.org/v2/style-guide/#Component-instance-options-order-recommended).
1110

12-
Examples of **incorrect** code for this rule:
13-
14-
```js
15-
name: 'app',
16-
data () {
17-
return {
18-
msg: 'Welcome to Your Vue.js App'
11+
<eslint-code-block :rules="{'vue/order-in-components': ['error']}">
12+
```
13+
<script>
14+
/* ✓ GOOD */
15+
export default {
16+
name: 'app',
17+
props: {
18+
propA: Number
19+
},
20+
data () {
21+
return {
22+
msg: 'Welcome to Your Vue.js App'
23+
}
1924
}
20-
},
21-
props: {
22-
propA: Number,
2325
}
26+
</script>
2427
```
28+
</eslint-code-block>
2529

26-
Examples of **correct**code for this rule:
27-
28-
```js
29-
30+
<eslint-code-block:rules="{'vue/order-in-components': ['error']}">
31+
```
32+
<script>
33+
/* ✗ BAD */
3034
export default {
3135
name: 'app',
32-
props: {
33-
propA: Number,
34-
},
3536
data () {
3637
return {
3738
msg: 'Welcome to Your Vue.js App'
3839
}
3940
},
41+
props: {
42+
propA: Number
43+
}
4044
}
41-
45+
</script>
4246
```
43-
44-
### Options
45-
46-
If you want you can change the order providing the optional configuration in your `.eslintrc` file. Setting responsible for the above order looks like this:
47-
48-
``` json
49-
"vue/order-in-components": ["error", {
50-
"order": [
51-
"el",
52-
"name",
53-
"parent",
54-
"functional",
55-
["delimiters", "comments"],
56-
["components", "directives", "filters"],
57-
"extends",
58-
"mixins",
59-
"inheritAttrs",
60-
"model",
61-
["props", "propsData"],
62-
"data",
63-
"computed",
64-
"watch",
65-
"LIFECYCLE_HOOKS",
66-
"methods",
67-
["template", "render"],
68-
"renderError"
69-
]
70-
}]
47+
</eslint-code-block>
48+
49+
## :wrench: Options
50+
51+
```json
52+
{
53+
"vue/order-in-components": ["error", {
54+
"order": [
55+
"el",
56+
"name",
57+
"parent",
58+
"functional",
59+
["delimiters", "comments"],
60+
["components", "directives", "filters"],
61+
"extends",
62+
"mixins",
63+
"inheritAttrs",
64+
"model",
65+
["props", "propsData"],
66+
"data",
67+
"computed",
68+
"watch",
69+
"LIFECYCLE_HOOKS",
70+
"methods",
71+
["template", "render"],
72+
"renderError"
73+
]
74+
}]
75+
}
7176
```
7277

73-
If you want some of properties to be treated equally in order you can group them into arrays, like we did with `delimiters` and `comments`.
78+
- `order` (`(string | string[])[]`) ... The order of properties. Elements are the property names or `LIFECYCLE_HOOKS`. If an element is the array of strings, it means any of those can be placed there unordered. Default is above.
79+
7480

75-
## Related links
81+
## :books: Further reading
7682

7783
- [Style guide - Component/instance options order](https://vuejs.org/v2/style-guide/#Component-instance-options-order-recommended)
7884

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /