Skip to content

Commit 08c4852

Browse files
committed
fix demo site
1 parent 79d445f commit 08c4852

File tree

10 files changed

+64
-49
lines changed

10 files changed

+64
-49
lines changed

.github/workflows/GHPages.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ on:
66

77
jobs:
88
deploy-docs:
9-
runs-on: ubuntu-latest
9+
runs-on: macos-latest
1010
steps:
1111
- uses: actions/checkout@v3
1212
- uses: actions/setup-node@v3
13+
with:
14+
node-version: 18.x
1315
- name: Install Packages
1416
run: yarn
1517
- name: Build docs
16-
run: yarn docs:build
18+
run: |+
19+
export NODE_OPTIONS=--openssl-legacy-provider
20+
yarn docs:build
1721
- name: Deploy
1822
uses: peaceiris/actions-gh-pages@v3
1923
with:

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<script>
1919
import EslintEditor from "vue-eslint-editor";
20+
import { Linter } from "eslint/lib/linter";
2021
import plugin from "../../../..";
2122
2223
export default {
@@ -58,7 +59,6 @@ export default {
5859
5960
data() {
6061
return {
61-
eslint4b: null,
6262
jsoncESLintParser: null,
6363
yamlESLintParser: null,
6464
tomlESLintParser: null,
@@ -108,15 +108,13 @@ export default {
108108
},
109109
linter() {
110110
if (
111-
!this.eslint4b ||
112111
!this.jsoncESLintParser ||
113112
!this.yamlESLintParser ||
114113
!this.tomlESLintParser ||
115114
!this.vueESLintParser
116115
) {
117116
return null;
118117
}
119-
const Linter = this.eslint4b;
120118
121119
const linter = new Linter();
122120
linter.defineParser("jsonc-eslint-parser", this.jsoncESLintParser);
@@ -136,19 +134,16 @@ export default {
136134
async mounted() {
137135
// Load linter asynchronously.
138136
const [
139-
{ default: eslint4b },
140137
jsoncESLintParser,
141138
yamlESLintParser,
142139
tomlESLintParser,
143140
vueESLintParser,
144141
] = await Promise.all([
145-
import("eslint4b"),
146142
import("jsonc-eslint-parser"),
147143
import("yaml-eslint-parser"),
148144
import("toml-eslint-parser"),
149145
import("espree").then(() => import("vue-eslint-parser")),
150146
]);
151-
this.eslint4b = eslint4b;
152147
this.jsoncESLintParser = jsoncESLintParser;
153148
this.yamlESLintParser = yamlESLintParser;
154149
this.tomlESLintParser = tomlESLintParser;

docs/.vuepress/components/components/SnsBar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default {
9292
align-items: flex-start;
9393
}
9494
95-
.sns-bar >>> .sns > * {
95+
.sns-bar :deep(.sns > *) {
9696
vertical-align: top !important;
9797
margin-left: 4px;
9898
height: 23px !important;

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
class="message"
3535
>
3636
[{{ msg.line }}:{{ msg.column }}]: {{ msg.message }} (<a
37-
:href="getURL(msg.ruleId)"
37+
:href="getRule(msg.ruleId).url"
3838
target="_blank"
3939
>
4040
{{ msg.ruleId }} </a
@@ -48,13 +48,11 @@
4848
</template>
4949

5050
<script>
51-
import * as coreRules from "../../../node_modules/eslint4b/dist/core-rules";
52-
import plugin from "../../..";
5351
import PgEditor from "./components/PgEditor.vue";
5452
import RulesSettings from "./components/RulesSettings.vue";
5553
import SnsBar from "./components/SnsBar.vue";
5654
import { deserializeState, serializeState } from "./state";
57-
import { DEFAULT_RULES_CONFIG } from "./rules";
55+
import { DEFAULT_RULES_CONFIG, getRule } from "./rules";
5856
5957
const DEFAULT_CODE = `{
6058
"extends": [ 42 ],
@@ -130,16 +128,6 @@ const VUE_CODE = `<i18n>
130128
${scriptEnd}
131129
`;
132130
133-
const ruleURLs = {};
134-
for (const k of Object.keys(plugin.rules)) {
135-
const rule = plugin.rules[k];
136-
ruleURLs[rule.meta.docs.ruleId] = rule.meta.docs.url;
137-
}
138-
for (const k of Object.keys(coreRules)) {
139-
const rule = coreRules[k];
140-
ruleURLs[k] = rule.meta.docs.url;
141-
}
142-
143131
export default {
144132
name: "PlaygroundBlock",
145133
components: { PgEditor, RulesSettings, SnsBar },
@@ -193,8 +181,8 @@ export default {
193181
onChange({ messages }) {
194182
this.messages = messages;
195183
},
196-
getURL(ruleId) {
197-
return ruleURLs[ruleId] || "";
184+
getRule(ruleId) {
185+
return getRule(ruleId);
198186
},
199187
onUrlHashChange() {
200188
const serializedString =

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

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
/* eslint node/no-unsupported-features/es-syntax: off -- not node */
2-
import * as coreRules from "../../../../node_modules/eslint4b/dist/core-rules";
2+
import { Linter } from "eslint/lib/linter";
33
// eslint-disable-next-line node/no-missing-import -- no build
44
import plugin from "../../../../";
55

6+
const coreRules = Object.fromEntries(new Linter().getRules());
7+
68
const CATEGORY_TITLES = {
79
recommended: "eslint-plugin-json-schema-validator",
8-
"eslint-core-rules@Possible Errors": "ESLint core rules(Possible Errors)",
9-
"eslint-core-rules@Best Practices": "ESLint core rules(Best Practices)",
10-
"eslint-core-rules@Strict Mode": "ESLint core rules(Strict Mode)",
11-
"eslint-core-rules@Variables": "ESLint core rules(Variables)",
12-
"eslint-core-rules@Node.js and CommonJS":
13-
"ESLint core rules(Node.js and CommonJS)",
14-
"eslint-core-rules@Stylistic Issues": "ESLint core rules(Stylistic Issues)",
15-
"eslint-core-rules@ECMAScript 6": "ESLint core rules(ECMAScript 6)",
10+
"eslint-core-rules@problem": "ESLint core rules(Possible Errors)",
11+
"eslint-core-rules@suggestion": "ESLint core rules(Suggestions)",
12+
"eslint-core-rules@layout": "ESLint core rules(Layout & Formatting)",
1613
};
1714
const CATEGORY_INDEX = {
1815
recommended: 2,
19-
"eslint-core-rules@Possible Errors": 6,
20-
"eslint-core-rules@Best Practices": 7,
21-
"eslint-core-rules@Strict Mode": 8,
22-
"eslint-core-rules@Variables": 9,
23-
"eslint-core-rules@Node.js and CommonJS": 10,
24-
"eslint-core-rules@Stylistic Issues": 11,
25-
"eslint-core-rules@ECMAScript 6": 12,
16+
"eslint-core-rules@problem": 20,
17+
"eslint-core-rules@suggestion": 21,
18+
"eslint-core-rules@layout": 22,
2619
};
2720
const CATEGORY_CLASSES = {
2821
recommended: "eslint-plugin-json-schema-validator__category",
22+
"eslint-core-rules@problem": "eslint-core-category",
23+
"eslint-core-rules@suggestion": "eslint-core-category",
24+
"eslint-core-rules@layout": "eslint-core-category",
2925
};
3026

3127
const allRules = [];
@@ -43,11 +39,12 @@ for (const k of Object.keys(plugin.rules)) {
4339
rule.meta.docs.categories.includes("recommended"),
4440
});
4541
}
42+
4643
for (const k of Object.keys(coreRules)) {
4744
const rule = coreRules[k];
4845
allRules.push({
49-
category: `eslint-core-rules@${rule.meta.docs.category}`,
50-
fallbackTitle: `ESLint core rules(${rule.meta.docs.category})`,
46+
classes: "eslint-core-rule",
47+
category: `eslint-core-rules@${rule.meta.type}`,
5148
ruleId: k,
5249
url: rule.meta.docs.url,
5350
initChecked: false, // rule.meta.docs.recommended,
@@ -104,3 +101,21 @@ export const DEFAULT_RULES_CONFIG = allRules.reduce((c, r) => {
104101
}, {});
105102

106103
export const rules = allRules;
104+
105+
export function getRule(ruleId) {
106+
if (!ruleId) {
107+
return { url: "" };
108+
}
109+
for (const category of categories) {
110+
for (const rule of category.rules) {
111+
if (rule.ruleId === ruleId) {
112+
return rule;
113+
}
114+
}
115+
}
116+
return {
117+
ruleId,
118+
url: "",
119+
classes: "",
120+
};
121+
}

docs/.vuepress/config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = {
3131
http: require.resolve("./shim/empty"),
3232
https: require.resolve("./shim/empty"),
3333
"json-schema-migrate": require.resolve("./shim/empty"),
34-
eslint: path.resolve(__dirname, "./shim/eslint"),
34+
eslint$: path.resolve(__dirname, "./shim/eslint"),
3535
ajv: path.resolve(
3636
require.resolve("eslint/package.json"),
3737
"../node_modules/ajv"
@@ -46,6 +46,16 @@ module.exports = {
4646
__dirname,
4747
"../../node_modules/yaml/dist/index.js"
4848
),
49+
// Adjust the esquery path as it gets confusing.
50+
esquery: path.resolve(
51+
__dirname,
52+
"../../node_modules/esquery/dist/esquery.min.js"
53+
),
54+
// Adjust the @eslint/eslintrc path as it gets confusing.
55+
"@eslint/eslintrc/universal": path.resolve(
56+
__dirname,
57+
"../../node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs"
58+
),
4959
},
5060
},
5161
};

docs/.vuepress/enhanceApp.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,11 @@ export default () =>
1111
if (typeof window.global === "undefined") {
1212
window.global = {};
1313
}
14+
if (typeof window.process === "undefined") {
15+
window.process = {
16+
env: {},
17+
cwd: () => undefined,
18+
};
19+
}
1420
}
1521
};
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const Linter = require("eslint4b");
21
const SourceCode =
32
require("../../../../node_modules/eslint/lib/source-code/index").SourceCode;
4-
class CLIEngine {}
5-
module.exports = { Linter, CLIEngine, SourceCode };
3+
module.exports = { SourceCode };

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
"eslint-plugin-toml": "^0.3.0",
8888
"eslint-plugin-vue": "^9.0.0",
8989
"eslint-plugin-yml": "^1.0.0",
90-
"eslint4b": "^7.3.1",
9190
"espree": "^9.0.0",
9291
"mocha": "^10.0.0",
9392
"monaco-editor": "^0.33.0",

src/utils/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function loadJsonFromURL<T>(
9494
if (!RELOADING.has(jsonFilePath)) {
9595
RELOADING.add(jsonFilePath)
9696
// eslint-disable-next-line @typescript-eslint/no-floating-promises -- ignore
97-
get(jsonFilePath, httpRequestOptions, httpGetModulePath).then(
97+
get(jsonPath, httpRequestOptions, httpGetModulePath).then(
9898
(json) => {
9999
postProcess(jsonPath, jsonFilePath, json, context, edit)
100100
RELOADING.delete(jsonFilePath)

0 commit comments

Comments
 (0)