Skip to content

Commit ac8dd67

Browse files
committed
Chore: use meta.docs.url
1 parent 9232ae8 commit ac8dd67

File tree

5 files changed

+20
-25
lines changed

5 files changed

+20
-25
lines changed

src/app-state.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ import defaultCode from "./app-state/default-code.js"
33
import defaultConfig from "./app-state/default-config.js"
44
import { linter, ruleCategories } from "./app-state/eslint.js"
55

6+
export { ruleCategories }
7+
8+
/**
9+
* Get the document URL of a rule.
10+
* @param {string} ruleId The rule ID to get.
11+
* @returns {string|null} The document URL of the rule.
12+
*/
13+
export function getRuleUrl(ruleId) {
14+
return linter.getRules().get(ruleId).meta.docs.url
15+
}
16+
617
/**
718
* The state object for this application.
819
*/
@@ -187,5 +198,3 @@ export default class PlaygroundState {
187198
}
188199
}
189200
}
190-
191-
export { ruleCategories }

src/app-state/eslint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const ruleCategories = (() => {
7676
category.rules.push({
7777
name,
7878
description: meta.docs.description || "no description",
79+
url: meta.docs.url,
7980
fixable: Boolean(meta.fixable),
8081
})
8182
}

src/configuration-rules-select.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
<script>
1212
import ConfigurationCategory from "./configuration-category.vue"
13-
import { getRuleUrl } from "./util.js"
1413
1514
export default {
1615
name: "ConfigurationRulesSelect",
@@ -35,13 +34,12 @@ export default {
3534
computed: {
3635
rules() {
3736
const severityMap = this.config.rules
38-
return this.category.rules.map(r => ({
39-
id: r.name,
40-
name: r.name,
41-
description: r.description,
42-
url: getRuleUrl(r.name),
43-
checked: severityMap[r.name] === 2,
44-
}))
37+
return this.category.rules.map(rule =>
38+
Object.assign(
39+
{ id: rule.name, checked: severityMap[rule.name] === 2 },
40+
rule
41+
)
42+
)
4543
},
4644
4745
countChecked() {
@@ -69,7 +67,7 @@ export default {
6967
const severityMap = this.config.rules
7068
if (id == null) {
7169
for (const rule of this.rules) {
72-
severityMap[rule.id] = (checked ? 2 : 0)
70+
severityMap[rule.name] = (checked ? 2 : 0)
7371
}
7472
}
7573
else {

src/message-list.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<script>
2323
import MdIcon from "./md-icon.vue"
24-
import { getRuleUrl } from "./util.js"
24+
import { getRuleUrl } from "./app-state"
2525
2626
export default {
2727
name: "MessageList",

src/util.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)