Skip to content

Commit c92b67e

Browse files
committed
fix
1 parent a6f3359 commit c92b67e

File tree

2 files changed

+96
-1
lines changed

2 files changed

+96
-1
lines changed

.github/workflows/website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Build
2323
run: |
2424
yarn install
25-
npm run website -- --metadataversion="${CURRENT_VERSION}"
25+
npm run website -- --metadataVersion="${CURRENT_VERSION}"
2626
env:
2727
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
2828
working-directory: example/
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Generated webworker code by textlint-script-compiler
2+
import { TextlintKernel } from "@textlint/kernel";
3+
import { moduleInterop } from "@textlint/module-interop";
4+
import { presetToKernelRules } from "@textlint/runtime-helper";
5+
import { parseOptionsFromConfig } from "@textlint/config-partial-parser";
6+
const kernel = new TextlintKernel();
7+
const presetRules = [
8+
presetToKernelRules(moduleInterop(require("textlint-rule-preset-jtf-style")), "preset-jtf-style")
9+
].flat();
10+
const rules = [];
11+
const filterRules = [];
12+
const plugins = [
13+
{
14+
pluginId: "@textlint/text",
15+
plugin: moduleInterop(require("@textlint/textlint-plugin-text")),
16+
options: true
17+
},
18+
{
19+
pluginId: "@textlint/markdown",
20+
plugin: moduleInterop(require("@textlint/textlint-plugin-markdown")),
21+
options: true
22+
}
23+
];
24+
const allRules = rules.concat(presetRules);
25+
const config = {
26+
rules: allRules,
27+
filterRules: filterRules,
28+
plugins: plugins
29+
};
30+
const assignConfig = (textlintrc) => {
31+
const userDefinedConfig = parseOptionsFromConfig(textlintrc);
32+
if (userDefinedConfig.rules) {
33+
config.rules = config.rules.map((rule) => {
34+
const override = userDefinedConfig.rules.find((o) => o.ruleId === rule.ruleId);
35+
return { ...rule, ...override };
36+
});
37+
}
38+
if (userDefinedConfig.filterRules) {
39+
config.filterRules = config.filterRules.map((rule) => {
40+
const override = userDefinedConfig.filterRules.find((o) => o.ruleId === rule.ruleId);
41+
return { ...rule, ...override };
42+
});
43+
}
44+
if (userDefinedConfig.plugins) {
45+
config.plugins = config.plugins.map((rule) => {
46+
const override = userDefinedConfig.plugins.find((o) => o.pluginId === rule.pluginId);
47+
return { ...rule, ...override };
48+
});
49+
}
50+
};
51+
self.addEventListener("message", (event) => {
52+
const data = event.data;
53+
const rules = data.ruleId === undefined ? config.rules : config.rules.filter((rule) => rule.ruleId === data.ruleId);
54+
switch (data.command) {
55+
case "merge-config":
56+
return assignConfig(data.textlintrc);
57+
case "lint":
58+
return kernel
59+
.lintText(data.text, {
60+
rules: rules,
61+
filterRules: config.filterRules,
62+
plugins: config.plugins,
63+
filePath: "/path/to/README" + data.ext,
64+
ext: data.ext
65+
})
66+
.then((result) => {
67+
return self.postMessage({
68+
command: "lint:result",
69+
result
70+
});
71+
});
72+
case "fix":
73+
return kernel
74+
.fixText(data.text, {
75+
rules: rules,
76+
filterRules: config.filterRules,
77+
plugins: config.plugins,
78+
filePath: "/path/to/README" + data.ext,
79+
ext: data.ext
80+
})
81+
.then((result) => {
82+
return self.postMessage({
83+
command: "fix:result",
84+
result
85+
});
86+
});
87+
default:
88+
console.log("Unknown command: " + data.command);
89+
}
90+
});
91+
// ====
92+
self.postMessage({
93+
command: "init",
94+
metadata: process.env.TEXTLINT_SCRIPT_METADATA
95+
});

0 commit comments

Comments
 (0)