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 ebd07e6

Browse files
mysticateamichalsnik
authored andcommitted
New: some core rules for <template> (#680)
* add core rule wrapper * add `array-bracket-spacing` rule * add `key-spacing` rule * add `eqeqeq` rule * add `object-curly-spacing` rule * add `space-infix-ops` rule * add `space-unary-ops` rule * switch error messages for minimal version tests
1 parent 5dd07bf commit ebd07e6

25 files changed

+566
-13
lines changed

‎docs/rules/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,22 @@ For example:
132132
```json
133133
{
134134
"rules": {
135-
"vue/component-name-in-template-casing": "error"
135+
"vue/array-bracket-spacing": "error"
136136
}
137137
}
138138
```
139139

140140
| Rule ID | Description | |
141141
|:--------|:------------|:---|
142+
| [vue/array-bracket-spacing](./array-bracket-spacing.md) | enforce consistent spacing inside array brackets | :wrench: |
142143
| [vue/component-name-in-template-casing](./component-name-in-template-casing.md) | enforce specific casing for the component naming style in template | :wrench: |
144+
| [vue/eqeqeq](./eqeqeq.md) | require the use of `===` and `!==` | :wrench: |
145+
| [vue/key-spacing](./key-spacing.md) | enforce consistent spacing between keys and values in object literal properties | :wrench: |
143146
| [vue/match-component-file-name](./match-component-file-name.md) | require component name property to match its file name | |
147+
| [vue/object-curly-spacing](./object-curly-spacing.md) | enforce consistent spacing inside braces | :wrench: |
144148
| [vue/script-indent](./script-indent.md) | enforce consistent indentation in `<script>` | :wrench: |
149+
| [vue/space-infix-ops](./space-infix-ops.md) | require spacing around infix operators | :wrench: |
150+
| [vue/space-unary-ops](./space-unary-ops.md) | enforce consistent spacing before or after unary operators | :wrench: |
145151

146152
## Deprecated
147153

‎docs/rules/array-bracket-spacing.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
pageClass: rule-details
3+
sidebarDepth: 0
4+
title: vue/array-bracket-spacing
5+
description: enforce consistent spacing inside array brackets
6+
---
7+
# vue/array-bracket-spacing
8+
> enforce consistent spacing inside array brackets
9+
10+
- :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.
11+
12+
This rule is the same rule as core [array-bracket-spacing] rule but it applies to the expressions in `<template>`.
13+
14+
## :books: Further reading
15+
16+
- [array-bracket-spacing]
17+
18+
[array-bracket-spacing]: https://eslint.org/docs/rules/array-bracket-spacing
19+
20+
## :mag: Implementation
21+
22+
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/array-bracket-spacing.js)
23+
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/array-bracket-spacing.js)

‎docs/rules/eqeqeq.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
pageClass: rule-details
3+
sidebarDepth: 0
4+
title: vue/eqeqeq
5+
description: require the use of `===` and `!==`
6+
---
7+
# vue/eqeqeq
8+
> require the use of `===` and `!==`
9+
10+
- :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.
11+
12+
This rule is the same rule as core [eqeqeq] rule but it applies to the expressions in `<template>`.
13+
14+
## :books: Further reading
15+
16+
- [eqeqeq]
17+
18+
[eqeqeq]: https://eslint.org/docs/rules/eqeqeq
19+
20+
## :mag: Implementation
21+
22+
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/eqeqeq.js)
23+
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/eqeqeq.js)

‎docs/rules/key-spacing.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
pageClass: rule-details
3+
sidebarDepth: 0
4+
title: vue/key-spacing
5+
description: enforce consistent spacing between keys and values in object literal properties
6+
---
7+
# vue/key-spacing
8+
> enforce consistent spacing between keys and values in object literal properties
9+
10+
- :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.
11+
12+
This rule is the same rule as core [key-spacing] rule but it applies to the expressions in `<template>`.
13+
14+
## :books: Further reading
15+
16+
- [key-spacing]
17+
18+
[key-spacing]: https://eslint.org/docs/rules/key-spacing
19+
20+
## :mag: Implementation
21+
22+
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/key-spacing.js)
23+
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/key-spacing.js)

‎docs/rules/object-curly-spacing.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
pageClass: rule-details
3+
sidebarDepth: 0
4+
title: vue/object-curly-spacing
5+
description: enforce consistent spacing inside braces
6+
---
7+
# vue/object-curly-spacing
8+
> enforce consistent spacing inside braces
9+
10+
- :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.
11+
12+
This rule is the same rule as core [object-curly-spacing] rule but it applies to the expressions in `<template>`.
13+
14+
## :books: Further reading
15+
16+
- [object-curly-spacing]
17+
18+
[object-curly-spacing]: https://eslint.org/docs/rules/object-curly-spacing
19+
20+
## :mag: Implementation
21+
22+
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/object-curly-spacing.js)
23+
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/object-curly-spacing.js)

‎docs/rules/space-infix-ops.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
pageClass: rule-details
3+
sidebarDepth: 0
4+
title: vue/space-infix-ops
5+
description: require spacing around infix operators
6+
---
7+
# vue/space-infix-ops
8+
> require spacing around infix operators
9+
10+
- :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.
11+
12+
This rule is the same rule as core [space-infix-ops] rule but it applies to the expressions in `<template>`.
13+
14+
## :books: Further reading
15+
16+
- [space-infix-ops]
17+
18+
[space-infix-ops]: https://eslint.org/docs/rules/space-infix-ops
19+
20+
## :mag: Implementation
21+
22+
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/space-infix-ops.js)
23+
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/space-infix-ops.js)

‎docs/rules/space-unary-ops.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
pageClass: rule-details
3+
sidebarDepth: 0
4+
title: vue/space-unary-ops
5+
description: enforce consistent spacing before or after unary operators
6+
---
7+
# vue/space-unary-ops
8+
> enforce consistent spacing before or after unary operators
9+
10+
- :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.
11+
12+
This rule is the same rule as core [space-unary-ops] rule but it applies to the expressions in `<template>`.
13+
14+
## :books: Further reading
15+
16+
- [space-unary-ops]
17+
18+
[space-unary-ops]: https://eslint.org/docs/rules/space-unary-ops
19+
20+
## :mag: Implementation
21+
22+
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/space-unary-ops.js)
23+
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/space-unary-ops.js)

‎eslint-internal-rules/consistent-docs-description.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ const ALLOWED_FIRST_WORDS = [
2323
* @returns {ASTNode} The Property node or null if not found.
2424
*/
2525
function getPropertyFromObject (property, node) {
26-
const properties = node.properties
26+
if (node && node.type === 'ObjectExpression') {
27+
const properties = node.properties
2728

28-
for (let i = 0; i < properties.length; i++) {
29-
if (properties[i].key.name === property) {
30-
return properties[i]
29+
for (let i = 0; i < properties.length; i++) {
30+
if (properties[i].key.name === property) {
31+
return properties[i]
32+
}
3133
}
3234
}
33-
3435
return null
3536
}
3637

@@ -128,7 +129,8 @@ module.exports = {
128129
node.right &&
129130
node.left.type === 'MemberExpression' &&
130131
node.left.object.name === 'module' &&
131-
node.left.property.name === 'exports') {
132+
node.left.property.name === 'exports' &&
133+
node.right.type === 'ObjectExpression') {
132134
checkMetaDocsDescription(context, node.right)
133135
}
134136
}

‎eslint-internal-rules/no-invalid-meta.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
* @returns {ASTNode} The Property node or null if not found.
1818
*/
1919
function getPropertyFromObject (property, node) {
20-
const properties = node.properties
20+
if (node && node.type === 'ObjectExpression') {
21+
const properties = node.properties
2122

22-
for (let i = 0; i < properties.length; i++) {
23-
if (properties[i].key.name === property) {
24-
return properties[i]
23+
for (let i = 0; i < properties.length; i++) {
24+
if (properties[i].key.name === property) {
25+
return properties[i]
26+
}
2527
}
2628
}
27-
2829
return null
2930
}
3031

‎lib/configs/no-layout-rules.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@
55
*/
66
module.exports = {
77
rules: {
8+
'vue/array-bracket-spacing': 'off',
89
'vue/html-closing-bracket-newline': 'off',
910
'vue/html-closing-bracket-spacing': 'off',
1011
'vue/html-indent': 'off',
1112
'vue/html-quotes': 'off',
1213
'vue/html-self-closing': 'off',
14+
'vue/key-spacing': 'off',
1315
'vue/max-attributes-per-line': 'off',
1416
'vue/multiline-html-element-content-newline': 'off',
1517
'vue/mustache-interpolation-spacing': 'off',
1618
'vue/no-multi-spaces': 'off',
1719
'vue/no-spaces-around-equal-signs-in-attribute': 'off',
20+
'vue/object-curly-spacing': 'off',
1821
'vue/script-indent': 'off',
19-
'vue/singleline-html-element-content-newline': 'off'
22+
'vue/singleline-html-element-content-newline': 'off',
23+
'vue/space-infix-ops': 'off',
24+
'vue/space-unary-ops': 'off'
2025
}
2126
}

0 commit comments

Comments
(0)

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