fork-ts-checker-webpack-plugin 4.0.0-beta.3 → 4.0.2
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 +21 -73
- package/lib/ApiIncrementalChecker.d.ts +2 -15
- package/lib/ApiIncrementalChecker.js +79 -109
- package/lib/ApiIncrementalChecker.js.map +1 -1
- package/lib/CancellationToken.js +32 -24
- 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.d.ts +0 -3
- package/lib/hooks.js +5 -16
- package/lib/hooks.js.map +1 -1
- package/lib/index.d.ts +2 -10
- package/lib/index.js +247 -377
- 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 -33
- 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,7 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
-
This plugin requires minimum **
|
|
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
|
+
|
|
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.
|
|
19
21
|
|
|
20
22
|
```sh
|
|
21
23
|
# with npm
|
|
@@ -98,17 +100,6 @@ module.exports = {
|
|
|
98
100
|
|
|
99
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).
|
|
100
102
|
|
|
101
|
-
## TSLint
|
|
102
|
-
|
|
103
|
-
*[TSLint is being replaced by ESLint](https://medium.com/palantir/tslint-in-2019-1a144c2317a9).
|
|
104
|
-
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.*
|
|
105
|
-
|
|
106
|
-
If you have installed [tslint](https://palantir.github.io/tslint), you can enable it by setting `tslint: true` or
|
|
107
|
-
`tslint: './path/to/tslint.json'`. We recommend changing `defaultSeverity` to a `"warning"` in `tslint.json` file.
|
|
108
|
-
It helps to distinguish lints from TypeScript's diagnostics.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
103
|
## Options
|
|
113
104
|
|
|
114
105
|
- **tsconfig** `string`:
|
|
@@ -124,34 +115,7 @@ It helps to distinguish lints from TypeScript's diagnostics.
|
|
|
124
115
|
- **eslintOptions** `object`:
|
|
125
116
|
|
|
126
117
|
- Options that can be used to initialise ESLint. See https://eslint.org/docs/1.0.0/developer-guide/nodejs-api#cliengine
|
|
127
|
-
|
|
128
|
-
- **tslint** `string | true | undefined`:
|
|
129
|
-
|
|
130
|
-
- If `string`, path to _tslint.json_ file to check source files against.
|
|
131
|
-
- If `true`, path to `tslint.json` file will be computed with respect to currently checked file, just like TSLint
|
|
132
|
-
CLI would do. Suppose you have a project:
|
|
133
|
-
|
|
134
|
-
```
|
|
135
|
-
./
|
|
136
|
-
tslint.json
|
|
137
|
-
|
|
138
|
-
src/
|
|
139
|
-
file.ts
|
|
140
|
-
anotherFile.ts
|
|
141
|
-
|
|
142
|
-
lib/
|
|
143
|
-
tslint.json
|
|
144
|
-
someHelperFile.ts
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
In such a case `src/file.ts` and `src/anotherFile.ts` would be checked against root `tslint.json`, and
|
|
148
|
-
`src/lib/someHelperFile.ts` would be checked against `src/lib/tslint.json`.
|
|
149
|
-
|
|
150
|
-
Default: `undefined`.
|
|
151
|
-
|
|
152
|
-
- **tslintAutoFix** `boolean`:
|
|
153
|
-
Passes on `--fix` flag while running `tslint` to auto fix linting errors. Default: false.
|
|
154
|
-
|
|
118
|
+
|
|
155
119
|
- **async** `boolean`:
|
|
156
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.
|
|
157
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`.
|
|
@@ -160,7 +124,7 @@ It helps to distinguish lints from TypeScript's diagnostics.
|
|
|
160
124
|
List of TypeScript diagnostic codes to ignore.
|
|
161
125
|
|
|
162
126
|
- **ignoreLints** `string[]`:
|
|
163
|
-
List of
|
|
127
|
+
List of eslint rule names to ignore.
|
|
164
128
|
|
|
165
129
|
- **ignoreLintWarnings** `boolean`:
|
|
166
130
|
If true, will ignore all lint warnings.
|
|
@@ -204,7 +168,7 @@ new ForkTsCheckerWebpackPlugin({
|
|
|
204
168
|
|
|
205
169
|
- **measureCompilationTime** `boolean`:
|
|
206
170
|
If true, the plugin will measure the time spent inside the compilation code. This may be useful to compare modes,
|
|
207
|
-
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**
|
|
208
172
|
|
|
209
173
|
- **typescript** `string`:
|
|
210
174
|
If supplied this is a custom path where `typescript` can be found. Defaults to `require.resolve('typescript')`.
|
|
@@ -273,26 +237,21 @@ We hope this will be resolved in future; the issue can be tracked [here](https:/
|
|
|
273
237
|
|
|
274
238
|
This plugin provides some custom webpack hooks (all are sync):
|
|
275
239
|
|
|
276
|
-
|
|
|
277
|
-
|
|
|
278
|
-
| `
|
|
279
|
-
| `
|
|
280
|
-
| `
|
|
281
|
-
| `
|
|
282
|
-
| `
|
|
283
|
-
| `
|
|
284
|
-
| `
|
|
285
|
-
| `
|
|
286
|
-
| `
|
|
287
|
-
|
|
288
|
-
The **Event name** is there for backward compatibility with webpack 2/3. Regardless
|
|
289
|
-
of the version of webpack (2, 3 or 4) you are using, we will always access plugin hooks with **Hook Access Keys** as
|
|
290
|
-
described below.
|
|
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` |
|
|
291
251
|
|
|
292
252
|
### Accessing plugin hooks
|
|
293
253
|
|
|
294
|
-
|
|
295
|
-
4 and version 2. To access plugin hooks and tap into the event, we need to use
|
|
254
|
+
To access plugin hooks and tap into the event, we need to use
|
|
296
255
|
the `getCompilerHooks` static method. When we call this method with a [webpack compiler instance](https://webpack.js.org/api/node/),
|
|
297
256
|
it returns the series of [tapable](https://github.com/webpack/tapable)
|
|
298
257
|
hooks where you can pass in your callbacks.
|
|
@@ -384,14 +343,12 @@ if ('compilers' in compiler) {
|
|
|
384
343
|
|
|
385
344
|
```js
|
|
386
345
|
new ForkTsCheckerWebpackPlugin({
|
|
387
|
-
tslint: true,
|
|
388
346
|
vue: true
|
|
389
347
|
});
|
|
390
348
|
```
|
|
391
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)
|
|
392
350
|
```
|
|
393
351
|
new ForkTsCheckerWebpackPlugin({
|
|
394
|
-
tslint: true,
|
|
395
352
|
vue: { enabled: true, compiler: 'nativescript-vue-template-compiler' }
|
|
396
353
|
});
|
|
397
354
|
```
|
|
@@ -426,16 +383,7 @@ new ForkTsCheckerWebpackPlugin({
|
|
|
426
383
|
},
|
|
427
384
|
```
|
|
428
385
|
|
|
429
|
-
4.
|
|
430
|
-
|
|
431
|
-
```json
|
|
432
|
-
{
|
|
433
|
-
"defaultSeverity": "error",
|
|
434
|
-
"extends": ["tslint-config-standard"]
|
|
435
|
-
}
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
5. Ensure your `tsconfig.json` includes .vue files:
|
|
386
|
+
4. Ensure your `tsconfig.json` includes .vue files:
|
|
439
387
|
|
|
440
388
|
```js
|
|
441
389
|
// tsconfig.json
|
|
@@ -450,7 +398,7 @@ new ForkTsCheckerWebpackPlugin({
|
|
|
450
398
|
}
|
|
451
399
|
```
|
|
452
400
|
|
|
453
|
-
|
|
401
|
+
5. It accepts any wildcard in your TypeScript configuration:
|
|
454
402
|
|
|
455
403
|
```js
|
|
456
404
|
// tsconfig.json
|
|
@@ -475,7 +423,7 @@ new ForkTsCheckerWebpackPlugin({
|
|
|
475
423
|
import Hello from '@/components/hello.vue'
|
|
476
424
|
```
|
|
477
425
|
|
|
478
|
-
|
|
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.
|
|
479
427
|
|
|
480
428
|
## Credits
|
|
481
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,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mB,CAAC,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,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
+
if (mod && mod.__esModule) return mod;
|
|
4
|
+
var result = {};
|
|
5
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
+
result["default"] = mod;
|
|
7
|
+
return result;
|
|
8
|
+
};
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
var crypto = __importStar(require("crypto"));
|
|
11
|
+
var fs = __importStar(require("fs"));
|
|
12
|
+
var os = __importStar(require("os"));
|
|
13
|
+
var path = __importStar(require("path"));
|
|
14
|
+
var FsHelper_1 = require("./FsHelper");
|
|
15
|
+
var CancellationToken = /** @class */ (function () {
|
|
16
|
+
function CancellationToken(typescript, cancellationFileName, isCancelled) {
|
|
10
17
|
this.typescript = typescript;
|
|
11
18
|
this.isCancelled = !!isCancelled;
|
|
12
19
|
this.cancellationFileName =
|
|
13
20
|
cancellationFileName || crypto.randomBytes(64).toString('hex');
|
|
14
21
|
this.lastCancellationCheckTime = 0;
|
|
15
22
|
}
|
|
16
|
-
|
|
23
|
+
CancellationToken.createFromJSON = function (typescript, json) {
|
|
17
24
|
return new CancellationToken(typescript, json.cancellationFileName, json.isCancelled);
|
|
18
|
-
}
|
|
19
|
-
toJSON() {
|
|
25
|
+
};
|
|
26
|
+
CancellationToken.prototype.toJSON = function () {
|
|
20
27
|
return {
|
|
21
28
|
cancellationFileName: this.cancellationFileName,
|
|
22
29
|
isCancelled: this.isCancelled
|
|
23
30
|
};
|
|
24
|
-
}
|
|
25
|
-
getCancellationFilePath() {
|
|
31
|
+
};
|
|
32
|
+
CancellationToken.prototype.getCancellationFilePath = function () {
|
|
26
33
|
return path.join(os.tmpdir(), this.cancellationFileName);
|
|
27
|
-
}
|
|
28
|
-
isCancellationRequested() {
|
|
34
|
+
};
|
|
35
|
+
CancellationToken.prototype.isCancellationRequested = function () {
|
|
29
36
|
if (this.isCancelled) {
|
|
30
37
|
return true;
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
var time = Date.now();
|
|
40
|
+
var duration = Math.abs(time - this.lastCancellationCheckTime);
|
|
34
41
|
if (duration > 10) {
|
|
35
42
|
// check no more than once every 10ms
|
|
36
43
|
this.lastCancellationCheckTime = time;
|
|
37
44
|
this.isCancelled = FsHelper_1.fileExistsSync(this.getCancellationFilePath());
|
|
38
45
|
}
|
|
39
46
|
return this.isCancelled;
|
|
40
|
-
}
|
|
41
|
-
throwIfCancellationRequested() {
|
|
47
|
+
};
|
|
48
|
+
CancellationToken.prototype.throwIfCancellationRequested = function () {
|
|
42
49
|
if (this.isCancellationRequested()) {
|
|
43
50
|
throw new this.typescript.OperationCanceledException();
|
|
44
51
|
}
|
|
45
|
-
}
|
|
46
|
-
requestCancellation() {
|
|
52
|
+
};
|
|
53
|
+
CancellationToken.prototype.requestCancellation = function () {
|
|
47
54
|
fs.writeFileSync(this.getCancellationFilePath(), '');
|
|
48
55
|
this.isCancelled = true;
|
|
49
|
-
}
|
|
50
|
-
cleanupCancellation() {
|
|
56
|
+
};
|
|
57
|
+
CancellationToken.prototype.cleanupCancellation = function () {
|
|
51
58
|
if (this.isCancelled && FsHelper_1.fileExistsSync(this.getCancellationFilePath())) {
|
|
52
59
|
fs.unlinkSync(this.getCancellationFilePath());
|
|
53
60
|
this.isCancelled = false;
|
|
54
61
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
62
|
+
};
|
|
63
|
+
return CancellationToken;
|
|
64
|
+
}());
|
|
57
65
|
exports.CancellationToken = CancellationToken;
|
|
58
66
|
//# 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,6CAAiC;AACjC,qCAAyB;AACzB,qCAAyB;AACzB,yCAA6B;AAG7B,uCAA4C;AAO5C;IAIE,2BACU,UAAqB,EAC7B,oBAA6B,EAC7B,WAAqB;QAFb,eAAU,GAAV,UAAU,CAAW;QAI7B,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC;QACjC,IAAI,CAAC,oBAAoB;YACvB,oBAAoB,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK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AG,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
|
}
|