Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { TextlintScriptMetadata } from "@textlint/script-parser";

export type MessageId = string;
export type TextlintWorkerCommandLint = {
id?: MessageId;
id: MessageId;
command: "lint";
text: string;
ext: string;
ruleId?: string;
};
export type TextlintWorkerCommandFix = {
id?: MessageId;
id: MessageId;
command: "fix";
text: string;
ext: string;
Expand All @@ -31,17 +31,17 @@ export type TextlintWorkerCommandResponseInit = {
metadata: TextlintScriptMetadata;
};
export type TextlintWorkerCommandResponseLint = {
id: MessageId | undefined;
id: MessageId;
command: "lint:result";
result: TextlintResult;
};
export type TextlintWorkerCommandResponseFix = {
id: MessageId | undefined;
id: MessageId;
command: "fix:result";
result: TextlintFixResult;
};
export type TextlintWorkerCommandResponseError = {
id?: MessageId | undefined;
id?: MessageId;
command: "error";
error: Error;
};
Expand Down Expand Up @@ -151,6 +151,12 @@ self.addEventListener('message', (event) => {
case "merge-config":
return assignConfig(data.textlintrc);
case "lint":
if (data.id === undefined) {
self.postMessage({
command: "error",
error: new TypeError("Property 'id' is missing but required for lint command message")
});
}
return kernel.lintText(data.text, {
rules: rules,
filterRules: config.filterRules,
Expand All @@ -174,6 +180,12 @@ self.addEventListener('message', (event) => {
})
});
case "fix":
if (data.id === undefined) {
self.postMessage({
command: "error",
error: new TypeError("Property 'id' is missing but required for fix command message")
});
}
return kernel.fixText(data.text, {
rules: rules,
filterRules: config.filterRules,
Expand Down