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

lintCommand does not work with useFlatConfig

Open MrEfrem opened this issue 1 year ago • 2 comments

Describe the bug

I use different ESLint config files:

  1. For IDE with a standard name (eslint.config.mjs). It contains more warnings.
  2. For CI, Vite Checher with disabled some rules. I set lintCommand to eslint -c eslint.config.ide.mjs ... With an old ESLint (below 9 version) Vite Checker use my different ESLint config and I don't see any excess warnings in a terminal or Vite Checker UI. But with the ESLint 9 when I use useFlatConfig flag lintCommand doesn't work. dev.overrideConfig doesn't work with useFlatConfig too.

Reproduction

Set useFlatConfig: true, lintCommand: "eslint -c eslint.config.ide.mjs ."

Expected behavior

When using useFlatConfig Vite Checker should process lintCommand and dev.overrideConfig.

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
    Memory: 23.95 GB / 31.19 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
    npm: 10.9.1 - ~/.nvm/versions/node/v18.20.2/bin/npm
  npmPackages:
    vite-plugin-checker: ^0.8.0 => 0.8.0

Additional context

No response

Validations

  • [X] Read the docs.
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

MrEfrem avatar Nov 28 '24 07:11 MrEfrem

The issue is here:

https://github.com/fi3ework/vite-plugin-checker/blob/e6d564f3e281d66f037bd54333cc852639e87af4/packages/vite-plugin-checker/src/checkers/eslint/main.ts#L76

Additional configured options from the lintCommand & overrideConfig are not passed to the FlatESLint constructor. The FlatESLint constructor is just an alias to ESLint in ESLint 9. However, if I just use the the default option, I still get errors thrown about no longer valid options generated by translatedOptions

Error: Invalid Options:
- Unknown options: extensions, ignorePath, reportUnusedDisableDirectives, resolvePluginsRelativeTo, rulePaths, useEslintrc
- 'extensions' has been removed.
- 'resolvePluginsRelativeTo' has been removed.
- 'ignorePath' has been removed.
- 'rulePaths' has been removed. Please define your rules using plugins.
- 'reportUnusedDisableDirectives' has been removed. Please use the 'overrideConfig.linterOptions.reportUnusedDisableDirectives' option instead.

I cannot pass undefined for those options in overrideConfig because eslint is looking for the presence of the keys using Object.keys

MichaelGoff avatar Dec 13 '24 21:12 MichaelGoff

For anyone else coming here with the same issue. Try passing useFlatConfig: true in the config.

checker({
  eslint: {
    lintCommand: 'eslint "./src/**/*.{js,jsx}"',
    useFlatConfig: true
  },
  overlay: true,
})

ThomasFindlay avatar Jul 04 '25 07:07 ThomasFindlay