Skip to content

Commit 7dab777

Browse files
authored
Merge branch 'master' into refactor(no-import-compiler-macros)--check-only-in-<script-setup>
2 parents 2d4a9b8 + 3bf079c commit 7dab777

14 files changed

+1204
-96
lines changed

.changeset/neat-coats-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-vue": patch
3+
---
4+
5+
Updated dependency [postcss-selector-parser](https://github.com/postcss/postcss-selector-parser) to v7.1.0

.changeset/ten-lines-fail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-vue': minor
3+
---
4+
5+
Added new [`vue/no-duplicate-class-names`](https://eslint.vuejs.org/rules/no-duplicate-class-names.html) rule

.github/workflows/Release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ jobs:
1414
permissions:
1515
contents: write # to create release (changesets/action)
1616
pull-requests: write # to create pull request (changesets/action)
17+
id-token: write # OpenID Connect token needed for Trusted Publisher
1718
name: Release
1819
runs-on: ubuntu-latest
1920
steps:
2021
- name: Checkout Repo
2122
uses: actions/checkout@v4
2223
- name: Setup Node.js
2324
uses: actions/setup-node@v4
25+
with:
26+
node-version: 24
2427
- name: Install Dependencies
2528
run: npm install
2629

@@ -32,4 +35,3 @@ jobs:
3235
publish: npm run changeset:publish
3336
env:
3437
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# eslint-plugin-vue
22

3+
## 10.5.1
4+
5+
### Patch Changes
6+
7+
- Fixed [`vue/no-negated-v-if-condition`](https://eslint.vuejs.org/rules/no-negated-v-if-condition.html) rule to swap entire elements ([#2941](https://github.com/vuejs/eslint-plugin-vue/pull/2941))
8+
39
## 10.5.0
410

511
### Minor Changes

docs/rules/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ For example:
234234
| [vue/no-bare-strings-in-template] | disallow the use of bare strings in `<template>` | | :hammer: |
235235
| [vue/no-boolean-default] | disallow boolean defaults | | :hammer: |
236236
| [vue/no-duplicate-attr-inheritance] | enforce `inheritAttrs` to be set to `false` when using `v-bind="$attrs"` | | :hammer: |
237+
| [vue/no-duplicate-class-names] | disallow duplication of class names in class attributes | :wrench: | :hammer: |
237238
| [vue/no-empty-component-block] | disallow the `<template>` `<script>` `<style>` block to be empty | :wrench: | :hammer: |
238239
| [vue/no-import-compiler-macros] | disallow importing Vue compiler macros | :wrench: | :warning: |
239240
| [vue/no-multiple-objects-in-class] | disallow passing multiple objects in an array to class | | :hammer: |
@@ -468,6 +469,7 @@ The following rules extend the rules provided by ESLint itself and apply them to
468469
[vue/no-dupe-v-else-if]: ./no-dupe-v-else-if.md
469470
[vue/no-duplicate-attr-inheritance]: ./no-duplicate-attr-inheritance.md
470471
[vue/no-duplicate-attributes]: ./no-duplicate-attributes.md
472+
[vue/no-duplicate-class-names]: ./no-duplicate-class-names.md
471473
[vue/no-empty-component-block]: ./no-empty-component-block.md
472474
[vue/no-empty-pattern]: ./no-empty-pattern.md
473475
[vue/no-export-in-script-setup]: ./no-export-in-script-setup.md

docs/rules/no-bare-strings-in-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ If you want to report these string literals, enable the [vue/no-useless-v-bind]
7272
}
7373
```
7474

75-
- `allowlist` ... An array of allowed strings or regular expression patterns (e.g. `/\d+/` to allow numbers).
75+
- `allowlist` ... An array of allowed strings or regular expression patterns (e.g. `"/\d+/"` to allow numbers).
7676
- `attributes` ... An object whose keys are tag name or patterns and value is an array of attributes to check for that tag name.
7777
- `directives` ... An array of directive names to check literal value.
7878

docs/rules/no-deprecated-slot-attribute.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ This rule reports deprecated `slot` attribute in Vue.js v2.6.0+.
4949
}
5050
```
5151

52-
- `"ignore"` (`string[]`) An array of tags or regular expression patterns (e.g. `/^custom-/`) that ignore these rules. This option will check both kebab-case and PascalCase versions of the given tag names. Default is empty.
53-
- `"ignoreParents"` (`string[]`) An array of tags or regular expression patterns (e.g. `/^custom-/`) for parents that ignore these rules. This option is especially useful for [Web-Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components). Default is empty.
52+
- `"ignore"` (`string[]`) An array of tags or regular expression patterns (e.g. `"/^custom-/"`) that ignore these rules. This option will check both kebab-case and PascalCase versions of the given tag names. Default is empty.
53+
- `"ignoreParents"` (`string[]`) An array of tags or regular expression patterns (e.g. `"/^custom-/"`) for parents that ignore these rules. This option is especially useful for [Web-Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components). Default is empty.
5454

5555
### `"ignore": ["my-component"]`
5656

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
pageClass: rule-details
3+
sidebarDepth: 0
4+
title: vue/no-duplicate-class-names
5+
description: disallow duplication of class names in class attributes
6+
---
7+
8+
# vue/no-duplicate-class-names
9+
10+
> disallow duplication of class names in class attributes
11+
12+
- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> _**This rule has not been released yet.**_ </badge>
13+
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix-problems) can automatically fix some of the problems reported by this rule.
14+
15+
## :book: Rule Details
16+
17+
This rule prevents the same class name from appearing multiple times within the same class attribute or directive.
18+
19+
<eslint-code-block fix :rules="{'vue/no-duplicate-class-names': ['error']}">
20+
21+
```vue
22+
<template>
23+
<!-- ✓ GOOD -->
24+
<div class="foo bar"></div>
25+
<div :class="'foo bar'"></div>
26+
<div :class="{ 'foo bar': isActive }"></div>
27+
<div :class="['foo', 'bar']"></div>
28+
<div :class="isActive ? 'foo' : 'bar'"></div>
29+
<div class="foo" :class="{ bar: isActive }"></div>
30+
31+
<!-- ✗ BAD -->
32+
<div class="foo foo"></div>
33+
<div class="foo bar foo baz bar"></div>
34+
<div :class="'foo foo'"></div>
35+
<div :class="`foo foo`"></div>
36+
<div :class="{ 'foo foo': isActive }"></div>
37+
<div :class="['foo foo']"></div>
38+
<div :class="['foo foo', { 'bar bar baz': isActive }]"></div>
39+
<div :class="isActive ? 'foo foo' : 'bar'"></div>
40+
<div :class="'foo foo ' + 'bar'"></div>
41+
<div class="foo" :class="'foo'"></div>
42+
<div :class="['foo', 'foo']"></div>
43+
<div :class="'foo ' + 'foo'"></div>
44+
<div :class="['foo', { 'foo': isActive }]"></div>
45+
</template>
46+
```
47+
48+
</eslint-code-block>
49+
50+
## :wrench: Options
51+
52+
Nothing.
53+
54+
## :mag: Implementation
55+
56+
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-duplicate-class-names.js)
57+
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/no-duplicate-class-names.js)

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const plugin = {
125125
'no-dupe-v-else-if': require('./rules/no-dupe-v-else-if'),
126126
'no-duplicate-attr-inheritance': require('./rules/no-duplicate-attr-inheritance'),
127127
'no-duplicate-attributes': require('./rules/no-duplicate-attributes'),
128+
'no-duplicate-class-names': require('./rules/no-duplicate-class-names'),
128129
'no-empty-component-block': require('./rules/no-empty-component-block'),
129130
'no-empty-pattern': require('./rules/no-empty-pattern'),
130131
'no-export-in-script-setup': require('./rules/no-export-in-script-setup'),

0 commit comments

Comments
 (0)