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: v9.20.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: v9.21.0
Choose a head ref
  • 9 commits
  • 389 files changed
  • 8 contributors

Commits on Jan 16, 2024

  1. feat: implement require-explicit-slots (#2325)

    Co-authored-by: Mussin Benarbia <[email protected]>
    Co-authored-by: Yosuke Ota <[email protected]>
    3 people authored Jan 16, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    634f38d View commit details
  2. Add new vue/no-restricted-v-on rule (#2367)

    Co-authored-by: Flo Edelmann <[email protected]>
    thesheppard and FloEdelmann authored Jan 16, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7d13ce3 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    959858c View commit details

Commits on Jan 23, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    fdc4d46 View commit details

Commits on Jan 24, 2024

  1. Update docs

    FloEdelmann committed Jan 24, 2024
    Copy the full SHA
    3698652 View commit details

Commits on Jan 25, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    037ada2 View commit details

Commits on Jan 29, 2024

  1. Chore: fix errors in tests using ESLint v9.0.0-alpha.2 (#2382)

    ota-meshi authored Jan 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9bf52e4 View commit details
  2. feat(v-bind-style): add sameNameShorthand option (#2381)

    Co-authored-by: Flo Edelmann <[email protected]>
    waynzh and FloEdelmann authored Jan 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2dc7889 View commit details

Commits on Jan 30, 2024

  1. 9.21.0

    ota-meshi committed Jan 30, 2024
    Copy the full SHA
    ac73565 View commit details
Showing 389 changed files with 4,423 additions and 2,592 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -26,8 +26,18 @@ jobs:
name: Test
strategy:
matrix:
node: [17, 18, 20]
node: [18, 20]
os: [ubuntu-latest]
eslint: [8]
include:
# On next ESLint version
- eslint: ^9.0.0-0
node: 20
os: ubuntu-latest
# On old Node version
- eslint: 8
node: 17
os: ubuntu-latest

runs-on: ${{ matrix.os }}
steps:
@@ -39,6 +49,8 @@ jobs:
node-version: ${{ matrix.node }}
- name: Install Packages
run: npm install --legacy-peer-deps
- name: Install ESLint v${{ matrix.eslint }}
run: npm install --save-dev eslint@${{ matrix.eslint }} --legacy-peer-deps
- name: Test
run: npm test

2 changes: 2 additions & 0 deletions docs/rules/index.md
Original file line number Diff line number Diff line change
@@ -244,6 +244,7 @@ For example:
| [vue/no-restricted-props](./no-restricted-props.md) | disallow specific props | :bulb: | :hammer: |
| [vue/no-restricted-static-attribute](./no-restricted-static-attribute.md) | disallow specific attribute | | :hammer: |
| [vue/no-restricted-v-bind](./no-restricted-v-bind.md) | disallow specific argument in `v-bind` | | :hammer: |
| [vue/no-restricted-v-on](./no-restricted-v-on.md) | disallow specific argument in `v-on` | | :hammer: |
| [vue/no-root-v-if](./no-root-v-if.md) | disallow `v-if` directives on root element | | :hammer: |
| [vue/no-setup-props-reactivity-loss](./no-setup-props-reactivity-loss.md) | disallow usages that lose the reactivity of `props` passed to `setup` | | :hammer: |
| [vue/no-static-inline-styles](./no-static-inline-styles.md) | disallow static inline `style` attributes | | :hammer: |
@@ -268,6 +269,7 @@ For example:
| [vue/prefer-true-attribute-shorthand](./prefer-true-attribute-shorthand.md) | require shorthand form attribute when `v-bind` value is `true` | :bulb: | :hammer: |
| [vue/require-direct-export](./require-direct-export.md) | require the component to be directly exported | | :hammer: |
| [vue/require-emit-validator](./require-emit-validator.md) | require type definitions in emits | :bulb: | :hammer: |
| [vue/require-explicit-slots](./require-explicit-slots.md) | require slots to be explicitly defined | | :warning: |
| [vue/require-expose](./require-expose.md) | require declare public properties using `expose` | :bulb: | :hammer: |
| [vue/require-macro-variable-name](./require-macro-variable-name.md) | require a certain macro variable name | :bulb: | :hammer: |
| [vue/require-name-property](./require-name-property.md) | require a name property in Vue components | :bulb: | :hammer: |
5 changes: 4 additions & 1 deletion docs/rules/no-restricted-static-attribute.md
Original file line number Diff line number Diff line change
@@ -39,7 +39,8 @@ Alternatively, the rule also accepts objects.

```json
{
"vue/no-restricted-static-attribute": ["error",
"vue/no-restricted-static-attribute": [
"error",
{
"key": "stlye",
"message": "Using \"stlye\" is not allowed. Use \"style\" instead."
@@ -95,8 +96,10 @@ The following properties can be specified for the object.
## :couple: Related Rules

- [vue/no-restricted-v-bind]
- [vue/no-restricted-v-on]

[vue/no-restricted-v-bind]: ./no-restricted-v-bind.md
[vue/no-restricted-v-on]: ./no-restricted-v-on.md

## :rocket: Version

5 changes: 4 additions & 1 deletion docs/rules/no-restricted-v-bind.md
Original file line number Diff line number Diff line change
@@ -53,7 +53,8 @@ Alternatively, the rule also accepts objects.

```json
{
"vue/no-restricted-v-bind": ["error",
"vue/no-restricted-v-bind": [
"error",
{
"argument": "/^v-/",
"message": "Using `:v-xxx` is not allowed. Instead, remove `:` and use it as directive."
@@ -112,8 +113,10 @@ The following properties can be specified for the object.
## :couple: Related Rules

- [vue/no-restricted-static-attribute]
- [vue/no-restricted-v-on]

[vue/no-restricted-static-attribute]: ./no-restricted-static-attribute.md
[vue/no-restricted-v-on]: ./no-restricted-v-on.md

## :rocket: Version

114 changes: 114 additions & 0 deletions docs/rules/no-restricted-v-on.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
pageClass: rule-details
sidebarDepth: 0
title: vue/no-restricted-v-on
description: disallow specific argument in `v-on`
since: v9.21.0
---
# vue/no-restricted-v-on

> disallow specific argument in `v-on`
## :book: Rule Details

This rule allows you to specify `v-on` argument names that you don't want to use in your application.

## :wrench: Options

This rule takes a list of strings, where each string is a argument name or pattern to be restricted:

```json
{
"vue/no-restricted-v-on": ["error", "foo", "/^bar/"]
}
```

<eslint-code-block :rules="{'vue/no-restricted-v-on': ['error', 'foo', '/^bar/']}">

```vue
<template>
<!-- ✓ GOOD -->
<div v-on:click="x" />
<div @tap="x" />
<!-- ✗ BAD -->
<div v-on:foo="x" />
<div @bar-baz="x" />
</template>
```

</eslint-code-block>

Alternatively, the rule also accepts objects.

```json
{
"vue/no-restricted-v-on": [
"error",
{
"argument": "foo",
"message": "Use \"v-on:x\" instead."
},
{
"argument": "bar",
"message": "\"@bar\" is deprecated."
}
]
}
```

The following properties can be specified for the object.

- `argument` ... Specify the argument name or pattern or `null`. If `null` is specified, it matches `v-on=`.
- `modifiers` ... Specifies an array of the modifier names. If specified, it will only be reported if the specified modifier is used.
- `element` ... Specify the element name or pattern. If specified, it will only be reported if used on the specified element.
- `message` ... Specify an optional custom message.

### `{ "argument": "foo", "modifiers": ["prevent"] }`

<eslint-code-block :rules="{'vue/no-restricted-v-on': ['error', { argument: 'foo', modifiers: ['prevent'] }]}">

```vue
<template>
<!-- ✓ GOOD -->
<div @foo="x" />
<!-- ✗ BAD -->
<div @foo.prevent="x" />
</template>
```

</eslint-code-block>

### `{ "argument": "foo", "element": "MyButton" }`

<eslint-code-block :rules="{'vue/no-restricted-v-on': ['error', { argument: 'foo', element: 'MyButton' }]}">

```vue
<template>
<!-- ✓ GOOD -->
<CoolButton @foo="x" />
<!-- ✗ BAD -->
<MyButton @foo="x" />
</template>
```

</eslint-code-block>

## :couple: Related Rules

- [vue/no-restricted-static-attribute]
- [vue/no-restricted-v-bind]

[vue/no-restricted-static-attribute]: ./no-restricted-static-attribute.md
[vue/no-restricted-v-bind]: ./no-restricted-v-bind.md

## :rocket: Version

This rule was introduced in eslint-plugin-vue v9.21.0

## :mag: Implementation

- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-restricted-v-on.js)
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/no-restricted-v-on.js)
1 change: 1 addition & 0 deletions docs/rules/require-explicit-emits.md
Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@ export default {
## :couple: Related Rules

- [vue/no-unused-emit-declarations](./no-unused-emit-declarations.md)
- [vue/require-explicit-slots](./require-explicit-slots.md)

## :books: Further Reading

75 changes: 75 additions & 0 deletions docs/rules/require-explicit-slots.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
pageClass: rule-details
sidebarDepth: 0
title: vue/require-explicit-slots
description: require slots to be explicitly defined
since: v9.21.0
---
# vue/require-explicit-slots

> require slots to be explicitly defined
## :book: Rule Details

This rule enforces all slots used in the template to be defined once either in the `script setup` block with the [`defineSlots`](https://vuejs.org/api/sfc-script-setup.html) macro, or with the [`slots property`](https://vuejs.org/api/options-rendering.html#slots) in the Options API.

<eslint-code-block :rules="{'vue/require-explicit-slots': ['error']}">

```vue
<template>
<div>
<!-- ✓ GOOD -->
<slot />
<slot name="foo" />
<!-- ✗ BAD -->
<slot name="bar" />
</div>
</template>
<script setup lang="ts">
defineSlots<{
default(props: { msg: string }): any
foo(props: { msg: string }): any
}>()
</script>
```

</eslint-code-block>

<eslint-code-block :rules="{'vue/require-explicit-slots': ['error']}">

```vue
<template>
<div>
<!-- ✓ GOOD -->
<slot />
<slot name="foo" />
<!-- ✗ BAD -->
<slot name="bar" />
</div>
</template>
<script lang="ts">
import { SlotsType } from 'vue'
defineComponent({
slots: Object as SlotsType<{
default: { msg: string }
foo: { msg: string }
}>
})
</script>
```

</eslint-code-block>

## :wrench: Options

Nothing.

## :rocket: Version

This rule was introduced in eslint-plugin-vue v9.21.0

## :mag: Implementation

- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/require-explicit-slots.js)
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/require-explicit-slots.js)
42 changes: 39 additions & 3 deletions docs/rules/v-bind-style.md
Original file line number Diff line number Diff line change
@@ -32,16 +32,20 @@ This rule enforces `v-bind` directive style which you should use shorthand or lo

## :wrench: Options

Default is set to `shorthand`.

```json
{
"vue/v-bind-style": ["error", "shorthand" | "longform"]
"vue/v-bind-style": ["error", "shorthand" | "longform", {
"sameNameShorthand": "ignore" | "always" | "never"
}]
}
```

- `"shorthand"` (default) ... requires using shorthand.
- `"longform"` ... requires using long form.
- `sameNameShorthand` ... enforce the `v-bind` same-name shorthand style (Vue 3.4+).
- `"ignore"` (default) ... ignores the same-name shorthand style.
- `"always"` ... always enforces same-name shorthand where possible.
- `"never"` ... always disallow same-name shorthand where possible.

### `"longform"`

@@ -59,6 +63,38 @@ Default is set to `shorthand`.

</eslint-code-block>

### `{ "sameNameShorthand": "always" }`

<eslint-code-block fix :rules="{'vue/v-bind-style': ['error', 'shorthand', { 'sameNameShorthand': 'always' }]}">

```vue
<template>
<!-- ✓ GOOD -->
<div :foo />
<!-- ✗ BAD -->
<div :foo="foo" />
</template>
```

</eslint-code-block>

### `{ "sameNameShorthand": "never" }`

<eslint-code-block fix :rules="{'vue/v-bind-style': ['error', 'shorthand', { 'sameNameShorthand': 'never' }]}">

```vue
<template>
<!-- ✓ GOOD -->
<div :foo="foo" />
<!-- ✗ BAD -->
<div :foo />
</template>
```

</eslint-code-block>

## :books: Further Reading

- [Style guide - Directive shorthands](https://vuejs.org/style-guide/rules-strongly-recommended.html#directive-shorthands)
1 change: 0 additions & 1 deletion docs/rules/valid-v-bind.md
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@ This rule does not report `v-bind` directives which do not have their argument (
<!-- ✗ BAD -->
<div v-bind/>
<div :aaa/>
<div v-bind:aaa.bbb="foo"/>
</template>
```
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -131,6 +131,7 @@ module.exports = {
'no-restricted-static-attribute': require('./rules/no-restricted-static-attribute'),
'no-restricted-syntax': require('./rules/no-restricted-syntax'),
'no-restricted-v-bind': require('./rules/no-restricted-v-bind'),
'no-restricted-v-on': require('./rules/no-restricted-v-on'),
'no-root-v-if': require('./rules/no-root-v-if'),
'no-setup-props-destructure': require('./rules/no-setup-props-destructure'),
'no-setup-props-reactivity-loss': require('./rules/no-setup-props-reactivity-loss'),
@@ -189,6 +190,7 @@ module.exports = {
'require-direct-export': require('./rules/require-direct-export'),
'require-emit-validator': require('./rules/require-emit-validator'),
'require-explicit-emits': require('./rules/require-explicit-emits'),
'require-explicit-slots': require('./rules/require-explicit-slots'),
'require-expose': require('./rules/require-expose'),
'require-macro-variable-name': require('./rules/require-macro-variable-name'),
'require-name-property': require('./rules/require-name-property'),
Loading