Skip to content

Commit 2b53c5a

Browse files
committed
Update demo site
1 parent d8643d1 commit 2b53c5a

14 files changed

+209
-199
lines changed

docs/.vuepress/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
22
rules: {
3-
"eslint-comments/no-unused-disable": "off",
3+
"require-jsdoc": "off",
44
},
55
}

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

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
<script>
2121
import EslintEditor from "vue-eslint-editor"
22+
import { Linter } from "eslint/lib/linter"
2223
import plugin from "../../../.."
2324
2425
export default {
@@ -60,7 +61,6 @@ export default {
6061
6162
data() {
6263
return {
63-
eslint4b: null,
6464
svelteESLintParser: null,
6565
format: {
6666
insertSpaces: true,
@@ -103,16 +103,14 @@ export default {
103103
parser: this.parser,
104104
parserOptions: {
105105
sourceType: "script",
106-
ecmaVersion: 2020,
106+
ecmaVersion: 2021,
107107
},
108108
}
109109
},
110110
linter() {
111-
if (!this.eslint4b || !this.svelteESLintParser) {
111+
if (!this.svelteESLintParser) {
112112
return null
113113
}
114-
const Linter = this.eslint4b
115-
116114
const linter = new Linter()
117115
linter.defineParser("svelte-eslint-parser", this.svelteESLintParser)
118116
@@ -126,13 +124,46 @@ export default {
126124
},
127125
128126
async mounted() {
129-
// Load linter asynchronously.
130-
const [{ default: eslint4b }, svelteESLintParser] = await Promise.all([
131-
import("eslint4b"),
127+
// Load parser asynchronously.
128+
const [svelteESLintParser] = await Promise.all([
132129
import("espree").then(() => import("svelte-eslint-parser")),
133130
])
134-
this.eslint4b = eslint4b
135131
this.svelteESLintParser = svelteESLintParser
132+
133+
const editor = this.$refs.editor
134+
135+
editor.$watch("monaco", () => {
136+
const { monaco } = editor
137+
// monaco.languages.j()
138+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
139+
validate: false,
140+
})
141+
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
142+
validate: false,
143+
})
144+
})
145+
editor.$watch("codeEditor", () => {
146+
if (editor.codeEditor) {
147+
editor.codeEditor.onDidChangeModelDecorations(() =>
148+
this.onDidChangeModelDecorations(editor.codeEditor),
149+
)
150+
}
151+
})
152+
editor.$watch("fixedCodeEditor", () => {
153+
if (editor.fixedCodeEditor) {
154+
editor.fixedCodeEditor.onDidChangeModelDecorations(() =>
155+
this.onDidChangeModelDecorations(editor.fixedCodeEditor),
156+
)
157+
}
158+
})
159+
},
160+
161+
methods: {
162+
onDidChangeModelDecorations(editor) {
163+
const { monaco } = this.$refs.editor
164+
const model = editor.getModel()
165+
monaco.editor.setModelMarkers(model, "json", [])
166+
},
136167
},
137168
}
138169
</script>

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

Lines changed: 66 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,35 @@
11
<template>
22
<div class="rules-settings">
33
<div class="tools">
4-
<div class="tools-title" @click="state.toolsClose = !state.toolsClose">
5-
Tools
6-
<button
7-
class="tools-button"
8-
:class="{ 'tools-button--close': state.toolsClose }"
9-
>
10-
<svg
11-
xmlns="http://www.w3.org/2000/svg"
12-
height="10"
13-
viewBox="0 0 10 10"
14-
width="10"
15-
>
16-
<path d="M2.5 10l5-5-5-5v10z" fill="#ddd" />
17-
</svg>
18-
</button>
19-
</div>
20-
<template v-if="!state.toolsClose">
21-
<div class="tool">
22-
<button class="tool-button" @click="onAllOffClick">
23-
Turn OFF All Rules
24-
</button>
25-
</div>
26-
<div class="tool">
27-
<label>
28-
<span class="tool-label">Filter:</span>
29-
<input
30-
v-model="filterValue"
31-
type="search"
32-
placeholder="Rule Filter"
33-
class="tool-form"
34-
/>
35-
</label>
36-
</div>
37-
</template>
4+
<label class="tool">
5+
<span class="tool-label">Filter:</span>
6+
<input
7+
v-model="filterValue"
8+
type="search"
9+
placeholder="Rule Filter"
10+
class="tool-form"
11+
/>
12+
</label>
13+
<label class="tool">
14+
<input
15+
:checked="
16+
categories.every((category) =>
17+
category.rules.every((rule) => isErrorState(rule.ruleId)),
18+
)
19+
"
20+
type="checkbox"
21+
:indeterminate.prop="
22+
categories.some((category) =>
23+
category.rules.some((rule) => isErrorState(rule.ruleId)),
24+
) &&
25+
categories.some((category) =>
26+
category.rules.some((rule) => !isErrorState(rule.ruleId)),
27+
)
28+
"
29+
@input="onAllClick($event)"
30+
/>
31+
<span class="tool-label">All Rules</span>
32+
</label>
3833
</div>
3934
<ul class="categories">
4035
<template v-for="category in categories">
@@ -74,15 +69,15 @@
7469
!category.rules.every((rule) => isErrorState(rule.ruleId)) &&
7570
!category.rules.every((rule) => !isErrorState(rule.ruleId))
7671
"
77-
@input="onAllClick(category, $event)"
72+
@input="onCategoryClick(category, $event)"
7873
/>
7974
{{ category.title }}
8075
</label>
8176
</div>
8277

8378
<ul v-show="!categoryState[category.title].close" class="rules">
8479
<li
85-
v-for="rule in filterRules(category.rules)"
80+
v-for="rule in category.rules"
8681
:key="rule.ruleId"
8782
class="rule"
8883
:class="rule.classes"
@@ -104,6 +99,7 @@
10499
viewBox="0 0 100 100"
105100
width="15"
106101
height="15"
102+
class="icon outbound"
107103
>
108104
<path
109105
fill="currentColor"
@@ -145,33 +141,32 @@ export default {
145141
]
146142
}),
147143
),
148-
state: {
149-
toolsClose: true,
150-
},
151144
filterValue: "",
152145
}
153146
},
154147
computed: {
155148
categories() {
156149
return categories.map((c) => {
157-
let rules = this.filterRules(c.rules)
158-
if (this.filterValue) {
159-
rules = rules.filter((r) => r.ruleId.includes(this.filterValue))
160-
}
161150
return {
162151
...c,
163-
rules,
152+
rules: this.filterRules(c.rules),
164153
}
165154
})
166155
},
167156
},
168157
methods: {
169158
filterRules(rules) {
170-
return rules.filter((rule) => rule.ruleId !== "jsonc/auto")
159+
let filteredRules = rules
160+
if (this.filterValue) {
161+
filteredRules = filteredRules.filter((r) =>
162+
r.ruleId.includes(this.filterValue),
163+
)
164+
}
165+
return filteredRules
171166
},
172-
onAllClick(category, e) {
167+
onCategoryClick(category, e) {
173168
const rules = Object.assign({}, this.rules)
174-
for (const rule of this.filterRules(category.rules)) {
169+
for (const rule of category.rules) {
175170
if (e.target.checked) {
176171
rules[rule.ruleId] = "error"
177172
} else {
@@ -180,8 +175,18 @@ export default {
180175
}
181176
this.$emit("update:rules", rules)
182177
},
183-
onAllOffClick() {
184-
this.$emit("update:rules", {})
178+
onAllClick(e) {
179+
const rules = Object.assign({}, this.rules)
180+
for (const category of this.categories) {
181+
for (const rule of category.rules) {
182+
if (e.target.checked) {
183+
rules[rule.ruleId] = "error"
184+
} else {
185+
delete rules[rule.ruleId]
186+
}
187+
}
188+
}
189+
this.$emit("update:rules", rules)
185190
},
186191
onClick(ruleId, e) {
187192
const rules = Object.assign({}, this.rules)
@@ -206,25 +211,12 @@ export default {
206211
207212
.tool {
208213
display: flex;
209-
}
210-
211-
.tool,
212-
.tools-title {
213214
padding: 4px;
214215
}
215216
216-
.tool > label {
217-
display: flex;
218-
width: 100%;
219-
}
220-
221-
.tool > button {
222-
margin: auto;
223-
}
224-
225217
.tool-label {
226-
width: 3.5rem;
227218
flex-shrink: 0;
219+
padding: 0 4px;
228220
}
229221
230222
.tool-form {
@@ -244,24 +236,19 @@ export default {
244236
transform: rotate(90deg);
245237
}
246238
247-
.filter .tool-label {
248-
color: #ddd;
249-
}
250-
251239
.categories {
252240
font-size: 14px;
253241
list-style-type: none;
254242
}
255243
256244
.category {
257245
position: relative;
258-
color: #fff;
259246
}
260247
261248
.category-button {
262249
position: absolute;
263250
left: -12px;
264-
top: 4px;
251+
top: 2px;
265252
background-color: transparent;
266253
color: #ddd;
267254
border: none;
@@ -279,13 +266,11 @@ export default {
279266
font-weight: bold;
280267
}
281268
282-
.eslint-plugin-svelte__category .category-title,
283-
.eslint-plugin-svelte__rule a {
269+
.eslint-plugin-svelte-category .category-title {
284270
color: #40b3ff;
285271
}
286272
287-
.eslint-category .category-title,
288-
.eslint-rule a {
273+
.eslint-core-category .category-title {
289274
color: #8080f2;
290275
}
291276
@@ -303,11 +288,17 @@ export default {
303288
304289
.rule a {
305290
margin-left: auto;
306-
display: inline-flex;
307-
align-items: center;
308291
}
309292
310293
a {
311294
text-decoration: none;
312295
}
296+
297+
.eslint-core-rule a > svg {
298+
color: #8080f2;
299+
}
300+
301+
.eslint-plugin-svelte-rule a > svg {
302+
color: #40b3ff;
303+
}
313304
</style>

docs/.vuepress/components/demo/.eslintrc.js

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

0 commit comments

Comments
 (0)