fork-ts-checker-webpack-plugin 4.0.0-beta.4 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +19 -68
- package/lib/ApiIncrementalChecker.d.ts +2 -15
- package/lib/ApiIncrementalChecker.js +79 -109
- package/lib/ApiIncrementalChecker.js.map +1 -1
- package/lib/CancellationToken.js +36 -25
- package/lib/CancellationToken.js.map +1 -1
- package/lib/CompilerHost.d.ts +7 -7
- package/lib/CompilerHost.js +225 -155
- package/lib/CompilerHost.js.map +1 -1
- package/lib/FilesRegister.d.ts +2 -4
- package/lib/FilesRegister.js +24 -23
- package/lib/FilesRegister.js.map +1 -1
- package/lib/FsHelper.js +9 -1
- package/lib/FsHelper.js.map +1 -1
- package/lib/IncrementalChecker.d.ts +2 -15
- package/lib/IncrementalChecker.js +146 -172
- package/lib/IncrementalChecker.js.map +1 -1
- package/lib/IncrementalCheckerInterface.d.ts +0 -4
- package/lib/IncrementalCheckerInterface.js.map +1 -1
- package/lib/LinkedList.js +38 -36
- package/lib/LinkedList.js.map +1 -1
- package/lib/Message.js.map +1 -1
- package/lib/RpcTypes.js.map +1 -1
- package/lib/VueProgram.d.ts +1 -1
- package/lib/VueProgram.js +92 -71
- package/lib/VueProgram.js.map +1 -1
- package/lib/createEslinter.d.ts +2 -2
- package/lib/createEslinter.js +13 -6
- package/lib/createEslinter.js.map +1 -1
- package/lib/formatter/CodeframeFormatter.js +41 -17
- package/lib/formatter/CodeframeFormatter.js.map +1 -1
- package/lib/formatter/DefaultFormatter.js +18 -8
- package/lib/formatter/DefaultFormatter.js.map +1 -1
- package/lib/formatter/Formatter.js.map +1 -1
- package/lib/formatter/FormatterFactory.js +2 -2
- package/lib/formatter/FormatterFactory.js.map +1 -1
- package/lib/formatter/InternalFormatter.js +17 -7
- package/lib/formatter/InternalFormatter.js.map +1 -1
- package/lib/formatter/RawFormatter.js +3 -3
- package/lib/formatter/RawFormatter.js.map +1 -1
- package/lib/formatter/index.js.map +1 -1
- package/lib/hooks.js +5 -5
- package/lib/hooks.js.map +1 -1
- package/lib/index.d.ts +2 -10
- package/lib/index.js +219 -229
- package/lib/index.js.map +1 -1
- package/lib/issue/Issue.js +6 -4
- package/lib/issue/Issue.js.map +1 -1
- package/lib/issue/IssueOrigin.d.ts +0 -1
- package/lib/issue/IssueOrigin.js +8 -9
- package/lib/issue/IssueOrigin.js.map +1 -1
- package/lib/issue/IssueSeverity.js +4 -2
- package/lib/issue/IssueSeverity.js.map +1 -1
- package/lib/issue/eslint/EsLintIssueFactory.d.ts +2 -2
- package/lib/issue/eslint/EsLintIssueFactory.js +17 -12
- package/lib/issue/eslint/EsLintIssueFactory.js.map +1 -1
- package/lib/issue/eslint/FileAwareEsLintMessage.d.ts +2 -2
- package/lib/issue/eslint/FileAwareEsLintMessage.js.map +1 -1
- package/lib/issue/eslint/index.js.map +1 -1
- package/lib/issue/index.d.ts +0 -1
- package/lib/issue/index.js +0 -1
- package/lib/issue/index.js.map +1 -1
- package/lib/issue/internal/InternalIssueFactory.d.ts +6 -1
- package/lib/issue/internal/InternalIssueFactory.js +5 -3
- package/lib/issue/internal/InternalIssueFactory.js.map +1 -1
- package/lib/issue/internal/index.js.map +1 -1
- package/lib/issue/typescript/TypeScriptIssueFactory.js +14 -14
- package/lib/issue/typescript/TypeScriptIssueFactory.js.map +1 -1
- package/lib/issue/typescript/index.js.map +1 -1
- package/lib/patchTypescript.js +27 -20
- package/lib/patchTypescript.js.map +1 -1
- package/lib/resolution.js +3 -11
- package/lib/resolution.js.map +1 -1
- package/lib/service.js +107 -63
- package/lib/service.js.map +1 -1
- package/lib/types/eslint.d.ts +33 -0
- package/lib/types/eslint.js +3 -0
- package/lib/types/eslint.js.map +1 -0
- package/lib/types/vue-options.js.map +1 -1
- package/package.json +11 -32
- package/lib/issue/tslint/TsLintIssueFactory.d.ts +0 -5
- package/lib/issue/tslint/TsLintIssueFactory.js +0 -25
- package/lib/issue/tslint/TsLintIssueFactory.js.map +0 -1
- package/lib/issue/tslint/index.d.ts +0 -1
- package/lib/issue/tslint/index.js +0 -7
- package/lib/issue/tslint/index.js.map +0 -1
- package/lib/linterConfigHelpers.d.ts +0 -10
- package/lib/linterConfigHelpers.js +0 -35
- package/lib/linterConfigHelpers.js.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
-
This plugin requires minimum **webpack 4
|
|
18
|
+
This plugin requires minimum **Node.js 6.11.5**, **webpack 4**, **TypeScript 2.1** and optionally **ESLint 6** (which itself requires minimum **Node.js 8.10.0**)
|
|
19
19
|
|
|
20
|
-
If you depend on **webpack 2
|
|
20
|
+
If you depend on **webpack 2**, **webpack 3**, or **tslint 4**, please use [older version](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v3.1.1) of the plugin.
|
|
21
21
|
|
|
22
22
|
```sh
|
|
23
23
|
# with npm
|
|
@@ -100,17 +100,6 @@ module.exports = {
|
|
|
100
100
|
|
|
101
101
|
There's a good explanation on setting up TypeScript ESLint support by Robert Cooper [here](https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb).
|
|
102
102
|
|
|
103
|
-
## TSLint
|
|
104
|
-
|
|
105
|
-
*[TSLint is being replaced by ESLint](https://medium.com/palantir/tslint-in-2019-1a144c2317a9).
|
|
106
|
-
https://eslint.org/blog/2019/01/future-typescript-eslint. As a consequence, support for TSLint in fork-ts-checker-webpack-plugin will be deprecated and removed in future versions of the plugin.*
|
|
107
|
-
|
|
108
|
-
If you have installed [tslint](https://palantir.github.io/tslint), you can enable it by setting `tslint: true` or
|
|
109
|
-
`tslint: './path/to/tslint.json'`. We recommend changing `defaultSeverity` to a `"warning"` in `tslint.json` file.
|
|
110
|
-
It helps to distinguish lints from TypeScript's diagnostics.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
103
|
## Options
|
|
115
104
|
|
|
116
105
|
- **tsconfig** `string`:
|
|
@@ -126,34 +115,7 @@ It helps to distinguish lints from TypeScript's diagnostics.
|
|
|
126
115
|
- **eslintOptions** `object`:
|
|
127
116
|
|
|
128
117
|
- Options that can be used to initialise ESLint. See https://eslint.org/docs/1.0.0/developer-guide/nodejs-api#cliengine
|
|
129
|
-
|
|
130
|
-
- **tslint** `string | true | undefined`:
|
|
131
|
-
|
|
132
|
-
- If `string`, path to _tslint.json_ file to check source files against.
|
|
133
|
-
- If `true`, path to `tslint.json` file will be computed with respect to currently checked file, just like TSLint
|
|
134
|
-
CLI would do. Suppose you have a project:
|
|
135
|
-
|
|
136
|
-
```
|
|
137
|
-
./
|
|
138
|
-
tslint.json
|
|
139
|
-
|
|
140
|
-
src/
|
|
141
|
-
file.ts
|
|
142
|
-
anotherFile.ts
|
|
143
|
-
|
|
144
|
-
lib/
|
|
145
|
-
tslint.json
|
|
146
|
-
someHelperFile.ts
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
In such a case `src/file.ts` and `src/anotherFile.ts` would be checked against root `tslint.json`, and
|
|
150
|
-
`src/lib/someHelperFile.ts` would be checked against `src/lib/tslint.json`.
|
|
151
|
-
|
|
152
|
-
Default: `undefined`.
|
|
153
|
-
|
|
154
|
-
- **tslintAutoFix** `boolean`:
|
|
155
|
-
Passes on `--fix` flag while running `tslint` to auto fix linting errors. Default: false.
|
|
156
|
-
|
|
118
|
+
|
|
157
119
|
- **async** `boolean`:
|
|
158
120
|
True by default - `async: false` can block webpack's emit to wait for type checker/linter and to add errors to the webpack's compilation.
|
|
159
121
|
We recommend to set this to `false` in projects where type checking is faster than webpack's build - it's better for integration with other plugins. Another scenario where you might want to set this to `false` is if you use the `overlay` functionality of `webpack-dev-server`.
|
|
@@ -162,7 +124,7 @@ It helps to distinguish lints from TypeScript's diagnostics.
|
|
|
162
124
|
List of TypeScript diagnostic codes to ignore.
|
|
163
125
|
|
|
164
126
|
- **ignoreLints** `string[]`:
|
|
165
|
-
List of
|
|
127
|
+
List of eslint rule names to ignore.
|
|
166
128
|
|
|
167
129
|
- **ignoreLintWarnings** `boolean`:
|
|
168
130
|
If true, will ignore all lint warnings.
|
|
@@ -206,7 +168,7 @@ new ForkTsCheckerWebpackPlugin({
|
|
|
206
168
|
|
|
207
169
|
- **measureCompilationTime** `boolean`:
|
|
208
170
|
If true, the plugin will measure the time spent inside the compilation code. This may be useful to compare modes,
|
|
209
|
-
especially if there are other loaders/plugins involved in the compilation. **requires
|
|
171
|
+
especially if there are other loaders/plugins involved in the compilation. **requires Node.js >= 8.5.0**
|
|
210
172
|
|
|
211
173
|
- **typescript** `string`:
|
|
212
174
|
If supplied this is a custom path where `typescript` can be found. Defaults to `require.resolve('typescript')`.
|
|
@@ -275,17 +237,17 @@ We hope this will be resolved in future; the issue can be tracked [here](https:/
|
|
|
275
237
|
|
|
276
238
|
This plugin provides some custom webpack hooks (all are sync):
|
|
277
239
|
|
|
278
|
-
| Hook Access Key | Description | Params
|
|
279
|
-
| -------------------- | ------------------------------------------------------------------------------ |
|
|
280
|
-
| `cancel` | Cancellation has been requested | `cancellationToken`
|
|
281
|
-
| `waiting` | Waiting for results |
|
|
282
|
-
| `serviceBeforeStart` | Async plugin that can be used for delaying `fork-ts-checker-service-start` | -
|
|
283
|
-
| `serviceStart` | Service will be started | `tsconfigPath`, `
|
|
284
|
-
| `serviceStartError` | Cannot start service | `error`
|
|
285
|
-
| `serviceOutOfMemory` | Service is out of memory | -
|
|
286
|
-
| `receive` | Plugin receives diagnostics and lints from service | `diagnostics`, `lints`
|
|
287
|
-
| `emit` | Service will add errors and warnings to webpack compilation ('build' mode) | `diagnostics`, `lints`, `elapsed`
|
|
288
|
-
| `done` | Service finished type checking and webpack finished compilation ('watch' mode) | `diagnostics`, `lints`, `elapsed`
|
|
240
|
+
| Hook Access Key | Description | Params |
|
|
241
|
+
| -------------------- | ------------------------------------------------------------------------------ | --------------------------------- |
|
|
242
|
+
| `cancel` | Cancellation has been requested | `cancellationToken` |
|
|
243
|
+
| `waiting` | Waiting for results | - |
|
|
244
|
+
| `serviceBeforeStart` | Async plugin that can be used for delaying `fork-ts-checker-service-start` | - |
|
|
245
|
+
| `serviceStart` | Service will be started | `tsconfigPath`, `memoryLimit` |
|
|
246
|
+
| `serviceStartError` | Cannot start service | `error` |
|
|
247
|
+
| `serviceOutOfMemory` | Service is out of memory | - |
|
|
248
|
+
| `receive` | Plugin receives diagnostics and lints from service | `diagnostics`, `lints` |
|
|
249
|
+
| `emit` | Service will add errors and warnings to webpack compilation ('build' mode) | `diagnostics`, `lints`, `elapsed` |
|
|
250
|
+
| `done` | Service finished type checking and webpack finished compilation ('watch' mode) | `diagnostics`, `lints`, `elapsed` |
|
|
289
251
|
|
|
290
252
|
### Accessing plugin hooks
|
|
291
253
|
|
|
@@ -381,14 +343,12 @@ if ('compilers' in compiler) {
|
|
|
381
343
|
|
|
382
344
|
```js
|
|
383
345
|
new ForkTsCheckerWebpackPlugin({
|
|
384
|
-
tslint: true,
|
|
385
346
|
vue: true
|
|
386
347
|
});
|
|
387
348
|
```
|
|
388
349
|
Optionally change default [vue-template-compiler](https://github.com/vuejs/vue/tree/dev/packages/vue-template-compiler) to [nativescript-vue-template-compiler](https://github.com/nativescript-vue/nativescript-vue/tree/master/packages/nativescript-vue-template-compiler) if you use [nativescript-vue](https://github.com/nativescript-vue/nativescript-vue)
|
|
389
350
|
```
|
|
390
351
|
new ForkTsCheckerWebpackPlugin({
|
|
391
|
-
tslint: true,
|
|
392
352
|
vue: { enabled: true, compiler: 'nativescript-vue-template-compiler' }
|
|
393
353
|
});
|
|
394
354
|
```
|
|
@@ -423,16 +383,7 @@ new ForkTsCheckerWebpackPlugin({
|
|
|
423
383
|
},
|
|
424
384
|
```
|
|
425
385
|
|
|
426
|
-
4.
|
|
427
|
-
|
|
428
|
-
```json
|
|
429
|
-
{
|
|
430
|
-
"defaultSeverity": "error",
|
|
431
|
-
"extends": ["tslint-config-standard"]
|
|
432
|
-
}
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
5. Ensure your `tsconfig.json` includes .vue files:
|
|
386
|
+
4. Ensure your `tsconfig.json` includes .vue files:
|
|
436
387
|
|
|
437
388
|
```js
|
|
438
389
|
// tsconfig.json
|
|
@@ -447,7 +398,7 @@ new ForkTsCheckerWebpackPlugin({
|
|
|
447
398
|
}
|
|
448
399
|
```
|
|
449
400
|
|
|
450
|
-
|
|
401
|
+
5. It accepts any wildcard in your TypeScript configuration:
|
|
451
402
|
|
|
452
403
|
```js
|
|
453
404
|
// tsconfig.json
|
|
@@ -472,7 +423,7 @@ new ForkTsCheckerWebpackPlugin({
|
|
|
472
423
|
import Hello from '@/components/hello.vue'
|
|
473
424
|
```
|
|
474
425
|
|
|
475
|
-
|
|
426
|
+
6. 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.
|
|
476
427
|
|
|
477
428
|
## Credits
|
|
478
429
|
|
|
@@ -2,28 +2,15 @@ import { IncrementalCheckerInterface, IncrementalCheckerParams } from './Increme
|
|
|
2
2
|
import { CancellationToken } from './CancellationToken';
|
|
3
3
|
import { CompilerHost } from './CompilerHost';
|
|
4
4
|
export declare class ApiIncrementalChecker implements IncrementalCheckerInterface {
|
|
5
|
-
private linterConfig?;
|
|
6
|
-
private linterConfigs;
|
|
7
5
|
protected readonly tsIncrementalCompiler: CompilerHost;
|
|
8
|
-
private linterExclusions;
|
|
9
|
-
private currentLintErrors;
|
|
10
6
|
private currentEsLintErrors;
|
|
11
7
|
private lastUpdatedFiles;
|
|
12
8
|
private lastRemovedFiles;
|
|
13
|
-
private readonly hasFixedConfig;
|
|
14
|
-
private readonly context;
|
|
15
|
-
private readonly linterConfigFile;
|
|
16
|
-
private readonly linterAutoFix;
|
|
17
9
|
private readonly eslinter;
|
|
18
|
-
constructor({ typescript,
|
|
19
|
-
private initLinterConfig;
|
|
20
|
-
private getLinterConfig;
|
|
21
|
-
private createLinter;
|
|
22
|
-
hasTsLinter(): boolean;
|
|
10
|
+
constructor({ typescript, programConfigFile, compilerOptions, eslinter, vue, checkSyntacticErrors, resolveModuleName, resolveTypeReferenceDirective }: IncrementalCheckerParams);
|
|
23
11
|
hasEsLinter(): boolean;
|
|
24
12
|
isFileExcluded(filePath: string): boolean;
|
|
25
13
|
nextIteration(): void;
|
|
26
|
-
getTypeScriptIssues(
|
|
27
|
-
getTsLintIssues(_cancellationToken: CancellationToken): Promise<import("./issue/Issue").Issue[]>;
|
|
14
|
+
getTypeScriptIssues(): Promise<import("./issue/Issue").Issue[]>;
|
|
28
15
|
getEsLintIssues(cancellationToken: CancellationToken): Promise<import("./issue/Issue").Issue[]>;
|
|
29
16
|
}
|
|
@@ -7,130 +7,100 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
10
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const issue_1 = require("./issue");
|
|
17
|
-
class ApiIncrementalChecker {
|
|
18
|
-
constructor({ typescript, context, programConfigFile, compilerOptions, linterConfigFile, linterAutoFix, eslinter, vue, checkSyntacticErrors = false, resolveModuleName, resolveTypeReferenceDirective }) {
|
|
19
|
-
this.linterConfigs = {};
|
|
20
|
-
this.linterExclusions = [];
|
|
21
|
-
this.currentLintErrors = new Map();
|
|
38
|
+
var CompilerHost_1 = require("./CompilerHost");
|
|
39
|
+
var issue_1 = require("./issue");
|
|
40
|
+
var ApiIncrementalChecker = /** @class */ (function () {
|
|
41
|
+
function ApiIncrementalChecker(_a) {
|
|
42
|
+
var typescript = _a.typescript, programConfigFile = _a.programConfigFile, compilerOptions = _a.compilerOptions, eslinter = _a.eslinter, vue = _a.vue, _b = _a.checkSyntacticErrors, checkSyntacticErrors = _b === void 0 ? false : _b, resolveModuleName = _a.resolveModuleName, resolveTypeReferenceDirective = _a.resolveTypeReferenceDirective;
|
|
22
43
|
this.currentEsLintErrors = new Map();
|
|
23
44
|
this.lastUpdatedFiles = [];
|
|
24
45
|
this.lastRemovedFiles = [];
|
|
25
|
-
this.getLinterConfig = linterConfigHelpers_1.makeGetLinterConfig(this.linterConfigs, this.linterExclusions, this.context);
|
|
26
|
-
this.context = context;
|
|
27
|
-
this.linterConfigFile = linterConfigFile;
|
|
28
|
-
this.linterAutoFix = linterAutoFix;
|
|
29
46
|
this.eslinter = eslinter;
|
|
30
|
-
this.hasFixedConfig = typeof this.linterConfigFile === 'string';
|
|
31
|
-
this.initLinterConfig();
|
|
32
47
|
this.tsIncrementalCompiler = new CompilerHost_1.CompilerHost(typescript, vue, programConfigFile, compilerOptions, checkSyntacticErrors, resolveModuleName, resolveTypeReferenceDirective);
|
|
33
48
|
}
|
|
34
|
-
|
|
35
|
-
if (!this.linterConfig && this.hasFixedConfig) {
|
|
36
|
-
this.linterConfig = linterConfigHelpers_1.loadLinterConfig(this.linterConfigFile);
|
|
37
|
-
if (this.linterConfig.linterOptions &&
|
|
38
|
-
this.linterConfig.linterOptions.exclude) {
|
|
39
|
-
// Pre-build minimatch patterns to avoid additional overhead later on.
|
|
40
|
-
// Note: Resolving the path is required to properly match against the full file paths,
|
|
41
|
-
// and also deals with potential cross-platform problems regarding path separators.
|
|
42
|
-
this.linterExclusions = this.linterConfig.linterOptions.exclude.map(pattern => new minimatch.Minimatch(path.resolve(pattern)));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
createLinter(program) {
|
|
47
|
-
// tslint:disable-next-line:no-implicit-dependencies
|
|
48
|
-
const { Linter } = require('tslint');
|
|
49
|
-
return new Linter({ fix: this.linterAutoFix }, program);
|
|
50
|
-
}
|
|
51
|
-
hasTsLinter() {
|
|
52
|
-
return !!this.linterConfigFile;
|
|
53
|
-
}
|
|
54
|
-
hasEsLinter() {
|
|
49
|
+
ApiIncrementalChecker.prototype.hasEsLinter = function () {
|
|
55
50
|
return this.eslinter !== undefined;
|
|
56
|
-
}
|
|
57
|
-
isFileExcluded(filePath) {
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
nextIteration() {
|
|
51
|
+
};
|
|
52
|
+
ApiIncrementalChecker.prototype.isFileExcluded = function (filePath) {
|
|
53
|
+
return filePath.endsWith('.d.ts');
|
|
54
|
+
};
|
|
55
|
+
ApiIncrementalChecker.prototype.nextIteration = function () {
|
|
62
56
|
// do nothing
|
|
63
|
-
}
|
|
64
|
-
getTypeScriptIssues(
|
|
65
|
-
return __awaiter(this, void 0, void 0, function
|
|
66
|
-
|
|
67
|
-
this
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
};
|
|
58
|
+
ApiIncrementalChecker.prototype.getTypeScriptIssues = function () {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
var tsDiagnostics;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0: return [4 /*yield*/, this.tsIncrementalCompiler.processChanges()];
|
|
64
|
+
case 1:
|
|
65
|
+
tsDiagnostics = _a.sent();
|
|
66
|
+
this.lastUpdatedFiles = tsDiagnostics.updatedFiles;
|
|
67
|
+
this.lastRemovedFiles = tsDiagnostics.removedFiles;
|
|
68
|
+
return [2 /*return*/, issue_1.createIssuesFromTsDiagnostics(tsDiagnostics.results)];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
70
71
|
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return __awaiter(this, void 0, void 0, function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
};
|
|
73
|
+
ApiIncrementalChecker.prototype.getEsLintIssues = function (cancellationToken) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
var _i, _a, removedFile, _b, _c, updatedFile, report, reports;
|
|
76
|
+
return __generator(this, function (_d) {
|
|
77
|
+
if (!this.eslinter) {
|
|
78
|
+
throw new Error('EsLint is not enabled in the plugin.');
|
|
79
|
+
}
|
|
80
|
+
for (_i = 0, _a = this.lastRemovedFiles; _i < _a.length; _i++) {
|
|
81
|
+
removedFile = _a[_i];
|
|
82
|
+
this.currentEsLintErrors.delete(removedFile);
|
|
77
83
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
: this.getLinterConfig(updatedFile);
|
|
83
|
-
if (!config) {
|
|
84
|
+
for (_b = 0, _c = this.lastUpdatedFiles; _b < _c.length; _b++) {
|
|
85
|
+
updatedFile = _c[_b];
|
|
86
|
+
cancellationToken.throwIfCancellationRequested();
|
|
87
|
+
if (this.isFileExcluded(updatedFile)) {
|
|
84
88
|
continue;
|
|
85
89
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (FsHelper_1.fileExistsSync(updatedFile) &&
|
|
93
|
-
// check the error type due to file system lag
|
|
94
|
-
!(e instanceof Error) &&
|
|
95
|
-
!(e.constructor.name === 'FatalError') &&
|
|
96
|
-
!(e.message && e.message.trim().startsWith('Invalid source file'))) {
|
|
97
|
-
// it's not because file doesn't exist - throw error
|
|
98
|
-
throw e;
|
|
90
|
+
report = this.eslinter.getReport(updatedFile);
|
|
91
|
+
if (report !== undefined) {
|
|
92
|
+
this.currentEsLintErrors.set(updatedFile, report);
|
|
93
|
+
}
|
|
94
|
+
else if (this.currentEsLintErrors.has(updatedFile)) {
|
|
95
|
+
this.currentEsLintErrors.delete(updatedFile);
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
const allLints = [];
|
|
106
|
-
for (const [, value] of this.currentLintErrors) {
|
|
107
|
-
allLints.push(...value.failures);
|
|
108
|
-
}
|
|
109
|
-
return issue_1.createIssuesFromTsLintRuleFailures(allLints);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
getEsLintIssues(cancellationToken) {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
for (const removedFile of this.lastRemovedFiles) {
|
|
115
|
-
this.currentEsLintErrors.delete(removedFile);
|
|
116
|
-
}
|
|
117
|
-
for (const updatedFile of this.lastUpdatedFiles) {
|
|
118
|
-
cancellationToken.throwIfCancellationRequested();
|
|
119
|
-
if (this.isFileExcluded(updatedFile)) {
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
const report = this.eslinter.getReport(updatedFile);
|
|
123
|
-
if (report !== undefined) {
|
|
124
|
-
this.currentEsLintErrors.set(updatedFile, report);
|
|
125
|
-
}
|
|
126
|
-
else if (this.currentEsLintErrors.has(updatedFile)) {
|
|
127
|
-
this.currentEsLintErrors.delete(updatedFile);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const reports = Array.from(this.currentEsLintErrors.values());
|
|
131
|
-
return issue_1.createIssuesFromEsLintReports(reports);
|
|
98
|
+
reports = Array.from(this.currentEsLintErrors.values());
|
|
99
|
+
return [2 /*return*/, issue_1.createIssuesFromEsLintReports(reports)];
|
|
100
|
+
});
|
|
132
101
|
});
|
|
133
|
-
}
|
|
134
|
-
|
|
102
|
+
};
|
|
103
|
+
return ApiIncrementalChecker;
|
|
104
|
+
}());
|
|
135
105
|
exports.ApiIncrementalChecker = ApiIncrementalChecker;
|
|
136
106
|
//# sourceMappingURL=ApiIncrementalChecker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiIncrementalChecker.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"ApiIncrementalChecker.js","sourceRoot":"./","sources":["ApiIncrementalChecker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,+CAA8C;AAE9C,iCAGiB;AAGjB;IASE,+BAAY,EASe;Y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AC,MAAM,CAAC,WAAW,CAAC,CAAC;iBAC9C;gBAED,WAA+C,EAArB,KAAA,IAAI,CAAC,gBAAgB,EAArB,cAAqB,EAArB,IAAqB,EAAE;oBAAtC,WAAW;oBACpB,iBAAiB,CAAC,4BAA4B,EAAE,CAAC;oBACjD,IAAI,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;wBACpC,SAAS;qBACV;oBAEK,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;oBAEpD,IAAI,MAAM,KAAK,SAAS,EAAE;wBACxB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;qBACnD;yBAAM,IAAI,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;wBACpD,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;qBAC9C;iBACF;gBAEK,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC9D,sBAAO,qCAA6B,CAAC,OAAO,CAAC,EAAC;;;KAC/C;IACH,4BAAC;AAAD,CAAC,AA/ED,IA+EC;AA/EY,sDAAqB"}
|
package/lib/CancellationToken.js
CHANGED
|
@@ -1,58 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
6
|
+
if (mod && mod.__esModule) return mod;
|
|
7
|
+
var result = {};
|
|
8
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
9
|
+
result["default"] = mod;
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
2
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
var crypto_1 = __importDefault(require("crypto"));
|
|
14
|
+
var fs = __importStar(require("fs"));
|
|
15
|
+
var os = __importStar(require("os"));
|
|
16
|
+
var path = __importStar(require("path"));
|
|
17
|
+
var FsHelper_1 = require("./FsHelper");
|
|
18
|
+
var CancellationToken = /** @class */ (function () {
|
|
19
|
+
function CancellationToken(typescript, cancellationFileName, isCancelled) {
|
|
10
20
|
this.typescript = typescript;
|
|
11
21
|
this.isCancelled = !!isCancelled;
|
|
12
22
|
this.cancellationFileName =
|
|
13
|
-
cancellationFileName ||
|
|
23
|
+
cancellationFileName || crypto_1.default.randomBytes(64).toString('hex');
|
|
14
24
|
this.lastCancellationCheckTime = 0;
|
|
15
25
|
}
|
|
16
|
-
|
|
26
|
+
CancellationToken.createFromJSON = function (typescript, json) {
|
|
17
27
|
return new CancellationToken(typescript, json.cancellationFileName, json.isCancelled);
|
|
18
|
-
}
|
|
19
|
-
toJSON() {
|
|
28
|
+
};
|
|
29
|
+
CancellationToken.prototype.toJSON = function () {
|
|
20
30
|
return {
|
|
21
31
|
cancellationFileName: this.cancellationFileName,
|
|
22
32
|
isCancelled: this.isCancelled
|
|
23
33
|
};
|
|
24
|
-
}
|
|
25
|
-
getCancellationFilePath() {
|
|
34
|
+
};
|
|
35
|
+
CancellationToken.prototype.getCancellationFilePath = function () {
|
|
26
36
|
return path.join(os.tmpdir(), this.cancellationFileName);
|
|
27
|
-
}
|
|
28
|
-
isCancellationRequested() {
|
|
37
|
+
};
|
|
38
|
+
CancellationToken.prototype.isCancellationRequested = function () {
|
|
29
39
|
if (this.isCancelled) {
|
|
30
40
|
return true;
|
|
31
41
|
}
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
var time = Date.now();
|
|
43
|
+
var duration = Math.abs(time - this.lastCancellationCheckTime);
|
|
34
44
|
if (duration > 10) {
|
|
35
45
|
// check no more than once every 10ms
|
|
36
46
|
this.lastCancellationCheckTime = time;
|
|
37
47
|
this.isCancelled = FsHelper_1.fileExistsSync(this.getCancellationFilePath());
|
|
38
48
|
}
|
|
39
49
|
return this.isCancelled;
|
|
40
|
-
}
|
|
41
|
-
throwIfCancellationRequested() {
|
|
50
|
+
};
|
|
51
|
+
CancellationToken.prototype.throwIfCancellationRequested = function () {
|
|
42
52
|
if (this.isCancellationRequested()) {
|
|
43
53
|
throw new this.typescript.OperationCanceledException();
|
|
44
54
|
}
|
|
45
|
-
}
|
|
46
|
-
requestCancellation() {
|
|
55
|
+
};
|
|
56
|
+
CancellationToken.prototype.requestCancellation = function () {
|
|
47
57
|
fs.writeFileSync(this.getCancellationFilePath(), '');
|
|
48
58
|
this.isCancelled = true;
|
|
49
|
-
}
|
|
50
|
-
cleanupCancellation() {
|
|
59
|
+
};
|
|
60
|
+
CancellationToken.prototype.cleanupCancellation = function () {
|
|
51
61
|
if (this.isCancelled && FsHelper_1.fileExistsSync(this.getCancellationFilePath())) {
|
|
52
62
|
fs.unlinkSync(this.getCancellationFilePath());
|
|
53
63
|
this.isCancelled = false;
|
|
54
64
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
65
|
+
};
|
|
66
|
+
return CancellationToken;
|
|
67
|
+
}());
|
|
57
68
|
exports.CancellationToken = CancellationToken;
|
|
58
69
|
//# sourceMappingURL=CancellationToken.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CancellationToken.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"CancellationToken.js","sourceRoot":"./","sources":["CancellationToken.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA4B;AAC5B,qCAAyB;AACzB,qCAAyB;AACzB,yCAA6B;AAG7B,uCAA4C;AAO5C;IAIE,2BACU,UAAqB,EAC7B,oBAA6B,EAC7B,WAAqB;QAFb,eAAU,GAAV,UAAU,CAAW;QAI7B,IAAI,CAAC,WAAW,GAA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,CAAC;IAEM,+CAAmB,GAA1B;QACE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAEM,+CAAmB,GAA1B;QACE,IAAI,IAAI,CAAC,WAAW,IAAI,yBAAc,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,EAAE;YACtE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAC;YAC9C,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;SAC1B;IACH,CAAC;IACH,wBAAC;AAAD,CAAC,AAvED,IAuEC;AAvEY,8CAAiB"}
|
package/lib/CompilerHost.d.ts
CHANGED
|
@@ -25,11 +25,11 @@ export declare class CompilerHost implements ts.WatchCompilerHostOfConfigFile<ts
|
|
|
25
25
|
updatedFiles: string[];
|
|
26
26
|
removedFiles: string[];
|
|
27
27
|
}>;
|
|
28
|
-
setTimeout(callback: (...args: any[]) => void,
|
|
28
|
+
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
|
|
29
29
|
clearTimeout(timeoutId: any): void;
|
|
30
|
-
onWatchStatusChange(
|
|
30
|
+
onWatchStatusChange(): void;
|
|
31
31
|
watchDirectory(path: string, callback: ts.DirectoryWatcherCallback, recursive?: boolean): ts.FileWatcher;
|
|
32
|
-
watchFile(path: string, callback: ts.FileWatcherCallback,
|
|
32
|
+
watchFile(path: string, callback: ts.FileWatcherCallback, pollingInterval?: number): ts.FileWatcher;
|
|
33
33
|
fileExists(path: string): boolean;
|
|
34
34
|
readFile(path: string, encoding?: string): string | undefined;
|
|
35
35
|
directoryExists(path: string): boolean;
|
|
@@ -43,9 +43,9 @@ export declare class CompilerHost implements ts.WatchCompilerHostOfConfigFile<ts
|
|
|
43
43
|
realpath(path: string): string;
|
|
44
44
|
trace(s: string): void;
|
|
45
45
|
useCaseSensitiveFileNames(): boolean;
|
|
46
|
-
onUnRecoverableConfigFileDiagnostic(
|
|
46
|
+
onUnRecoverableConfigFileDiagnostic(): void;
|
|
47
47
|
afterProgramCreate(program: ts.EmitAndSemanticDiagnosticsBuilderProgram): void;
|
|
48
|
-
createDirectory(
|
|
49
|
-
writeFile(
|
|
50
|
-
onCachedDirectoryStructureHostCreate?(
|
|
48
|
+
createDirectory(): void;
|
|
49
|
+
writeFile(): void;
|
|
50
|
+
onCachedDirectoryStructureHostCreate?(): void;
|
|
51
51
|
}
|