Skip to content

Commit b706b3e

Browse files
authored
Fix demo (#56)
1 parent 773d8c1 commit b706b3e

File tree

7 files changed

+49
-27
lines changed

7 files changed

+49
-27
lines changed

docs/.vuepress/.eslintrc.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
// 'use strict'
2-
31
module.exports = {
42
rules: {
5-
"prettier/prettier": "off",
6-
"require-jsdoc": "off"
3+
"require-jsdoc": "off",
74
},
85
}

docs/.vuepress/components/components/EslintPluginEditor.vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ export default {
4444
},
4545
language: {
4646
type: String,
47-
default:"json"
47+
default: "json",
4848
},
4949
fileName: {
5050
type: String,
51-
default: "a.json"
51+
default: "a.json",
5252
},
5353
parser: {
5454
type: String,
55-
default: "jsonc-eslint-parser"
55+
default: "jsonc-eslint-parser",
5656
},
5757
},
5858
@@ -105,7 +105,11 @@ export default {
105105
}
106106
},
107107
linter() {
108-
if (!this.eslint4b || !this.jsoncESLintParser || !this.vueESLintParser) {
108+
if (
109+
!this.eslint4b ||
110+
!this.jsoncESLintParser ||
111+
!this.vueESLintParser
112+
) {
109113
return null
110114
}
111115
const Linter = this.eslint4b
@@ -125,7 +129,11 @@ export default {
125129
126130
async mounted() {
127131
// Load linter asynchronously.
128-
const [{ default: eslint4b }, jsoncESLintParser, vueESLintParser] = await Promise.all([
132+
const [
133+
{ default: eslint4b },
134+
jsoncESLintParser,
135+
vueESLintParser,
136+
] = await Promise.all([
129137
import("eslint4b"),
130138
import("espree").then(() => import("jsonc-eslint-parser")),
131139
import("espree").then(() => import("vue-eslint-parser")),
@@ -142,25 +150,25 @@ export default {
142150
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions(
143151
{
144152
validate: false,
145-
}
153+
},
146154
)
147155
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions(
148156
{
149157
validate: false,
150-
}
158+
},
151159
)
152160
})
153161
editor.$watch("codeEditor", () => {
154162
if (editor.codeEditor) {
155163
editor.codeEditor.onDidChangeModelDecorations(() =>
156-
this.onDidChangeModelDecorations(editor.codeEditor)
164+
this.onDidChangeModelDecorations(editor.codeEditor),
157165
)
158166
}
159167
})
160168
editor.$watch("fixedCodeEditor", () => {
161169
if (editor.fixedCodeEditor) {
162170
editor.fixedCodeEditor.onDidChangeModelDecorations(() =>
163-
this.onDidChangeModelDecorations(editor.fixedCodeEditor)
171+
this.onDidChangeModelDecorations(editor.fixedCodeEditor),
164172
)
165173
}
166174
})

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
<input
1313
:checked="
1414
filterRules(category.rules).every((rule) =>
15-
isErrorState(rule.ruleId)
15+
isErrorState(rule.ruleId),
1616
)
1717
"
1818
type="checkbox"
1919
:indeterminate.prop="
2020
!filterRules(category.rules).every((rule) =>
21-
isErrorState(rule.ruleId)
21+
isErrorState(rule.ruleId),
2222
) &&
2323
!filterRules(category.rules).every(
24-
(rule) => !isErrorState(rule.ruleId)
24+
(rule) => !isErrorState(rule.ruleId),
2525
)
2626
"
2727
@input="onAllClick(category, $event)"
@@ -91,7 +91,7 @@ export default {
9191
watch: {},
9292
methods: {
9393
filterRules(rules) {
94-
return rules.filter(rule=>rule.ruleId !== 'jsonc/auto')
94+
return rules.filter((rule) => rule.ruleId !== "jsonc/auto")
9595
},
9696
onAllClick(category, e) {
9797
const rules = Object.assign({}, this.rules)

docs/.vuepress/components/eslint-code-block.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ export default {
3030
},
3131
language: {
3232
type: String,
33-
default:undefined
33+
default: undefined,
3434
},
3535
fileName: {
3636
type: String,
37-
default:undefined
37+
default: undefined,
3838
},
3939
parser: {
4040
type: String,
41-
default:undefined
41+
default: undefined,
4242
},
4343
},
4444
@@ -65,7 +65,7 @@ export default {
6565
return nodes
6666
.map(
6767
(node) =>
68-
node.text || this.computeCodeFromSlot(node.children)
68+
node.text || this.computeCodeFromSlot(node.children),
6969
)
7070
.join("")
7171
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ categories.sort((a, b) =>
8888

8989
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
9090
export const DEFAULT_RULES_CONFIG = allRules.reduce((c, r) => {
91-
if(r.ruleId === "jsonc/auto") {
91+
if (r.ruleId === "jsonc/auto") {
9292
return c
9393
}
9494
if (r.ruleId === "vue/no-parsing-error") {

docs/.vuepress/config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const path = require('path')
1+
const path = require("path")
22
const { rules } = require("../../dist/utils/rules")
33

44
function ruleToLink({
@@ -20,7 +20,7 @@ module.exports = {
2020
resolve: {
2121
alias: {
2222
module: require.resolve("./shim/module"),
23-
eslint: path.resolve(__dirname, './shim/eslint')
23+
eslint: path.resolve(__dirname, "./shim/eslint"),
2424
},
2525
},
2626
}
@@ -58,7 +58,7 @@ module.exports = {
5858
.filter(
5959
(rule) =>
6060
!rule.meta.docs.extensionRule &&
61-
!rule.meta.deprecated
61+
!rule.meta.deprecated,
6262
)
6363
.map(ruleToLink),
6464
},
@@ -69,7 +69,7 @@ module.exports = {
6969
.filter(
7070
(rule) =>
7171
rule.meta.docs.extensionRule &&
72-
!rule.meta.deprecated
72+
!rule.meta.deprecated,
7373
)
7474
.map(ruleToLink),
7575
},
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1-
const Linter = require('eslint4b')
1+
const Linter = require("eslint4b")
22
class CLIEngine {}
3+
4+
// Workaround
5+
// https://github.com/mysticatea/eslint4b/issues/8
6+
const getRules = Linter.prototype.getRules
7+
Linter.prototype.getRules = function (...args) {
8+
const map = getRules.apply(this, args)
9+
const originalGet = map.get
10+
map.get = (ruleId) => {
11+
try {
12+
return require(`../../../../node_modules/eslint/lib/rules/${ruleId}`)
13+
} catch (_e) {
14+
return originalGet.call(map, ruleId)
15+
}
16+
}
17+
return map
18+
}
19+
320
module.exports = { Linter, CLIEngine }

0 commit comments

Comments
 (0)