'use strict'; var eslintPluginUtils = require('eslint-plugin-utils'); var path = require('node:path'); var node_url = require('node:url'); var synckit = require('synckit'); var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); const base = { parser: "eslint-plugin-markup", plugins: ["markup", "utils"], processor: "utils/jsonMessage" }; const recommended = __spreadProps(__spreadValues({}, base), { rules: { "markup/markup": 1 } }); var configs = /*#__PURE__*/Object.freeze({ __proto__: null, base: base, recommended: recommended }); const parseForESLint = (text, _options) => { const lines = text.split("\n"); return { ast: { type: "Program", sourceType: "module", comments: [], tokens: [], body: [], range: [0, text.length], loc: { start: { line: 1, column: 0 }, end: { line: lines.length, column: lines[lines.length - 1].length } } } }; }; const parse = (text, options) => parseForESLint(text).ast; const import_meta = {}; const _dirname = typeof __dirname === "undefined" ? path.dirname(node_url.fileURLToPath(import_meta.url)) : __dirname; const workerPath = path.resolve(_dirname, "./worker.mjs"); const sync = { get markuplintSync() { return synckit.createSyncFn(workerPath); } }; const markup = { meta: { fixable: "code", type: "problem" }, create(context) { const filename = context.getFilename(); const sourceText = context.getSourceCode().text; const markuplintOptions = { sourceCode: sourceText, name: filename }; const runMarkuplint = (fix) => sync.markuplintSync(markuplintOptions, fix); return { Program() { const { violations } = runMarkuplint(); if (violations.length === 0) { return; } let fixed = 0; for (const { ruleId, severity, message, line, col } of violations) { context.report({ message: JSON.stringify({ severity, message, ruleId }), loc: { line, // ! eslint ast column is 0-indexed, but markuplint is 1-indexed column: col - 1 }, fix() { if (fixed++) { return null; } const { fixedCode } = runMarkuplint(true); return sourceText === fixedCode ? null : { range: [0, sourceText.length], text: fixedCode }; } }); } } }; } }; var index = /*#__PURE__*/Object.freeze({ __proto__: null, markup: markup }); const SEVERITIES = ["info", "warning", "error"]; eslintPluginUtils.registerJsonMessageHandler( "markup/markup", ({ ruleId, severity, message }, { severity: eslintSeverity }) => ({ ruleId: `markup/${ruleId}`, message, severity: Math.max( eslintSeverity, SEVERITIES.indexOf(severity) ) }) ); exports.configs = configs; exports.markup = markup; exports.parse = parse; exports.parseForESLint = parseForESLint; exports.rules = index;