feat: init
This commit is contained in:
18
node_modules/vite-plugin-checker/dist/checkers/oxlint/cli.d.ts
generated
vendored
Normal file
18
node_modules/vite-plugin-checker/dist/checkers/oxlint/cli.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { NormalizedDiagnostic } from '../../logger.js';
|
||||
import { DiagnosticLevel } from '../../types.js';
|
||||
import '@babel/code-frame';
|
||||
import 'eslint';
|
||||
import 'stylelint';
|
||||
import 'typescript';
|
||||
import 'vscode-languageclient/node';
|
||||
import 'node:worker_threads';
|
||||
import 'vite';
|
||||
import '../vls/initParams.js';
|
||||
import 'vscode-languageserver/node';
|
||||
import 'vscode-uri';
|
||||
|
||||
declare function mapSeverity(s: string): DiagnosticLevel;
|
||||
declare function getOxlintCommand(command: string): string[];
|
||||
declare function runOxlint(command: string, cwd: string): Promise<NormalizedDiagnostic[]>;
|
||||
|
||||
export { getOxlintCommand, mapSeverity, runOxlint };
|
||||
135
node_modules/vite-plugin-checker/dist/checkers/oxlint/cli.js
generated
vendored
Normal file
135
node_modules/vite-plugin-checker/dist/checkers/oxlint/cli.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
import { exec } from "node:child_process";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { stripVTControlCharacters as strip } from "node:util";
|
||||
import colors from "picocolors";
|
||||
import { createFrame, offsetRangeToBabelLocation } from "../../codeFrame.js";
|
||||
import { consoleLog } from "../../logger.js";
|
||||
import { DiagnosticLevel } from "../../types.js";
|
||||
import { parseArgsStringToArgv } from "../stylelint/argv.js";
|
||||
const severityMap = {
|
||||
error: DiagnosticLevel.Error,
|
||||
warning: DiagnosticLevel.Warning,
|
||||
info: DiagnosticLevel.Suggestion
|
||||
};
|
||||
function mapSeverity(s) {
|
||||
return severityMap[s] ?? DiagnosticLevel.Error;
|
||||
}
|
||||
function getOxlintCommand(command) {
|
||||
const parsed = parseArgsStringToArgv(command);
|
||||
const index = parsed.findIndex((p) => p === "--format" || p === "-f");
|
||||
if (index === -1) {
|
||||
parsed.push("--format", "json");
|
||||
} else {
|
||||
consoleLog(
|
||||
colors.yellow(
|
||||
`vite-plugin-checker will force append "--format json" to the flags in dev mode, please don't use "--format" or "-f" flag in "config.oxlint.lintCommand".`
|
||||
),
|
||||
"warn"
|
||||
);
|
||||
parsed.splice(index, 2, "--format", "json");
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
function runOxlint(command, cwd) {
|
||||
return new Promise((resolve, _reject) => {
|
||||
exec(
|
||||
command,
|
||||
{
|
||||
cwd,
|
||||
maxBuffer: Number.POSITIVE_INFINITY
|
||||
},
|
||||
(_error, stdout, _stderr) => {
|
||||
parseOxlintOutput(stdout, cwd).then(resolve).catch(() => resolve([]));
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
async function parseOxlintOutput(output, cwd) {
|
||||
const parsed = safeParseOxlint(output);
|
||||
if (!parsed) return [];
|
||||
const entries = getEntries(parsed, cwd);
|
||||
if (entries.length === 0) return [];
|
||||
const files = getUniqueFiles(entries);
|
||||
const sourceCache = await readSources(files);
|
||||
return buildDiagnostics(entries, sourceCache);
|
||||
}
|
||||
function safeParseOxlint(output) {
|
||||
try {
|
||||
return JSON.parse(output);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function getEntries(parsed, cwd) {
|
||||
return parsed.diagnostics.flatMap(
|
||||
({ filename, labels, code, message, severity }) => {
|
||||
const file = normalizePath(filename, cwd);
|
||||
const [label] = labels;
|
||||
if (!label) return [];
|
||||
return [
|
||||
{
|
||||
file,
|
||||
span: label.span,
|
||||
code,
|
||||
message,
|
||||
severity
|
||||
}
|
||||
];
|
||||
}
|
||||
);
|
||||
}
|
||||
function getUniqueFiles(entries) {
|
||||
return [...new Set(entries.map((e) => e.file))];
|
||||
}
|
||||
async function readSources(files) {
|
||||
const cache = /* @__PURE__ */ new Map();
|
||||
await Promise.all(
|
||||
files.map(async (file) => {
|
||||
try {
|
||||
const source = await fs.readFile(file, "utf8");
|
||||
cache.set(file, source);
|
||||
} catch {
|
||||
}
|
||||
})
|
||||
);
|
||||
return cache;
|
||||
}
|
||||
function buildDiagnostics(entries, sources) {
|
||||
return entries.flatMap((entry) => {
|
||||
const source = sources.get(entry.file);
|
||||
if (!source) return [];
|
||||
const loc = offsetRangeToBabelLocation(
|
||||
source,
|
||||
entry.span.offset,
|
||||
entry.span.length
|
||||
);
|
||||
const codeFrame = createFrame(source, loc);
|
||||
return [
|
||||
{
|
||||
message: `${entry.code}: ${entry.message}`,
|
||||
conclusion: "",
|
||||
level: mapSeverity(entry.severity),
|
||||
checker: "oxlint",
|
||||
id: entry.file,
|
||||
codeFrame,
|
||||
stripedCodeFrame: codeFrame && strip(codeFrame),
|
||||
loc
|
||||
}
|
||||
];
|
||||
});
|
||||
}
|
||||
function normalizePath(p, cwd) {
|
||||
let filename = p;
|
||||
if (filename) {
|
||||
filename = path.isAbsolute(filename) ? filename : path.resolve(cwd, filename);
|
||||
filename = path.normalize(filename);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
export {
|
||||
getOxlintCommand,
|
||||
mapSeverity,
|
||||
runOxlint
|
||||
};
|
||||
//# sourceMappingURL=cli.js.map
|
||||
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/cli.js.map
generated
vendored
Normal file
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/cli.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
18
node_modules/vite-plugin-checker/dist/checkers/oxlint/diagnostics.d.ts
generated
vendored
Normal file
18
node_modules/vite-plugin-checker/dist/checkers/oxlint/diagnostics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { NormalizedDiagnostic } from '../../logger.js';
|
||||
import { CreateDiagnostic } from '../../types.js';
|
||||
import { DisplayTarget } from './types.js';
|
||||
import '@babel/code-frame';
|
||||
import 'eslint';
|
||||
import 'stylelint';
|
||||
import 'typescript';
|
||||
import 'vscode-languageclient/node';
|
||||
import 'node:worker_threads';
|
||||
import 'vite';
|
||||
import '../vls/initParams.js';
|
||||
import 'vscode-languageserver/node';
|
||||
import 'vscode-uri';
|
||||
|
||||
declare const createDiagnostic: CreateDiagnostic<'oxlint'>;
|
||||
declare function dispatchDiagnostics(diagnostics: NormalizedDiagnostic[], targets: Set<DisplayTarget>): void;
|
||||
|
||||
export { createDiagnostic, dispatchDiagnostics };
|
||||
75
node_modules/vite-plugin-checker/dist/checkers/oxlint/diagnostics.js
generated
vendored
Normal file
75
node_modules/vite-plugin-checker/dist/checkers/oxlint/diagnostics.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
import { parentPort } from "node:worker_threads";
|
||||
import { FileDiagnosticManager } from "../../FileDiagnosticManager.js";
|
||||
import {
|
||||
composeCheckerSummary,
|
||||
consoleLog,
|
||||
diagnosticToConsoleLevel,
|
||||
diagnosticToRuntimeError,
|
||||
diagnosticToTerminalLog,
|
||||
toClientPayload
|
||||
} from "../../logger.js";
|
||||
import {
|
||||
ACTION_TYPES,
|
||||
DiagnosticLevel
|
||||
} from "../../types.js";
|
||||
import { resolveOptions } from "./options.js";
|
||||
import { setupDevServer } from "./server.js";
|
||||
const createDiagnostic = (pluginConfig) => {
|
||||
const manager = new FileDiagnosticManager();
|
||||
const oxlintConfig = pluginConfig.oxlint;
|
||||
const displayTargets = /* @__PURE__ */ new Set();
|
||||
return {
|
||||
config: async ({ enableOverlay, enableTerminal }) => {
|
||||
displayTargets.clear();
|
||||
if (enableOverlay) displayTargets.add("overlay");
|
||||
if (enableTerminal) displayTargets.add("terminal");
|
||||
},
|
||||
async configureServer({ root }) {
|
||||
if (!oxlintConfig) return;
|
||||
const options = resolveOptions(root, oxlintConfig);
|
||||
await setupDevServer(root, options, manager, displayTargets);
|
||||
}
|
||||
};
|
||||
};
|
||||
function dispatchDiagnostics(diagnostics, targets) {
|
||||
if (targets.size === 0) return;
|
||||
if (targets.has("terminal")) {
|
||||
dispatchTerminalDiagnostics(diagnostics);
|
||||
}
|
||||
if (targets.has("overlay")) {
|
||||
dispatchOverlayDiagnostics(diagnostics);
|
||||
}
|
||||
}
|
||||
function dispatchTerminalDiagnostics(diagnostics) {
|
||||
for (const d of diagnostics) {
|
||||
consoleLog(
|
||||
diagnosticToTerminalLog(d, "oxlint"),
|
||||
diagnosticToConsoleLevel(d)
|
||||
);
|
||||
}
|
||||
const errorCount = diagnostics.filter(
|
||||
(d) => d.level === DiagnosticLevel.Error
|
||||
).length;
|
||||
const warningCount = diagnostics.filter(
|
||||
(d) => d.level === DiagnosticLevel.Warning
|
||||
).length;
|
||||
consoleLog(
|
||||
composeCheckerSummary("oxlint", errorCount, warningCount),
|
||||
errorCount ? "error" : warningCount ? "warn" : "info"
|
||||
);
|
||||
}
|
||||
function dispatchOverlayDiagnostics(diagnostics) {
|
||||
var _a;
|
||||
(_a = parentPort) == null ? void 0 : _a.postMessage({
|
||||
type: ACTION_TYPES.overlayError,
|
||||
payload: toClientPayload(
|
||||
"oxlint",
|
||||
diagnostics.map((d) => diagnosticToRuntimeError(d))
|
||||
)
|
||||
});
|
||||
}
|
||||
export {
|
||||
createDiagnostic,
|
||||
dispatchDiagnostics
|
||||
};
|
||||
//# sourceMappingURL=diagnostics.js.map
|
||||
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/diagnostics.js.map
generated
vendored
Normal file
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/diagnostics.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/checkers/oxlint/diagnostics.ts"],"sourcesContent":["import { parentPort } from 'node:worker_threads'\nimport { FileDiagnosticManager } from '../../FileDiagnosticManager.js'\nimport {\n composeCheckerSummary,\n consoleLog,\n diagnosticToConsoleLevel,\n diagnosticToRuntimeError,\n diagnosticToTerminalLog,\n type NormalizedDiagnostic,\n toClientPayload,\n} from '../../logger.js'\nimport {\n ACTION_TYPES,\n type CreateDiagnostic,\n DiagnosticLevel,\n} from '../../types.js'\nimport { resolveOptions } from './options.js'\nimport { setupDevServer } from './server.js'\nimport type { DisplayTarget } from './types'\n\nexport const createDiagnostic: CreateDiagnostic<'oxlint'> = (pluginConfig) => {\n const manager = new FileDiagnosticManager()\n\n const oxlintConfig = pluginConfig.oxlint\n const displayTargets = new Set<DisplayTarget>()\n\n return {\n config: async ({ enableOverlay, enableTerminal }) => {\n displayTargets.clear()\n if (enableOverlay) displayTargets.add('overlay')\n if (enableTerminal) displayTargets.add('terminal')\n },\n async configureServer({ root }) {\n if (!oxlintConfig) return\n\n const options = resolveOptions(root, oxlintConfig)\n await setupDevServer(root, options, manager, displayTargets)\n },\n }\n}\n\nexport function dispatchDiagnostics(\n diagnostics: NormalizedDiagnostic[],\n targets: Set<DisplayTarget>,\n) {\n if (targets.size === 0) return\n\n if (targets.has('terminal')) {\n dispatchTerminalDiagnostics(diagnostics)\n }\n if (targets.has('overlay')) {\n dispatchOverlayDiagnostics(diagnostics)\n }\n}\n\nfunction dispatchTerminalDiagnostics(diagnostics: NormalizedDiagnostic[]) {\n for (const d of diagnostics) {\n consoleLog(\n diagnosticToTerminalLog(d, 'oxlint'),\n diagnosticToConsoleLevel(d),\n )\n }\n\n const errorCount = diagnostics.filter(\n (d) => d.level === DiagnosticLevel.Error,\n ).length\n const warningCount = diagnostics.filter(\n (d) => d.level === DiagnosticLevel.Warning,\n ).length\n consoleLog(\n composeCheckerSummary('oxlint', errorCount, warningCount),\n errorCount ? 'error' : warningCount ? 'warn' : 'info',\n )\n}\n\nfunction dispatchOverlayDiagnostics(diagnostics: NormalizedDiagnostic[]) {\n parentPort?.postMessage({\n type: ACTION_TYPES.overlayError,\n payload: toClientPayload(\n 'oxlint',\n diagnostics.map((d) => diagnosticToRuntimeError(d)),\n ),\n })\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EAEA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ACnB,SAAS;AAAA,MACP;AAAA,MACA,YAAY,IAAI,CAAC,MAAM,yBAAyB,CAAC,CAAC;AAAA,IACpD;AAAA,EACF;AACF;","names":[]}
|
||||
17
node_modules/vite-plugin-checker/dist/checkers/oxlint/main.d.ts
generated
vendored
Normal file
17
node_modules/vite-plugin-checker/dist/checkers/oxlint/main.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { ServeAndBuildChecker } from '../../types.js';
|
||||
import * as vite from 'vite';
|
||||
import { Checker } from '../../Checker.js';
|
||||
import 'node:worker_threads';
|
||||
import 'eslint';
|
||||
import 'stylelint';
|
||||
import '../vls/initParams.js';
|
||||
import 'vscode-languageserver/node';
|
||||
import 'vscode-uri';
|
||||
import '../../worker.js';
|
||||
|
||||
declare class OxlintChecker extends Checker<'oxlint'> {
|
||||
constructor();
|
||||
}
|
||||
declare const createServeAndBuild: ((config: any, env: vite.ConfigEnv) => ServeAndBuildChecker) | undefined;
|
||||
|
||||
export { OxlintChecker, createServeAndBuild };
|
||||
30
node_modules/vite-plugin-checker/dist/checkers/oxlint/main.js
generated
vendored
Normal file
30
node_modules/vite-plugin-checker/dist/checkers/oxlint/main.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { Checker } from "../../Checker.js";
|
||||
import parseArgsStringToArgv from "../stylelint/argv.js";
|
||||
import { createDiagnostic } from "./diagnostics.js";
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
class OxlintChecker extends Checker {
|
||||
constructor() {
|
||||
super({
|
||||
name: "oxlint",
|
||||
absFilePath: __filename,
|
||||
build: {
|
||||
buildBin: ({ oxlint: oxlint2 }) => {
|
||||
const commandStr = typeof oxlint2 === "boolean" ? "oxlint" : (oxlint2 == null ? void 0 : oxlint2.lintCommand) ?? "oxlint";
|
||||
const command = parseArgsStringToArgv(commandStr);
|
||||
return [command[0], command.slice(1)];
|
||||
}
|
||||
},
|
||||
createDiagnostic
|
||||
});
|
||||
}
|
||||
}
|
||||
const oxlint = new OxlintChecker();
|
||||
oxlint.prepare();
|
||||
oxlint.initWorkerThread();
|
||||
const createServeAndBuild = oxlint.initMainThread();
|
||||
export {
|
||||
OxlintChecker,
|
||||
createServeAndBuild
|
||||
};
|
||||
//# sourceMappingURL=main.js.map
|
||||
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/main.js.map
generated
vendored
Normal file
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/main.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/checkers/oxlint/main.ts"],"sourcesContent":["import { fileURLToPath } from 'node:url'\nimport { Checker } from '../../Checker.js'\nimport parseArgsStringToArgv from '../stylelint/argv.js'\nimport { createDiagnostic } from './diagnostics.js'\n\nconst __filename = fileURLToPath(import.meta.url)\n\nexport class OxlintChecker extends Checker<'oxlint'> {\n public constructor() {\n super({\n name: 'oxlint',\n absFilePath: __filename,\n build: {\n buildBin: ({ oxlint }) => {\n const commandStr =\n typeof oxlint === 'boolean'\n ? 'oxlint'\n : (oxlint?.lintCommand ?? 'oxlint')\n const command = parseArgsStringToArgv(commandStr)\n return [command[0]!, command.slice(1)]\n },\n },\n createDiagnostic,\n })\n }\n}\n\nconst oxlint = new OxlintChecker()\noxlint.prepare()\noxlint.initWorkerThread()\n\nexport const createServeAndBuild = oxlint.initMainThread()\n"],"mappings":"AAAA,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,OAAO,2BAA2B;AAClC,SAAS,wBAAwB;AAEjC,MAAM,aAAa,cAAc,YAAY,GAAG;AAEzC,MAAM,sBAAsB,QAAkB;AAAA,EAC5C,cAAc;AACnB,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,aAAa;AAAA,MACb,OAAO;AAAA,QACL,UAAU,CAAC,EAAE,QAAAA,QAAO,MAAM;AACxB,gBAAM,aACJ,OAAOA,YAAW,YACd,YACCA,WAAA,gBAAAA,QAAQ,gBAAe;AAC9B,gBAAM,UAAU,sBAAsB,UAAU;AAChD,iBAAO,CAAC,QAAQ,CAAC,GAAI,QAAQ,MAAM,CAAC,CAAC;AAAA,QACvC;AAAA,MACF;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEA,MAAM,SAAS,IAAI,cAAc;AACjC,OAAO,QAAQ;AACf,OAAO,iBAAiB;AAEjB,MAAM,sBAAsB,OAAO,eAAe;","names":["oxlint"]}
|
||||
17
node_modules/vite-plugin-checker/dist/checkers/oxlint/options.d.ts
generated
vendored
Normal file
17
node_modules/vite-plugin-checker/dist/checkers/oxlint/options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { DiagnosticLevel, OxlintConfig } from '../../types.js';
|
||||
import 'node:worker_threads';
|
||||
import 'eslint';
|
||||
import 'stylelint';
|
||||
import 'vite';
|
||||
import '../vls/initParams.js';
|
||||
import 'vscode-languageserver/node';
|
||||
import 'vscode-uri';
|
||||
|
||||
interface ResolvedOptions {
|
||||
watchTarget: string | string[];
|
||||
logLevel?: DiagnosticLevel[];
|
||||
command: string;
|
||||
}
|
||||
declare function resolveOptions(root: string, config: Exclude<OxlintConfig, false>): ResolvedOptions;
|
||||
|
||||
export { type ResolvedOptions, resolveOptions };
|
||||
22
node_modules/vite-plugin-checker/dist/checkers/oxlint/options.js
generated
vendored
Normal file
22
node_modules/vite-plugin-checker/dist/checkers/oxlint/options.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import path from "node:path";
|
||||
import { DiagnosticLevel } from "../../types.js";
|
||||
import { getOxlintCommand, mapSeverity } from "./cli.js";
|
||||
function resolveOptions(root, config) {
|
||||
var _a, _b;
|
||||
const options = config === true ? { lintCommand: "oxlint" } : config;
|
||||
return {
|
||||
watchTarget: resolveWatchTarget(root, options.watchPath),
|
||||
logLevel: ((_b = (_a = options.dev) == null ? void 0 : _a.logLevel) == null ? void 0 : _b.map((l) => mapSeverity(l))) ?? [
|
||||
DiagnosticLevel.Warning,
|
||||
DiagnosticLevel.Error
|
||||
],
|
||||
command: getOxlintCommand(options.lintCommand ?? "oxlint").join(" ")
|
||||
};
|
||||
}
|
||||
function resolveWatchTarget(root, watchPath) {
|
||||
return Array.isArray(watchPath) ? watchPath.map((p) => path.resolve(root, p)) : typeof watchPath === "string" ? path.resolve(root, watchPath) : root;
|
||||
}
|
||||
export {
|
||||
resolveOptions
|
||||
};
|
||||
//# sourceMappingURL=options.js.map
|
||||
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/options.js.map
generated
vendored
Normal file
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/options.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/checkers/oxlint/options.ts"],"sourcesContent":["import path from 'node:path'\nimport { DiagnosticLevel, type OxlintConfig } from '../../types.js'\nimport { getOxlintCommand, mapSeverity } from './cli.js'\n\nexport interface ResolvedOptions {\n watchTarget: string | string[]\n logLevel?: DiagnosticLevel[]\n command: string\n}\n\nexport function resolveOptions(\n root: string,\n config: Exclude<OxlintConfig, false>,\n): ResolvedOptions {\n const options = config === true ? { lintCommand: 'oxlint' } : config\n return {\n watchTarget: resolveWatchTarget(root, options.watchPath),\n logLevel: options.dev?.logLevel?.map((l) => mapSeverity(l)) ?? [\n DiagnosticLevel.Warning,\n DiagnosticLevel.Error,\n ],\n command: getOxlintCommand(options.lintCommand ?? 'oxlint').join(' '),\n }\n}\n\nfunction resolveWatchTarget(\n root: string,\n watchPath?: string | string[],\n): string | string[] {\n return Array.isArray(watchPath)\n ? watchPath.map((p) => path.resolve(root, p))\n : typeof watchPath === 'string'\n ? path.resolve(root, watchPath)\n : root\n}\n"],"mappings":"AAAA,OAAO,UAAU;AACjB,SAAS,uBAA0C;AACnD,SAAS,kBAAkB,mBAAmB;AAQvC,SAAS,eACd,MACA,QACiB;AAbnB;AAcE,QAAM,UAAU,WAAW,OAAO,EAAE,aAAa,SAAS,IAAI;AAC9D,SAAO;AAAA,IACL,aAAa,mBAAmB,MAAM,QAAQ,SAAS;AAAA,IACvD,YAAU,mBAAQ,QAAR,mBAAa,aAAb,mBAAuB,IAAI,CAAC,MAAM,YAAY,CAAC,OAAM;AAAA,MAC7D,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,IAClB;AAAA,IACA,SAAS,iBAAiB,QAAQ,eAAe,QAAQ,EAAE,KAAK,GAAG;AAAA,EACrE;AACF;AAEA,SAAS,mBACP,MACA,WACmB;AACnB,SAAO,MAAM,QAAQ,SAAS,IAC1B,UAAU,IAAI,CAAC,MAAM,KAAK,QAAQ,MAAM,CAAC,CAAC,IAC1C,OAAO,cAAc,WACnB,KAAK,QAAQ,MAAM,SAAS,IAC5B;AACR;","names":[]}
|
||||
19
node_modules/vite-plugin-checker/dist/checkers/oxlint/server.d.ts
generated
vendored
Normal file
19
node_modules/vite-plugin-checker/dist/checkers/oxlint/server.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { FileDiagnosticManager } from '../../FileDiagnosticManager.js';
|
||||
import { ResolvedOptions } from './options.js';
|
||||
import { DisplayTarget } from './types.js';
|
||||
import '../../logger.js';
|
||||
import '@babel/code-frame';
|
||||
import '../../types.js';
|
||||
import 'node:worker_threads';
|
||||
import 'eslint';
|
||||
import 'stylelint';
|
||||
import 'vite';
|
||||
import '../vls/initParams.js';
|
||||
import 'vscode-languageserver/node';
|
||||
import 'vscode-uri';
|
||||
import 'typescript';
|
||||
import 'vscode-languageclient/node';
|
||||
|
||||
declare function setupDevServer(root: string, options: ResolvedOptions, manager: FileDiagnosticManager, displayTargets: Set<DisplayTarget>): Promise<void>;
|
||||
|
||||
export { setupDevServer };
|
||||
51
node_modules/vite-plugin-checker/dist/checkers/oxlint/server.js
generated
vendored
Normal file
51
node_modules/vite-plugin-checker/dist/checkers/oxlint/server.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import path from "node:path";
|
||||
import chokidar from "chokidar";
|
||||
import { filterLogLevel } from "../../logger.js";
|
||||
import { runOxlint } from "./cli.js";
|
||||
import { dispatchDiagnostics } from "./diagnostics.js";
|
||||
async function setupDevServer(root, options, manager, displayTargets) {
|
||||
const initial = await runOxlint(options.command, root);
|
||||
manager.initWith(initial);
|
||||
dispatchDiagnostics(
|
||||
filterLogLevel(manager.getDiagnostics(), options.logLevel),
|
||||
displayTargets
|
||||
);
|
||||
const watcher = chokidar.watch(options.watchTarget, {
|
||||
cwd: root,
|
||||
ignored: (path2) => path2.includes("node_modules")
|
||||
});
|
||||
watcher.on("change", async (filePath) => {
|
||||
await handleFileChange(root, options.command, filePath, manager);
|
||||
dispatchDiagnostics(
|
||||
filterLogLevel(manager.getDiagnostics(), options.logLevel),
|
||||
displayTargets
|
||||
);
|
||||
});
|
||||
watcher.on("unlink", (filePath) => {
|
||||
handleFileUnlink(root, filePath, manager);
|
||||
dispatchDiagnostics(
|
||||
filterLogLevel(manager.getDiagnostics(), options.logLevel),
|
||||
displayTargets
|
||||
);
|
||||
});
|
||||
watcher.add(".");
|
||||
}
|
||||
function handleFileUnlink(root, filePath, manager) {
|
||||
const absPath = path.resolve(root, filePath);
|
||||
manager.updateByFileId(absPath, []);
|
||||
}
|
||||
async function handleFileChange(root, command, filePath, manager) {
|
||||
const absPath = path.resolve(root, filePath);
|
||||
const isConfigFile = path.basename(absPath) === ".oxlintrc.json";
|
||||
if (isConfigFile) {
|
||||
const diagnostics = await runOxlint(`${command} ${root}`, root);
|
||||
manager.initWith(diagnostics);
|
||||
} else {
|
||||
const diagnostics = await runOxlint(`${command} ${absPath}`, root);
|
||||
manager.updateByFileId(absPath, diagnostics);
|
||||
}
|
||||
}
|
||||
export {
|
||||
setupDevServer
|
||||
};
|
||||
//# sourceMappingURL=server.js.map
|
||||
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/server.js.map
generated
vendored
Normal file
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/server.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/checkers/oxlint/server.ts"],"sourcesContent":["import path from 'node:path'\nimport chokidar from 'chokidar'\nimport type { FileDiagnosticManager } from '../../FileDiagnosticManager.js'\nimport { filterLogLevel } from '../../logger.js'\nimport { runOxlint } from './cli.js'\nimport { dispatchDiagnostics } from './diagnostics.js'\nimport type { ResolvedOptions } from './options.js'\nimport type { DisplayTarget } from './types'\n\nexport async function setupDevServer(\n root: string,\n options: ResolvedOptions,\n manager: FileDiagnosticManager,\n displayTargets: Set<DisplayTarget>,\n): Promise<void> {\n const initial = await runOxlint(options.command, root)\n manager.initWith(initial)\n dispatchDiagnostics(\n filterLogLevel(manager.getDiagnostics(), options.logLevel),\n displayTargets,\n )\n\n const watcher = chokidar.watch(options.watchTarget, {\n cwd: root,\n ignored: (path: string) => path.includes('node_modules'),\n })\n\n watcher.on('change', async (filePath) => {\n await handleFileChange(root, options.command, filePath, manager)\n dispatchDiagnostics(\n filterLogLevel(manager.getDiagnostics(), options.logLevel),\n displayTargets,\n )\n })\n\n watcher.on('unlink', (filePath) => {\n handleFileUnlink(root, filePath, manager)\n dispatchDiagnostics(\n filterLogLevel(manager.getDiagnostics(), options.logLevel),\n displayTargets,\n )\n })\n\n watcher.add('.')\n}\n\nfunction handleFileUnlink(\n root: string,\n filePath: string,\n manager: FileDiagnosticManager,\n) {\n const absPath = path.resolve(root, filePath)\n manager.updateByFileId(absPath, [])\n}\n\nasync function handleFileChange(\n root: string,\n command: string,\n filePath: string,\n manager: FileDiagnosticManager,\n) {\n const absPath = path.resolve(root, filePath)\n\n const isConfigFile = path.basename(absPath) === '.oxlintrc.json'\n if (isConfigFile) {\n const diagnostics = await runOxlint(`${command} ${root}`, root)\n manager.initWith(diagnostics)\n } else {\n const diagnostics = await runOxlint(`${command} ${absPath}`, root)\n manager.updateByFileId(absPath, diagnostics)\n }\n}\n"],"mappings":"AAAA,OAAO,UAAU;AACjB,OAAO,cAAc;AAErB,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,2BA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/dist/checkers/oxlint/types.d.ts
generated
vendored
Normal file
3
node_modules/vite-plugin-checker/dist/checkers/oxlint/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
type DisplayTarget = 'overlay' | 'terminal';
|
||||
|
||||
export type { DisplayTarget };
|
||||
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/types.js
generated
vendored
Normal file
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/types.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
//# sourceMappingURL=types.js.map
|
||||
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/types.js.map
generated
vendored
Normal file
1
node_modules/vite-plugin-checker/dist/checkers/oxlint/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
||||
Reference in New Issue
Block a user