vite-plugin-checker icon indicating copy to clipboard operation
vite-plugin-checker copied to clipboard

Ability to run eslint on single files

Open mikew opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

Linting all files all the time is much slower than linting a single file when it changes.

Describe the solution you'd like

Would be nice if vite-plugin-checker would:

  • lint all files when starting the dev server
  • lint all files when building
  • lint single files when they're changed

Something like

type EslintConfig =
  | false
  | {
      /**
       * lintCommand will be executed at build mode, and will also be used as
       * default config for dev mode when options.eslint.dev.eslint is nullable.
       */
      lintCommand: string | ((file?: string) => string)
      dev?: Partial<{
        /** You can override the options of translated from lintCommand. */
        overrideConfig: ESLint.Options
        /** which level of the diagnostic will be emitted from plugin */
        logLevel: ('error' | 'warning')[]
      }>
    }

would let people write

vitePluginChecker({
  eslint: {
    lintCommand: (file) => {
      const fileOrAllFiles = file ? file : './src/**/*.{ts,tsx}'
      return `eslint "${fileOrAllFiles}"`
    }
  }
})

Describe alternatives you've considered

There is eslint_d, but the nature of the command built by vite-plugin-checker still lints all files.

Additional context

I'm willing to work on this.

Validations

  • [X] Read the docs.
  • [X] Read the Contributing Guidelines.
  • [X] Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.

mikew avatar Jan 16 '24 18:01 mikew