Skip to content

Commit 2b4f0d3

Browse files
committed
Update demo and docs
1 parent 586f113 commit 2b4f0d3

23 files changed

+254
-42
lines changed

README.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,22 +239,61 @@ The rules with the following star :star: are included in the configs.
239239

240240
<!--RULES_TABLE_START-->
241241

242+
## Possible Errors
243+
244+
These rules relate to possible syntax or logic errors in Svelte code:
245+
242246
| Rule ID | Description | |
243247
|:--------|:------------|:---|
244-
| [@ota-meshi/svelte/button-has-type](https://ota-meshi.github.io/eslint-plugin-svelte/rules/button-has-type.html) | disallow usage of button without an explicit type attribute | |
245-
| [@ota-meshi/svelte/comment-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/comment-directive.html) | support comment-directives in HTML template | :star: |
246-
| [@ota-meshi/svelte/indent](https://ota-meshi.github.io/eslint-plugin-svelte/rules/indent.html) | enforce consistent indentation | :wrench: |
247-
| [@ota-meshi/svelte/max-attributes-per-line](https://ota-meshi.github.io/eslint-plugin-svelte/rules/max-attributes-per-line.html) | enforce the maximum number of attributes per line | :wrench: |
248-
| [@ota-meshi/svelte/no-at-debug-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-debug-tags.html) | disallow the use of `{@debug}` | :star: |
249-
| [@ota-meshi/svelte/no-at-html-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-html-tags.html) | disallow use of `{@html}` to prevent XSS attack | :star: |
250248
| [@ota-meshi/svelte/no-dupe-else-if-blocks](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-dupe-else-if-blocks.html) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
251-
| [@ota-meshi/svelte/no-inner-declarations](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-inner-declarations.html) | disallow variable or `function` declarations in nested blocks | :star: |
249+
250+
## Security Vulnerability
251+
252+
These rules relate to security vulnerabilities in Svelte code:
253+
254+
| Rule ID | Description | |
255+
|:--------|:------------|:---|
256+
| [@ota-meshi/svelte/no-at-html-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-html-tags.html) | disallow use of `{@html}` to prevent XSS attack | :star: |
252257
| [@ota-meshi/svelte/no-target-blank](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-target-blank.html) | disallow target="_blank" attribute without rel="noopener noreferrer" | |
258+
259+
## Best Practices
260+
261+
These rules relate to better ways of doing things to help you avoid problems:
262+
263+
| Rule ID | Description | |
264+
|:--------|:------------|:---|
265+
| [@ota-meshi/svelte/button-has-type](https://ota-meshi.github.io/eslint-plugin-svelte/rules/button-has-type.html) | disallow usage of button without an explicit type attribute | |
266+
| [@ota-meshi/svelte/no-at-debug-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-debug-tags.html) | disallow the use of `{@debug}` | :star: |
253267
| [@ota-meshi/svelte/no-useless-mustaches](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-useless-mustaches.html) | disallow unnecessary mustache interpolations | :wrench: |
268+
269+
## Stylistic Issues
270+
271+
These rules relate to style guidelines, and are therefore quite subjective:
272+
273+
| Rule ID | Description | |
274+
|:--------|:------------|:---|
275+
| [@ota-meshi/svelte/indent](https://ota-meshi.github.io/eslint-plugin-svelte/rules/indent.html) | enforce consistent indentation | :wrench: |
276+
| [@ota-meshi/svelte/max-attributes-per-line](https://ota-meshi.github.io/eslint-plugin-svelte/rules/max-attributes-per-line.html) | enforce the maximum number of attributes per line | :wrench: |
254277
| [@ota-meshi/svelte/prefer-class-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/prefer-class-directive.html) | require class directives instead of ternary expressions | :wrench: |
255278
| [@ota-meshi/svelte/spaced-html-comment](https://ota-meshi.github.io/eslint-plugin-svelte/rules/spaced-html-comment.html) | enforce consistent spacing after the `<!--` and before the `-->` in a HTML comment | :wrench: |
279+
280+
## System
281+
282+
These rules relate to this plugin works:
283+
284+
| Rule ID | Description | |
285+
|:--------|:------------|:---|
286+
| [@ota-meshi/svelte/comment-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/comment-directive.html) | support comment-directives in HTML template | :star: |
256287
| [@ota-meshi/svelte/system](https://ota-meshi.github.io/eslint-plugin-svelte/rules/system.html) | system rule for working this plugin | :star: |
257288

289+
## Extension Rules
290+
291+
These rules extend the rules provided by ESLint itself to work well in Svelte:
292+
293+
| Rule ID | Description | |
294+
|:--------|:------------|:---|
295+
| [@ota-meshi/svelte/no-inner-declarations](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-inner-declarations.html) | disallow variable or `function` declarations in nested blocks | :star: |
296+
258297
<!--RULES_TABLE_END-->
259298
<!--RULES_SECTION_END-->
260299

docs/.vuepress/components/components/RulesSettings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,6 @@ a {
146146
}
147147
148148
.eslint-plugin-svelte__category {
149-
color: #f8c555;
149+
color: #ffdcd3;
150150
}
151151
</style>

docs/.vuepress/components/playground-block.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,8 @@ function equalsRules(a, b) {
250250
padding: 8px;
251251
font-size: 12px;
252252
}
253+
254+
.main-content > .editor-content > .messages a {
255+
color: #40b3ff;
256+
}
253257
</style>

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import * as coreRules from "../../../../node_modules/eslint4b/dist/core-rules"
44
import plugin from "../../../../"
55

66
const CATEGORY_TITLES = {
7-
recommended: "eslint-plugin-svelte",
7+
"Possible Errors": "Svelte Rules(Possible Errors)",
8+
"Security Vulnerability": "Svelte Rules(Security Vulnerability)",
9+
"Best Practices": "Svelte Rules(Best Practices)",
10+
"Stylistic Issues": "Svelte Rules(Stylistic Issues)",
11+
System: "Svelte Rules(System)",
12+
"Extension Rules": "Svelte Rules(Extension Rules)",
813
"eslint-core-rules@Possible Errors": "ESLint core rules(Possible Errors)",
914
"eslint-core-rules@Best Practices": "ESLint core rules(Best Practices)",
1015
"eslint-core-rules@Strict Mode": "ESLint core rules(Strict Mode)",
@@ -15,7 +20,12 @@ const CATEGORY_TITLES = {
1520
"eslint-core-rules@ECMAScript 6": "ESLint core rules(ECMAScript 6)",
1621
}
1722
const CATEGORY_INDEX = {
18-
recommended: 2,
23+
"Possible Errors": 1,
24+
"Security Vulnerability": 2,
25+
"Best Practices": 3,
26+
"Stylistic Issues": 4,
27+
System: 5,
28+
"Extension Rules": 5.5,
1929
"eslint-core-rules@Possible Errors": 6,
2030
"eslint-core-rules@Best Practices": 7,
2131
"eslint-core-rules@Strict Mode": 8,
@@ -25,16 +35,29 @@ const CATEGORY_INDEX = {
2535
"eslint-core-rules@ECMAScript 6": 12,
2636
}
2737
const CATEGORY_CLASSES = {
28-
recommended: "eslint-plugin-svelte__category",
38+
"Possible Errors": "eslint-plugin-svelte__category",
39+
"Security Vulnerability": "eslint-plugin-svelte__category",
40+
"Best Practices": "eslint-plugin-svelte__category",
41+
"Stylistic Issues": "eslint-plugin-svelte__category",
42+
System: "eslint-plugin-svelte__category",
43+
"Extension Rules": "eslint-plugin-svelte__category",
2944
}
3045

3146
const allRules = []
3247

3348
for (const k of Object.keys(plugin.rules)) {
3449
const rule = plugin.rules[k]
50+
if (rule.meta.deprecated) {
51+
continue
52+
}
53+
54+
const category = rule.meta.docs.extensionRule
55+
? "Extension Rules"
56+
: rule.meta.docs.category
57+
3558
allRules.push({
3659
classes: "eslint-plugin-svelte__rule",
37-
category: "recommended",
60+
category,
3861
ruleId: rule.meta.docs.ruleId,
3962
url: rule.meta.docs.url,
4063
initChecked: true,

docs/.vuepress/config.js

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@ const path = require("path")
22
// eslint-disable-next-line node/no-missing-require, node/no-unpublished-require -- no build
33
const { rules } = require("../../lib/utils/rules")
44

5+
const svelteRules = rules.filter(
6+
(rule) => !rule.meta.docs.extensionRule && !rule.meta.deprecated,
7+
)
8+
9+
const categories = [
10+
"Possible Errors",
11+
"Security Vulnerability",
12+
"Best Practices",
13+
"Stylistic Issues",
14+
"System",
15+
]
16+
svelteRules.forEach((rule) => {
17+
if (!categories.includes(rule.meta.docs.category)) {
18+
throw new Error(`missing categories:${rule.meta.docs.category}`)
19+
}
20+
})
21+
const categoryRules = categories.map((cat) => {
22+
return {
23+
title: cat,
24+
rules: svelteRules.filter((rule) => rule.meta.docs.category === cat),
25+
}
26+
})
27+
28+
const extensionRules = rules.filter(
29+
(rule) => rule.meta.docs.extensionRule && !rule.meta.deprecated,
30+
)
31+
532
function ruleToLink({
633
meta: {
734
docs: { ruleId, ruleName },
@@ -50,28 +77,19 @@ module.exports = {
5077
sidebar: {
5178
"/rules/": [
5279
"/rules/",
53-
{
54-
title: "Svelte Rules",
55-
collapsable: false,
56-
children: rules
57-
.filter(
58-
(rule) => !rule.meta.docs.extensionRule && !rule.meta.deprecated,
59-
)
60-
.map(ruleToLink),
61-
},
62-
...(rules.some(
63-
(rule) => rule.meta.docs.extensionRule && !rule.meta.deprecated,
64-
)
80+
...categoryRules.map((cat) => {
81+
return {
82+
title: cat.title,
83+
collapsable: false,
84+
children: cat.rules.map(ruleToLink),
85+
}
86+
}),
87+
...(extensionRules.length
6588
? [
6689
{
6790
title: "Extension Rules",
6891
collapsable: false,
69-
children: rules
70-
.filter(
71-
(rule) =>
72-
rule.meta.docs.extensionRule && !rule.meta.deprecated,
73-
)
74-
.map(ruleToLink),
92+
children: extensionRules.map(ruleToLink),
7593
},
7694
]
7795
: []),

docs/.vuepress/styles/index.styl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Theme
2+
#app
3+
a:hover
4+
color #40b3ff
5+
.nav-item > a:not(.external):hover
6+
border-bottom none
7+
.nav-item > a:not(.external).router-link-active
8+
color #ff3e00
9+
border-bottom none
10+
111
@media screen and (min-width: 400px) and (max-width: 450px)
212
#app .navbar .site-name
313
font-size calc(1.3rem * 0.8)

docs/.vuepress/styles/palette.styl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$accentColor = #ff3e00

docs/rules/README.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,57 @@ The rules with the following star :star: are included in the `plugin:@ota-meshi/
99

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

12+
## Possible Errors
13+
14+
These rules relate to possible syntax or logic errors in Svelte code:
15+
1216
| Rule ID | Description | |
1317
|:--------|:------------|:---|
14-
| [@ota-meshi/svelte/button-has-type](./button-has-type.md) | disallow usage of button without an explicit type attribute | |
15-
| [@ota-meshi/svelte/comment-directive](./comment-directive.md) | support comment-directives in HTML template | :star: |
16-
| [@ota-meshi/svelte/indent](./indent.md) | enforce consistent indentation | :wrench: |
17-
| [@ota-meshi/svelte/max-attributes-per-line](./max-attributes-per-line.md) | enforce the maximum number of attributes per line | :wrench: |
18-
| [@ota-meshi/svelte/no-at-debug-tags](./no-at-debug-tags.md) | disallow the use of `{@debug}` | :star: |
19-
| [@ota-meshi/svelte/no-at-html-tags](./no-at-html-tags.md) | disallow use of `{@html}` to prevent XSS attack | :star: |
2018
| [@ota-meshi/svelte/no-dupe-else-if-blocks](./no-dupe-else-if-blocks.md) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
21-
| [@ota-meshi/svelte/no-inner-declarations](./no-inner-declarations.md) | disallow variable or `function` declarations in nested blocks | :star: |
19+
20+
## Security Vulnerability
21+
22+
These rules relate to security vulnerabilities in Svelte code:
23+
24+
| Rule ID | Description | |
25+
|:--------|:------------|:---|
26+
| [@ota-meshi/svelte/no-at-html-tags](./no-at-html-tags.md) | disallow use of `{@html}` to prevent XSS attack | :star: |
2227
| [@ota-meshi/svelte/no-target-blank](./no-target-blank.md) | disallow target="_blank" attribute without rel="noopener noreferrer" | |
28+
29+
## Best Practices
30+
31+
These rules relate to better ways of doing things to help you avoid problems:
32+
33+
| Rule ID | Description | |
34+
|:--------|:------------|:---|
35+
| [@ota-meshi/svelte/button-has-type](./button-has-type.md) | disallow usage of button without an explicit type attribute | |
36+
| [@ota-meshi/svelte/no-at-debug-tags](./no-at-debug-tags.md) | disallow the use of `{@debug}` | :star: |
2337
| [@ota-meshi/svelte/no-useless-mustaches](./no-useless-mustaches.md) | disallow unnecessary mustache interpolations | :wrench: |
38+
39+
## Stylistic Issues
40+
41+
These rules relate to style guidelines, and are therefore quite subjective:
42+
43+
| Rule ID | Description | |
44+
|:--------|:------------|:---|
45+
| [@ota-meshi/svelte/indent](./indent.md) | enforce consistent indentation | :wrench: |
46+
| [@ota-meshi/svelte/max-attributes-per-line](./max-attributes-per-line.md) | enforce the maximum number of attributes per line | :wrench: |
2447
| [@ota-meshi/svelte/prefer-class-directive](./prefer-class-directive.md) | require class directives instead of ternary expressions | :wrench: |
2548
| [@ota-meshi/svelte/spaced-html-comment](./spaced-html-comment.md) | enforce consistent spacing after the `<!--` and before the `-->` in a HTML comment | :wrench: |
49+
50+
## System
51+
52+
These rules relate to this plugin works:
53+
54+
| Rule ID | Description | |
55+
|:--------|:------------|:---|
56+
| [@ota-meshi/svelte/comment-directive](./comment-directive.md) | support comment-directives in HTML template | :star: |
2657
| [@ota-meshi/svelte/system](./system.md) | system rule for working this plugin | :star: |
58+
59+
## Extension Rules
60+
61+
These rules extend the rules provided by ESLint itself to work well in Svelte:
62+
63+
| Rule ID | Description | |
64+
|:--------|:------------|:---|
65+
| [@ota-meshi/svelte/no-inner-declarations](./no-inner-declarations.md) | disallow variable or `function` declarations in nested blocks | :star: |

src/rules/button-has-type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default createRule("button-has-type", {
1818
docs: {
1919
description:
2020
"disallow usage of button without an explicit type attribute",
21+
category: "Best Practices",
2122
recommended: false,
2223
},
2324
schema: [

src/rules/comment-directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default createRule("comment-directive", {
3030
meta: {
3131
docs: {
3232
description: "support comment-directives in HTML template",
33+
category: "System",
3334
recommended: "base",
3435
},
3536
schema: [

src/rules/indent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default createRule("indent", {
55
meta: {
66
docs: {
77
description: "enforce consistent indentation",
8+
category: "Stylistic Issues",
89
recommended: false,
910
},
1011
fixable: "whitespace",

src/rules/max-attributes-per-line.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default createRule("max-attributes-per-line", {
2828
meta: {
2929
docs: {
3030
description: "enforce the maximum number of attributes per line",
31+
category: "Stylistic Issues",
3132
recommended: false,
3233
},
3334
fixable: "whitespace",

src/rules/no-at-debug-tags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default createRule("no-at-debug-tags", {
44
meta: {
55
docs: {
66
description: "disallow the use of `{@debug}`",
7+
category: "Best Practices",
78
recommended: true,
89
default: "warn",
910
},

src/rules/no-at-html-tags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default createRule("no-at-html-tags", {
55
meta: {
66
docs: {
77
description: "disallow use of `{@html}` to prevent XSS attack",
8+
category: "Security Vulnerability",
89
recommended: true,
910
},
1011
schema: [],

src/rules/no-dupe-else-if-blocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export default createRule("no-dupe-else-if-blocks", {
7171
docs: {
7272
description:
7373
"disallow duplicate conditions in `{#if}` / `{:else if}` chains",
74+
category: "Possible Errors",
7475
recommended: true,
7576
},
7677
schema: [],

src/rules/no-inner-declarations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default createRule("no-inner-declarations", {
1313
docs: {
1414
description:
1515
"disallow variable or `function` declarations in nested blocks",
16+
category: "Possible Errors",
1617
recommended: true,
1718
extensionRule: "no-inner-declarations",
1819
},

src/rules/no-target-blank.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export default createRule("no-target-blank", {
6464
meta: {
6565
docs: {
6666
description: `disallow target="_blank" attribute without rel="noopener noreferrer"`,
67+
category: "Security Vulnerability",
6768
recommended: false,
6869
},
6970
schema: [

src/rules/no-useless-mustaches.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default createRule("no-useless-mustaches", {
1818
meta: {
1919
docs: {
2020
description: "disallow unnecessary mustache interpolations",
21+
category: "Best Practices",
2122
recommended: false,
2223
},
2324
fixable: "code",

src/rules/prefer-class-directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default createRule("prefer-class-directive", {
77
meta: {
88
docs: {
99
description: "require class directives instead of ternary expressions",
10+
category: "Stylistic Issues",
1011
recommended: false,
1112
},
1213
fixable: "code",

src/rules/spaced-html-comment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default createRule("spaced-html-comment", {
55
docs: {
66
description:
77
"enforce consistent spacing after the `<!--` and before the `-->` in a HTML comment",
8+
category: "Stylistic Issues",
89
recommended: false,
910
},
1011
fixable: "whitespace",

0 commit comments

Comments
 (0)