-
-
Notifications
You must be signed in to change notification settings - Fork 73
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 * chore: move `@types/webpack`, `@types/micromatch` to devDependencies * chore: move `@types/stylelint` to devDependencies
- Loading branch information
1 parent
4da99a2
commit b7dfa19
Showing
17 changed files
with
4,971 additions
and
1,761 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** @typedef {import('webpack').Compiler} Compiler */ | ||
/** @typedef {import('./getOptions').Options} Options */ | ||
/** @typedef {import('./linter').Lint} Lint */ | ||
/** @typedef {import('./linter').LinterCallback} LinterCallback */ | ||
/** @typedef {Partial<{timestamp:number} | number>} FileSystemInfoEntry */ | ||
export default class LintDirtyModulesPlugin { | ||
/** | ||
* @param {Lint} lint | ||
* @param {Compiler} compiler | ||
* @param {Options} options | ||
*/ | ||
constructor(lint: Lint, compiler: Compiler, options: Options); | ||
lint: import('./linter').Lint; | ||
compiler: import('webpack').Compiler; | ||
options: import('./getOptions').Options; | ||
startTime: number; | ||
prevTimestamps: Map<any, any>; | ||
isFirstRun: boolean; | ||
/** | ||
* @param {Compiler} compilation | ||
* @param {LinterCallback} callback | ||
* @returns {void} | ||
*/ | ||
apply(compilation: Compiler, callback: LinterCallback): void; | ||
/** | ||
* @param {Map<string, number>} fileTimestamps | ||
* @param {string | ReadonlyArray<string>} glob | ||
* @returns {Array<string>} | ||
*/ | ||
getChangedFiles( | ||
fileTimestamps: Map<string, number>, | ||
glob: string | ReadonlyArray<string> | ||
): Array<string>; | ||
} | ||
export type Compiler = import('webpack').Compiler; | ||
export type Options = { | ||
context?: string | undefined; | ||
emitError?: boolean | undefined; | ||
emitWarning?: boolean | undefined; | ||
failOnError?: boolean | undefined; | ||
failOnWarning?: boolean | undefined; | ||
files: string | string[]; | ||
formatter: TimerHandler; | ||
lintDirtyModulesOnly?: boolean | undefined; | ||
quiet?: boolean | undefined; | ||
stylelintPath: string; | ||
}; | ||
export type Lint = ( | ||
options: import('./getOptions').Options | ||
) => Promise<import('stylelint').LinterResult>; | ||
export type LinterCallback = ( | ||
error?: import('./StylelintError').default | null | undefined | ||
) => void; | ||
export type FileSystemInfoEntry = | ||
| number | ||
| Partial<{ | ||
timestamp: number; | ||
}>; |
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,30 @@ | ||
/** @typedef {import('stylelint').LintResult} LintResult */ | ||
/** @typedef {import('./getOptions').Options} Options */ | ||
export default class StylelintError extends Error { | ||
/** | ||
* @param {Options} options | ||
* @param {Array<LintResult>} messages | ||
* @returns {StylelintError} | ||
*/ | ||
static format( | ||
{ formatter }: Options, | ||
messages: Array<LintResult> | ||
): StylelintError; | ||
/** | ||
* @param {Partial<string>} messages | ||
*/ | ||
constructor(messages: Partial<string>); | ||
} | ||
export type LintResult = import('stylelint').LintResult; | ||
export type Options = { | ||
context?: string | undefined; | ||
emitError?: boolean | undefined; | ||
emitWarning?: boolean | undefined; | ||
failOnError?: boolean | undefined; | ||
failOnWarning?: boolean | undefined; | ||
files: string | string[]; | ||
formatter: TimerHandler; | ||
lintDirtyModulesOnly?: boolean | undefined; | ||
quiet?: boolean | undefined; | ||
stylelintPath: 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,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,32 @@ | ||
/** @typedef {import("stylelint")} stylelint */ | ||
/** | ||
* @typedef {Object} Options | ||
* @property {string=} context | ||
* @property {boolean=} emitError | ||
* @property {boolean=} emitWarning | ||
* @property {boolean=} failOnError | ||
* @property {boolean=} failOnWarning | ||
* @property {Array<string> | string} files | ||
* @property {Function | string} formatter | ||
* @property {boolean=} lintDirtyModulesOnly | ||
* @property {boolean=} quiet | ||
* @property {string} stylelintPath | ||
*/ | ||
/** | ||
* @param {Partial<Options>} pluginOptions | ||
* @returns {Options} | ||
*/ | ||
export default function getOptions(pluginOptions: Partial<Options>): Options; | ||
export type stylelint = typeof import('stylelint'); | ||
export type Options = { | ||
context?: string | undefined; | ||
emitError?: boolean | undefined; | ||
emitWarning?: boolean | undefined; | ||
failOnError?: boolean | undefined; | ||
failOnWarning?: boolean | undefined; | ||
files: Array<string> | string; | ||
formatter: Function | string; | ||
lintDirtyModulesOnly?: boolean | undefined; | ||
quiet?: boolean | undefined; | ||
stylelintPath: 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,18 @@ | ||
export default StylelintWebpackPlugin; | ||
export type Compiler = import('webpack').Compiler; | ||
/** @typedef {import('webpack').Compiler} Compiler */ | ||
declare class StylelintWebpackPlugin { | ||
constructor(options?: {}); | ||
options: import('./getOptions').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,47 @@ | ||
/** @typedef {import('stylelint').LinterResult} LinterResult */ | ||
/** @typedef {import('stylelint').LintResult} LintResult */ | ||
/** @typedef {import('webpack').Compiler} Compiler */ | ||
/** @typedef {import('./getOptions').Options} Options */ | ||
/** | ||
* @callback Lint | ||
* @param {Options} options | ||
* @returns {Promise<LinterResult>} | ||
*/ | ||
/** | ||
* @callback LinterCallback | ||
* @param {StylelintError | null=} error | ||
* @returns {void} | ||
*/ | ||
/** | ||
* @param {Lint} lint | ||
* @param {Options} options | ||
* @param {Compiler} compiler | ||
* @param {LinterCallback} callback | ||
* @returns {void} | ||
*/ | ||
export default function linter( | ||
lint: Lint, | ||
options: Options, | ||
compiler: Compiler, | ||
callback: LinterCallback | ||
): void; | ||
export type LinterResult = import('stylelint').LinterResult; | ||
export type LintResult = import('stylelint').LintResult; | ||
export type Compiler = import('webpack').Compiler; | ||
export type Options = { | ||
context?: string | undefined; | ||
emitError?: boolean | undefined; | ||
emitWarning?: boolean | undefined; | ||
failOnError?: boolean | undefined; | ||
failOnWarning?: boolean | undefined; | ||
files: string | string[]; | ||
formatter: TimerHandler; | ||
lintDirtyModulesOnly?: boolean | undefined; | ||
quiet?: boolean | undefined; | ||
stylelintPath: string; | ||
}; | ||
export type Lint = (options: Options) => Promise<LinterResult>; | ||
export type LinterCallback = ( | ||
error?: (StylelintError | null) | undefined | ||
) => void; | ||
import StylelintError from './StylelintError'; |
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,14 @@ | ||
/** | ||
* @param {Array<string> | string} files | ||
* @param {string} context | ||
* @returns {Array<string>} | ||
*/ | ||
export function parseFiles( | ||
files: Array<string> | string, | ||
context: string | ||
): Array<string>; | ||
/** | ||
* @param {string} str | ||
* @returns {string} | ||
*/ | ||
export function replaceBackslashes(str: 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'], | ||
'*.{json,md,yml,css}': ['prettier --write'], | ||
'*.{json,md,yml,css,ts}': ['prettier --write'], | ||
}; |
Oops, something went wrong.