Skip to content

Commit

Permalink
refactor: change ESLint property
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Feb 6, 2022
1 parent 437a607 commit 02b96cf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,17 @@ _coming soon._

### config.eslint

<<<<<<< HEAD
| field | Type | Default value | Description |
| :------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| lintCommand | `string` | This value is required | `lintCommand` will be executed at build mode, and will also be used as default config for dev mode when `eslint.dev.overrideConfig` is nullable. |
| `dev.overrideConfig` | [`ESLint.Options`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eslint/index.d.ts) | `undefined` | You can override the options of the translated from `lintCommand`. Config priority: `const eslint = new ESLint({cwd: root, ...translatedOptions, ...pluginConfig.eslint.devOptions, })`. |
=======
| field | Type | Default value | Description |
| :----------- | ---------------------------------------------------------------------------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| lintCommand | `string` | This value is required | `lintCommand` will be executed at build mode, and will also be used as default config for dev mode when `eslint.dev.eslint` is nullable. |
| `dev.eslint` | [`ESLint.Options`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eslint/index.d.ts) | `undefined` | You can override the options of the translated from `lintCommand`. Config priority: `const eslint = new ESLint({cwd: root, ...translatedOptions, ...pluginConfig.eslint.dev, })`. |
>>>>>>> refactor: change ESLint property
## Playground

Expand Down
11 changes: 10 additions & 1 deletion packages/vite-plugin-checker/src/checkers/eslint/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
/* eslint-disable */

// Copied from /eslint@7.28.0/node_modules/eslint/lib/cli.js
/**
* This file is directly copied from https://github.com/eslint/eslint/blob/6f940c3ce715327f282c197d0f71b91848e5d83d/lib/cli.js
*
* Usually, developer rarely use JS programming API to run ESLint. So we let
* developers to write their own ESLint commands just like in CI or lint-staged.
* And the config will be translated and pass to `new ESLint(translatedOptions)`.
* So in build mode, it's the same as the command you pass in.
* In dev mode, some flag will be ignored (such as `max-warnings`) because it
* will be only respected in ESLint CLI.
*/

// @ts-expect-error
function quietFixPredicate(message) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-checker/src/checkers/eslint/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const createDiagnostic: CreateDiagnostic<'eslint'> = (pluginConfig) => {
const eslint = new ESLint({
cwd: root,
...translatedOptions,
...pluginConfig.eslint.devOptions,
...pluginConfig.eslint.dev,
})

const dispatchDiagnostics = () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/vite-plugin-checker/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export type EslintConfig =
| {
/**
* lintCommand will be executed at build mode, and will also be used as
* default config for dev mode when options.eslint.devOptions.eslint is nullable.
* default config for dev mode when options.eslint.dev.eslint is nullable.
*/
lintCommand: string
devOptions?: {
dev?: {
/** You can override the options of translated from lintCommand. */
eslint?: ESLint.Options
}
Expand Down

0 comments on commit 02b96cf

Please sign in to comment.