Skip to content

Commit 18c9e37

Browse files
committed
use yarn
1 parent ad07939 commit 18c9e37

File tree

5 files changed

+4317
-3
lines changed

5 files changed

+4317
-3
lines changed

.github/workflows/website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: yarn install
2424
- name: Build
2525
run: |
26-
npm install
26+
yarn install
2727
npm run website -- --metadataversion="${CURRENT_VERSION}"
2828
env:
2929
OWNER_NAME: ${{ env.OWNER_NAME }}

example/.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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-ja-technical-writing')), 'preset-ja-technical-writing')
9+
].flat();
10+
const rules = [];
11+
const filterRules = [
12+
{
13+
"ruleId": "comments",
14+
"rule": moduleInterop(require('textlint-filter-rule-comments')),
15+
"options": true
16+
}
17+
];
18+
const plugins = [
19+
{
20+
"pluginId": "@textlint/text",
21+
"plugin": moduleInterop(require('@textlint/textlint-plugin-text')),
22+
"options": true
23+
},
24+
{
25+
"pluginId": "@textlint/markdown",
26+
"plugin": moduleInterop(require('@textlint/textlint-plugin-markdown')),
27+
"options": true
28+
}
29+
];
30+
const allRules = rules.concat(presetRules);
31+
const config = {
32+
rules: allRules,
33+
filterRules: filterRules,
34+
plugins: plugins
35+
};
36+
const assignConfig = (textlintrc) => {
37+
const userDefinedConfig = parseOptionsFromConfig(textlintrc);
38+
if (userDefinedConfig.rules) {
39+
config.rules = config.rules.map(rule => {
40+
const override = userDefinedConfig.rules.find(o => o.ruleId === rule.ruleId);
41+
return { ...rule, ...override };
42+
});
43+
}
44+
if (userDefinedConfig.filterRules) {
45+
config.filterRules = config.filterRules.map(rule => {
46+
const override = userDefinedConfig.filterRules.find(o => o.ruleId === rule.ruleId);
47+
return { ...rule, ...override };
48+
});
49+
}
50+
if (userDefinedConfig.plugins) {
51+
config.plugins = config.plugins.map(rule => {
52+
const override = userDefinedConfig.plugins.find(o => o.pluginId === rule.pluginId);
53+
return { ...rule, ...override };
54+
});
55+
}
56+
};
57+
self.addEventListener('message', (event) => {
58+
const data = event.data;
59+
const rules = data.ruleId === undefined
60+
? config.rules
61+
: config.rules.filter(rule => rule.ruleId === data.ruleId);
62+
switch (data.command) {
63+
case "merge-config":
64+
return assignConfig(data.textlintrc);
65+
case "lint":
66+
return kernel.lintText(data.text, {
67+
rules: rules,
68+
filterRules: config.filterRules,
69+
plugins: config.plugins,
70+
filePath: "/path/to/README" + data.ext,
71+
ext: data.ext,
72+
}).then(result => {
73+
return self.postMessage({
74+
command: "lint:result",
75+
result
76+
});
77+
});
78+
case "fix":
79+
return kernel.fixText(data.text, {
80+
rules: rules,
81+
filterRules: config.filterRules,
82+
plugins: config.plugins,
83+
filePath: "/path/to/README" + data.ext,
84+
ext: data.ext,
85+
}).then(result => {
86+
return self.postMessage({
87+
command: "fix:result",
88+
result
89+
});
90+
});
91+
default:
92+
console.log("Unknown command: " + data.command);
93+
}
94+
});
95+
// ====
96+
self.postMessage({
97+
command: "init",
98+
metadata: process.env.TEXTLINT_SCRIPT_METADATA
99+
});

0 commit comments

Comments
 (0)