Skip to content

Commit

Permalink
fix demo site
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Jul 21, 2022
1 parent 79d445f commit 08c4852
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 49 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/GHPages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ on:

jobs:
deploy-docs:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install Packages
run: yarn
- name: Build docs
run: yarn docs:build
run: |+
export NODE_OPTIONS=--openssl-legacy-provider
yarn docs:build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
7 changes: 1 addition & 6 deletions docs/.vuepress/components/components/EslintPluginEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<script>
import EslintEditor from "vue-eslint-editor";
import { Linter } from "eslint/lib/linter";
import plugin from "../../../..";
export default {
Expand Down Expand Up @@ -58,7 +59,6 @@ export default {
data() {
return {
eslint4b: null,
jsoncESLintParser: null,
yamlESLintParser: null,
tomlESLintParser: null,
Expand Down Expand Up @@ -108,15 +108,13 @@ export default {
},
linter() {
if (
!this.eslint4b ||
!this.jsoncESLintParser ||
!this.yamlESLintParser ||
!this.tomlESLintParser ||
!this.vueESLintParser
) {
return null;
}
const Linter = this.eslint4b;
const linter = new Linter();
linter.defineParser("jsonc-eslint-parser", this.jsoncESLintParser);
Expand All @@ -136,19 +134,16 @@ export default {
async mounted() {
// Load linter asynchronously.
const [
{ default: eslint4b },
jsoncESLintParser,
yamlESLintParser,
tomlESLintParser,
vueESLintParser,
] = await Promise.all([
import("eslint4b"),
import("jsonc-eslint-parser"),
import("yaml-eslint-parser"),
import("toml-eslint-parser"),
import("espree").then(() => import("vue-eslint-parser")),
]);
this.eslint4b = eslint4b;
this.jsoncESLintParser = jsoncESLintParser;
this.yamlESLintParser = yamlESLintParser;
this.tomlESLintParser = tomlESLintParser;
Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/components/components/SnsBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default {
align-items: flex-start;
}
.sns-bar >>> .sns > * {
.sns-bar :deep(.sns > *) {
vertical-align: top !important;
margin-left: 4px;
height: 23px !important;
Expand Down
20 changes: 4 additions & 16 deletions docs/.vuepress/components/playground-block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
class="message"
>
[{{ msg.line }}:{{ msg.column }}]: {{ msg.message }} (<a
:href="getURL(msg.ruleId)"
:href="getRule(msg.ruleId).url"
target="_blank"
>
{{ msg.ruleId }} </a
Expand All @@ -48,13 +48,11 @@
</template>

<script>
import * as coreRules from "../../../node_modules/eslint4b/dist/core-rules";
import plugin from "../../..";
import PgEditor from "./components/PgEditor.vue";
import RulesSettings from "./components/RulesSettings.vue";
import SnsBar from "./components/SnsBar.vue";
import { deserializeState, serializeState } from "./state";
import { DEFAULT_RULES_CONFIG } from "./rules";
import { DEFAULT_RULES_CONFIG, getRule } from "./rules";
const DEFAULT_CODE = `{
"extends": [ 42 ],
Expand Down Expand Up @@ -130,16 +128,6 @@ const VUE_CODE = `<i18n>
${scriptEnd}
`;
const ruleURLs = {};
for (const k of Object.keys(plugin.rules)) {
const rule = plugin.rules[k];
ruleURLs[rule.meta.docs.ruleId] = rule.meta.docs.url;
}
for (const k of Object.keys(coreRules)) {
const rule = coreRules[k];
ruleURLs[k] = rule.meta.docs.url;
}
export default {
name: "PlaygroundBlock",
components: { PgEditor, RulesSettings, SnsBar },
Expand Down Expand Up @@ -193,8 +181,8 @@ export default {
onChange({ messages }) {
this.messages = messages;
},
getURL(ruleId) {
return ruleURLs[ruleId] || "";
getRule(ruleId) {
return getRule(ruleId);
},
onUrlHashChange() {
const serializedString =
Expand Down
51 changes: 33 additions & 18 deletions docs/.vuepress/components/rules/index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
/* eslint node/no-unsupported-features/es-syntax: off -- not node */
import * as coreRules from "../../../../node_modules/eslint4b/dist/core-rules";
import { Linter } from "eslint/lib/linter";
// eslint-disable-next-line node/no-missing-import -- no build
import plugin from "../../../../";

const coreRules = Object.fromEntries(new Linter().getRules());

const CATEGORY_TITLES = {
recommended: "eslint-plugin-json-schema-validator",
"eslint-core-rules@Possible Errors": "ESLint core rules(Possible Errors)",
"eslint-core-rules@Best Practices": "ESLint core rules(Best Practices)",
"eslint-core-rules@Strict Mode": "ESLint core rules(Strict Mode)",
"eslint-core-rules@Variables": "ESLint core rules(Variables)",
"[email protected] and CommonJS":
"ESLint core rules(Node.js and CommonJS)",
"eslint-core-rules@Stylistic Issues": "ESLint core rules(Stylistic Issues)",
"eslint-core-rules@ECMAScript 6": "ESLint core rules(ECMAScript 6)",
"eslint-core-rules@problem": "ESLint core rules(Possible Errors)",
"eslint-core-rules@suggestion": "ESLint core rules(Suggestions)",
"eslint-core-rules@layout": "ESLint core rules(Layout & Formatting)",
};
const CATEGORY_INDEX = {
recommended: 2,
"eslint-core-rules@Possible Errors": 6,
"eslint-core-rules@Best Practices": 7,
"eslint-core-rules@Strict Mode": 8,
"eslint-core-rules@Variables": 9,
"[email protected] and CommonJS": 10,
"eslint-core-rules@Stylistic Issues": 11,
"eslint-core-rules@ECMAScript 6": 12,
"eslint-core-rules@problem": 20,
"eslint-core-rules@suggestion": 21,
"eslint-core-rules@layout": 22,
};
const CATEGORY_CLASSES = {
recommended: "eslint-plugin-json-schema-validator__category",
"eslint-core-rules@problem": "eslint-core-category",
"eslint-core-rules@suggestion": "eslint-core-category",
"eslint-core-rules@layout": "eslint-core-category",
};

const allRules = [];
Expand All @@ -43,11 +39,12 @@ for (const k of Object.keys(plugin.rules)) {
rule.meta.docs.categories.includes("recommended"),
});
}

for (const k of Object.keys(coreRules)) {
const rule = coreRules[k];
allRules.push({
category: `eslint-core-rules@${rule.meta.docs.category}`,
fallbackTitle: `ESLint core rules(${rule.meta.docs.category})`,
classes: "eslint-core-rule",
category: `eslint-core-rules@${rule.meta.type}`,
ruleId: k,
url: rule.meta.docs.url,
initChecked: false, // rule.meta.docs.recommended,
Expand Down Expand Up @@ -104,3 +101,21 @@ export const DEFAULT_RULES_CONFIG = allRules.reduce((c, r) => {
}, {});

export const rules = allRules;

export function getRule(ruleId) {
if (!ruleId) {
return { url: "" };
}
for (const category of categories) {
for (const rule of category.rules) {
if (rule.ruleId === ruleId) {
return rule;
}
}
}
return {
ruleId,
url: "",
classes: "",
};
}
12 changes: 11 additions & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
http: require.resolve("./shim/empty"),
https: require.resolve("./shim/empty"),
"json-schema-migrate": require.resolve("./shim/empty"),
eslint: path.resolve(__dirname, "./shim/eslint"),
eslint$: path.resolve(__dirname, "./shim/eslint"),
ajv: path.resolve(
require.resolve("eslint/package.json"),
"../node_modules/ajv"
Expand All @@ -46,6 +46,16 @@ module.exports = {
__dirname,
"../../node_modules/yaml/dist/index.js"
),
// Adjust the esquery path as it gets confusing.
esquery: path.resolve(
__dirname,
"../../node_modules/esquery/dist/esquery.min.js"
),
// Adjust the @eslint/eslintrc path as it gets confusing.
"@eslint/eslintrc/universal": path.resolve(
__dirname,
"../../node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs"
),
},
},
};
Expand Down
6 changes: 6 additions & 0 deletions docs/.vuepress/enhanceApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ export default () =>
if (typeof window.global === "undefined") {
window.global = {};
}
if (typeof window.process === "undefined") {
window.process = {
env: {},
cwd: () => undefined,
};
}
}
};
4 changes: 1 addition & 3 deletions docs/.vuepress/shim/eslint/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const Linter = require("eslint4b");
const SourceCode =
require("../../../../node_modules/eslint/lib/source-code/index").SourceCode;
class CLIEngine {}
module.exports = { Linter, CLIEngine, SourceCode };
module.exports = { SourceCode };
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"eslint-plugin-toml": "^0.3.0",
"eslint-plugin-vue": "^9.0.0",
"eslint-plugin-yml": "^1.0.0",
"eslint4b": "^7.3.1",
"espree": "^9.0.0",
"mocha": "^10.0.0",
"monaco-editor": "^0.33.0",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function loadJsonFromURL<T>(
if (!RELOADING.has(jsonFilePath)) {
RELOADING.add(jsonFilePath)
// eslint-disable-next-line @typescript-eslint/no-floating-promises -- ignore
get(jsonFilePath, httpRequestOptions, httpGetModulePath).then(
get(jsonPath, httpRequestOptions, httpGetModulePath).then(
(json) => {
postProcess(jsonPath, jsonFilePath, json, context, edit)
RELOADING.delete(jsonFilePath)
Expand Down

0 comments on commit 08c4852

Please sign in to comment.