This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

View File

@@ -0,0 +1,318 @@
## ⚠️ Next versions are available only on the [GitHub Releases](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/releases) page ⚠️
# [1.3.0-beta.1](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/compare/v1.2.0...v1.3.0-beta.1@beta) (2019-04-30)
### Bug Fixes
- **tests:** fix linter tests that were doing nothing ([d078278](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/d078278))
- **tests:** linter tests - useTypescriptIncrementalApi usage ([e0020d6](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/e0020d6))
- **tests:** rework vue integration tests ([5ad2568](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/5ad2568))
### Features
- **apiincrementalchecker:** improve generation of diagnostics ([ae80e5f](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/ae80e5f)), closes [#257](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/257)
# [1.2.0](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/compare/v1.1.1...v1.2.0) (2019-04-22)
### Bug Fixes
- semantic-release update `CHANGELOG.md` on the git repo ([8ad58af](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/8ad58af))
### Features
- add semantic-release integration ([5fe0653](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/5fe0653))
# [1.2.0-beta.4](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/compare/v1.2.0-beta.3@beta...v1.2.0-beta.4@beta) (2019-04-23)
### Bug Fixes
- **tests:** fix linter tests that were doing nothing ([d078278](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/d078278))
- **tests:** linter tests - useTypescriptIncrementalApi usage ([e0020d6](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/e0020d6))
### Features
- **apiincrementalchecker:** improve generation of diagnostics ([ae80e5f](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/ae80e5f)), closes [#257](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/257)
# [1.2.0-beta.3](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/compare/v1.2.0-beta.2@beta...v1.2.0-beta.3@beta) (2019-04-22)
### Bug Fixes
- **tests:** rework vue integration tests ([5ad2568](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/5ad2568))
# [1.2.0-beta.2](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/compare/v1.2.0-beta.1@beta...v1.2.0-beta.2@beta) (2019-04-22)
### Bug Fixes
- semantic-release update `CHANGELOG.md` on the git repo ([8ad58af](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/8ad58af))
# [1.2.0-beta.1](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/compare/v1.1.0...v1.2.0-beta.1@beta) (2019-04-22)
### Features
- add semantic-release integration ([5fe0653](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/commit/5fe0653))
## v1.1.1
- [Fix a regression w/ plugins like tsconfig-paths-webpack-plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/260)
## v1.1.0
- [Add new custom resolution options](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/250)
## v1.0.4
- [gracefully handle error thrown from the service](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/249)
## v1.0.3
- [use worker-rpc library for inter-process communication](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/231)
## v1.0.2
- [Fix ignoreLintWarning mark warnings as errors](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/243)
## v1.0.1
- [Apply rounding to compilation time](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/235)
## v1.0.0
- [Going 1.0](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/218)
This is the first major version of `fork-ts-checker-webpack-plugin`. A long time coming :-)
There are actually no breaking changes that we're aware of; users of 0.x `fork-ts-checker-webpack-plugin` should be be able to upgrade without any drama. Users of TypeScript 3+ may notice a performance improvement as by default the plugin now uses the [incremental watch API](https://github.com/Microsoft/TypeScript/pull/20234) in TypeScript. Should this prove problematic you can opt out of using it by supplying `useTypescriptIncrementalApi: false`.
We are aware of an [issue with Vue and the incremental API](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/219). We hope it will be fixed soon - a generous member of the community is taking a look. In the meantime, we will _not_ default to using the incremental watch API when in Vue mode.
The plugin supports webpack 2, 3, 4 and 5 alpha and TypeScript 2.1+ alongside tslint 4+.
See also: https://blog.johnnyreilly.com/2019/03/the-big-one-point-oh.html
## v1.0.0-alpha.10
- [Fix incremental api to work with TS 3+ by default](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/223)
## v1.0.0-alpha.9
- [Default to incremental api usage to true if TS 3+](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/217)
## v1.0.0-alpha.8
- [Respect tslint configs hierarchical order](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/214)
## v1.0.0-alpha.7
- [Add ignoreLintWarnings option](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/213)
## v1.0.0-alpha.6
- [don't directly depend upon typescript](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/208)
## v1.0.0-alpha.5
- [can now provide path where typescript can be found](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/204)
## v1.0.0-alpha.4
- [make node 6 compatible](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/202)
## v1.0.0-alpha.3
- [replace peerDeps with runtime checks](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/201)
## v1.0.0-alpha.2
- [Add `useTypescriptIncrementalApi`](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/198) (#196)
## v1.0.0-alpha.1
- [Use object-spread instead of `Object.assign`](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/194) (#194)
## v1.0.0-alpha.0
- [Add support for webpack 5](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/166)
### Breaking Changes
Version `1.x` additionally supports webpack 5 alongside webpack 4, whose hooks are now tapped differently:
```diff
- compiler.hooks.forkTsCheckerDone.tap(...args)
+ const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler)
+ forkTsCheckerHooks.done.tap(...args)
```
v1.0.0-alpha.0 drops support for node 6.
## v0.5.2
- [Fix erroneous error on diagnostics at 0 line; remove deprecated fs.existsSync](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/190) (#190)
## v0.5.1
- [Make the checker compile with TypeScript 3.2](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/189)
## 0.5.0
- Removed unused dependency `resolve`.
- Replace `lodash` usage with native calls.
- ** Breaking Changes**:
- Removed all getters from `NormalizedMessage`, use direct property access instead.
- **Internal**:
- Test against ts-loader v5
- Enable all strict type checks
- Update dev dependencies
## v0.4.15
- [Add `tslintAutoFix` option to be passed on to tslint to auto format typescript files](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/174) (#174)
## v0.4.14
- [Add support for `reportFiles` option](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/179) (#179)
## v0.4.13
- [Merge in `compilerOptions` prior to calling `parseJsonConfigFileContent`](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/176) (#176)
## v0.4.12
- [Add `compilerOptions` option](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/173) (#173)
## v0.4.11
- [Fix os.cpus is not a function](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/172) (#172)
## v0.4.10
- [Allow fork-ts-checker-webpack-plugin to be imported in .ts files using ESM import syntax](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/163) (#163)
## v0.4.9
- [Set "compilationDone" before resolving "forkTsCheckerServiceBeforeStart"](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/146) (#146)
## v0.4.8
- [Fix(types collision): update webpack](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/151) (#142)
## v0.4.7
- [Fix(types collision): update chalk and chokidar](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/147) (#142)
- [Fix(logger): Don't limit Options.logger to Console type](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/143)
## v0.4.6
- [Fix(types): Make options Partial<Options>](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/141) (#140)
## v0.4.5
- [Fix(types): Add types to the plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/139) (#137)
- [Fix(vue): Avoid false positive of no-consecutive-blank-lines TSLint rule in Vue file](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/138) (#130)
## v0.4.4
- [Fix(vue): resolve src attribute on the script block on Vue files](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/130) (#111, #85)
- Add TypeScript ^3.0.0 to peerDependencies
## v0.4.3
- Fix "File system lag can cause Invalid source file errors to slip through" (#127)
## v0.4.2
- Format messages when `async` is false
## v0.4.1
- Fix webpack 4 hooks bug
## v0.4.0
- Support webpack 4
## v0.3.0
- Add `vue` support
## v0.2.10
- Fix #80 "Cannot read property 'getLineAndCharacterOfPosition' of undefined"
- Fix #76 "TypeError: Cannot read property '0' of undefined"
## v0.2.9
- Make errors formatting closer to `ts-loader` style
- Handle tslint exclude option
## v0.2.8
- Add `checkSyntacticErrors` option
- Fix `process.env` pass to the child process
- Add `fork-ts-checker-service-before-start` hook
## v0.2.7
- Fix service is not killed when webpack watch is done
## v0.2.6
- Add diagnostics/lints formatters - `formatter` and `formatterOptions` option
## v0.2.5
- Add `async` option - more information in `README.md`
## v0.2.4
- Fix `ESLint: "fork-ts-checker-webpack-plugin" is not published.` issue
## v0.2.3
- Add support for webpack 3 as peerDependency
## v0.2.2
- Force `isolatedModule: false` in checker compiler for better performance
## v0.2.1
- Fix for `tslint: true` option issue
## v0.2.0
- tsconfig.json and tslint.json path are not printed anymore.
- `watch` option is not used on 'build' mode
- Handle case with no options object (`new ForkTsCheckerWebpacPlugin()`)
- Basic integration tests (along units)
- **Breaking changes**:
- tslint is not enabled by default - you have to set `tslint: true` or `tslint: './path/to/tslint.json'` to enable it.
- `blockEmit` option is removed - it choose automatically - blocks always on 'build' mode, never on 'watch' mode.
## v0.1.5
- Disable tslint if module is not installed and no tslint path is passed
- Improve README.md
## v0.1.4
- Fix send to closed channel case
- Fix removed files case
- Add `fork-ts-checker-service-start-error` hook
## v0.1.3
- Fix "Cannot read property 'mtime' of undefined on OSX"
## v0.1.2
- Workers mode works correctly (fixed typo)
## v0.1.1
- Support memory limit in multi-process mode
- Handle already closed channel case on sending ipc message
## v0.1.0
- Initial release - not production ready.

21
node_modules/fork-ts-checker-webpack-plugin/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 TypeStrong
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

438
node_modules/fork-ts-checker-webpack-plugin/README.md generated vendored Normal file
View File

@@ -0,0 +1,438 @@
<div align="center">
<h1>Fork TS Checker Webpack Plugin</h1>
<p>Webpack plugin that runs TypeScript type checker on a separate process.</p>
[![npm version](https://img.shields.io/npm/v/fork-ts-checker-webpack-plugin.svg)](https://www.npmjs.com/package/fork-ts-checker-webpack-plugin)
[![build status](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/workflows/CI/CD/badge.svg?branch=main&event=push)](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/actions?query=branch%3Amain+event%3Apush)
[![downloads](http://img.shields.io/npm/dm/fork-ts-checker-webpack-plugin.svg)](https://npmjs.org/package/fork-ts-checker-webpack-plugin)
[![commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
</div>
## Features
* Speeds up [TypeScript](https://github.com/Microsoft/TypeScript) type checking and [ESLint](https://eslint.org/) linting (by moving each to a separate process) 🏎
* Supports modern TypeScript features like [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) and [incremental mode](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#faster-subsequent-builds-with-the---incremental-flag) ✨
* Supports [Vue Single File Component](https://vuejs.org/v2/guide/single-file-components.html) ✅ 
* Displays nice error messages with the [code frame](https://babeljs.io/docs/en/next/babel-code-frame.html) formatter 🌈
## Installation
This plugin requires minimum **Node.js 10**, **Webpack 4**, **TypeScript 2.7** and optionally **ESLint 6**
* If you depend on **Webpack 2**, **Webpack 3**, or **TSLint 4**, please use [version 3](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v3.1.1) of the plugin.
* If you depend on **TypeScript >= 2.1** and **< 2.7** or you can't update to **Node 10**, please use [version 4](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v4.1.4) of the plugin.
```sh
# with npm
npm install --save-dev fork-ts-checker-webpack-plugin
# with yarn
yarn add --dev fork-ts-checker-webpack-plugin
```
The minimal webpack config (with [ts-loader](https://github.com/TypeStrong/ts-loader))
```js
// webpack.config.js
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = {
context: __dirname, // to automatically find tsconfig.json
entry: './src/index.ts',
resolve: {
extensions: [".ts", ".tsx", ".js"],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
// disable type checker - we will use it in fork plugin
transpileOnly: true
}
}
]
},
plugins: [new ForkTsCheckerWebpackPlugin()]
};
```
> Examples how to configure it with [babel-loader](https://github.com/babel/babel-loader), [ts-loader](https://github.com/TypeStrong/ts-loader),
> [eslint](https://github.com/eslint/eslint) and [Visual Studio Code](https://code.visualstudio.com/) are in the
> [**examples**](./examples) directory.
## Modules resolution
It's very important to be aware that **this plugin uses [TypeScript](https://github.com/Microsoft/TypeScript)'s, not
[webpack](https://github.com/webpack/webpack)'s modules resolution**. It means that you have to setup `tsconfig.json` correctly.
> It's because of the performance - with TypeScript's module resolution we don't have to wait for webpack to compile files.
>
> To debug TypeScript's modules resolution, you can use `tsc --traceResolution` command.
## ESLint
If you'd like to use ESLint with the plugin, ensure you have the relevant dependencies installed:
```sh
# with npm
npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
# with yarn
yarn add --dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
```
Then set up ESLint in the plugin. This is the minimal configuration:
```js
// webpack.config.js
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = {
// ...the webpack configuration
plugins: [
new ForkTsCheckerWebpackPlugin({
eslint: {
files: './src/**/*.{ts,tsx,js,jsx}' // required - same as command `eslint ./src/**/*.{ts,tsx,js,jsx} --ext .ts,.tsx,.js,.jsx`
}
})
]
};
```
You should also have an ESLint configuration file in your root project directory.
Here is a sample `.eslintrc.js` configuration for a TypeScript project:
```js
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
extends: [
'plugin:@typescript-eslint/recommended'
],
rules: {
// place to specify ESLint rules - can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
}
};
```
There's a [good explanation on setting up TypeScript ESLint support by Robert Cooper](https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb).
## Options
This plugin uses [`cosmiconfig`](https://github.com/davidtheclark/cosmiconfig). This means that besides the plugin constructor,
you can place your configuration in the:
* `"fork-ts-checker"` field in the `package.json`
* `.fork-ts-checkerrc` file in JSON or YAML format
* `fork-ts-checker.config.js` file exporting a JS object
Options passed to the plugin constructor will overwrite options from the cosmiconfig (using [deepmerge](https://github.com/TehShrike/deepmerge)).
| Name | Type | Default value | Description |
| ----------------- | ---------------------------------- | ------------------------------------------------------------------ | ----------- |
| `async` | `boolean` | `compiler.options.mode === 'development'` | If `true`, reports issues **after** webpack's compilation is done. Thanks to that it doesn't block the compilation. Used only in the `watch` mode. |
| `typescript` | `object` or `boolean` | `true` | If a `boolean`, it enables/disables TypeScript checker. If an `object`, see [TypeScript options](#typescript-options). |
| `eslint` | `object` | `undefined` | If `undefined`, it disables ESLint linter. If an `object`, see [ESLint options](#eslint-options). |
| `issue` | `object` | `{}` | See [Issues options](#issues-options). |
| `formatter` | `string` or `object` or `function` | `codeframe` | Available formatters are `basic`, `codeframe` and a custom `function`. To [configure](https://babeljs.io/docs/en/babel-code-frame#options) `codeframe` formatter, pass object: `{ type: 'codeframe', options: { <coderame options> } }`. |
| `logger` | `object` | `{ infrastructure: 'silent', issues: 'console', devServer: true }` | Available loggers are `silent`, `console`, and `webpack-infrastructure`. Infrastructure logger prints additional information, issue logger prints `issues` in the `async` mode. If `devServer` is set to `false`, errors will not be reported to Webpack Dev Server. |
### TypeScript options
Options for the TypeScript checker (`typescript` option object).
| Name | Type | Default value | Description |
| -------------------- | --------- | -------------------------------------------------------------------------------------------------------------- | ----------- |
| `enabled` | `boolean` | `true` | If `true`, it enables TypeScript checker. |
| `memoryLimit` | `number` | `2048` | Memory limit for the checker process in MB. If the process exits with the allocation failed error, try to increase this number. |
| `configFile` | `string` | `'tsconfig.json'` | Path to the `tsconfig.json` file (path relative to the `compiler.options.context` or absolute path) |
| `configOverwrite` | `object` | `{ compilerOptions: { skipLibCheck: true, sourceMap: false, inlineSourceMap: false, declarationMap: false } }` | This configuration will overwrite configuration from the `tsconfig.json` file. Supported fields are: `extends`, `compilerOptions`, `include`, `exclude`, `files`, and `references`. |
| `context` | `string` | `dirname(configuration.configFile)` | The base path for finding files specified in the `tsconfig.json`. Same as the `context` option from the [ts-loader](https://github.com/TypeStrong/ts-loader#context). Useful if you want to keep your `tsconfig.json` in an external package. Keep in mind that **not** having a `tsconfig.json` in your project root can cause different behaviour between `fork-ts-checker-webpack-plugin` and `tsc`. When using editors like `VS Code` it is advised to add a `tsconfig.json` file to the root of the project and extend the config file referenced in option `configFile`. |
| `build` | `boolean` | `false` | The equivalent of the `--build` flag for the `tsc` command. |
| `mode` | `'readonly'` or `'write-tsbuildinfo'` or `'write-dts'` or `'write-references'` | `'write-tsbuildinfo'` | If you use the `babel-loader`, it's recommended to use `write-references` mode to improve initial compilation time. If you use `ts-loader`, it's recommended to use `write-tsbuildinfo` mode to not overwrite files emitted by the `ts-loader`. If you use `ts-loader` with `transpileOnly` flag set to `true`, use `'write-dts` to emit the type definition files. |
| `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
| `extensions` | `object` | `{}` | See [TypeScript extensions options](#typescript-extensions-options). |
| `profile` | `boolean` | `false` | Measures and prints timings related to the TypeScript performance. |
| `typescriptPath` | `string` | `require.resolve('typescript')` | If supplied this is a custom path where TypeScript can be found. |
#### TypeScript extensions options
Options for the TypeScript checker extensions (`typescript.extensions` option object).
| Name | Type | Default value | Description |
| -------------------- | --------------------- | ------------------------- | ----------- |
| `vue` | `object` or `boolean` | `false` | If `true`, it enables Vue [Single File Component](https://vuejs.org/v2/guide/single-file-components.html) support. |
| `vue.enabled` | `boolean` | `false` | Same as the `vue` option |
| `vue.compiler` | `string` | `'vue-template-compiler'` | The package name of the compiler that will be used to parse `.vue` files. You can use `'nativescript-vue-template-compiler'` if you use [nativescript-vue](https://github.com/nativescript-vue/nativescript-vue) |
### ESLint options
Options for the ESLint linter (`eslint` option object).
| Name | Type | Default value | Description |
| -------------------- | ---------------------- | ------------------------- | ----------- |
| `enabled` | `boolean` | `false` | If `true`, it enables ESLint linter. If you set the `files` option, it will be `true` by default. |
| `files` | `string` or `string[]` | This value is required | One or more [glob patterns](https://en.wikipedia.org/wiki/Glob_(programming)) to the files that should be linted. Works the same as the `eslint` command. |
| `memoryLimit` | `number` | `2048` | Memory limit for the linter process in MB. If the process exits with the allocation failed error, try to increase this number. |
| `options` | `object` | `{}` | [Options](https://eslint.org/docs/developer-guide/nodejs-api#cliengine) that can be used to initialize ESLint. |
### Issues options
Options for the issues filtering (`issue` option object).
I could write some plain text explanation of these options but I think code will explain it better:
```typescript
interface Issue {
origin: 'typescript' | 'eslint';
severity: 'error' | 'warning';
code: string;
file?: string;
}
type IssueMatch = Partial<Issue>; // file field supports glob matching
type IssuePredicate = (issue: Issue) => boolean;
type IssueFilter = IssueMatch | IssuePredicate | (IssueMatch | IssuePredicate)[];
```
| Name | Type | Default value | Description |
| --------- | ------------- | ------------- | ----------- |
| `include` | `IssueFilter` | `undefined` | If `object`, defines issue properties that should be [matched](./src/issue/IssueMatch.ts). If `function`, acts as a predicate where `issue` is an argument. |
| `exclude` | `IssueFilter` | `undefined` | Same as `include` but issues that match this predicate will be excluded. |
<details>
<summary>Expand example</summary>
Include issues from the `src` directory, exclude eslint issues from `.spec.ts` files:
```js
module.exports = {
// ...the webpack configuration
plugins: [
new ForkTsCheckerWebpackPlugin({
issue: {
include: [
{ file: '**/src/**/*' }
],
exclude: [
{ origin: 'eslint', file: '**/*.spec.ts' }
]
}
})
]
};
```
</details>
## Vue.js
⚠️ There are additional **constraints** regarding Vue.js Single File Component support: ⚠️
* It requires **TypeScript >= 3.8.0** (it's a limitation of the `transpileOnly` mode from `ts-loader`)
* It doesn't work with the `build` mode (project references)
To enable Vue.js support, follow these steps:
<details>
<summary>Expand Vue.js set up instruction</summary>
1. Ensure you have all required packages installed:
```sh
# with npm
npm install --save vue vue-class-component
npm install --save-dev vue-loader ts-loader css-loader vue-template-compiler
# with yarn
yarn add vue vue-class-component
yarn add --dev vue-loader ts-loader css-loader vue-template-compiler
```
2. Add `tsconfig.json` configuration:
```json
{
"compilerOptions": {
"experimentalDecorators": true,
"jsx": "preserve",
"target": "ES5",
"lib": ["ES6", "DOM"],
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"~/*": ["src/*"]
},
"sourceMap": true,
"importsNotUsedAsValues": "preserve"
},
"include": [
"src/**/*.ts",
"src/**/*.vue"
],
"exclude": [
"node_modules"
]
}
```
3. Add `webpack.config.js` configuration:
```js
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = {
entry: './src/index.ts',
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
appendTsSuffixTo: [/\.vue$/],
transpileOnly: true
}
},
{
test: /\.css$/,
loader: 'css-loader'
},
],
},
resolve: {
extensions: ['.ts', '.js', '.vue', '.json'],
alias: {
'@': path.resolve(__dirname, './src'),
'~': path.resolve(__dirname, './src'),
}
},
plugins: [
new VueLoaderPlugin(),
new ForkTsCheckerWebpackPlugin({
typescript: {
extensions: {
vue: true
}
}
})
]
};
```
4. Add `src/types/vue.d.ts` file to shim `.vue` modules:
```typescript
declare module "*.vue" {
import Vue from "vue";
export default Vue;
}
```
5. If you are working in VSCode, you can get the [Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur) extension to complete the developer workflow.
</details>
## Plugin hooks
This plugin provides some custom webpack hooks:
| Hook key | Type | Params | Description |
| ---------- | -------------------------- | --------------------- | ----------- |
| `start` | `AsyncSeriesWaterfallHook` | `change, compilation` | Starts issues checking for a compilation. It's an async waterfall hook, so you can modify the list of changed and removed files or delay the start of the service. |
| `waiting` | `SyncHook` | `compilation` | Waiting for the issues checking. |
| `canceled` | `SyncHook` | `compilation` | Issues checking for the compilation has been canceled. |
| `error` | `SyncHook` | `compilation` | An error occurred during issues checking. |
| `issues` | `SyncWaterfallHook` | `issues, compilation` | Issues have been received and will be reported. It's a waterfall hook, so you can modify the list of received issues. |
To access plugin hooks and tap into the event, we need to use the `getCompilerHooks` static method.
When we call this method with a [webpack compiler instance](https://webpack.js.org/api/node/), it returns the object with
[tapable](https://github.com/webpack/tapable) hooks where you can pass in your callbacks.
```js
// ./src/webpack/MyWebpackPlugin.js
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
class MyWebpackPlugin {
apply(compiler) {
const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);
// log some message on waiting
hooks.waiting.tap('MyPlugin', () => {
console.log('waiting for issues');
});
// don't show warnings
hooks.issues.tap('MyPlugin', (issues) =>
issues.filter((issue) => issue.severity === 'error')
);
}
}
module.exports = MyWebpackPlugin;
// webpack.config.js
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const MyWebpackPlugin = require('./src/webpack/MyWebpackPlugin');
module.exports = {
/* ... */
plugins: [
new ForkTsCheckerWebpackPlugin(),
new MyWebpackPlugin()
]
};
```
## Typings
To use the plugin typings, you have to install `@types/webpack`. It's not included by default to not collide with your
existing typings (`@types/webpack` imports `@types/node`). [It's an old TypeScript issue](https://github.com/microsoft/TypeScript/issues/18588),
the alternative is to set `skipLibCheck: true` in the `compilerOptions` 😉
```sh
# with npm
npm install --save-dev @types/webpack
# with yarn
yarn add --dev @types/webpack
```
## Profiling types resolution
Starting from TypeScript 4.1.0, you can profile long type checks by
setting "generateTrace" compiler option. This is an instruction from [microsoft/TypeScript#40063](https://github.com/microsoft/TypeScript/pull/40063):
1. Set "generateTrace": "{folderName}" in your `tsconfig.json`
2. Look in the resulting folder. If you used build mode, there will be a `legend.json` telling you what went where.
Otherwise, there will be `trace.json` file and `types.json` files.
3. Navigate to [edge://tracing](edge://tracing) or [chrome://tracing](chrome://tracing) and load `trace.json`
4. Expand Process 1 with the little triangle in the left sidebar
5. Click on different blocks to see their payloads in the bottom pane
6. Open `types.json` in an editor
7. When you see a type ID in the tracing output, go-to-line {id} to find data about that type
## Related projects
* [`ts-loader`](https://github.com/TypeStrong/ts-loader) - TypeScript loader for webpack.
* [`babel-loader`](https://github.com/babel/babel-loader) - Alternative TypeScript loader for webpack.
* [`fork-ts-checker-notifier-webpack-plugin`](https://github.com/johnnyreilly/fork-ts-checker-notifier-webpack-plugin) - Notifies about build status using system notifications (similar to the [webpack-notifier](https://github.com/Turbo87/webpack-notifier)).
## Credits
This plugin was created in [Realytics](https://www.realytics.io/) in 2017. Thank you for supporting Open Source.
## License
MIT License

View File

@@ -0,0 +1,36 @@
module.exports = {
list: ['feat', 'fix', 'refactor', 'perf', 'test', 'chore', 'docs'],
maxMessageLength: 64,
minMessageLength: 3,
questions: ['type', 'subject', 'body', 'breaking', 'issues'],
types: {
feat: {
description: 'A new feature',
value: 'feat',
},
fix: {
description: 'A bug fix',
value: 'fix',
},
refactor: {
description: 'A code change that neither adds a feature or fixes a bug',
value: 'refactor',
},
perf: {
description: 'A code change that improves performance',
value: 'perf',
},
test: {
description: 'Adding missing tests',
value: 'test',
},
chore: {
description: 'Build process, CI or auxiliary tool changes',
value: 'chore',
},
docs: {
description: 'Documentation only changes',
value: 'docs',
},
},
};

View File

@@ -0,0 +1,29 @@
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginOptions } from './ForkTsCheckerWebpackPluginOptions';
import { Pool } from './utils/async/pool';
declare class ForkTsCheckerWebpackPlugin implements webpack.Plugin {
/**
* Current version of the plugin
*/
static readonly version: string;
/**
* Default pools for the plugin concurrency limit
*/
static readonly issuesPool: Pool;
static readonly dependenciesPool: Pool;
/**
* @deprecated Use ForkTsCheckerWebpackPlugin.issuesPool instead
*/
static get pool(): Pool;
private readonly options;
constructor(options?: ForkTsCheckerWebpackPluginOptions);
static getCompilerHooks(compiler: webpack.Compiler): {
start: import("tapable").AsyncSeriesWaterfallHook<import("./reporter/FilesChange").FilesChange, webpack.compilation.Compilation, any>;
waiting: import("tapable").SyncHook<webpack.compilation.Compilation, any, any>;
canceled: import("tapable").SyncHook<webpack.compilation.Compilation, any, any>;
error: import("tapable").SyncHook<Error, webpack.compilation.Compilation, any>;
issues: import("tapable").SyncWaterfallHook<import("./issue/Issue").Issue[], webpack.compilation.Compilation | undefined, void>;
};
apply(compiler: webpack.Compiler): void;
}
export { ForkTsCheckerWebpackPlugin };

View File

@@ -0,0 +1,84 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const schema_utils_1 = __importDefault(require("schema-utils"));
const cosmiconfig_1 = require("cosmiconfig");
const deepmerge_1 = __importDefault(require("deepmerge"));
const ForkTsCheckerWebpackPluginOptions_json_1 = __importDefault(require("./ForkTsCheckerWebpackPluginOptions.json"));
const ForkTsCheckerWebpackPluginConfiguration_1 = require("./ForkTsCheckerWebpackPluginConfiguration");
const ForkTsCheckerWebpackPluginState_1 = require("./ForkTsCheckerWebpackPluginState");
const reporter_1 = require("./reporter");
const TypeScriptSupport_1 = require("./typescript-reporter/TypeScriptSupport");
const TypeScriptReporterRpcClient_1 = require("./typescript-reporter/reporter/TypeScriptReporterRpcClient");
const assertEsLintSupport_1 = require("./eslint-reporter/assertEsLintSupport");
const EsLintReporterRpcClient_1 = require("./eslint-reporter/reporter/EsLintReporterRpcClient");
const tapStartToConnectAndRunReporter_1 = require("./hooks/tapStartToConnectAndRunReporter");
const tapStopToDisconnectReporter_1 = require("./hooks/tapStopToDisconnectReporter");
const tapAfterCompileToAddDependencies_1 = require("./hooks/tapAfterCompileToAddDependencies");
const tapErrorToLogMessage_1 = require("./hooks/tapErrorToLogMessage");
const pluginHooks_1 = require("./hooks/pluginHooks");
const tapAfterEnvironmentToPatchWatching_1 = require("./hooks/tapAfterEnvironmentToPatchWatching");
const pool_1 = require("./utils/async/pool");
const os_1 = __importDefault(require("os"));
class ForkTsCheckerWebpackPlugin {
constructor(options = {}) {
const explorerSync = cosmiconfig_1.cosmiconfigSync('fork-ts-checker');
const { config: externalOptions } = explorerSync.search() || {};
// first validate options directly passed to the constructor
const configuration = { name: 'ForkTsCheckerWebpackPlugin' };
schema_utils_1.default(ForkTsCheckerWebpackPluginOptions_json_1.default, options, configuration);
this.options = deepmerge_1.default(externalOptions || {}, options || {});
// then validate merged options
schema_utils_1.default(ForkTsCheckerWebpackPluginOptions_json_1.default, this.options, configuration);
}
/**
* @deprecated Use ForkTsCheckerWebpackPlugin.issuesPool instead
*/
static get pool() {
// for backward compatibility
return ForkTsCheckerWebpackPlugin.issuesPool;
}
static getCompilerHooks(compiler) {
return pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
}
apply(compiler) {
const configuration = ForkTsCheckerWebpackPluginConfiguration_1.createForkTsCheckerWebpackPluginConfiguration(compiler, this.options);
const state = ForkTsCheckerWebpackPluginState_1.createForkTsCheckerWebpackPluginState();
const issuesReporters = [];
const dependenciesReporters = [];
if (configuration.typescript.enabled) {
TypeScriptSupport_1.assertTypeScriptSupport(configuration.typescript);
issuesReporters.push(TypeScriptReporterRpcClient_1.createTypeScriptReporterRpcClient(configuration.typescript));
dependenciesReporters.push(TypeScriptReporterRpcClient_1.createTypeScriptReporterRpcClient(configuration.typescript));
}
if (configuration.eslint.enabled) {
assertEsLintSupport_1.assertEsLintSupport(configuration.eslint);
issuesReporters.push(EsLintReporterRpcClient_1.createEsLintReporterRpcClient(configuration.eslint));
dependenciesReporters.push(EsLintReporterRpcClient_1.createEsLintReporterRpcClient(configuration.eslint));
}
if (issuesReporters.length) {
const issuesReporter = reporter_1.createAggregatedReporter(reporter_1.composeReporterRpcClients(issuesReporters));
const dependenciesReporter = reporter_1.createAggregatedReporter(reporter_1.composeReporterRpcClients(dependenciesReporters));
tapAfterEnvironmentToPatchWatching_1.tapAfterEnvironmentToPatchWatching(compiler, state);
tapStartToConnectAndRunReporter_1.tapStartToConnectAndRunReporter(compiler, issuesReporter, dependenciesReporter, configuration, state);
tapAfterCompileToAddDependencies_1.tapAfterCompileToAddDependencies(compiler, configuration, state);
tapStopToDisconnectReporter_1.tapStopToDisconnectReporter(compiler, issuesReporter, dependenciesReporter, state);
tapErrorToLogMessage_1.tapErrorToLogMessage(compiler, configuration);
}
else {
throw new Error(`ForkTsCheckerWebpackPlugin is configured to not use any issue reporter. It's probably a configuration issue.`);
}
}
}
exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
/**
* Current version of the plugin
*/
ForkTsCheckerWebpackPlugin.version = '6.5.3'; // will be replaced by the @semantic-release/exec
/**
* Default pools for the plugin concurrency limit
*/
ForkTsCheckerWebpackPlugin.issuesPool = pool_1.createPool(Math.max(1, os_1.default.cpus().length));
ForkTsCheckerWebpackPlugin.dependenciesPool = pool_1.createPool(Math.max(1, os_1.default.cpus().length));

View File

@@ -0,0 +1,17 @@
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginOptions } from './ForkTsCheckerWebpackPluginOptions';
import { IssueConfiguration } from './issue/IssueConfiguration';
import { FormatterConfiguration } from './formatter';
import { TypeScriptReporterConfiguration } from './typescript-reporter/TypeScriptReporterConfiguration';
import { EsLintReporterConfiguration } from './eslint-reporter/EsLintReporterConfiguration';
import { LoggerConfiguration } from './logger/LoggerConfiguration';
interface ForkTsCheckerWebpackPluginConfiguration {
async: boolean;
typescript: TypeScriptReporterConfiguration;
eslint: EsLintReporterConfiguration;
issue: IssueConfiguration;
formatter: FormatterConfiguration;
logger: LoggerConfiguration;
}
declare function createForkTsCheckerWebpackPluginConfiguration(compiler: webpack.Compiler, options?: ForkTsCheckerWebpackPluginOptions): ForkTsCheckerWebpackPluginConfiguration;
export { ForkTsCheckerWebpackPluginConfiguration, createForkTsCheckerWebpackPluginConfiguration };

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const IssueConfiguration_1 = require("./issue/IssueConfiguration");
const formatter_1 = require("./formatter");
const TypeScriptReporterConfiguration_1 = require("./typescript-reporter/TypeScriptReporterConfiguration");
const EsLintReporterConfiguration_1 = require("./eslint-reporter/EsLintReporterConfiguration");
const LoggerConfiguration_1 = require("./logger/LoggerConfiguration");
function createForkTsCheckerWebpackPluginConfiguration(compiler, options = {}) {
return {
async: options.async === undefined ? compiler.options.mode === 'development' : options.async,
typescript: TypeScriptReporterConfiguration_1.createTypeScriptReporterConfiguration(compiler, options.typescript),
eslint: EsLintReporterConfiguration_1.createEsLintReporterConfiguration(compiler, options.eslint),
issue: IssueConfiguration_1.createIssueConfiguration(compiler, options.issue),
formatter: formatter_1.createFormatterConfiguration(options.formatter),
logger: LoggerConfiguration_1.createLoggerConfiguration(compiler, options.logger),
};
}
exports.createForkTsCheckerWebpackPluginConfiguration = createForkTsCheckerWebpackPluginConfiguration;

View File

@@ -0,0 +1,14 @@
import { TypeScriptReporterOptions } from './typescript-reporter/TypeScriptReporterOptions';
import { EsLintReporterOptions } from './eslint-reporter/EsLintReporterOptions';
import { IssueOptions } from './issue/IssueOptions';
import { FormatterOptions } from './formatter';
import LoggerOptions from './logger/LoggerOptions';
interface ForkTsCheckerWebpackPluginOptions {
async?: boolean;
typescript?: TypeScriptReporterOptions;
eslint?: EsLintReporterOptions;
formatter?: FormatterOptions;
issue?: IssueOptions;
logger?: LoggerOptions;
}
export { ForkTsCheckerWebpackPluginOptions };

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,297 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"async": {
"type": "boolean",
"description": "When true, plugin will not block compilation to finish issues checking"
},
"typescript": {
"$ref": "#/definitions/TypeScriptReporterOptions"
},
"eslint": {
"$ref": "#/definitions/EsLintReporterOptions"
},
"formatter": {
"$ref": "#/definitions/FormatterOptions"
},
"issue": {
"$ref": "#/definitions/IssueOptions"
},
"logger": {
"$ref": "#/definitions/LoggerOptions"
}
},
"additionalProperties": false,
"definitions": {
"Formatter": {
"instanceof": "Function"
},
"ComplexFormatterPreferences": {
"type": "object",
"properties": {
"type": {
"$ref": "#/definitions/FormatterType"
},
"options": {
"type": "object",
"additionalProperties": true
}
},
"required": ["type"]
},
"FormatterType": {
"type": "string",
"enum": ["basic", "codeframe"]
},
"IssueMatch": {
"type": "object",
"properties": {
"origin": {
"type": "string",
"enum": ["typescript", "eslint"]
},
"severity": {
"type": "string",
"enum": ["error", "warning"]
},
"code": {
"type": "string"
},
"file": {
"type": "string"
}
}
},
"IssuePredicate": {
"instanceof": "Function"
},
"IssuePredicateOption": {
"oneOf": [
{
"$ref": "#/definitions/IssuePredicate"
},
{
"$ref": "#/definitions/IssueMatch"
},
{
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#/definitions/IssuePredicate"
},
{
"$ref": "#/definitions/IssueMatch"
}
]
}
}
]
},
"LoggerType": {
"type": "string",
"enum": ["console", "webpack-infrastructure", "silent"]
},
"Logger": {
"type": "object",
"properties": {
"error": {
"instanceof": "Function"
},
"info": {
"instanceof": "Function"
},
"log": {
"instanceof": "Function"
}
}
},
"TypeScriptReporterOptions": {
"oneOf": [
{
"type": "boolean",
"description": "Enable TypeScript reporter."
},
{
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"description": "Enable TypeScript reporter."
},
"memoryLimit": {
"type": "number",
"description": "Memory limit for TypeScript reporter process."
},
"configFile": {
"type": "string",
"description": "Path to tsconfig.json. By default plugin uses context or process.cwd() to localize tsconfig.json file."
},
"context": {
"type": "string",
"description": "The base path for finding files specified in the tsconfig.json. Same as context option from the ts-loader."
},
"build": {
"type": "boolean",
"description": "The equivalent of the `--build` flag from the `tsc`."
},
"mode": {
"type": "string",
"enum": ["readonly", "write-tsbuildinfo", "write-dts", "write-references"],
"description": "`readonly` keeps all emitted files in memory, `write-tsbuildinfo` which writes only .tsbuildinfo files, `write-dts` writes .tsbuildinfo and type definition files, and `write-references` which writes both .tsbuildinfo and referenced projects output"
},
"compilerOptions": {
"type": "object",
"description": "Custom compilerOptions to be passed to the TypeScript compiler.",
"additionalProperties": true
},
"diagnosticOptions": {
"type": "object",
"description": "Types of diagnostics to be reported.",
"properties": {
"syntactic": {
"type": "boolean"
},
"semantic": {
"type": "boolean"
},
"declaration": {
"type": "boolean"
},
"global": {
"type": "boolean"
}
}
},
"extensions": {
"type": "object",
"properties": {
"vue": {
"$ref": "#/definitions/TypeScriptVueExtensionOptions"
}
}
},
"profile": {
"type": "boolean",
"description": "Measures and prints timings related to the TypeScript performance."
},
"typescriptPath": {
"type": "string",
"description": "If supplied this is a custom path where TypeScript can be found."
}
}
}
]
},
"TypeScriptVueExtensionOptions": {
"oneOf": [
{
"type": "boolean",
"description": "Enable TypeScript Vue extension."
},
{
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"description": "Enable TypeScript Vue extension."
},
"compiler": {
"type": "string",
"description": "Custom vue-template-compiler package"
}
}
}
]
},
"EsLintReporterOptions": {
"type": "object",
"properties": {
"files": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
},
{
"type": "string"
}
],
"description": "List of glob patterns or files to be linted."
},
"enabled": {
"type": "boolean",
"description": "Enable EsLint reporter."
},
"memoryLimit": {
"type": "number",
"description": "Memory limit for EsLint reporter process."
},
"options": {
"type": "object",
"description": "Custom options to be passed to the EsLint engine.",
"additionalProperties": true
}
},
"required": ["files"]
},
"FormatterOptions": {
"oneOf": [
{
"$ref": "#/definitions/FormatterType"
},
{
"$ref": "#/definitions/ComplexFormatterPreferences"
},
{
"$ref": "#/definitions/Formatter"
}
]
},
"IssueOptions": {
"type": "object",
"properties": {
"include": {
"$ref": "#/definitions/IssuePredicateOption"
},
"exclude": {
"$ref": "#/definitions/IssuePredicateOption"
}
}
},
"LoggerOptions": {
"type": "object",
"properties": {
"infrastructure": {
"oneOf": [
{
"$ref": "#/definitions/LoggerType"
},
{
"$ref": "#/definitions/Logger"
}
]
},
"issues": {
"oneOf": [
{
"$ref": "#/definitions/LoggerType"
},
{
"$ref": "#/definitions/Logger"
}
]
},
"devServer": {
"type": "boolean",
"description": "Enable reporting to Webpack Dev Server."
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
import { Tap } from 'tapable';
import { FilesMatch, Report } from './reporter';
import { Issue } from './issue';
interface ForkTsCheckerWebpackPluginState {
issuesReportPromise: Promise<Report | undefined>;
dependenciesReportPromise: Promise<Report | undefined>;
issuesPromise: Promise<Issue[] | undefined>;
dependenciesPromise: Promise<FilesMatch | undefined>;
lastDependencies: FilesMatch | undefined;
watching: boolean;
initialized: boolean;
webpackDevServerDoneTap: Tap | undefined;
}
declare function createForkTsCheckerWebpackPluginState(): ForkTsCheckerWebpackPluginState;
export { ForkTsCheckerWebpackPluginState, createForkTsCheckerWebpackPluginState };

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function createForkTsCheckerWebpackPluginState() {
return {
issuesReportPromise: Promise.resolve(undefined),
dependenciesReportPromise: Promise.resolve(undefined),
issuesPromise: Promise.resolve(undefined),
dependenciesPromise: Promise.resolve(undefined),
lastDependencies: undefined,
watching: false,
initialized: false,
webpackDevServerDoneTap: undefined,
};
}
exports.createForkTsCheckerWebpackPluginState = createForkTsCheckerWebpackPluginState;

View File

@@ -0,0 +1,4 @@
declare class OperationCanceledError extends Error {
readonly canceled = true;
}
export { OperationCanceledError };

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class OperationCanceledError extends Error {
constructor() {
super(...arguments);
this.canceled = true;
}
}
exports.OperationCanceledError = OperationCanceledError;

View File

@@ -0,0 +1,11 @@
import webpack from 'webpack';
import { EsLintReporterOptions } from './EsLintReporterOptions';
import { CLIEngineOptions } from './types/eslint';
interface EsLintReporterConfiguration {
enabled: boolean;
memoryLimit: number;
options: CLIEngineOptions;
files: string[];
}
declare function createEsLintReporterConfiguration(compiler: webpack.Compiler, options: EsLintReporterOptions | undefined): EsLintReporterConfiguration;
export { EsLintReporterConfiguration, createEsLintReporterConfiguration };

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
function castToArray(value) {
if (!value) {
return [];
}
else if (!Array.isArray(value)) {
return [value];
}
else {
return value;
}
}
function createEsLintReporterConfiguration(compiler, options) {
const filesPatterns = (typeof options === 'object' ? castToArray(options.files) : []).map((filesPattern) =>
// ensure that `filesPattern` is an absolute path
path_1.isAbsolute(filesPattern)
? filesPattern
: path_1.join(compiler.options.context || process.cwd(), filesPattern));
return Object.assign(Object.assign({ enabled: !!options &&
typeof options !== 'boolean' &&
filesPatterns.length > 0 && // enable by default if files are provided
options.enabled !== false, memoryLimit: 2048 }, (typeof options === 'object' ? options : {})), { files: filesPatterns, options: Object.assign({ cwd: compiler.options.context || process.cwd(), extensions: ['.ts', '.tsx', '.js', '.jsx'] }, (typeof options === 'object' ? options.options || {} : {})) });
}
exports.createEsLintReporterConfiguration = createEsLintReporterConfiguration;

View File

@@ -0,0 +1,8 @@
import { CLIEngineOptions } from './types/eslint';
declare type EsLintReporterOptions = {
files: string | string[];
enabled?: boolean;
memoryLimit?: number;
options?: CLIEngineOptions;
};
export { EsLintReporterOptions };

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,3 @@
import { EsLintReporterConfiguration } from './EsLintReporterConfiguration';
declare function assertEsLintSupport(configuration: EsLintReporterConfiguration): void;
export { assertEsLintSupport };

View File

@@ -0,0 +1,30 @@
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const semver = __importStar(require("semver"));
function assertEsLintSupport(configuration) {
if (semver.lt(process.version, '8.10.0')) {
throw new Error(`To use 'eslint' option, please update to Node.js >= v8.10.0 ` +
`(current version is ${process.version})`);
}
let eslintVersion;
try {
eslintVersion = require('eslint').Linter.version;
}
catch (error) {
throw new Error(`When you use 'eslint' option, make sure to install 'eslint'.`);
}
if (semver.lt(eslintVersion, '6.0.0')) {
throw new Error(`Cannot use current eslint version of ${eslintVersion}, the minimum required version is 6.0.0`);
}
if (!configuration.files) {
throw new Error('The `eslint.files` settings is required for EsLint reporter to work.');
}
}
exports.assertEsLintSupport = assertEsLintSupport;

View File

@@ -0,0 +1,4 @@
import { Issue } from '../../issue';
import { LintResult } from '../types/eslint';
declare function createIssuesFromEsLintResults(results: LintResult[]): Issue[];
export { createIssuesFromEsLintResults };

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function createIssueFromEsLintMessage(filePath, message) {
let location;
if (message.line) {
location = {
start: {
line: message.line,
column: message.column,
},
end: {
line: message.endLine || message.line,
column: message.endColumn || message.column,
},
};
}
return {
origin: 'eslint',
code: message.ruleId ? String(message.ruleId) : '[unknown]',
severity: message.severity === 1 ? 'warning' : 'error',
message: message.message,
file: filePath,
location,
};
}
function createIssuesFromEsLintResults(results) {
return results.reduce((messages, result) => [
...messages,
...result.messages.map((message) => createIssueFromEsLintMessage(result.filePath, message)),
], []);
}
exports.createIssuesFromEsLintResults = createIssuesFromEsLintResults;

View File

@@ -0,0 +1,4 @@
import { EsLintReporterConfiguration } from '../EsLintReporterConfiguration';
import { Reporter } from '../../reporter';
declare function createEsLintReporter(configuration: EsLintReporterConfiguration): Reporter;
export { createEsLintReporter };

View File

@@ -0,0 +1,179 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const EsLintIssueFactory_1 = require("../issue/EsLintIssueFactory");
const path_1 = __importDefault(require("path"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const minimatch_1 = __importDefault(require("minimatch"));
const glob_1 = __importDefault(require("glob"));
const isOldCLIEngine = (eslint) => eslint.resolveFileGlobPatterns !== undefined;
function createEsLintReporter(configuration) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { CLIEngine, ESLint } = require('eslint');
const eslint = ESLint
? new ESLint(configuration.options)
: new CLIEngine(configuration.options);
let isInitialRun = true;
let isInitialGetFiles = true;
const lintResults = new Map();
const includedGlobPatterns = resolveFileGlobPatterns(configuration.files);
const includedFiles = new Set();
function isFileIncluded(path) {
return __awaiter(this, void 0, void 0, function* () {
return (!path.includes('node_modules') &&
includedGlobPatterns.some((pattern) => minimatch_1.default(path, pattern)) &&
!(yield eslint.isPathIgnored(path)));
});
}
function getFiles() {
return __awaiter(this, void 0, void 0, function* () {
if (isInitialGetFiles) {
isInitialGetFiles = false;
const resolvedGlobs = yield Promise.all(includedGlobPatterns.map((globPattern) => new Promise((resolve) => {
glob_1.default(globPattern, (error, resolvedFiles) => {
if (error) {
// fail silently
resolve([]);
}
else {
resolve(resolvedFiles || []);
}
});
})));
for (const resolvedGlob of resolvedGlobs) {
for (const resolvedFile of resolvedGlob) {
if (yield isFileIncluded(resolvedFile)) {
includedFiles.add(resolvedFile);
}
}
}
}
return Array.from(includedFiles);
});
}
function getDirs() {
return includedGlobPatterns || [];
}
function getExtensions() {
return configuration.options.extensions || [];
}
// Copied from the eslint 6 implementation, as it's not available in eslint 8
function resolveFileGlobPatterns(globPatterns) {
if (configuration.options.globInputPaths === false) {
return globPatterns.filter(Boolean);
}
const extensions = getExtensions().map((ext) => ext.replace(/^\./u, ''));
const dirSuffix = `/**/*.{${extensions.join(',')}}`;
return globPatterns.filter(Boolean).map((globPattern) => {
const resolvedPath = path_1.default.resolve(configuration.options.cwd || '', globPattern);
const newPath = directoryExists(resolvedPath)
? globPattern.replace(/[/\\]$/u, '') + dirSuffix
: globPattern;
return path_1.default.normalize(newPath).replace(/\\/gu, '/');
});
}
// Copied from the eslint 6 implementation, as it's not available in eslint 8
function directoryExists(resolvedPath) {
try {
return fs_extra_1.default.statSync(resolvedPath).isDirectory();
}
catch (error) {
if (error && error.code === 'ENOENT') {
return false;
}
throw error;
}
}
return {
getReport: ({ changedFiles = [], deletedFiles = [] }) => __awaiter(this, void 0, void 0, function* () {
return {
getDependencies() {
return __awaiter(this, void 0, void 0, function* () {
for (const changedFile of changedFiles) {
if (yield isFileIncluded(changedFile)) {
includedFiles.add(changedFile);
}
}
for (const deletedFile of deletedFiles) {
includedFiles.delete(deletedFile);
}
return {
files: (yield getFiles()).map((file) => path_1.default.normalize(file)),
dirs: getDirs().map((dir) => path_1.default.normalize(dir)),
excluded: [],
extensions: getExtensions(),
};
});
},
getIssues() {
return __awaiter(this, void 0, void 0, function* () {
// cleanup old results
for (const changedFile of changedFiles) {
lintResults.delete(changedFile);
}
for (const deletedFile of deletedFiles) {
lintResults.delete(deletedFile);
}
// get reports
const lintReports = [];
if (isInitialRun) {
const lintReport = yield (isOldCLIEngine(eslint)
? Promise.resolve(eslint.executeOnFiles(includedGlobPatterns))
: eslint.lintFiles(includedGlobPatterns).then((results) => ({ results })));
lintReports.push(lintReport);
isInitialRun = false;
}
else {
// we need to take care to not lint files that are not included by the configuration.
// the eslint engine will not exclude them automatically
const changedAndIncludedFiles = [];
for (const changedFile of changedFiles) {
if (yield isFileIncluded(changedFile)) {
changedAndIncludedFiles.push(changedFile);
}
}
if (changedAndIncludedFiles.length) {
const lintReport = yield (isOldCLIEngine(eslint)
? Promise.resolve(eslint.executeOnFiles(changedAndIncludedFiles))
: eslint.lintFiles(changedAndIncludedFiles).then((results) => ({ results })));
lintReports.push(lintReport);
}
}
// output fixes if `fix` option is provided
if (configuration.options.fix) {
yield Promise.all(lintReports.map((lintReport) => isOldCLIEngine(eslint)
? CLIEngine.outputFixes(lintReport)
: ESLint.outputFixes(lintReport.results)));
}
// store results
for (const lintReport of lintReports) {
for (const lintResult of lintReport.results) {
lintResults.set(lintResult.filePath, lintResult);
}
}
// get actual list of previous and current reports
const results = Array.from(lintResults.values());
return EsLintIssueFactory_1.createIssuesFromEsLintResults(results);
});
},
close() {
return __awaiter(this, void 0, void 0, function* () {
// do nothing
});
},
};
}),
};
}
exports.createEsLintReporter = createEsLintReporter;

View File

@@ -0,0 +1,4 @@
import { EsLintReporterConfiguration } from '../EsLintReporterConfiguration';
import { ReporterRpcClient } from '../../reporter';
declare function createEsLintReporterRpcClient(configuration: EsLintReporterConfiguration): ReporterRpcClient;
export { createEsLintReporterRpcClient };

View File

@@ -0,0 +1,13 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const reporter_1 = require("../../reporter");
const rpc_ipc_1 = require("../../rpc/rpc-ipc");
function createEsLintReporterRpcClient(configuration) {
const channel = rpc_ipc_1.createRpcIpcMessageChannel(path_1.default.resolve(__dirname, './EsLintReporterRpcService.js'), configuration.memoryLimit);
return reporter_1.createReporterRpcClient(channel, configuration);
}
exports.createEsLintReporterRpcClient = createEsLintReporterRpcClient;

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,11 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const process_1 = __importDefault(require("process"));
const EsLintReporter_1 = require("./EsLintReporter");
const reporter_1 = require("../../reporter");
const rpc_ipc_1 = require("../../rpc/rpc-ipc");
const service = reporter_1.registerReporterRpcService(rpc_ipc_1.createRpcIpcMessagePort(process_1.default), EsLintReporter_1.createEsLintReporter);
service.open();

View File

@@ -0,0 +1,37 @@
export interface LintMessage {
ruleId: string | null;
severity: number;
message: string;
line: number;
column: number;
endColumn?: number;
endLine?: number;
[key: string]: any;
}
export interface LintResult {
filePath: string;
messages: LintMessage[];
[key: string]: any;
}
export interface LintReport {
results: LintResult[];
[key: string]: any;
}
export interface CLIEngine {
version: string;
executeOnFiles(filesPatterns: string[]): LintReport;
resolveFileGlobPatterns(filesPatterns: string[]): string[];
isPathIgnored(filePath: string): boolean;
}
export interface ESLint {
version: string;
lintFiles(filesPatterns: string[]): Promise<LintResult[]>;
isPathIgnored(filePath: string): Promise<boolean>;
}
export declare type ESLintOrCLIEngine = CLIEngine | ESLint;
export interface CLIEngineOptions {
cwd?: string;
extensions?: string[];
fix?: boolean;
[key: string]: any;
}

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,3 @@
import { Formatter } from './Formatter';
declare function createBasicFormatter(): Formatter;
export { createBasicFormatter };

View File

@@ -0,0 +1,12 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
function createBasicFormatter() {
return function basicFormatter(issue) {
return chalk_1.default.grey(issue.code + ': ') + issue.message;
};
}
exports.createBasicFormatter = createBasicFormatter;

View File

@@ -0,0 +1,4 @@
import { Formatter } from './Formatter';
import { BabelCodeFrameOptions } from './types/babel__code-frame';
declare function createCodeFrameFormatter(options?: BabelCodeFrameOptions): Formatter;
export { createCodeFrameFormatter, BabelCodeFrameOptions };

View File

@@ -0,0 +1,28 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const os_1 = __importDefault(require("os"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const code_frame_1 = require("@babel/code-frame");
const BasicFormatter_1 = require("./BasicFormatter");
function createCodeFrameFormatter(options) {
const basicFormatter = BasicFormatter_1.createBasicFormatter();
return function codeFrameFormatter(issue) {
const source = issue.file && fs_extra_1.default.existsSync(issue.file) && fs_extra_1.default.readFileSync(issue.file, 'utf-8');
let frame = '';
if (source && issue.location) {
frame = code_frame_1.codeFrameColumns(source, issue.location, Object.assign({ highlightCode: true }, (options || {})))
.split('\n')
.map((line) => ' ' + line)
.join(os_1.default.EOL);
}
const lines = [basicFormatter(issue)];
if (frame) {
lines.push(frame);
}
return lines.join(os_1.default.EOL);
};
}
exports.createCodeFrameFormatter = createCodeFrameFormatter;

View File

@@ -0,0 +1,3 @@
import { Issue } from '../issue';
declare type Formatter = (issue: Issue) => string;
export { Formatter };

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,5 @@
import { FormatterOptions } from './FormatterOptions';
import { Formatter } from './Formatter';
declare type FormatterConfiguration = Formatter;
declare function createFormatterConfiguration(options: FormatterOptions | undefined): Formatter;
export { FormatterConfiguration, createFormatterConfiguration };

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const FormatterFactory_1 = require("./FormatterFactory");
function createFormatterConfiguration(options) {
return FormatterFactory_1.createFormatter(options ? (typeof options === 'object' ? options.type || 'codeframe' : options) : 'codeframe', options && typeof options === 'object' ? options.options || {} : {});
}
exports.createFormatterConfiguration = createFormatterConfiguration;

View File

@@ -0,0 +1,13 @@
import { Formatter } from './Formatter';
import { BabelCodeFrameOptions } from './CodeFrameFormatter';
declare type NotConfigurableFormatterType = undefined | 'basic' | Formatter;
declare type ConfigurableFormatterType = 'codeframe';
declare type FormatterType = NotConfigurableFormatterType | ConfigurableFormatterType;
declare type ConfigurableFormatterOptions = {
codeframe: BabelCodeFrameOptions;
};
declare type ComplexFormatterOptions<T extends FormatterType> = T extends ConfigurableFormatterType ? ConfigurableFormatterOptions[T] : never;
declare function createFormatter<T extends NotConfigurableFormatterType>(type?: T): Formatter;
declare function createFormatter<T extends ConfigurableFormatterType>(type: T, options?: ConfigurableFormatterOptions[T]): Formatter;
declare function createFormatter<T extends FormatterType>(type: T, options?: object): Formatter;
export { createFormatter, FormatterType, ComplexFormatterOptions, NotConfigurableFormatterType, ConfigurableFormatterType, ConfigurableFormatterOptions, };

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const CodeFrameFormatter_1 = require("./CodeFrameFormatter");
const BasicFormatter_1 = require("./BasicFormatter");
// declare function implementation
function createFormatter(type, options) {
if (typeof type === 'function') {
return type;
}
if (typeof type === 'undefined' || type === 'basic') {
return BasicFormatter_1.createBasicFormatter();
}
if (type === 'codeframe') {
return CodeFrameFormatter_1.createCodeFrameFormatter(options);
}
throw new Error(`Unknown "${type}" formatter. Available types are: "basic", "codeframe" or a custom function.`);
}
exports.createFormatter = createFormatter;

View File

@@ -0,0 +1,7 @@
import { ComplexFormatterOptions, FormatterType } from './FormatterFactory';
declare type ComplexFormatterPreferences<T extends FormatterType = FormatterType> = {
type: T;
options?: ComplexFormatterOptions<T>;
};
declare type FormatterOptions = FormatterType | ComplexFormatterPreferences;
export { FormatterOptions };

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,3 @@
import { Formatter } from './Formatter';
declare function createWebpackFormatter(formatter: Formatter): Formatter;
export { createWebpackFormatter };

View File

@@ -0,0 +1,28 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const os_1 = __importDefault(require("os"));
const chalk_1 = __importDefault(require("chalk"));
const path_1 = __importDefault(require("path"));
const issue_1 = require("../issue");
const forwardSlash_1 = __importDefault(require("../utils/path/forwardSlash"));
function createWebpackFormatter(formatter) {
// mimics webpack error formatter
return function webpackFormatter(issue) {
const color = issue.severity === 'warning' ? chalk_1.default.yellow.bold : chalk_1.default.red.bold;
const severity = issue.severity.toUpperCase();
if (issue.file) {
let location = forwardSlash_1.default(path_1.default.relative(process.cwd(), issue.file));
if (issue.location) {
location += `:${issue_1.formatIssueLocation(issue.location)}`;
}
return [color(`${severity} in ${location}`), formatter(issue), ''].join(os_1.default.EOL);
}
else {
return [color(`${severity} in `) + formatter(issue), ''].join(os_1.default.EOL);
}
};
}
exports.createWebpackFormatter = createWebpackFormatter;

View File

@@ -0,0 +1,7 @@
export * from './Formatter';
export * from './BasicFormatter';
export * from './CodeFrameFormatter';
export * from './WebpackFormatter';
export * from './FormatterFactory';
export * from './FormatterOptions';
export * from './FormatterConfiguration';

View File

@@ -0,0 +1,10 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./BasicFormatter"));
__export(require("./CodeFrameFormatter"));
__export(require("./WebpackFormatter"));
__export(require("./FormatterFactory"));
__export(require("./FormatterConfiguration"));

View File

@@ -0,0 +1,21 @@
export interface BabelCodeFrameOptions {
/** Syntax highlight the code as JavaScript for terminals. default: false */
highlightCode?: boolean;
/** The number of lines to show above the error. default: 2 */
linesAbove?: number;
/** The number of lines to show below the error. default: 3 */
linesBelow?: number;
/**
* Forcibly syntax highlight the code as JavaScript (for non-terminals);
* overrides highlightCode.
* default: false
*/
forceColor?: boolean;
/**
* Pass in a string to be displayed inline (if possible) next to the
* highlighted location in the code. If it can't be positioned inline,
* it will be placed above the code frame.
* default: nothing
*/
message?: string;
}

View File

@@ -0,0 +1,7 @@
"use strict";
// Base on the type definitions for @babel/code-frame 7.0
// Project: https://github.com/babel/babel/tree/main/packages/babel-code-frame, https://babeljs.io
// Definitions by: Mohsen Azimi <https://github.com/mohsen1>
// Forbes Lindesay <https://github.com/ForbesLindesay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,5 @@
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
declare function interceptDoneToGetWebpackDevServerTap(compiler: webpack.Compiler, configuration: ForkTsCheckerWebpackPluginConfiguration, state: ForkTsCheckerWebpackPluginState): void;
export { interceptDoneToGetWebpackDevServerTap };

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function interceptDoneToGetWebpackDevServerTap(compiler, configuration, state) {
// inspired by https://github.com/ypresto/fork-ts-checker-async-overlay-webpack-plugin
compiler.hooks.done.intercept({
register: (tap) => {
if (tap.name === 'webpack-dev-server' &&
tap.type === 'sync' &&
configuration.logger.devServer) {
state.webpackDevServerDoneTap = tap;
}
return tap;
},
});
}
exports.interceptDoneToGetWebpackDevServerTap = interceptDoneToGetWebpackDevServerTap;

View File

@@ -0,0 +1,20 @@
import * as webpack from 'webpack';
import { SyncHook, SyncWaterfallHook, AsyncSeriesWaterfallHook } from 'tapable';
import { FilesChange } from '../reporter';
import { Issue } from '../issue';
declare function createForkTsCheckerWebpackPluginHooks(): {
start: AsyncSeriesWaterfallHook<FilesChange, webpack.compilation.Compilation, any>;
waiting: SyncHook<webpack.compilation.Compilation, any, any>;
canceled: SyncHook<webpack.compilation.Compilation, any, any>;
error: SyncHook<Error, webpack.compilation.Compilation, any>;
issues: SyncWaterfallHook<Issue[], webpack.compilation.Compilation | undefined, void>;
};
declare type ForkTsCheckerWebpackPluginHooks = ReturnType<typeof createForkTsCheckerWebpackPluginHooks>;
declare function getForkTsCheckerWebpackPluginHooks(compiler: webpack.Compiler | webpack.MultiCompiler): {
start: AsyncSeriesWaterfallHook<FilesChange, webpack.compilation.Compilation, any>;
waiting: SyncHook<webpack.compilation.Compilation, any, any>;
canceled: SyncHook<webpack.compilation.Compilation, any, any>;
error: SyncHook<Error, webpack.compilation.Compilation, any>;
issues: SyncWaterfallHook<Issue[], webpack.compilation.Compilation | undefined, void>;
};
export { getForkTsCheckerWebpackPluginHooks, ForkTsCheckerWebpackPluginHooks };

View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tapable_1 = require("tapable");
const compilerHookMap = new WeakMap();
function createForkTsCheckerWebpackPluginHooks() {
return {
start: new tapable_1.AsyncSeriesWaterfallHook([
'change',
'compilation',
]),
waiting: new tapable_1.SyncHook(['compilation']),
canceled: new tapable_1.SyncHook(['compilation']),
error: new tapable_1.SyncHook(['error', 'compilation']),
issues: new tapable_1.SyncWaterfallHook([
'issues',
'compilation',
]),
};
}
function forwardForkTsCheckerWebpackPluginHooks(source, target) {
source.start.tapPromise('ForkTsCheckerWebpackPlugin', target.start.promise);
source.waiting.tap('ForkTsCheckerWebpackPlugin', target.waiting.call);
source.canceled.tap('ForkTsCheckerWebpackPlugin', target.canceled.call);
source.error.tap('ForkTsCheckerWebpackPlugin', target.error.call);
source.issues.tap('ForkTsCheckerWebpackPlugin', target.issues.call);
}
function getForkTsCheckerWebpackPluginHooks(compiler) {
let hooks = compilerHookMap.get(compiler);
if (hooks === undefined) {
hooks = createForkTsCheckerWebpackPluginHooks();
compilerHookMap.set(compiler, hooks);
// proxy hooks for multi-compiler
if ('compilers' in compiler) {
compiler.compilers.forEach((childCompiler) => {
const childHooks = getForkTsCheckerWebpackPluginHooks(childCompiler);
if (hooks) {
forwardForkTsCheckerWebpackPluginHooks(childHooks, hooks);
}
});
}
}
return hooks;
}
exports.getForkTsCheckerWebpackPluginHooks = getForkTsCheckerWebpackPluginHooks;

View File

@@ -0,0 +1,5 @@
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
declare function tapAfterCompileToAddDependencies(compiler: webpack.Compiler, configuration: ForkTsCheckerWebpackPluginConfiguration, state: ForkTsCheckerWebpackPluginState): void;
export { tapAfterCompileToAddDependencies };

View File

@@ -0,0 +1,27 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
function tapAfterCompileToAddDependencies(compiler, configuration, state) {
compiler.hooks.afterCompile.tapPromise('ForkTsCheckerWebpackPlugin', (compilation) => __awaiter(this, void 0, void 0, function* () {
if (compilation.compiler !== compiler) {
// run only for the compiler that the plugin was registered for
return;
}
const dependencies = yield state.dependenciesPromise;
if (dependencies) {
state.lastDependencies = dependencies;
dependencies.files.forEach((file) => {
compilation.fileDependencies.add(file);
});
}
}));
}
exports.tapAfterCompileToAddDependencies = tapAfterCompileToAddDependencies;

View File

@@ -0,0 +1,5 @@
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
declare function tapAfterCompileToGetIssues(compiler: webpack.Compiler, configuration: ForkTsCheckerWebpackPluginConfiguration, state: ForkTsCheckerWebpackPluginState): void;
export { tapAfterCompileToGetIssues };

View File

@@ -0,0 +1,48 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const pluginHooks_1 = require("./pluginHooks");
const IssueWebpackError_1 = require("../issue/IssueWebpackError");
function tapAfterCompileToGetIssues(compiler, configuration, state) {
const hooks = pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
compiler.hooks.afterCompile.tapPromise('ForkTsCheckerWebpackPlugin', (compilation) => __awaiter(this, void 0, void 0, function* () {
if (compilation.compiler !== compiler) {
// run only for the compiler that the plugin was registered for
return;
}
let issues = [];
try {
issues = yield state.issuesPromise;
}
catch (error) {
hooks.error.call(error, compilation);
return;
}
if (!issues) {
// some error has been thrown or it was canceled
return;
}
// filter list of issues by provided issue predicate
issues = issues.filter(configuration.issue.predicate);
// modify list of issues in the plugin hooks
issues = hooks.issues.call(issues, compilation);
issues.forEach((issue) => {
const error = new IssueWebpackError_1.IssueWebpackError(configuration.formatter(issue), issue);
if (issue.severity === 'warning') {
compilation.warnings.push(error);
}
else {
compilation.errors.push(error);
}
});
}));
}
exports.tapAfterCompileToGetIssues = tapAfterCompileToGetIssues;

View File

@@ -0,0 +1,4 @@
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
declare function tapAfterEnvironmentToPatchWatching(compiler: webpack.Compiler, state: ForkTsCheckerWebpackPluginState): void;
export { tapAfterEnvironmentToPatchWatching };

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const InclusiveNodeWatchFileSystem_1 = require("../watch/InclusiveNodeWatchFileSystem");
function tapAfterEnvironmentToPatchWatching(compiler, state) {
compiler.hooks.afterEnvironment.tap('ForkTsCheckerWebpackPlugin', () => {
const watchFileSystem = compiler.watchFileSystem;
if (watchFileSystem) {
// wrap original watch file system
compiler.watchFileSystem = new InclusiveNodeWatchFileSystem_1.InclusiveNodeWatchFileSystem(watchFileSystem, compiler, state);
}
});
}
exports.tapAfterEnvironmentToPatchWatching = tapAfterEnvironmentToPatchWatching;

View File

@@ -0,0 +1,5 @@
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
declare function tapDoneToAsyncGetIssues(compiler: webpack.Compiler, configuration: ForkTsCheckerWebpackPluginConfiguration, state: ForkTsCheckerWebpackPluginState): void;
export { tapDoneToAsyncGetIssues };

View File

@@ -0,0 +1,85 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const pluginHooks_1 = require("./pluginHooks");
const WebpackFormatter_1 = require("../formatter/WebpackFormatter");
const IssueWebpackError_1 = require("../issue/IssueWebpackError");
const isPending_1 = __importDefault(require("../utils/async/isPending"));
const wait_1 = __importDefault(require("../utils/async/wait"));
function tapDoneToAsyncGetIssues(compiler, configuration, state) {
const hooks = pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', (stats) => __awaiter(this, void 0, void 0, function* () {
if (stats.compilation.compiler !== compiler) {
// run only for the compiler that the plugin was registered for
return;
}
const reportPromise = state.issuesReportPromise;
const issuesPromise = state.issuesPromise;
let issues;
try {
if (yield isPending_1.default(issuesPromise)) {
hooks.waiting.call(stats.compilation);
configuration.logger.issues.log(chalk_1.default.cyan('Issues checking in progress...'));
}
else {
// wait 10ms to log issues after webpack stats
yield wait_1.default(10);
}
issues = yield issuesPromise;
}
catch (error) {
hooks.error.call(error, stats.compilation);
return;
}
if (!issues) {
// some error has been thrown or it was canceled
return;
}
if (reportPromise !== state.issuesReportPromise) {
// there is a newer report - ignore this one
return;
}
// filter list of issues by provided issue predicate
issues = issues.filter(configuration.issue.predicate);
// modify list of issues in the plugin hooks
issues = hooks.issues.call(issues, stats.compilation);
const formatter = WebpackFormatter_1.createWebpackFormatter(configuration.formatter);
if (issues.length) {
// follow webpack's approach - one process.write to stderr with all errors and warnings
configuration.logger.issues.error(issues.map((issue) => formatter(issue)).join('\n'));
}
else {
configuration.logger.issues.log(chalk_1.default.green('No issues found.'));
}
// report issues to webpack-dev-server, if it's listening
// skip reporting if there are no issues, to avoid an extra hot reload
if (issues.length && state.webpackDevServerDoneTap) {
issues.forEach((issue) => {
const error = new IssueWebpackError_1.IssueWebpackError(configuration.formatter(issue), issue);
if (issue.severity === 'warning') {
stats.compilation.warnings.push(error);
}
else {
stats.compilation.errors.push(error);
}
});
state.webpackDevServerDoneTap.fn(stats);
}
if (stats.startTime) {
configuration.logger.infrastructure.info(`Time: ${Math.round(Date.now() - stats.startTime).toString()} ms`);
}
}));
}
exports.tapDoneToAsyncGetIssues = tapDoneToAsyncGetIssues;

View File

@@ -0,0 +1,4 @@
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
declare function tapErrorToLogMessage(compiler: webpack.Compiler, configuration: ForkTsCheckerWebpackPluginConfiguration): void;
export { tapErrorToLogMessage };

View File

@@ -0,0 +1,27 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const pluginHooks_1 = require("./pluginHooks");
const RpcIpcMessagePortClosedError_1 = require("../rpc/rpc-ipc/error/RpcIpcMessagePortClosedError");
const chalk_1 = __importDefault(require("chalk"));
function tapErrorToLogMessage(compiler, configuration) {
const hooks = pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
hooks.error.tap('ForkTsCheckerWebpackPlugin', (error) => {
configuration.logger.issues.error(String(error));
if (error instanceof RpcIpcMessagePortClosedError_1.RpcIpcMessagePortClosedError) {
if (error.signal === 'SIGINT') {
configuration.logger.issues.error(chalk_1.default.red('Issues checking service interrupted - If running in a docker container, this may be caused ' +
"by the container running out of memory. If so, try increasing the container's memory limit " +
'or lowering the `memoryLimit` value in the ForkTsCheckerWebpackPlugin configuration.'));
}
else {
configuration.logger.issues.error(chalk_1.default.red('Issues checking service aborted - probably out of memory. ' +
'Check the `memoryLimit` option in the ForkTsCheckerWebpackPlugin configuration.\n' +
"If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript or EsLint."));
}
}
});
}
exports.tapErrorToLogMessage = tapErrorToLogMessage;

View File

@@ -0,0 +1,6 @@
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
import { ReporterRpcClient } from '../reporter';
declare function tapStartToConnectAndRunReporter(compiler: webpack.Compiler, issuesReporter: ReporterRpcClient, dependenciesReporter: ReporterRpcClient, configuration: ForkTsCheckerWebpackPluginConfiguration, state: ForkTsCheckerWebpackPluginState): void;
export { tapStartToConnectAndRunReporter };

View File

@@ -0,0 +1,125 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const pluginHooks_1 = require("./pluginHooks");
const reporter_1 = require("../reporter");
const OperationCanceledError_1 = require("../error/OperationCanceledError");
const tapDoneToAsyncGetIssues_1 = require("./tapDoneToAsyncGetIssues");
const tapAfterCompileToGetIssues_1 = require("./tapAfterCompileToGetIssues");
const interceptDoneToGetWebpackDevServerTap_1 = require("./interceptDoneToGetWebpackDevServerTap");
const ForkTsCheckerWebpackPlugin_1 = require("../ForkTsCheckerWebpackPlugin");
function tapStartToConnectAndRunReporter(compiler, issuesReporter, dependenciesReporter, configuration, state) {
const hooks = pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
compiler.hooks.run.tap('ForkTsCheckerWebpackPlugin', () => {
if (!state.initialized) {
state.initialized = true;
state.watching = false;
tapAfterCompileToGetIssues_1.tapAfterCompileToGetIssues(compiler, configuration, state);
}
});
compiler.hooks.watchRun.tap('ForkTsCheckerWebpackPlugin', () => __awaiter(this, void 0, void 0, function* () {
if (!state.initialized) {
state.initialized = true;
state.watching = true;
if (configuration.async) {
tapDoneToAsyncGetIssues_1.tapDoneToAsyncGetIssues(compiler, configuration, state);
interceptDoneToGetWebpackDevServerTap_1.interceptDoneToGetWebpackDevServerTap(compiler, configuration, state);
}
else {
tapAfterCompileToGetIssues_1.tapAfterCompileToGetIssues(compiler, configuration, state);
}
}
}));
compiler.hooks.compilation.tap('ForkTsCheckerWebpackPlugin', (compilation) => __awaiter(this, void 0, void 0, function* () {
if (compilation.compiler !== compiler) {
// run only for the compiler that the plugin was registered for
return;
}
let change = {};
if (state.watching) {
change = reporter_1.getFilesChange(compiler);
configuration.logger.infrastructure.info([
'Calling reporter service for incremental check.',
` Changed files: ${JSON.stringify(change.changedFiles)}`,
` Deleted files: ${JSON.stringify(change.deletedFiles)}`,
].join('\n'));
}
else {
configuration.logger.infrastructure.info('Calling reporter service for single check.');
}
let resolveDependencies;
let rejectDependencies;
let resolveIssues;
let rejectIssues;
state.dependenciesPromise = new Promise((resolve, reject) => {
resolveDependencies = resolve;
rejectDependencies = reject;
});
state.issuesPromise = new Promise((resolve, reject) => {
resolveIssues = resolve;
rejectIssues = reject;
});
const previousIssuesReportPromise = state.issuesReportPromise;
const previousDependenciesReportPromise = state.dependenciesReportPromise;
change = yield hooks.start.promise(change, compilation);
state.issuesReportPromise = ForkTsCheckerWebpackPlugin_1.ForkTsCheckerWebpackPlugin.issuesPool.submit((done) => new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
try {
yield issuesReporter.connect();
const previousReport = yield previousIssuesReportPromise;
if (previousReport) {
yield previousReport.close();
}
const report = yield issuesReporter.getReport(change);
resolve(report);
report.getIssues().then(resolveIssues).catch(rejectIssues).finally(done);
}
catch (error) {
if (error instanceof OperationCanceledError_1.OperationCanceledError) {
hooks.canceled.call(compilation);
}
else {
hooks.error.call(error, compilation);
}
resolve(undefined);
resolveIssues(undefined);
done();
}
})));
state.dependenciesReportPromise = ForkTsCheckerWebpackPlugin_1.ForkTsCheckerWebpackPlugin.dependenciesPool.submit((done) => new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
try {
yield dependenciesReporter.connect();
const previousReport = yield previousDependenciesReportPromise;
if (previousReport) {
yield previousReport.close();
}
const report = yield dependenciesReporter.getReport(change);
resolve(report);
report
.getDependencies()
.then(resolveDependencies)
.catch(rejectDependencies)
.finally(done);
}
catch (error) {
if (error instanceof OperationCanceledError_1.OperationCanceledError) {
hooks.canceled.call(compilation);
}
else {
hooks.error.call(error, compilation);
}
resolve(undefined);
resolveDependencies(undefined);
done();
}
})));
}));
}
exports.tapStartToConnectAndRunReporter = tapStartToConnectAndRunReporter;

View File

@@ -0,0 +1,5 @@
import webpack from 'webpack';
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
import { ReporterRpcClient } from '../reporter';
declare function tapStopToDisconnectReporter(compiler: webpack.Compiler, issuesReporter: ReporterRpcClient, dependenciesReporter: ReporterRpcClient, state: ForkTsCheckerWebpackPluginState): void;
export { tapStopToDisconnectReporter };

View File

@@ -0,0 +1,29 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
function tapStopToDisconnectReporter(compiler, issuesReporter, dependenciesReporter, state) {
compiler.hooks.watchClose.tap('ForkTsCheckerWebpackPlugin', () => {
issuesReporter.disconnect();
dependenciesReporter.disconnect();
});
compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', () => __awaiter(this, void 0, void 0, function* () {
if (!state.watching) {
yield Promise.all([issuesReporter.disconnect(), dependenciesReporter.disconnect()]);
}
}));
compiler.hooks.failed.tap('ForkTsCheckerWebpackPlugin', () => {
if (!state.watching) {
issuesReporter.disconnect();
dependenciesReporter.disconnect();
}
});
}
exports.tapStopToDisconnectReporter = tapStopToDisconnectReporter;

View File

@@ -0,0 +1,2 @@
import { ForkTsCheckerWebpackPlugin } from './ForkTsCheckerWebpackPlugin';
export = ForkTsCheckerWebpackPlugin;

View File

@@ -0,0 +1,3 @@
"use strict";
const ForkTsCheckerWebpackPlugin_1 = require("./ForkTsCheckerWebpackPlugin");
module.exports = ForkTsCheckerWebpackPlugin_1.ForkTsCheckerWebpackPlugin;

View File

@@ -0,0 +1,13 @@
import { IssueSeverity } from './IssueSeverity';
import { IssueLocation } from './IssueLocation';
interface Issue {
origin: string;
severity: IssueSeverity;
code: string;
message: string;
file?: string;
location?: IssueLocation;
}
declare function isIssue(value: unknown): value is Issue;
declare function deduplicateAndSortIssues(issues: Issue[]): Issue[];
export { Issue, isIssue, deduplicateAndSortIssues };

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const IssueSeverity_1 = require("./IssueSeverity");
const IssueLocation_1 = require("./IssueLocation");
function isIssue(value) {
return (!!value &&
typeof value === 'object' &&
!!value.origin &&
IssueSeverity_1.isIssueSeverity(value.severity) &&
!!value.code &&
!!value.message);
}
exports.isIssue = isIssue;
function compareStrings(stringA, stringB) {
if (stringA === stringB) {
return 0;
}
if (stringA === undefined || stringA === null) {
return -1;
}
if (stringB === undefined || stringB === null) {
return 1;
}
return stringA.toString().localeCompare(stringB.toString());
}
function compareIssues(issueA, issueB) {
return (IssueSeverity_1.compareIssueSeverities(issueA.severity, issueB.severity) ||
compareStrings(issueA.origin, issueB.origin) ||
compareStrings(issueA.file, issueB.file) ||
IssueLocation_1.compareIssueLocations(issueA.location, issueB.location) ||
compareStrings(issueA.code, issueB.code) ||
compareStrings(issueA.message, issueB.message) ||
0 /* EqualTo */);
}
function equalsIssues(issueA, issueB) {
return compareIssues(issueA, issueB) === 0;
}
function deduplicateAndSortIssues(issues) {
const sortedIssues = issues.filter(isIssue).sort(compareIssues);
return sortedIssues.filter((issue, index) => index === 0 || !equalsIssues(issue, sortedIssues[index - 1]));
}
exports.deduplicateAndSortIssues = deduplicateAndSortIssues;

View File

@@ -0,0 +1,8 @@
import webpack from 'webpack';
import { IssuePredicate } from './IssuePredicate';
import { IssueOptions } from './IssueOptions';
interface IssueConfiguration {
predicate: IssuePredicate;
}
declare function createIssueConfiguration(compiler: webpack.Compiler, options: IssueOptions | undefined): IssueConfiguration;
export { IssueConfiguration, createIssueConfiguration };

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const IssueMatch_1 = require("./IssueMatch");
const IssuePredicate_1 = require("./IssuePredicate");
function createIssuePredicateFromOption(context, option) {
if (Array.isArray(option)) {
return IssuePredicate_1.composeIssuePredicates(option.map((option) => typeof option === 'function' ? option : IssueMatch_1.createIssuePredicateFromIssueMatch(context, option)));
}
return typeof option === 'function'
? option
: IssueMatch_1.createIssuePredicateFromIssueMatch(context, option);
}
function createIssueConfiguration(compiler, options) {
const context = compiler.options.context || process.cwd();
if (!options) {
options = {};
}
const include = options.include
? createIssuePredicateFromOption(context, options.include)
: IssuePredicate_1.createTrivialIssuePredicate(true);
const exclude = options.exclude
? createIssuePredicateFromOption(context, options.exclude)
: IssuePredicate_1.createTrivialIssuePredicate(false);
return {
predicate: (issue) => include(issue) && !exclude(issue),
};
}
exports.createIssueConfiguration = createIssueConfiguration;

View File

@@ -0,0 +1,8 @@
import { IssuePosition } from './IssuePosition';
interface IssueLocation {
start: IssuePosition;
end: IssuePosition;
}
declare function compareIssueLocations(locationA?: IssueLocation, locationB?: IssueLocation): number;
declare function formatIssueLocation(location: IssueLocation): string;
export { IssueLocation, compareIssueLocations, formatIssueLocation };

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const IssuePosition_1 = require("./IssuePosition");
function compareIssueLocations(locationA, locationB) {
if (locationA === locationB) {
return 0;
}
if (!locationA) {
return -1;
}
if (!locationB) {
return 1;
}
return (IssuePosition_1.compareIssuePositions(locationA.start, locationB.start) ||
IssuePosition_1.compareIssuePositions(locationA.end, locationB.end));
}
exports.compareIssueLocations = compareIssueLocations;
function formatIssueLocation(location) {
return `${location.start.line}:${location.start.column}`;
}
exports.formatIssueLocation = formatIssueLocation;

View File

@@ -0,0 +1,5 @@
import { Issue } from './index';
import { IssuePredicate } from './IssuePredicate';
declare type IssueMatch = Partial<Pick<Issue, 'origin' | 'severity' | 'code' | 'file'>>;
declare function createIssuePredicateFromIssueMatch(context: string, match: IssueMatch): IssuePredicate;
export { IssueMatch, createIssuePredicateFromIssueMatch };

View File

@@ -0,0 +1,20 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const minimatch_1 = __importDefault(require("minimatch"));
const path_1 = __importDefault(require("path"));
const forwardSlash_1 = __importDefault(require("../utils/path/forwardSlash"));
function createIssuePredicateFromIssueMatch(context, match) {
return (issue) => {
const matchesOrigin = !match.origin || match.origin === issue.origin;
const matchesSeverity = !match.severity || match.severity === issue.severity;
const matchesCode = !match.code || match.code === issue.code;
const matchesFile = !issue.file ||
(!!issue.file &&
(!match.file || minimatch_1.default(forwardSlash_1.default(path_1.default.relative(context, issue.file)), match.file)));
return matchesOrigin && matchesSeverity && matchesCode && matchesFile;
};
}
exports.createIssuePredicateFromIssueMatch = createIssuePredicateFromIssueMatch;

View File

@@ -0,0 +1,8 @@
import { IssueMatch } from './IssueMatch';
import { IssuePredicate } from './IssuePredicate';
declare type IssuePredicateOption = IssuePredicate | IssueMatch | (IssuePredicate | IssueMatch)[];
interface IssueOptions {
include?: IssuePredicateOption;
exclude?: IssuePredicateOption;
}
export { IssueOptions, IssuePredicateOption };

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,6 @@
interface IssuePosition {
line: number;
column: number;
}
declare function compareIssuePositions(positionA?: IssuePosition, positionB?: IssuePosition): number;
export { IssuePosition, compareIssuePositions };

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function compareIssuePositions(positionA, positionB) {
if (positionA === positionB) {
return 0;
}
if (!positionA) {
return -1;
}
if (!positionB) {
return 1;
}
return (Math.sign(positionA.line - positionB.line) || Math.sign(positionA.column - positionB.column));
}
exports.compareIssuePositions = compareIssuePositions;

View File

@@ -0,0 +1,5 @@
import { Issue } from './index';
declare type IssuePredicate = (issue: Issue) => boolean;
declare function createTrivialIssuePredicate(result: boolean): IssuePredicate;
declare function composeIssuePredicates(predicates: IssuePredicate[]): IssuePredicate;
export { IssuePredicate, createTrivialIssuePredicate, composeIssuePredicates };

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function createTrivialIssuePredicate(result) {
return () => result;
}
exports.createTrivialIssuePredicate = createTrivialIssuePredicate;
function composeIssuePredicates(predicates) {
return (issue) => predicates.some((predicate) => predicate(issue));
}
exports.composeIssuePredicates = composeIssuePredicates;

View File

@@ -0,0 +1,4 @@
declare type IssueSeverity = 'error' | 'warning';
declare function isIssueSeverity(value: unknown): value is IssueSeverity;
declare function compareIssueSeverities(severityA: IssueSeverity, severityB: IssueSeverity): number;
export { IssueSeverity, isIssueSeverity, compareIssueSeverities };

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function isIssueSeverity(value) {
return ['error', 'warning'].includes(value);
}
exports.isIssueSeverity = isIssueSeverity;
function compareIssueSeverities(severityA, severityB) {
const [priorityA, priorityB] = [severityA, severityB].map((severity) => ['warning' /* 0 */, 'error' /* 1 */].indexOf(severity));
return Math.sign(priorityB - priorityA);
}
exports.compareIssueSeverities = compareIssueSeverities;

View File

@@ -0,0 +1,8 @@
import { Issue } from './Issue';
declare class IssueWebpackError extends Error {
readonly issue: Issue;
readonly hideStack = true;
readonly file: string | undefined;
constructor(message: string, issue: Issue);
}
export { IssueWebpackError };

View File

@@ -0,0 +1,26 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const IssueLocation_1 = require("./IssueLocation");
const forwardSlash_1 = __importDefault(require("../utils/path/forwardSlash"));
class IssueWebpackError extends Error {
constructor(message, issue) {
super(message);
this.issue = issue;
this.hideStack = true;
// to display issue location using `loc` property, webpack requires `error.module` which
// should be a NormalModule instance.
// to avoid such a dependency, we do a workaround - error.file will contain formatted location instead
if (issue.file) {
this.file = forwardSlash_1.default(path_1.relative(process.cwd(), issue.file));
if (issue.location) {
this.file += `:${IssueLocation_1.formatIssueLocation(issue.location)}`;
}
}
Error.captureStackTrace(this, this.constructor);
}
}
exports.IssueWebpackError = IssueWebpackError;

View File

@@ -0,0 +1,3 @@
export * from './Issue';
export * from './IssueSeverity';
export * from './IssueLocation';

View File

@@ -0,0 +1,8 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./Issue"));
__export(require("./IssueSeverity"));
__export(require("./IssueLocation"));

View File

@@ -0,0 +1,6 @@
interface Logger {
info: (message: string) => void;
log: (message: string) => void;
error: (message: string) => void;
}
export default Logger;

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,10 @@
import LoggerOptions from './LoggerOptions';
import Logger from './Logger';
import webpack from 'webpack';
interface LoggerConfiguration {
infrastructure: Logger;
issues: Logger;
devServer: boolean;
}
declare function createLoggerConfiguration(compiler: webpack.Compiler, options: LoggerOptions | undefined): LoggerConfiguration;
export { LoggerConfiguration, createLoggerConfiguration };

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const LoggerFactory_1 = require("./LoggerFactory");
function createLoggerConfiguration(compiler, options) {
return {
infrastructure: LoggerFactory_1.createLogger((options && options.infrastructure) || 'silent', compiler),
issues: LoggerFactory_1.createLogger((options && options.issues) || 'console', compiler),
devServer: (options === null || options === void 0 ? void 0 : options.devServer) !== false,
};
}
exports.createLoggerConfiguration = createLoggerConfiguration;

View File

@@ -0,0 +1,5 @@
import webpack from 'webpack';
import Logger from './Logger';
declare type LoggerType = 'console' | 'webpack-infrastructure' | 'silent';
declare function createLogger(type: LoggerType | Logger, compiler: webpack.Compiler): Logger;
export { createLogger, LoggerType };

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const WebpackInfrastructureLogger_1 = require("./WebpackInfrastructureLogger");
const PartialLogger_1 = require("./PartialLogger");
function createLogger(type, compiler) {
if (typeof type !== 'string') {
return type;
}
switch (type) {
case 'webpack-infrastructure':
return (WebpackInfrastructureLogger_1.createWebpackInfrastructureLogger(compiler) ||
PartialLogger_1.createPartialLogger(['log', 'error'], console));
case 'silent':
return PartialLogger_1.createPartialLogger([], console);
case 'console':
default:
return console;
}
}
exports.createLogger = createLogger;

View File

@@ -0,0 +1,8 @@
import { LoggerType } from './LoggerFactory';
import Logger from './Logger';
declare type LoggerOptions = {
infrastructure?: LoggerType | Logger;
issues?: LoggerType | Logger;
devServer?: boolean;
};
export default LoggerOptions;

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,4 @@
import Logger from './Logger';
declare type LoggerMethods = 'info' | 'log' | 'error';
declare function createPartialLogger(methods: LoggerMethods[], logger: Logger): Logger;
export { createPartialLogger };

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function createPartialLogger(methods, logger) {
return {
info: (message) => (methods.includes('info') ? logger.info(message) : undefined),
log: (message) => (methods.includes('log') ? logger.log(message) : undefined),
error: (message) => (methods.includes('error') ? logger.error(message) : undefined),
};
}
exports.createPartialLogger = createPartialLogger;

View File

@@ -0,0 +1,4 @@
import webpack from 'webpack';
import Logger from './Logger';
declare function createWebpackInfrastructureLogger(compiler: webpack.Compiler): Logger | undefined;
export { createWebpackInfrastructureLogger };

Some files were not shown because too many files have changed in this diff Show More