Skip to content

Commit d257150

Browse files
authored
no message (#39)
1 parent 506b869 commit d257150

File tree

19 files changed

+326
-92
lines changed

19 files changed

+326
-92
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,30 +86,31 @@ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/comm
8686

8787
<!--RULES_TABLE_START-->
8888

89-
## Recommended
89+
## Recommended for Vue.js 3.x
9090

9191
Enforce all the rules in this category with:
9292

9393
```json
9494
{
95-
"extends": "plugin:vue-scoped-css/recommended"
95+
"extends": "plugin:vue-scoped-css/vue3-recommended"
9696
}
9797
```
9898

9999
| Rule ID | Description | |
100100
|:--------|:------------|:---|
101+
| [vue-scoped-css/no-deprecated-deep-combinator](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-deprecated-deep-combinator.html) | disallow using deprecated deep combinators | |
101102
| [vue-scoped-css/no-parsing-error](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-parsing-error.html) | Disallow parsing errors in `<style>` | |
102103
| [vue-scoped-css/no-unused-keyframes](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-unused-keyframes.html) | Reports the `@keyframes` is not used in Scoped CSS. | |
103104
| [vue-scoped-css/no-unused-selector](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-unused-selector.html) | Reports selectors defined in Scoped CSS not used in `<template>`. | |
104105
| [vue-scoped-css/require-scoped](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/require-scoped.html) | Enforce the `<style>` tags to has the `scoped` attribute. | |
105106

106-
## Recommended for Vue.js 3.x
107+
## Recommended for Vue.js 2.x
107108

108109
Enforce all the rules in this category with:
109110

110111
```json
111112
{
112-
"extends": "plugin:vue-scoped-css/vue3-recommended"
113+
"extends": "plugin:vue-scoped-css/recommended"
113114
}
114115
```
115116

docs/.vuepress/categories.js

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,42 @@ const { rules } = require("../../dist/utils/rules")
33
const categoryTitles = {
44
base: "Base Rules (Enabling Plugin)",
55
recommended: "Recommended",
6+
"vue2-recommended": "Recommended for Vue.js 2.x",
7+
"vue3-recommended": "Recommended for Vue.js 3.x",
8+
uncategorized: "Uncategorized",
9+
deprecated: "Deprecated",
610
}
711

8-
const categoryConfigDescriptions = {
9-
base: "Enable this plugin using with:",
10-
recommended: "Enforce all the rules in this category with:",
12+
const isCategoryTest = {
13+
base: () => false,
14+
recommended: ({ deprecated, docs: { categories } }) =>
15+
!deprecated &&
16+
categories.length &&
17+
categories.every(
18+
(cat) => cat === "recommended" || cat === "vue3-recommended"
19+
),
20+
"vue2-recommended": ({ deprecated, docs: { categories } }) =>
21+
!deprecated &&
22+
categories.length &&
23+
categories.some((cat) => cat === "recommended") &&
24+
categories.every((cat) => cat !== "vue3-recommended"),
25+
"vue3-recommended": ({ deprecated, docs: { categories } }) =>
26+
!deprecated &&
27+
categories.length &&
28+
categories.some((cat) => cat === "vue3-recommended") &&
29+
categories.every((cat) => cat !== "recommended"),
30+
uncategorized: ({ deprecated, docs: { categories } }) =>
31+
!deprecated && !categories.length,
32+
deprecated: ({ deprecated }) => deprecated,
1133
}
1234

1335
const categoryIds = Object.keys(categoryTitles)
14-
const categoryRules = rules.reduce((obj, rule) => {
15-
const cat = rule.meta.docs.category || "uncategorized"
16-
const categories = obj[cat] || (obj[cat] = [])
17-
categories.push(rule)
18-
return obj
19-
}, {})
36+
const categoryRules = categoryIds
37+
.map((cat) => [cat, rules.filter((rule) => isCategoryTest[cat](rule.meta))])
38+
.reduce((ret, [key, value]) => {
39+
ret[key] = value
40+
return ret
41+
}, {})
2042

2143
// Throw if no title is defined for a category
2244
for (const categoryId of Object.keys(categoryRules)) {
@@ -30,7 +52,6 @@ for (const categoryId of Object.keys(categoryRules)) {
3052
module.exports = categoryIds.map((categoryId) => ({
3153
categoryId,
3254
title: categoryTitles[categoryId],
33-
configDescription: categoryConfigDescriptions[categoryId],
3455
rules: (categoryRules[categoryId] || []).filter(
3556
(rule) => !rule.meta.deprecated
3657
),

docs/.vuepress/components/rules/index.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import pluginVue from "eslint-plugin-vue"
55
const CATEGORY_TITLES = {
66
base: "Base Rules",
77
recommended: "Recommended",
8+
"vue2-recommended": "Recommended for Vue.js 2.x",
9+
"vue3-recommended": "Recommended for Vue.js 3.x",
810
uncategorized: "Uncategorized",
911
"eslint-plugin-vue": "eslint-plugin-vue rules",
1012
"eslint-core-rules@Possible Errors": "ESLint core rules(Possible Errors)",
@@ -18,7 +20,9 @@ const CATEGORY_TITLES = {
1820
}
1921
const CATEGORY_INDEX = {
2022
base: 0,
21-
recommended: 2,
23+
recommended: 1,
24+
"vue2-recommended": 2,
25+
"vue3-recommended": 3,
2226
uncategorized: 4,
2327
"eslint-plugin-vue": 5,
2428
"eslint-core-rules@Possible Errors": 6,
@@ -32,21 +36,37 @@ const CATEGORY_INDEX = {
3236
const CATEGORY_CLASSES = {
3337
base: "eslint-plugin-vue-scoped-css__category",
3438
recommended: "eslint-plugin-vue-scoped-css__category",
39+
"vue2-recommended": "eslint-plugin-vue-scoped-css__category",
40+
"vue3-recommended": "eslint-plugin-vue-scoped-css__category",
3541
uncategorized: "eslint-plugin-vue-scoped-css__category",
3642
"eslint-plugin-vue": "eslint-plugin-vue__category",
3743
}
3844

45+
function getCategory({ deprecated, docs: { categories } }) {
46+
if (deprecated) {
47+
return "deprecated"
48+
}
49+
const v2 = categories.some((cat) => cat === "recommended")
50+
const v3 = categories.some((cat) => cat === "vue3-recommended")
51+
if (v2) {
52+
return v3 ? "recommended" : "vue2-recommended"
53+
} else if (v3) {
54+
return "vue3-recommended"
55+
}
56+
return "uncategorized"
57+
}
58+
3959
const allRules = []
4060

4161
for (const k of Object.keys(plugin.rules)) {
4262
const rule = plugin.rules[k]
43-
rule.meta.docs.category = rule.meta.docs.category || "uncategorized"
63+
const category = getCategory(rule.meta)
4464
allRules.push({
4565
classes: "eslint-plugin-vue-scoped-css__rule",
46-
category: rule.meta.docs.category,
66+
category,
4767
ruleId: rule.meta.docs.ruleId,
4868
url: rule.meta.docs.url,
49-
initChecked: CATEGORY_INDEX[rule.meta.docs.category] <= 3,
69+
initChecked: CATEGORY_INDEX[category] <= 3,
5070
})
5171
}
5272
for (const k of Object.keys(pluginVue.rules)) {

docs/.vuepress/config.js

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,7 @@
1-
const { rules } = require("../../dist/utils/rules")
21
const categories = require("./categories")
32
// eslint-disable-next-line @mysticatea/node/no-extraneous-require
43
const webpack = require("webpack")
54

6-
const uncategorizedRules = rules.filter(
7-
(rule) => !rule.meta.docs.category && !rule.meta.deprecated
8-
)
9-
const deprecatedRules = rules.filter((rule) => rule.meta.deprecated)
10-
11-
const extraCategories = []
12-
if (uncategorizedRules.length > 0) {
13-
extraCategories.push({
14-
title: "Uncategorized",
15-
collapsable: false,
16-
children: uncategorizedRules.map(
17-
({
18-
meta: {
19-
docs: { ruleId, ruleName },
20-
},
21-
}) => [`/rules/${ruleName}`, ruleId]
22-
),
23-
})
24-
}
25-
if (deprecatedRules.length > 0) {
26-
extraCategories.push({
27-
title: "Deprecated",
28-
collapsable: false,
29-
children: deprecatedRules.map(
30-
({
31-
meta: {
32-
docs: { ruleId, ruleName },
33-
},
34-
}) => [`/rules/${ruleName}`, ruleId]
35-
),
36-
})
37-
}
38-
395
module.exports = {
406
base: "/eslint-plugin-vue-scoped-css/",
417
title: "eslint-plugin-vue-scoped-css",
@@ -50,6 +16,7 @@ module.exports = {
5016
stylus: require.resolve("stylus/lib/stylus"),
5117
glob: require.resolve("./shim/glob"),
5218
"safer-buffer": require.resolve("./shim/safer-buffer"),
19+
module: require.resolve("./shim/module"),
5320
},
5421
},
5522
plugins: [
@@ -100,9 +67,6 @@ module.exports = {
10067
),
10168
}))
10269
.filter((menu) => Boolean(menu.children.length)),
103-
104-
// Rules in no category.
105-
...extraCategories,
10670
],
10771
"/": ["/", "/user-guide/", "/rules/", "/playground/"],
10872
},

docs/.vuepress/shim/module.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
createRequire: () => () => null,
3+
}

docs/rules/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,31 @@ sidebarDepth: 0
66

77
<!-- This file is automatically generated in tools/update-docs-rules-index.js, do not change! -->
88

9-
## Recommended
9+
## Recommended for Vue.js 3.x
1010

1111
Enforce all the rules in this category with:
1212

1313
```json
1414
{
15-
"extends": "plugin:vue-scoped-css/recommended"
15+
"extends": "plugin:vue-scoped-css/vue3-recommended"
1616
}
1717
```
1818

1919
| Rule ID | Description | |
2020
|:--------|:------------|:---|
21+
| [vue-scoped-css/no-deprecated-deep-combinator](./no-deprecated-deep-combinator.md) | disallow using deprecated deep combinators | |
2122
| [vue-scoped-css/no-parsing-error](./no-parsing-error.md) | Disallow parsing errors in `<style>` | |
2223
| [vue-scoped-css/no-unused-keyframes](./no-unused-keyframes.md) | Reports the `@keyframes` is not used in Scoped CSS. | |
2324
| [vue-scoped-css/no-unused-selector](./no-unused-selector.md) | Reports selectors defined in Scoped CSS not used in `<template>`. | |
2425
| [vue-scoped-css/require-scoped](./require-scoped.md) | Enforce the `<style>` tags to has the `scoped` attribute. | |
2526

26-
## Recommended for Vue.js 3.x
27+
## Recommended for Vue.js 2.x
2728

2829
Enforce all the rules in this category with:
2930

3031
```json
3132
{
32-
"extends": "plugin:vue-scoped-css/vue3-recommended"
33+
"extends": "plugin:vue-scoped-css/recommended"
3334
}
3435
```
3536

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
pageClass: "rule-details"
3+
sidebarDepth: 0
4+
title: "vue-scoped-css/no-deprecated-deep-combinator"
5+
description: "disallow using deprecated deep combinators"
6+
---
7+
# vue-scoped-css/no-deprecated-deep-combinator
8+
9+
> disallow using deprecated deep combinators
10+
11+
- :gear: This rule is included in `"plugin:vue-scoped-css/vue3-recommended"` and `"plugin:vue-scoped-css/all"`.
12+
13+
## :book: Rule Details
14+
15+
This rule reports the use of deprecated deep combinators as errors.
16+
17+
<eslint-code-block :rules="{'vue-scoped-css/no-deprecated-deep-combinator': ['error']}">
18+
19+
```vue
20+
<style scoped>
21+
/* ✗ BAD */
22+
.a >>> .b {}
23+
.a /deep/ .b {}
24+
25+
/* ✓ GOOD */
26+
.a ::v-deep(.b) {} /* for Vue.js 3.x */
27+
.a ::v-deep .b {} /* for Vue.js 2.x */
28+
</style>
29+
```
30+
31+
</eslint-code-block>
32+
33+
## :wrench: Options
34+
35+
Nothing.
36+
37+
## Implementation
38+
39+
- [Rule source](https://github.com/future-architect/eslint-plugin-vue-scoped-css/blob/master/lib/rules/no-deprecated-deep-combinator.ts)
40+
- [Test source](https://github.com/future-architect/eslint-plugin-vue-scoped-css/blob/master/tests/lib/rules/no-deprecated-deep-combinator.js)

docs/rules/no-parsing-error.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ description: "Disallow parsing errors in `<style>`"
1010
1111
- :gear: This rule is included in all of `"plugin:vue-scoped-css/recommended"`, `"plugin:vue-scoped-css/vue3-recommended"` and `"plugin:vue-scoped-css/all"`.
1212

13+
## :book: Rule Details
14+
1315
This rule reports syntax errors in `<style>`.
1416

1517
<eslint-code-block :rules="{'vue-scoped-css/no-parsing-error': ['error']}">
@@ -23,9 +25,9 @@ This rule reports syntax errors in `<style>`.
2325

2426
</eslint-code-block>
2527

26-
## :books: Further reading
28+
## :wrench: Options
2729

28-
- None
30+
Nothing.
2931

3032
## Implementation
3133

docs/rules/no-unused-keyframes.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ description: "Reports the `@keyframes` is not used in Scoped CSS."
1010
1111
- :gear: This rule is included in all of `"plugin:vue-scoped-css/recommended"`, `"plugin:vue-scoped-css/vue3-recommended"` and `"plugin:vue-scoped-css/all"`.
1212

13+
## :book: Rule Details
14+
1315
This rule reports `@keyframes` is not used in Scoped CSS.
1416

1517
<eslint-code-block :rules="{'vue-scoped-css/no-unused-keyframes': ['error']}">
@@ -32,9 +34,9 @@ This rule reports `@keyframes` is not used in Scoped CSS.
3234

3335
</eslint-code-block>
3436

35-
## :books: Further reading
37+
## :wrench: Options
3638

37-
- None
39+
Nothing.
3840

3941
## Implementation
4042

0 commit comments

Comments
 (0)