Socket
Socket
Sign inDemoInstall

@nabla/vite-plugin-eslint

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nabla/vite-plugin-eslint - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

1

index.d.ts

@@ -7,4 +7,5 @@ import { ESLint } from "eslint";

shouldLint?: (path: string) => boolean;
formatter?: string;
}) => Plugin;
export default eslintPlugin;

33

index.js

@@ -8,6 +8,9 @@ const chalk = require("chalk");

eslintOptions = {},
shouldLint = (path) => path.match(/\.[jt]sx?$/),
shouldLint = (path) => path.match(/\/src\/.*\.[jt]sx?$/),
formatter: format,
} = options;
const eslint = new ESLint({ cache: true, ...eslintOptions });
const formatterPromise = format ? eslint.loadFormatter(format) : undefined;
return {

@@ -18,16 +21,22 @@ name: "eslint",

const path = normalizePath(id);
if (path.includes("/src/") && shouldLint(path)) {
if (shouldLint(path)) {
eslint.isPathIgnored(path).then(async (ignored) => {
if (ignored) return;
const [report] = await eslint.lintFiles(path);
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 (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}`
);
});
}
});

@@ -34,0 +43,0 @@ }

{
"name": "@nabla/vite-plugin-eslint",
"version": "1.1.0",
"version": "1.2.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Plugs ESLint into Vite dev server",

@@ -1,4 +0,4 @@

# @nabla/vite-plugin-eslint
# @nabla/vite-plugin-eslint [![npm](https://img.shields.io/npm/v/@nabla/vite-plugin-eslint)](https://www.npmjs.com/package/@nabla/vite-plugin-eslint)
Plugs ESLint into Vite dev server.
Plugs ESLint into Vite dev server.

@@ -39,2 +39,8 @@ ## Differences with [vite-plugin-eslint](https://github.com/gxmari007/vite-plugin-eslint)

- Type: `(path: string) => boolean`
- Default: `(path) => path.match(/\.[jt]sx?$/)`
- Default: `(path) => path.match(/\/src\/.*\.[jt]sx?$/)`
### formatter
- Type: `string`
If provided, the value is passed to `eslint.loadFormatter`. Default to a custom format with one line per warning/error. Use `stylish` to get a CRA like output.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc