Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,19 @@ Specify directories, files, or globs. Must be relative to `options.context`.
Directories are traveresed recursively looking for files matching `options.extensions`.
File and glob patterns ignore `options.extensions`.

### `extensions`

- Type: `String|Array[String]`
- Default: `'js'`

Specify extensions that should be checked.

### `fix`

- Type: `Boolean`
- Default: `false`

Will enable [ESLint autofix feature](http://eslint.org/docs/user-guide/command-line-interface#fix).
Will enable [ESLint autofix feature](https://eslint.org/docs/developer-guide/nodejs-api#%E2%97%86-eslint-outputfixes-results).

**Be careful: this option will change source files.**

Expand Down
28 changes: 28 additions & 0 deletions declarations/DirtyFileWatcher.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export default class DirtyFileWatcher {
/**
* @param {string|string[]=} files
* @param {string|string[]=} extensions
*/
constructor(
files?: (string | string[]) | undefined,
extensions?: (string | string[]) | undefined
);
startTime: number;
prevTimestamps: Map<any, any>;
isFirstRun: boolean;
globs: string[];
/**
* @param {Map<string,number>=} fileTimestamps
* @returns {string[]}
*/
getDirtyFiles(fileTimestamps?: Map<string, number> | undefined): string[];
/**
* @param {Map<string,number>} fileTimestamps
* @param {string|string[]} globs
* @returns {string[]}
*/
filterChangedFiles(
fileTimestamps: Map<string, number>,
globs: string | string[]
): string[];
}
6 changes: 6 additions & 0 deletions declarations/ESLintError.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default class ESLintError extends Error {
/**
* @param {string=} messages
*/
constructor(messages?: string | undefined);
}
2 changes: 2 additions & 0 deletions declarations/cjs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _exports: typeof import('.').default;
export = _exports;
28 changes: 28 additions & 0 deletions declarations/getESLint.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/** @typedef {import('eslint').ESLint} ESLint */
/** @typedef {import('./options').Options} Options */
/**
* @param {Options} options
* @returns {{ESLint: ESLint, eslint: ESLint}}
*/
export default function getESLint(
options: Options
): {
ESLint: import('eslint').ESLint;
eslint: import('eslint').ESLint;
};
export type ESLint = import('eslint').ESLint;
export type Options = {
context?: string | undefined;
emitError?: boolean | undefined;
emitWarning?: boolean | undefined;
eslintPath?: string | undefined;
failOnError?: boolean | undefined;
failOnWarning?: boolean | undefined;
files?: string | string[] | undefined;
extensions?: string | string[] | undefined;
fix?: boolean | undefined;
formatter?: string | import('./options').FormatterFunction | undefined;
lintDirtyModulesOnly?: boolean | undefined;
quiet?: boolean | undefined;
outputReport?: import('./options').OutputReport | undefined;
};
37 changes: 37 additions & 0 deletions declarations/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export default ESLintWebpackPlugin;
export type Compiler = import('webpack').Compiler;
export type Options = {
context?: string | undefined;
emitError?: boolean | undefined;
emitWarning?: boolean | undefined;
eslintPath?: string | undefined;
failOnError?: boolean | undefined;
failOnWarning?: boolean | undefined;
files?: string | string[] | undefined;
extensions?: string | string[] | undefined;
fix?: boolean | undefined;
formatter?: string | import('./options').FormatterFunction | undefined;
lintDirtyModulesOnly?: boolean | undefined;
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
* @returns {void}
*/
apply(compiler: Compiler): void;
/**
*
* @param {Compiler} compiler
* @returns {string}
*/
getContext(compiler: Compiler): string;
}
38 changes: 38 additions & 0 deletions declarations/linter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/** @typedef {import('eslint').ESLint} ESLint */
/** @typedef {import('eslint').ESLint.Formatter} Formatter */
/** @typedef {import('eslint').ESLint.LintResult} LintResult */
/** @typedef {import('webpack').Compiler} Compiler */
/** @typedef {import('./options').Options} Options */
/** @typedef {import('./options').FormatterFunction} FormatterFunction */
/**
* @param {Options} options
* @param {Compiler} compiler
* @returns {Promise<void>}
*/
export default function linter(
options: Options,
compiler: Compiler
): Promise<void>;
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 Options = {
context?: string | undefined;
emitError?: boolean | undefined;
emitWarning?: boolean | undefined;
eslintPath?: string | undefined;
failOnError?: boolean | undefined;
failOnWarning?: boolean | undefined;
files?: string | string[] | undefined;
extensions?: string | string[] | undefined;
fix?: boolean | undefined;
formatter?: string | import('./options').FormatterFunction | undefined;
lintDirtyModulesOnly?: boolean | undefined;
quiet?: boolean | undefined;
outputReport?: import('./options').OutputReport | undefined;
};
export type FormatterFunction = (
results: import('eslint').ESLint.LintResult[],
data?: import('eslint').ESLint.LintResultData | undefined
) => string;
66 changes: 66 additions & 0 deletions declarations/options.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/** @typedef {import("eslint").ESLint.Options} ESLintOptions */
/** @typedef {import('eslint').ESLint.LintResult} LintResult */
/** @typedef {import('eslint').ESLint.LintResultData} LintResultData */
/**
* @callback FormatterFunction
* @param {LintResult[]} results
* @param {LintResultData=} data
* @returns {string}
*/
/**
* @typedef {Object} OutputReport
* @property {string=} filePath
* @property {string|FormatterFunction=} formatter
*/
/**
* @typedef {Object} Options
* @property {string=} context
* @property {boolean=} emitError
* @property {boolean=} emitWarning
* @property {string=} eslintPath
* @property {boolean=} failOnError
* @property {boolean=} failOnWarning
* @property {string|string[]=} files
* @property {string|string[]=} extensions
* @property {boolean=} fix
* @property {string|FormatterFunction=} formatter
* @property {boolean=} lintDirtyModulesOnly
* @property {boolean=} quiet
* @property {OutputReport=} outputReport
*/
/**
* @param {Options} pluginOptions
* @returns {Options}
*/
export function getOptions(pluginOptions: Options): Options;
/**
* @param {Options} loaderOptions
* @returns {ESLintOptions}
*/
export function getESLintOptions(loaderOptions: Options): ESLintOptions;
export type ESLintOptions = import('eslint').ESLint.Options;
export type LintResult = import('eslint').ESLint.LintResult;
export type LintResultData = import('eslint').ESLint.LintResultData;
export type FormatterFunction = (
results: LintResult[],
data?: LintResultData | undefined
) => string;
export type OutputReport = {
filePath?: string | undefined;
formatter?: (string | FormatterFunction) | undefined;
};
export type Options = {
context?: string | undefined;
emitError?: boolean | undefined;
emitWarning?: boolean | undefined;
eslintPath?: string | undefined;
failOnError?: boolean | undefined;
failOnWarning?: boolean | undefined;
files?: (string | string[]) | undefined;
extensions?: (string | string[]) | undefined;
fix?: boolean | undefined;
formatter?: (string | FormatterFunction) | undefined;
lintDirtyModulesOnly?: boolean | undefined;
quiet?: boolean | undefined;
outputReport?: OutputReport | undefined;
};
20 changes: 20 additions & 0 deletions declarations/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @param {string|string[]} files
* @param {string} context
* @returns {string[]}
*/
export function parseFiles(files: string | string[], context: string): string[];
/**
* @param {string} str
* @returns {string}
*/
export function replaceBackslashes(str: string): string;
/**
* @param {string|string[]} patterns
* @param {string|string[]} extensions
* @returns {string[]}
*/
export function parseFoldersToGlobs(
patterns: string | string[],
extensions: string | string[]
): string[];
2 changes: 1 addition & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
'*.js': ['prettier --write', 'eslint --fix', 'git add'],
'*.{json,md,yml,css}': ['prettier --write', 'git add'],
'*.{json,md,yml,css,ts}': ['prettier --write', 'git add'],
};
Loading