-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support typescript * feat: add types * test: set testTimeout * chore: move types to dependencies * chore: move @types/webpack to devDependencies
- Loading branch information
1 parent
db526be
commit 6634d96
Showing
23 changed files
with
733 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const _exports: typeof import('.').default; | ||
export = _exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
}; |
Oops, something went wrong.