@nabla/vite-plugin-eslint
Advanced tools
Comparing version 1.2.0 to 1.3.0
34
index.js
@@ -1,3 +0,3 @@ | ||
const chalk = require("chalk"); | ||
const { ESLint } = require("eslint"); | ||
const path = require("path"); | ||
const { Worker } = require("worker_threads"); | ||
const { normalizePath } = require("vite"); | ||
@@ -9,7 +9,8 @@ | ||
shouldLint = (path) => path.match(/\/src\/.*\.[jt]sx?$/), | ||
formatter: format, | ||
formatter, | ||
} = options; | ||
const eslint = new ESLint({ cache: true, ...eslintOptions }); | ||
const formatterPromise = format ? eslint.loadFormatter(format) : undefined; | ||
const worker = new Worker(path.resolve(__dirname, "./worker.js"), { | ||
workerData: { options: { cache: true, ...eslintOptions }, formatter }, | ||
}); | ||
@@ -21,24 +22,3 @@ return { | ||
const path = normalizePath(id); | ||
if (shouldLint(path)) { | ||
eslint.isPathIgnored(path).then(async (ignored) => { | ||
if (ignored) return; | ||
const [report] = await eslint.lintFiles(path); | ||
if (report.messages.length === 0) return; | ||
if (formatterPromise) { | ||
const formatter = await formatterPromise; | ||
console.log(formatter.format([report])); | ||
} else { | ||
report.messages.forEach((m) => { | ||
const prettyPath = path.slice(path.indexOf("/src/") + 1); | ||
const location = `${prettyPath}(${m.line},${m.column})`; | ||
const rule = m.ruleId ? ` ${m.ruleId}` : ""; | ||
console.log( | ||
`${location}: ${chalk[m.severity === 2 ? "red" : "yellow"]( | ||
`${m.message}` | ||
)}${rule}` | ||
); | ||
}); | ||
} | ||
}); | ||
} | ||
if (shouldLint(path)) worker.postMessage(path); | ||
return null; | ||
@@ -45,0 +25,0 @@ }, |
{ | ||
"name": "@nabla/vite-plugin-eslint", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Plugs ESLint into Vite dev server", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65989
7
59
1