Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vuejs/eslint-plugin-vue
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.0.1
Choose a base ref
...
head repository: vuejs/eslint-plugin-vue
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.1.0
Choose a head ref
  • 11 commits
  • 65 files changed
  • 5 contributors

Commits on Oct 18, 2020

  1. Make rule vue/no-unregistered-components ignore recursive components (#…

    …1305)
    
    * Add tests
    
    * Modify rule to include `ignoreRecursive` argument
    
    * Modify docs
    
    * Address PR comments
    
    * empty commit
    
    * Refactor no-unregistered-components to always bypass recursive components
    
    * Update docs
    
    Co-authored-by: Joao Elias Arruda <joao.arruda@booking.com>
    arrudaje and Joao Elias Arruda authored Oct 18, 2020
    Copy the full SHA
    d626ec1 View commit details
  2. added options for events that ignore custom-event-name-casing (#1321)

    * added options for custom-event-name-casing
    
    * add test case to close #1260
    
    * update docs for custom-event-name-casing
    
    * Update test case event name with regex
    
    Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>
    
    * Update docs/rules/custom-event-name-casing.md for better description
    
    Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>
    
    * updated custom-event-name-casing readme with ignores options
    
    * added custom-event-name-casing invalid test cases
    
    Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>
    devTeaa and ota-meshi authored Oct 18, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9932d13 View commit details
  3. Add allowModifiers option to valid-v-slot (#1330)

    * add allowModifiers option to valid-v-slot
    
    * update doc
    
    * fix for missing cases & improve code
    
    * add test cases
    
    * revert option in test
    nokazn authored Oct 18, 2020
    Copy the full SHA
    0e1a05a View commit details
  4. Upgrade vue-eslint-parser to 7.1.1 and fixed CRLF issues. (#1332)

    * Upgrade vue-eslint-parser to 7.1.1 and fixed CRLF issues.
    
    * move  vue-eslint-parser repo
    ota-meshi authored Oct 18, 2020
    Copy the full SHA
    0e5480c View commit details
  5. Change not to use ESLint internal modules (#1322)

    * Change not to use ESLint internal modules
    
    * update
    
    * remove unused scrip
    ota-meshi authored Oct 18, 2020
    Copy the full SHA
    d44fb18 View commit details
  6. Copy the full SHA
    30da121 View commit details
  7. Fixed crash when the name property value was not literal, in `no-unre…

    …gistered-components` rule (#1336)
    ota-meshi authored Oct 18, 2020
    Copy the full SHA
    f4c21e5 View commit details
  8. Copy the full SHA
    bebb9b3 View commit details
  9. Add vue/array-bracket-newline rule (#1326)

    * Add `vue/array-bracket-newline` rule
    
    `vue/array-bracket-newline` rule that applies `array-bracket-newline` rule to expressions in <template>.
    
    * update
    ota-meshi authored Oct 18, 2020
    Copy the full SHA
    b75d312 View commit details
  10. Copy the full SHA
    2a3294d View commit details
  11. 7.1.0

    ota-meshi committed Oct 18, 2020
    Copy the full SHA
    d62b874 View commit details
Showing with 1,684 additions and 173 deletions.
  1. +1 −1 README.md
  2. +3 −3 docs/.vuepress/components/eslint-code-block.vue
  3. +3 −1 docs/.vuepress/config.js
  4. +2 −0 docs/.vuepress/shim/eslint/index.js
  5. 0 docs/.vuepress/shim/eslint/lib/rules/index.js
  6. +1 −1 docs/developer-guide/README.md
  7. +3 −1 docs/rules/README.md
  8. +25 −0 docs/rules/array-bracket-newline.md
  9. +161 −0 docs/rules/block-tag-newline.md
  10. +41 −1 docs/rules/custom-event-name-casing.md
  11. +1 −1 docs/rules/html-indent.md
  12. +2 −2 docs/rules/no-restricted-syntax.md
  13. +4 −0 docs/rules/no-textarea-mustache.md
  14. +1 −1 docs/rules/no-unused-vars.md
  15. +1 −1 docs/rules/script-indent.md
  16. +37 −1 docs/rules/valid-v-slot.md
  17. +2 −0 lib/configs/no-layout-rules.js
  18. +2 −0 lib/index.js
  19. +11 −0 lib/rules/array-bracket-newline.js
  20. +3 −4 lib/rules/array-bracket-spacing.js
  21. +1 −1 lib/rules/arrow-spacing.js
  22. +1 −1 lib/rules/block-spacing.js
  23. +375 −0 lib/rules/block-tag-newline.js
  24. +1 −1 lib/rules/brace-style.js
  25. +1 −1 lib/rules/camelcase.js
  26. +1 −1 lib/rules/comma-dangle.js
  27. +1 −1 lib/rules/comma-spacing.js
  28. +1 −1 lib/rules/comma-style.js
  29. +19 −2 lib/rules/custom-event-name-casing.js
  30. +1 −1 lib/rules/dot-location.js
  31. +1 −1 lib/rules/dot-notation.js
  32. +1 −1 lib/rules/eqeqeq.js
  33. +1 −1 lib/rules/func-call-spacing.js
  34. +1 −1 lib/rules/key-spacing.js
  35. +1 −1 lib/rules/keyword-spacing.js
  36. +1 −1 lib/rules/no-empty-pattern.js
  37. +1 −1 lib/rules/no-extra-parens.js
  38. +1 −1 lib/rules/no-restricted-syntax.js
  39. +1 −1 lib/rules/no-sparse-arrays.js
  40. +11 −0 lib/rules/no-unregistered-components.js
  41. +91 −9 lib/rules/no-unused-properties.js
  42. +1 −1 lib/rules/no-useless-concat.js
  43. +3 −4 lib/rules/object-curly-newline.js
  44. +3 −4 lib/rules/object-curly-spacing.js
  45. +3 −4 lib/rules/object-property-newline.js
  46. +1 −1 lib/rules/operator-linebreak.js
  47. +1 −1 lib/rules/prefer-template.js
  48. +1 −1 lib/rules/space-in-parens.js
  49. +1 −1 lib/rules/space-infix-ops.js
  50. +1 −1 lib/rules/space-unary-ops.js
  51. +3 −4 lib/rules/template-curly-spacing.js
  52. +34 −6 lib/rules/valid-v-slot.js
  53. +15 −2 lib/utils/index.js
  54. +2 −3 package.json
  55. +108 −0 tests/lib/rules/array-bracket-newline.js
  56. +247 −0 tests/lib/rules/block-tag-newline.js
  57. +122 −0 tests/lib/rules/custom-event-name-casing.js
  58. +85 −0 tests/lib/rules/no-unregistered-components.js
  59. +89 −0 tests/lib/rules/no-unused-properties.js
  60. +10 −1 tests/lib/rules/v-on-function-call.js
  61. +85 −0 tests/lib/rules/valid-v-slot.js
  62. +0 −52 tools/setup-eslint-rule-types.js
  63. +48 −40 typings/eslint-plugin-vue/util-types/ast/es-ast.ts
  64. +1 −1 typings/eslint-plugin-vue/util-types/ast/v-ast.ts
  65. +3 −0 typings/eslint/index.d.ts
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ Since single file components in Vue are not plain JavaScript, the default parser

To know more about certain nodes in produced ASTs, go here:
- [ESTree docs](https://github.com/estree/estree)
- [vue-eslint-parser AST docs](https://github.com/mysticatea/vue-eslint-parser/blob/master/docs/ast.md)
- [vue-eslint-parser AST docs](https://github.com/vuejs/vue-eslint-parser/blob/master/docs/ast.md)

The `vue-eslint-parser` provides a few useful parser services that help traverse the produced AST and access tokens of the template:
- `context.parserServices.defineTemplateBodyVisitor(visitor, scriptVisitor)`
6 changes: 3 additions & 3 deletions docs/.vuepress/components/eslint-code-block.vue
Original file line number Diff line number Diff line change
@@ -124,11 +124,11 @@ export default {
// Load linter.
const [
{ default: Linter },
{ default: noUndefRule },
{ default: coreRules },
{ parseForESLint }
] = await Promise.all([
import('eslint4b/dist/linter'),
import('eslint/lib/rules/no-undef'),
import('eslint4b/dist/core-rules'),
import('espree').then(() => import('vue-eslint-parser'))
])
@@ -137,7 +137,7 @@ export default {
for (const ruleId of Object.keys(rules)) {
linter.defineRule(`vue/${ruleId}`, rules[ruleId])
}
linter.defineRule('no-undef', noUndefRule)
linter.defineRule('no-undef', coreRules['no-undef'])
linter.defineParser('vue-eslint-parser', { parseForESLint })
}
4 changes: 3 additions & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
'use strict'

const rules = require('../../tools/lib/rules')
const path = require('path')

const uncategorizedRules = rules.filter(
(rule) =>
@@ -122,7 +123,8 @@ module.exports = {
return {
resolve: {
alias: {
module: require.resolve('./shim/module')
module: require.resolve('./shim/module'),
eslint: path.resolve(__dirname, './shim/eslint')
}
}
}
2 changes: 2 additions & 0 deletions docs/.vuepress/shim/eslint/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const Linter = require('eslint4b')
module.exports = { Linter }
Empty file.
2 changes: 1 addition & 1 deletion docs/developer-guide/README.md
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ Since single file components in Vue are not plain JavaScript, we can't use the d

To know more about certain nodes in produced ASTs, go here:
- [ESTree docs](https://github.com/estree/estree)
- [vue-eslint-parser AST docs](https://github.com/mysticatea/vue-eslint-parser/blob/master/docs/ast.md)
- [vue-eslint-parser AST docs](https://github.com/vuejs/vue-eslint-parser/blob/master/docs/ast.md)

The `vue-eslint-parser` provides few useful parser services, to help traverse the produced AST and access tokens of the template:
- `context.parserServices.defineTemplateBodyVisitor(visitor, scriptVisitor)`
4 changes: 3 additions & 1 deletion docs/rules/README.md
Original file line number Diff line number Diff line change
@@ -281,13 +281,14 @@ For example:
```json
{
"rules": {
"vue/component-name-in-template-casing": "error"
"vue/block-tag-newline": "error"
}
}
```

| Rule ID | Description | |
|:--------|:------------|:---|
| [vue/block-tag-newline](./block-tag-newline.md) | enforce line breaks after opening and before closing block-level tags | :wrench: |
| [vue/component-name-in-template-casing](./component-name-in-template-casing.md) | enforce specific casing for the component naming style in template | :wrench: |
| [vue/html-comment-content-newline](./html-comment-content-newline.md) | enforce unified line brake in HTML comments | :wrench: |
| [vue/html-comment-content-spacing](./html-comment-content-spacing.md) | enforce unified spacing in HTML comments | :wrench: |
@@ -325,6 +326,7 @@ The following rules extend the rules provided by ESLint itself and apply them to

| Rule ID | Description | |
|:--------|:------------|:---|
| [vue/array-bracket-newline](./array-bracket-newline.md) | enforce linebreaks after opening and before closing array brackets | :wrench: |
| [vue/array-bracket-spacing](./array-bracket-spacing.md) | enforce consistent spacing inside array brackets | :wrench: |
| [vue/arrow-spacing](./arrow-spacing.md) | enforce consistent spacing before and after the arrow in arrow functions | :wrench: |
| [vue/block-spacing](./block-spacing.md) | disallow or enforce spaces inside of blocks after opening block and before closing block | :wrench: |
25 changes: 25 additions & 0 deletions docs/rules/array-bracket-newline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
pageClass: rule-details
sidebarDepth: 0
title: vue/array-bracket-newline
description: enforce linebreaks after opening and before closing array brackets
---
# vue/array-bracket-newline
> enforce linebreaks after opening and before closing array brackets
- :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.

This rule is the same rule as core [array-bracket-newline] rule but it applies to the expressions in `<template>`.

## :books: Further Reading

- [array-bracket-newline]

[array-bracket-newline]: https://eslint.org/docs/rules/array-bracket-newline

## :mag: Implementation

- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/array-bracket-newline.js)
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/array-bracket-newline.js)

<sup>Taken with ❤️ [from ESLint core](https://eslint.org/docs/rules/array-bracket-newline)</sup>
161 changes: 161 additions & 0 deletions docs/rules/block-tag-newline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
---
pageClass: rule-details
sidebarDepth: 0
title: vue/block-tag-newline
description: enforce line breaks after opening and before closing block-level tags
---
# vue/block-tag-newline
> enforce line breaks after opening and before closing block-level tags
- :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.

## :book: Rule Details

This rule enforces a line break (or no line break) after opening and before closing block tags.

<eslint-code-block fix :rules="{'vue/block-tag-newline': ['error']}">

```vue
<!-- ✓ GOOD -->
<template><input></template>
<script>
export default {}
</script>
```

</eslint-code-block>

<eslint-code-block fix :rules="{'vue/block-tag-newline': ['error']}">

```vue
<!-- ✗ BAD -->
<template>
<input></template>
<script>
export default {}</script>
```

</eslint-code-block>

## :wrench: Options

```json
{
"vue/block-tag-newline": ["error", {
"singleline": "always" | "never" | "consistent" | "ignore",
"multiline": "always" | "never" | "consistent" | "ignore",
"maxEmptyLines": 0,
"blocks": {
"template": {
"singleline": "always" | "never" | "consistent" | "ignore",
"multiline": "always" | "never" | "consistent" | "ignore",
"maxEmptyLines": 0,
},
"script": {
"singleline": "always" | "never" | "consistent" | "ignore",
"multiline": "always" | "never" | "consistent" | "ignore",
"maxEmptyLines": 0,
},
"my-block": {
"singleline": "always" | "never" | "consistent" | "ignore",
"multiline": "always" | "never" | "consistent" | "ignore",
"maxEmptyLines": 0,
}
}
}]
}
```

- `singleline` ... the configuration for single-line blocks.
- `"consistent"` ... (default) requires consistent usage of line breaks for each pair of tags. It reports an error if one tag in the pair has a linebreak inside it and the other tag does not.
- `"always"` ... require one line break after opening and before closing block tags.
- `"never"` ... disallow line breaks after opening and before closing block tags.
- `multiline` ... the configuration for multi-line blocks.
- `"consistent"` ... requires consistent usage of line breaks for each pair of tags. It reports an error if one tag in the pair has a linebreak inside it and the other tag does not.
- `"always"` ... (default) require one line break after opening and before closing block tags.
- `"never"` ... disallow line breaks after opening and before closing block tags.
- `maxEmptyLines` ... specifies the maximum number of empty lines allowed. default 0.
- `blocks` ... specifies for each block name.

### `{ "singleline": "never", "multiline": "always" }`

<eslint-code-block fix :rules="{'vue/block-tag-newline': ['error', { 'singleline': 'never', 'multiline': 'always' }]}">

```vue
<!-- ✓ GOOD -->
<template><input></template>
<script>
export default {
}
</script>
```

</eslint-code-block>

<eslint-code-block fix :rules="{'vue/block-tag-newline': ['error', { 'singleline': 'never', 'multiline': 'always' }]}">

```vue
<!-- ✗ BAD -->
<template>
<input>
</template>
<script>export default {
}</script>
```

</eslint-code-block>

### `{ "singleline": "always", "multiline": "always", "maxEmptyLines": 1 }`

<eslint-code-block fix :rules="{'vue/block-tag-newline': ['error', { 'singleline': 'always', 'multiline': 'always', 'maxEmptyLines': 1 }]}">

```vue
<!-- ✓ GOOD -->
<template>
<input>
</template>
<script>
export default {
}
</script>
```

</eslint-code-block>

<eslint-code-block fix :rules="{'vue/block-tag-newline': ['error', { 'singleline': 'always', 'multiline': 'always', 'maxEmptyLines': 1 }]}">

```vue
<!-- ✗ BAD -->
<template>
<input>
</template>
<script>
export default {
}
</script>
```

</eslint-code-block>

## :mag: Implementation

- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/block-tag-newline.js)
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/block-tag-newline.js)
42 changes: 41 additions & 1 deletion docs/rules/custom-event-name-casing.md
Original file line number Diff line number Diff line change
@@ -49,7 +49,47 @@ export default {

## :wrench: Options

Nothing.

```json
{
"vue/custom-event-name-casing": ["error", {
"ignores": []
}]
}
```
- `ignores` (`string[]`) ... The event names to ignore. Sets the event name to allow. For example, custom event names, Vue components event with special name, or Vue library component event name. You can set the regexp by writing it like `"/^name/"` or `click:row` or `fooBar`.

### `"ignores": ["fooBar", "/^[a-z]+(?:-[a-z]+)*:[a-z]+(?:-[a-z]+)*$/u"]`

<eslint-code-block :rules="{'vue/custom-event-name-casing': ['error', {ignores:'/^[a-z]+(?:-[a-z]+)*:[a-z]+(?:-[a-z]+)*$/u'}]}">

```vue
<template>
<!-- ✓ GOOD -->
<button @click="$emit('click:row')" />
<button @click="$emit('fooBar')" />
<!-- ✗ BAD -->
<button @click="$emit('myEvent')" />
</template>
<script>
export default {
methods: {
onClick () {
/* ✓ GOOD */
this.$emit('click:row')
this.$emit('fooBar')
/* ✗ BAD */
this.$emit('myEvent')
}
}
}
</script>
```

</eslint-code-block>


## :books: Further Reading

2 changes: 1 addition & 1 deletion docs/rules/html-indent.md
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ This rule enforces a consistent indentation style in `<template>`. The default s
- `closeBracket.endTag` (`integer`) ... The multiplier of indentation for right brackets of end tags (`</div>`). Default is `0`.
- `closeBracket.selfClosingTag` (`integer`) ... The multiplier of indentation for right brackets of start tags (`<div/>`). Default is `0`.
- `alignAttributesVertically` (`boolean`) ... Condition for whether attributes should be vertically aligned to the first attribute in multiline case or not. Default is `true`
- `ignores` (`string[]`) ... The selector to ignore nodes. The AST spec is [here](https://github.com/mysticatea/vue-eslint-parser/blob/master/docs/ast.md). You can use [esquery](https://github.com/estools/esquery#readme) to select nodes. Default is an empty array.
- `ignores` (`string[]`) ... The selector to ignore nodes. The AST spec is [here](https://github.com/vuejs/vue-eslint-parser/blob/master/docs/ast.md). You can use [esquery](https://github.com/estools/esquery#readme) to select nodes. Default is an empty array.

### `2, {"attribute": 1, "closeBracket": 1}`

4 changes: 2 additions & 2 deletions docs/rules/no-restricted-syntax.md
Original file line number Diff line number Diff line change
@@ -46,8 +46,8 @@ Forbids call expressions inside mustache interpolation.

[no-restricted-syntax]: https://eslint.org/docs/rules/no-restricted-syntax
[ESTree]: https://github.com/estree/estree
[vue-eslint-parser]: https://github.com/mysticatea/vue-eslint-parser
[vue-eslint-parser - AST docs]: https://github.com/mysticatea/vue-eslint-parser/blob/master/docs/ast.md
[vue-eslint-parser]: https://github.com/vuejs/vue-eslint-parser
[vue-eslint-parser - AST docs]: https://github.com/vuejs/vue-eslint-parser/blob/master/docs/ast.md

## :mag: Implementation

4 changes: 4 additions & 0 deletions docs/rules/no-textarea-mustache.md
Original file line number Diff line number Diff line change
@@ -27,11 +27,15 @@ This rule reports mustaches in `<textarea>`.

</eslint-code-block>

<div v-pre>

::: warning Note
Interpolation on textareas (`<textarea>{{text}}</textarea>`) won't work. Use `v-model` instead.
[https://v3.vuejs.org/guide/forms.html#multiline-text](https://v3.vuejs.org/guide/forms.html#multiline-text)
:::

</div>

## :wrench: Options

Nothing.
2 changes: 1 addition & 1 deletion docs/rules/no-unused-vars.md
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ This rule report variable definitions of v-for directives or scope attributes if

## :wrench: Options

```js
```json
{
"vue/no-unused-vars": ["error", {
"ignorePattern": "^_"
2 changes: 1 addition & 1 deletion docs/rules/script-indent.md
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ This rule has some options.
- `TYPE` (`number | "tab"`) ... The type of indentation. Default is `2`. If this is a number, it's the number of spaces for one indent. If this is `"tab"`, it uses one tab for one indent.
- `baseIndent` (`integer`) ... The multiplier of indentation for top-level statements. Default is `0`.
- `switchCase` (`integer`) ... The multiplier of indentation for `case`/`default` clauses. Default is `0`.
- `ignores` (`string[]`) ... The selector to ignore nodes. The AST spec is [here](https://github.com/mysticatea/vue-eslint-parser/blob/master/docs/ast.md). You can use [esquery](https://github.com/estools/esquery#readme) to select nodes. Default is an empty array.
- `ignores` (`string[]`) ... The selector to ignore nodes. The AST spec is [here](https://github.com/vuejs/vue-eslint-parser/blob/master/docs/ast.md). You can use [esquery](https://github.com/estools/esquery#readme) to select nodes. Default is an empty array.

::: warning Note
This rule only checks `.vue` files and does not interfere with other `.js` files. Unfortunately the default `indent` rule when turned on will try to lint both, so in order to make them complementary you can use `overrides` setting and disable `indent` rule on `.vue` files:
Loading