Skip to content

Commit ee94874

Browse files
test: fix
1 parent 5997926 commit ee94874

File tree

12 files changed

+179
-117
lines changed

12 files changed

+179
-117
lines changed

package-lock.json

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"@types/micromatch": "^4.0.9",
7171
"@types/node": "^22.15.30",
7272
"@types/normalize-path": "^3.0.2",
73-
"@types/webpack": "^5.28.5",
7473
"babel-jest": "^30.0.0",
7574
"chokidar": "^4.0.3",
7675
"cross-env": "^7.0.3",

test/fixtures/good-entry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
require('./good');
1+
require("./good");

test/fixtures/good.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* @returns {string} value
3+
*/
14
function test() {
25
return "value"
36
}

test/utils/conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default (entry, pluginConf = {}, webpackConf = {}) => {
1414
},
1515
plugins: [
1616
new ESLintPlugin({
17-
configType: "eslintrc",
1817
// this disables the use of .eslintignore, since it contains the fixtures
1918
// folder to skip it on the global linting, but here we want the opposite
2019
// (we only use .eslintignore on the test that checks this)

types/ESLintError.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export = ESLintError;
22
declare class ESLintError extends Error {
33
/**
4-
* @param {string=} messages
4+
* @param {string=} messages messages
55
*/
66
constructor(messages?: string | undefined);
77
stack: string;

types/getESLint.d.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ export type Linter = {
1212
export type Worker = JestWorker & {
1313
lintFiles: LintTask;
1414
};
15+
/**
16+
* @param {string | undefined} key a cache key
17+
* @param {Options} options options
18+
* @returns {Promise<Linter>} linter
19+
*/
20+
export function getESLint(
21+
key: string | undefined,
22+
{ threads, ...options }: Options,
23+
): Promise<Linter>;
1524
/** @typedef {import('eslint').ESLint} ESLint */
1625
/** @typedef {import('eslint').ESLint.LintResult} LintResult */
1726
/** @typedef {import('./options').Options} Options */
@@ -20,28 +29,19 @@ export type Worker = JestWorker & {
2029
/** @typedef {{threads: number, eslint: ESLint, lintFiles: LintTask, cleanup: AsyncTask}} Linter */
2130
/** @typedef {JestWorker & {lintFiles: LintTask}} Worker */
2231
/**
23-
* @param {Options} options
24-
* @returns {Promise<Linter>}
32+
* @param {Options} options options
33+
* @returns {Promise<Linter>} linter
2534
*/
2635
export function loadESLint(options: Options): Promise<Linter>;
2736
/**
28-
* @param {string|undefined} key
29-
* @param {number} poolSize
30-
* @param {Options} options
31-
* @returns {Promise<Linter>}
37+
* @param {string | undefined} key a cache key
38+
* @param {number} poolSize number of workers
39+
* @param {Options} options options
40+
* @returns {Promise<Linter>} linter
3241
*/
3342
export function loadESLintThreaded(
3443
key: string | undefined,
3544
poolSize: number,
3645
options: Options,
3746
): Promise<Linter>;
38-
/**
39-
* @param {string|undefined} key
40-
* @param {Options} options
41-
* @returns {Promise<Linter>}
42-
*/
43-
export function getESLint(
44-
key: string | undefined,
45-
{ threads, ...options }: Options,
46-
): Promise<Linter>;
4747
import { Worker as JestWorker } from "jest-worker";

types/index.d.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
export = ESLintWebpackPlugin;
22
declare class ESLintWebpackPlugin {
33
/**
4-
* @param {Options} options
4+
* @param {Options=} options options
55
*/
6-
constructor(options?: Options);
6+
constructor(options?: Options | undefined);
77
key: string;
88
options: import("./options").PluginOptions;
99
/**
10-
* @param {Compiler} compiler
11-
* @param {Omit<Options, 'resourceQueryExclude'> & {resourceQueryExclude: RegExp[]}} options
12-
* @param {string[]} wanted
13-
* @param {string[]} exclude
10+
* @param {Compiler} compiler compiler
11+
* @param {Omit<Options, 'resourceQueryExclude'> & { resourceQueryExclude: RegExp[] }} options options
12+
* @param {string[]} wanted wanted files
13+
* @param {string[]} exclude excluded files
1414
*/
1515
run(
1616
compiler: Compiler,
@@ -21,14 +21,13 @@ declare class ESLintWebpackPlugin {
2121
exclude: string[],
2222
): Promise<void>;
2323
/**
24-
* @param {Compiler} compiler
24+
* @param {Compiler} compiler compiler
2525
* @returns {void}
2626
*/
2727
apply(compiler: Compiler): void;
2828
/**
29-
*
30-
* @param {Compiler} compiler
31-
* @returns {string}
29+
* @param {Compiler} compiler compiler
30+
* @returns {string} context
3231
*/
3332
getContext(compiler: Compiler): string;
3433
}

types/linter.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export = linter;
22
/**
3-
* @param {string|undefined} key
4-
* @param {Options} options
5-
* @param {Compilation} compilation
6-
* @returns {Promise<{lint: Linter, report: Reporter, threads: number}>}
3+
* @param {string | undefined} key a cache key
4+
* @param {Options} options options
5+
* @param {Compilation} compilation compilation
6+
* @returns {Promise<{lint: Linter, report: Reporter, threads: number}>} linter with additional functions
77
*/
88
declare function linter(
99
key: string | undefined,

types/options.d.ts

Lines changed: 88 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,126 @@ export type ESLintOptions = import("eslint").ESLint.Options;
22
export type LintResult = import("eslint").ESLint.LintResult;
33
export type FormatterFunction = (results: LintResult[]) => string;
44
export type OutputReport = {
5+
/**
6+
* a file path
7+
*/
58
filePath?: string | undefined;
9+
/**
10+
* a formatter
11+
*/
612
formatter?: (string | FormatterFunction) | undefined;
713
};
814
export type PluginOptions = {
15+
/**
16+
* a string indicating the root of your files
17+
*/
918
context?: string | undefined;
19+
/**
20+
* the errors found will always be emitted
21+
*/
1022
emitError?: boolean | undefined;
23+
/**
24+
* the warnings found will always be emitted
25+
*/
1126
emitWarning?: boolean | undefined;
12-
eslintPath?: string | undefined;
27+
/**
28+
* specify the files and/or directories to exclude
29+
*/
1330
exclude?: (string | string[]) | undefined;
31+
/**
32+
* specify the extensions that should be checked
33+
*/
1434
extensions?: (string | string[]) | undefined;
35+
/**
36+
* will cause the module build to fail if there are any errors
37+
*/
1538
failOnError?: boolean | undefined;
39+
/**
40+
* will cause the module build to fail if there are any warning
41+
*/
1642
failOnWarning?: boolean | undefined;
43+
/**
44+
* specify directories, files, or globs
45+
*/
1746
files?: (string | string[]) | undefined;
47+
/**
48+
* apply fixes
49+
*/
1850
fix?: boolean | undefined;
51+
/**
52+
* specify the formatter you would like to use to format your results
53+
*/
1954
formatter?: (string | FormatterFunction) | undefined;
55+
/**
56+
* lint only changed files, skip linting on start
57+
*/
2058
lintDirtyModulesOnly?: boolean | undefined;
59+
/**
60+
* will process and report errors only and ignore warnings
61+
*/
2162
quiet?: boolean | undefined;
63+
/**
64+
* path to `eslint` instance that will be used for linting
65+
*/
66+
eslintPath?: string | undefined;
67+
/**
68+
* writes the output of the errors to a file - for example, a `json` file for use for reporting
69+
*/
2270
outputReport?: OutputReport | undefined;
71+
/**
72+
* number of worker threads
73+
*/
2374
threads?: (number | boolean) | undefined;
75+
/**
76+
* Specify the resource query to exclude
77+
*/
2478
resourceQueryExclude?: (RegExp | RegExp[]) | undefined;
79+
/**
80+
* config type
81+
*/
2582
configType?: string | undefined;
2683
};
2784
export type Options = PluginOptions & ESLintOptions;
85+
/**
86+
* @param {Options} loaderOptions loader options
87+
* @returns {ESLintOptions} eslint options
88+
*/
89+
export function getESLintOptions(loaderOptions: Options): ESLintOptions;
2890
/** @typedef {import("eslint").ESLint.Options} ESLintOptions */
2991
/** @typedef {import('eslint').ESLint.LintResult} LintResult */
3092
/**
3193
* @callback FormatterFunction
32-
* @param {LintResult[]} results
33-
* @returns {string}
94+
* @param {LintResult[]} results results
95+
* @returns {string} formatted result
3496
*/
3597
/**
36-
* @typedef {Object} OutputReport
37-
* @property {string=} filePath
38-
* @property {string|FormatterFunction=} formatter
98+
* @typedef {object} OutputReport
99+
* @property {string=} filePath a file path
100+
* @property {string | FormatterFunction=} formatter a formatter
39101
*/
40102
/**
41-
* @typedef {Object} PluginOptions
42-
* @property {string=} context
43-
* @property {boolean=} emitError
44-
* @property {boolean=} emitWarning
45-
* @property {string=} eslintPath
46-
* @property {string|string[]=} exclude
47-
* @property {string|string[]=} extensions
48-
* @property {boolean=} failOnError
49-
* @property {boolean=} failOnWarning
50-
* @property {string|string[]=} files
51-
* @property {boolean=} fix
52-
* @property {string|FormatterFunction=} formatter
53-
* @property {boolean=} lintDirtyModulesOnly
54-
* @property {boolean=} quiet
55-
* @property {OutputReport=} outputReport
56-
* @property {number|boolean=} threads
57-
* @property {RegExp|RegExp[]=} resourceQueryExclude
58-
* @property {string=} configType
103+
* @typedef {object} PluginOptions
104+
* @property {string=} context a string indicating the root of your files
105+
* @property {boolean=} emitError the errors found will always be emitted
106+
* @property {boolean=} emitWarning the warnings found will always be emitted
107+
* @property {string | string[]=} exclude specify the files and/or directories to exclude
108+
* @property {string | string[]=} extensions specify the extensions that should be checked
109+
* @property {boolean=} failOnError will cause the module build to fail if there are any errors
110+
* @property {boolean=} failOnWarning will cause the module build to fail if there are any warning
111+
* @property {string | string[]=} files specify directories, files, or globs
112+
* @property {boolean=} fix apply fixes
113+
* @property {string | FormatterFunction=} formatter specify the formatter you would like to use to format your results
114+
* @property {boolean=} lintDirtyModulesOnly lint only changed files, skip linting on start
115+
* @property {boolean=} quiet will process and report errors only and ignore warnings
116+
* @property {string=} eslintPath path to `eslint` instance that will be used for linting
117+
* @property {OutputReport=} outputReport writes the output of the errors to a file - for example, a `json` file for use for reporting
118+
* @property {number | boolean=} threads number of worker threads
119+
* @property {RegExp | RegExp[]=} resourceQueryExclude Specify the resource query to exclude
120+
* @property {string=} configType config type
59121
*/
60122
/** @typedef {PluginOptions & ESLintOptions} Options */
61123
/**
62-
* @param {Options} pluginOptions
63-
* @returns {PluginOptions}
124+
* @param {Options} pluginOptions plugin options
125+
* @returns {PluginOptions} normalized plugin options
64126
*/
65127
export function getOptions(pluginOptions: Options): PluginOptions;
66-
/**
67-
* @param {Options} loaderOptions
68-
* @returns {ESLintOptions}
69-
*/
70-
export function getESLintOptions(loaderOptions: Options): ESLintOptions;

0 commit comments

Comments
 (0)