@@ -14,12 +14,9 @@ import { fromMarkdown } from "mdast-util-from-markdown";
1414//-----------------------------------------------------------------------------
1515
1616/**
17+ * @import { LintMessage, RuleTextEdit, SourceRange } from "@eslint/core";
1718 * @import { Node, Parent, Code, Html } from "mdast";
18- * @import { Linter, Rule, AST } from "eslint";
1919 * @import { Block, RangeMap } from "./types.js";
20- * @typedef {Linter.LintMessage } Message
21- * @typedef {Rule.Fix } Fix
22- * @typedef {AST.Range } Range
2320 */
2421
2522//-----------------------------------------------------------------------------
@@ -356,12 +353,12 @@ function preprocess(sourceText, filename) {
356353/**
357354 * Adjusts a fix in a code block.
358355 * @param {Block } block A code block.
359- * @param {Fix } fix A fix to adjust.
360- * @returns {Fix } The fix with adjusted ranges.
356+ * @param {RuleTextEdit } fix A fix to adjust.
357+ * @returns {RuleTextEdit } The fix with adjusted ranges.
361358 */
362359function adjustFix ( block , fix ) {
363360 return {
364- range : /** @type {Range } */ (
361+ range : /** @type {SourceRange } */ (
365362 fix . range . map ( range => {
366363 // Advance through the block's range map to find the last
367364 // matching range by finding the first range too far and
@@ -386,7 +383,7 @@ function adjustFix(block, fix) {
386383/**
387384 * Creates a map function that adjusts messages in a code block.
388385 * @param {Block } block A code block.
389- * @returns {(message: Message ) => Message } A function that adjusts messages in a code block.
386+ * @returns {(message: LintMessage ) => LintMessage | null } A function that adjusts messages in a code block.
390387 */
391388function adjustBlock ( block ) {
392389 const leadingCommentLines = block . comments . reduce (
@@ -398,8 +395,8 @@ function adjustBlock(block) {
398395
399396 /**
400397 * Adjusts ESLint messages to point to the correct location in the Markdown.
401- * @param {Message } message A message from ESLint.
402- * @returns {Message } The same message, but adjusted to the correct location.
398+ * @param {LintMessage } message A message from ESLint.
399+ * @returns {LintMessage } The same message, but adjusted to the correct location.
403400 */
404401 return function adjustMessage ( message ) {
405402 if ( ! Number . isInteger ( message . line ) ) {
@@ -416,7 +413,7 @@ function adjustBlock(block) {
416413 return null ;
417414 }
418415
419- /** @type {Pick<Message , "line" | "column" | "endLine" | "suggestions"> } */
416+ /** @type {Pick<LintMessage , "line" | "column" | "endLine" | "suggestions"> } */
420417 const out = {
421418 line : lineInCode + blockStart ,
422419 column : message . column + block . rangeMap [ lineInCode ] . indent ,
@@ -445,7 +442,7 @@ function adjustBlock(block) {
445442
446443/**
447444 * Excludes unsatisfiable rules from the list of messages.
448- * @param {Message } message A message from the linter.
445+ * @param {LintMessage } message A message from the linter.
449446 * @returns {boolean } True if the message should be included in output.
450447 */
451448function excludeUnsatisfiableRules ( message ) {
@@ -454,10 +451,10 @@ function excludeUnsatisfiableRules(message) {
454451
455452/**
456453 * Transforms generated messages for output.
457- * @param {Array<Message []> } messages An array containing one array of messages
454+ * @param {Array<LintMessage []> } messages An array containing one array of messages
458455 * for each code block returned from `preprocess`.
459456 * @param {string } filename The filename of the file
460- * @returns {Message [] } A flattened array of messages with mapped locations.
457+ * @returns {LintMessage [] } A flattened array of messages with mapped locations.
461458 */
462459function postprocess ( messages , filename ) {
463460 const blocks = blocksCache . get ( filename ) ;
0 commit comments