textlint
Version:
The pluggable linting tool for natural language.
60 lines • 2.57 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextlintFixResultSchema = exports.TextlintResultSchema = exports.TextlintMessageSchema = void 0;
const zod_1 = require("zod");
/**
* Zod schema for TextlintMessage that matches the TextlintMessage interface
* from @textlint/types
*/
exports.TextlintMessageSchema = zod_1.z.object({
// Core properties
ruleId: zod_1.z.string().optional(),
message: zod_1.z.string(),
line: zod_1.z.number().describe("Line number (1-based)"),
column: zod_1.z.number().describe("Column number (1-based)"),
severity: zod_1.z.number().describe("Severity level: 1=warning, 2=error, 3=info"),
fix: zod_1.z
.object({
range: zod_1.z.array(zod_1.z.number()).describe("Text range [start, end] (0-based)"),
text: zod_1.z.string().describe("Replacement text")
})
.optional()
.describe("Fix suggestion if available"),
// Additional TextlintMessage properties
type: zod_1.z.string().optional().describe("Message type"),
data: zod_1.z.unknown().optional().describe("Optional data associated with the message"),
index: zod_1.z.number().optional().describe("Start index where the issue is located (0-based, deprecated)"),
range: zod_1.z.array(zod_1.z.number()).length(2).optional().describe("Text range [start, end] (0-based)"),
loc: zod_1.z
.object({
start: zod_1.z.object({
line: zod_1.z.number().describe("Start line number (1-based)"),
column: zod_1.z.number().describe("Start column number (1-based)")
}),
end: zod_1.z.object({
line: zod_1.z.number().describe("End line number (1-based)"),
column: zod_1.z.number().describe("End column number (1-based)")
})
})
.optional()
.describe("Location info where the issue is located")
});
/**
* Zod schema for TextlintResult
*/
exports.TextlintResultSchema = zod_1.z.object({
filePath: zod_1.z.string(),
messages: zod_1.z.array(exports.TextlintMessageSchema),
output: zod_1.z.string().optional().describe("Fixed content if available")
});
/**
* Zod schema for TextlintFixResult
*/
exports.TextlintFixResultSchema = zod_1.z.object({
filePath: zod_1.z.string(),
output: zod_1.z.string().describe("Fixed content"),
messages: zod_1.z.array(exports.TextlintMessageSchema),
applyingMessages: zod_1.z.array(exports.TextlintMessageSchema),
remainingMessages: zod_1.z.array(exports.TextlintMessageSchema)
});
//# sourceMappingURL=schemas.js.map