Skip to content

Commit 47612f1

Browse files
authored
Lint only the imported files (#28)
* feat: only use the import graph, update tests * fix: use compiler.outputFileSystem to write report * fix: use fs callback forms because webpack5 does not work with promisify on outputFileSystem methods * fix: coverage * fix: do not accumulate more taps as watchRuns occur * fix: windows path escape, cleanup watch-fixture
1 parent 8c5aa19 commit 47612f1

30 files changed

+2916
-4989
lines changed

declarations/DirtyFileWatcher.d.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

declarations/ESLintError.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
export default class ESLintError extends Error {
1+
export default class ESLintError {
22
/**
33
* @param {string=} messages
44
*/
55
constructor(messages?: string | undefined);
6+
name: string;
7+
stack: string;
68
}

declarations/index.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ export type Options = {
1515
quiet?: boolean | undefined;
1616
outputReport?: import('./options').OutputReport | undefined;
1717
};
18-
/** @typedef {import('webpack').Compiler} Compiler */
19-
/** @typedef {import('./options').Options} Options */
2018
declare class ESLintWebpackPlugin {
2119
/**
2220
* @param {Options} options
2321
*/
2422
constructor(options?: Options);
2523
options: import('./options').Options;
24+
/**
25+
* @param {Compiler} compiler
26+
*/
27+
run(compiler: Compiler): Promise<void>;
2628
/**
2729
* @param {Compiler} compiler
2830
* @returns {void}

declarations/linter.d.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,30 @@
22
/** @typedef {import('eslint').ESLint.Formatter} Formatter */
33
/** @typedef {import('eslint').ESLint.LintResult} LintResult */
44
/** @typedef {import('webpack').Compiler} Compiler */
5+
/** @typedef {import('webpack').compilation.Compilation} Compilation */
6+
/** @typedef {import('webpack-sources').Source} Source */
57
/** @typedef {import('./options').Options} Options */
68
/** @typedef {import('./options').FormatterFunction} FormatterFunction */
9+
/** @typedef {(compilation: Compilation) => Promise<void>} GenerateReport */
10+
/** @typedef {{errors?: ESLintError, warnings?: ESLintError, generateReportAsset?: GenerateReport}} Report */
11+
/** @typedef {() => Promise<Report>} Reporter */
12+
/** @typedef {(files: string|string[]) => void} Linter */
713
/**
814
* @param {Options} options
9-
* @param {Compiler} compiler
10-
* @returns {Promise<void>}
15+
* @returns {{lint: Linter, report: Reporter}}
1116
*/
1217
export default function linter(
13-
options: Options,
14-
compiler: Compiler
15-
): Promise<void>;
18+
options: Options
19+
): {
20+
lint: Linter;
21+
report: Reporter;
22+
};
1623
export type ESLint = import('eslint').ESLint;
1724
export type Formatter = import('eslint').ESLint.Formatter;
1825
export type LintResult = import('eslint').ESLint.LintResult;
1926
export type Compiler = import('webpack').Compiler;
27+
export type Compilation = import('webpack').compilation.Compilation;
28+
export type Source = import('webpack-sources/lib/Source');
2029
export type Options = {
2130
context?: string | undefined;
2231
emitError?: boolean | undefined;
@@ -36,3 +45,14 @@ export type FormatterFunction = (
3645
results: import('eslint').ESLint.LintResult[],
3746
data?: import('eslint').ESLint.LintResultData | undefined
3847
) => string;
48+
export type GenerateReport = (compilation: Compilation) => Promise<void>;
49+
export type Report = {
50+
errors?: ESLintError | undefined;
51+
warnings?: ESLintError | undefined;
52+
generateReportAsset?:
53+
| ((compilation: Compilation) => Promise<void>)
54+
| undefined;
55+
};
56+
export type Reporter = () => Promise<Report>;
57+
export type Linter = (files: string | string[]) => void;
58+
import ESLintError from './ESLintError';

0 commit comments

Comments
 (0)