Skip to content

Commit

Permalink
Lint only the imported files (#28)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jsg2021 committed Nov 4, 2020
1 parent 8c5aa19 commit 47612f1
Show file tree
Hide file tree
Showing 30 changed files with 2,916 additions and 4,989 deletions.
28 changes: 0 additions & 28 deletions declarations/DirtyFileWatcher.d.ts

This file was deleted.

4 changes: 3 additions & 1 deletion declarations/ESLintError.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default class ESLintError extends Error {
export default class ESLintError {
/**
* @param {string=} messages
*/
constructor(messages?: string | undefined);
name: string;
stack: string;
}
6 changes: 4 additions & 2 deletions declarations/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ export type Options = {
quiet?: boolean | undefined;
outputReport?: import('./options').OutputReport | undefined;
};
/** @typedef {import('webpack').Compiler} Compiler */
/** @typedef {import('./options').Options} Options */
declare class ESLintWebpackPlugin {
/**
* @param {Options} options
*/
constructor(options?: Options);
options: import('./options').Options;
/**
* @param {Compiler} compiler
*/
run(compiler: Compiler): Promise<void>;
/**
* @param {Compiler} compiler
* @returns {void}
Expand Down
30 changes: 25 additions & 5 deletions declarations/linter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@
/** @typedef {import('eslint').ESLint.Formatter} Formatter */
/** @typedef {import('eslint').ESLint.LintResult} LintResult */
/** @typedef {import('webpack').Compiler} Compiler */
/** @typedef {import('webpack').compilation.Compilation} Compilation */
/** @typedef {import('webpack-sources').Source} Source */
/** @typedef {import('./options').Options} Options */
/** @typedef {import('./options').FormatterFunction} FormatterFunction */
/** @typedef {(compilation: Compilation) => Promise<void>} GenerateReport */
/** @typedef {{errors?: ESLintError, warnings?: ESLintError, generateReportAsset?: GenerateReport}} Report */
/** @typedef {() => Promise<Report>} Reporter */
/** @typedef {(files: string|string[]) => void} Linter */
/**
* @param {Options} options
* @param {Compiler} compiler
* @returns {Promise<void>}
* @returns {{lint: Linter, report: Reporter}}
*/
export default function linter(
options: Options,
compiler: Compiler
): Promise<void>;
options: Options
): {
lint: Linter;
report: Reporter;
};
export type ESLint = import('eslint').ESLint;
export type Formatter = import('eslint').ESLint.Formatter;
export type LintResult = import('eslint').ESLint.LintResult;
export type Compiler = import('webpack').Compiler;
export type Compilation = import('webpack').compilation.Compilation;
export type Source = import('webpack-sources/lib/Source');
export type Options = {
context?: string | undefined;
emitError?: boolean | undefined;
Expand All @@ -36,3 +45,14 @@ export type FormatterFunction = (
results: import('eslint').ESLint.LintResult[],
data?: import('eslint').ESLint.LintResultData | undefined
) => string;
export type GenerateReport = (compilation: Compilation) => Promise<void>;
export type Report = {
errors?: ESLintError | undefined;
warnings?: ESLintError | undefined;
generateReportAsset?:
| ((compilation: Compilation) => Promise<void>)
| undefined;
};
export type Reporter = () => Promise<Report>;
export type Linter = (files: string | string[]) => void;
import ESLintError from './ESLintError';

0 comments on commit 47612f1

Please sign in to comment.