npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-linter

v3.0.1

Published

Plugin for linting files with Vite

Downloads

27,437

Readme

vite-plugin-linter

Vite plugin to lint files and show the linter output in the Vite output and the browser console. The main difference between this plugin and using similar Rollup plugins is that this plugin shows the output in the browser console. Note this plugin is Vite only as it uses the Vite specific hook configureServer.

Included linters: ESLint & TypeScript

Install

npm install vite-plugin-linter --save-dev

Usage

Basic

import { defineConfig } from "vite";
import { EsLinter, linterPlugin, TypeScriptLinter } from "vite-plugin-linter";

export default defineConfig((configEnv) => ({
  plugins: [
    linterPlugin({
      include: ["./src/**/*.ts", "./src/**/*.tsx"],
      linters: [new EsLinter({ configEnv: configEnv }), new TypeScriptLinter()],
    }),
  ],
}));

Fancy

import { defineConfig } from "vite";
import { EsLinter, linterPlugin, TypeScriptLinter } from "vite-plugin-linter";

export default defineConfig((configEnv) => ({
  plugins: [
    linterPlugin({
      include: ["./src/**/*.ts", "./src/**/*.tsx"],
      linters: [
        new EsLinter({
          configEnv: configEnv,
          serveOptions: { clearCacheOnStart: true },
        }),
        new TypeScriptLinter(),
      ],
      build: {
        includeMode: "filesInFolder",
      }
    }),
  ],
}));

linterPlugin Options

build.disable / serve.disable

  • Type: boolean
  • Default: false

If the plugin should not execute when called via the build/serve command

build.includeMode / serve.includeMode

  • Type: "processedFiles" | "filesInFolder"
  • Default: processedFiles

Which files to lint when called via the build/serve command processedFiles lints only the files processed by Vite filesInFolder lints all files in the project folder

exclude

  • Type: String | RegExp | Array[...String|RegExp]
  • Default: /node_modules/

File(s) to exclude. A valid picomatch pattern, or array of patterns. Ex: .\src\mine.ts

include

  • Type: String | RegExp | Array[...String|RegExp]
  • Default: undefined

File(s) to include. A valid picomatch pattern, or array of patterns. Ex: .\src\**\*.ts

injectFile

  • Type: string
  • Default: The first file not in node_modules

File to inject the browser console logging code into

linters

  • Type: Linter[]
  • Required

Linters to run

EsLinter Options

buildOptions

  • Type: EsLintOptions
  • Default: cache: false, fix: false

Options used when called via the build command

configEnv

  • Type: ConfigEnv
  • Required

The current Vite configuration environment

serveOptions

  • Type: EsLintOptions
  • Default: cache: true, cacheLocation: "./node_modules/.cache/.eslintcache", fix: false

Options used when called via the serve command

EsLintOptions Type

This type extends ESLint.Options with the following additional members

clearCacheOnStart

  • Type: boolean
  • Default: false

If the cache file should be removed before each start

formatter

  • Type: string | ESLint.Formatter
  • Default: stylish

Output formatter https://eslint.org/docs/user-guide/formatters/

TypeScriptLinter Options

This type extends ts.CompilerOptions with the following additional member

configFilePath

  • Type: string
  • Default: tsconfig.json

Path to the TypeScript config file

Command Line

A node script that executes the configured linters is included that can be run via npm, for example, in package.json: "scripts": { "lint": "vite-plugin-linter" }. A example of where this could be used is in a Git pre-commit hook. The includeMode option is always filesInFolder when running via this script.

Custom Linters

Custom linters can be created by extending the Linter interface

See the included linters for examples

Feedback

Submit bug reports and other feedback in the issues section

License

MIT