8000 Merge branch 'master' into vuepress · vuejs/eslint-plugin-vue@62ef6c3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 62ef6c3

Browse files
committed
Merge branch 'master' into vuepress
2 parents e421e2f + 0fd0f7b commit 62ef6c3

File tree

88 files changed

+908
-337
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+908
-337
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
'eslint-plugin'
2020
],
2121
rules: {
22-
'eslint-plugin/report-message-format': ['error', '^[A-Z`\'].*\\.$'],
22+
'eslint-plugin/report-message-format': ['error', '^[A-Z`\'{].*\\.$'],
2323
'eslint-plugin/prefer-placeholders': 'error',
2424
'eslint-plugin/consistent-output': 'error'
2525
},

.github/ISSUE_TEMPLATE.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
<!--
8+
Before posting the issue, please confirm that the problem you're getting
9+
is not related with your code editor configuration.
10+
To make sure it's not, run: yarn eslint src/your-file.vue
11+
-->
12+
13+
**Tell us about your environment**
14+
* **ESLint version:**
15+
* **eslint-plugin-vue version:**
16+
* **Node version:**
17+
18+
**Please show your full configuration:**
19+
<!-- Paste content of your .eslintrc file -->
20+
```json
21+
22+
```
23+
24+
**What did you do?**
25+
<!-- Please include the actual source code causing the issue. -->
26+
```vue
27+
28+
```
29+
30+
**What did you expect to happen?**
31+
32+
33+
**What actually happened?**
34+
<!-- Please include the actual, raw output from ESLint. -->
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Rule Proposal
3+
about: Suggest an idea for a new rule
4+
5+
---
6+
7+
<!--
8+
Before proposing new rule, please make sure it hasn't been posted already.
9+
You can see all open propositions here:
10+
https://github.com/vuejs/eslint-plugin-vue/issues?q=is%3Aopen+is%3Aissue+label%3A%22new+rule+proposition%22
11+
-->
12+
13+
**Please describe what the rule should do:**
14+
<!-- A clear and concise description of what the rule should do. -->
15+
16+
**What category should the rule belong to?**
17+
<!-- (place an "X" next to just one item) -->
18+
- [ ] Enforces code style
19+
- [ ] Warns about a potential error
20+
- [ ] Suggests an alternate way of doing something
21+
- [ ] Other (please specify:)
22+
23+
**Provide 2-3 code examples that this rule should warn about:**
24+
```vue
25+
26+
```
27+
28+
**Additional context**
29+
<!-- Add any other context or screenshots about the feature request here. -->

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
2+
*.iml
23
/.nyc_output
34
/coverage
45
/tests/integrations/*/node_modules

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Start testing",
8+
"program": "${workspaceFolder}/node_modules/.bin/mocha",
9+
"args": [
10+
"${file}",
11+
"--watch"
12+
],
13+
"console": "integratedTerminal"
14+
}
15+
]
16+
}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
[![NPM version](https://img.shields.io/npm/v/eslint-plugin-vue.svg?style=flat)](https://npmjs.org/package/eslint-plugin-vue)
44
[![NPM downloads](https://img.shields.io/npm/dm/eslint-plugin-vue.svg?style=flat)](https://npmjs.org/package/eslint-plugin-vue)
5-
[![CircleCI](https://circleci.com/gh/vuejs/eslint-plugin-vue.svg?style=svg)](https://circleci.com/gh/vuejs/eslint-plugin-vue)
5+
[![CircleCI](https://img.shields.io/circleci/project/github/vuejs/eslint-plugin-vue/master.svg?style=flat)](https://circleci.com/gh/vuejs/eslint-plugin-vue)
6+
[![License](https://img.shields.io/github/license/vuejs/eslint-plugin-vue.svg?style=flat)](https://github.com/vuejs/eslint-plugin-vue/blob/master/LICENSE.md)
67

78
> Official ESLint plugin for Vue.js
89

docs/rules/no-multi-spaces.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,28 @@ This rule aims at removing multiple spaces in tags, which are not used for inden
2424

2525
## :wrench: Options
2626

27-
Nothing.
27+
This rule has an object option:
28+
29+
`"ignoreProperties": false` (default) whether or not objects' properties should be ignored
30+
31+
### Example:
32+
33+
```json
34+
"vue/no-multi-spaces": [2, {
35+
"ignoreProperties": true
36+
}]
37+
```
38+
39+
:+1: Examples of **correct** code for this rule:
40+
41+
```html
42+
<i
43+
:class="{
44+
'fa-angle-up' : isExpanded,
45+
'fa-angle-down' : !isExpanded,
46+
}"
47+
/>
48+
```
2849

2950
## :mag: Implementation
3051

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ module.exports = {
5252
'script-indent': require('./rules/script-indent'),
5353
'singleline-html-element-content-newline': require('./rules/singleline-html-element-content-newline'),
5454
'this-in-template': require('./rules/this-in-template'),
55+
'use-v-on-exact': require('./rules/use-v-on-exact'),
5556
'v-bind-style': require('./rules/v-bind-style'),
5657
'v-on-style': require('./rules/v-on-style'),
5758
'valid-template-root': require('./rules/valid-template-root'),

lib/rules/attribute-hyphenation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
docs: {
1717
description: 'enforce attribute naming style on custom components in template',
1818
category: 'strongly-recommended',
19-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/attribute-hyphenation.md'
19+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/attribute-hyphenation.md'
2020
},
2121
fixable: 'code',
2222
schema: [

lib/rules/attributes-order.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,10 @@ function create (context) {
7777
const attributes = node.parent.attributes
7878
const shiftAttrs = attributes.slice(attributes.indexOf(previousNode), attributes.indexOf(node) + 1)
7979

80-
// If we can upgrade requirements to `eslint@>4.1.0`, this code can be replaced by:
81-
// return shiftAttrs.map((attr, i) => {
82-
// const text = attr === previousNode ? sourceCode.getText(node) : sourceCode.getText(shiftAttrs[i - 1])
83-
// return fixer.replaceText(attr, text)
84-
// })
85-
const replaceDataList = shiftAttrs.map((attr, i) => {
80+
return shiftAttrs.map((attr, i) => {
8681
const text = attr === previousNode ? sourceCode.getText(node) : sourceCode.getText(shiftAttrs[i - 1])
87-
return {
88-
range: attr.range,
89-
text
90-
}
82+
return fixer.replaceText(attr, text)
9183
})
92-
const replaceRange = [previousNode.range[0], node.range[1]]
93-
let text = sourceCode.text.slice(replaceRange[0], replaceRange[1])
94-
replaceDataList.reverse().forEach((data) => {
95-
const textRange = data.range.map(r => r - replaceRange[0])
96-
text = text.slice(0, textRange[0]) + data.text + text.slice(textRange[1], text.length)
97-
})
98-
return fixer.replaceTextRange(replaceRange, text)
9984
}
10085
})
10186
}
@@ -121,7 +106,7 @@ module.exports = {
121106
docs: {
122107
description: 'enforce order of attributes',
123108
category: 'recommended',
124-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/attributes-order.md'
109+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/attributes-order.md'
125110
},
126111
fixable: 'code',
127112
schema: {

lib/rules/comment-directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module.exports = {
109109
docs: {
110110
description: 'support comment-directives in `<template>`',
111111
category: 'base',
112-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/comment-directive.md'
112+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/comment-directive.md'
113113
},
114114
schema: []
115115
},

lib/rules/component-name-in-template-casing.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
docs: {
2424
description: 'enforce specific casing for the component naming style in template',
2525
category: undefined, // strongly-recommended
26-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/component-name-in-template-casing.md'
26+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/component-name-in-template-casing.md'
2727
},
2828
fixable: 'code',
2929
schema: [
@@ -51,7 +51,6 @@ module.exports = {
5151
const caseType = allowedCaseOptions.indexOf(caseOption) !== -1 ? caseOption : defaultCase
5252
const ignores = options.ignores || []
5353
const tokens = context.parserServices.getTemplateBodyTokenStore && context.parserServices.getTemplateBodyTokenStore()
54-
const sourceCode = context.getSourceCode()
5554

5655
let hasInvalidEOF = false
5756

@@ -61,7 +60,11 @@ module.exports = {
6160
return
6261
}
6362

64-
if (!utils.isCustomComponent(node)) {
63+
if (
64+
(!utils.isHtmlElementNode(node) && !utils.isSvgElementNode(node)) ||
65+
utils.isHtmlWellKnownElementName(node.rawName) ||
66+
utils.isSvgWellKnownElementName(node.rawName)
67+
) {
6568
return
6669
}
6770

@@ -88,13 +91,10 @@ module.exports = {
8891
return fixer.replaceText(open, `<${casingName}`)
8992
}
9093
const endTagOpen = tokens.getFirstToken(endTag)
91-
// If we can upgrade requirements to `eslint@>4.1.0`, this code can be replaced by:
92-
// return [
93-
// fixer.replaceText(open, `<${casingName}`),
94-
// fixer.replaceText(endTagOpen, `</${casingName}`)
95-
// ]
96-
const code = `<${casingName}${sourceCode.text.slice(open.range[1], endTagOpen.range[0])}</${casingName}`
97-
return fixer.replaceTextRange([open.range[0], endTagOpen.range[1]], code)
94+
return [
95+
fixer.replaceText(open, `<${casingName}`),
96+
fixer.replaceText(endTagOpen, `</${casingName}`)
97+
]
9898
}
9999
})
100100
}

lib/rules/html-closing-bracket-newline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = {
3232
docs: {
3333
description: "require or disallow a line break before tag's closing brackets",
3434
category: 'strongly-recommended',
35-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/html-closing-bracket-newline.md'
35+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/html-closing-bracket-newline.md'
3636
},
3737
fixable: 'whitespace',
3838
schema: [{

lib/rules/html-closing-bracket-spacing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = {
5353
docs: {
5454
description: 'require or disallow a space before tag\'s closing brackets',
5555
category: 'strongly-recommended',
56-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/html-closing-bracket-spacing.md'
56+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/html-closing-bracket-spacing.md'
5757
},
5858
schema: [{
5959
type: 'object',

lib/rules/html-end-tags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
docs: {
2121
description: 'enforce end tag style',
2222
category: 'strongly-recommended',
23-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/html-end-tags.md'
23+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/html-end-tags.md'
2424
},
2525
fixable: 'code',
2626
schema: []

lib/rules/html-indent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = {
2929
docs: {
3030
description: 'enforce consistent indentation in `<template>`',
3131
category: 'strongly-recommended',
32-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/html-indent.md'
32+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/html-indent.md'
3333
},
3434
fixable: 'whitespace',
3535
schema: [

lib/rules/html-quotes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
docs: {
2121
description: 'enforce quotes style of HTML attributes',
2222
category: 'recommended',
23-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/html-quotes.md'
23+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/html-quotes.md'
2424
},
2525
fixable: 'code',
2626
schema: [

lib/rules/html-self-closing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = {
8888
docs: {
8989
description: 'enforce self-closing style',
9090
category: 'strongly-recommended',
91-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/html-self-closing.md'
91+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/html-self-closing.md'
9292
},
9393
fixable: 'code',
9494
schema: {

lib/rules/jsx-uses-vars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = {
3939
docs: {
4040
description: 'prevent variables used in JSX to be marked as unused', // eslint-disable-line consistent-docs-description
4141
category: 'base',
42-
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.3/docs/rules/jsx-uses-vars.md'
42+
url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/jsx-uses-vars.md'
4343
},
4444
schema: []
4545
},

0 commit comments

Comments
 (0)
0