fork-ts-checker-webpack-plugin 0.4.14 → 0.5.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/CHANGELOG.md +23 -0
- package/README.md +3 -0
- package/lib/{types/CancellationToken.d.ts → CancellationToken.d.ts} +4 -4
- package/lib/CancellationToken.js +28 -27
- package/lib/{types/FilesRegister.d.ts → FilesRegister.d.ts} +9 -14
- package/lib/FilesRegister.js +24 -24
- package/lib/{types/FilesWatcher.d.ts → FilesWatcher.d.ts} +4 -7
- package/lib/FilesWatcher.js +27 -29
- package/lib/FsHelper.d.ts +5 -0
- package/lib/FsHelper.js +20 -0
- package/lib/IncrementalChecker.d.ts +34 -0
- package/lib/IncrementalChecker.js +97 -109
- package/lib/{types/Message.d.ts → Message.d.ts} +0 -0
- package/lib/{types/NormalizedMessage.d.ts → NormalizedMessage.d.ts} +16 -23
- package/lib/NormalizedMessage.js +76 -86
- package/lib/{types/VueProgram.d.ts → VueProgram.d.ts} +0 -0
- package/lib/VueProgram.js +62 -77
- package/lib/{types/WorkResult.d.ts → WorkResult.d.ts} +6 -6
- package/lib/WorkResult.js +22 -25
- package/lib/{types/WorkSet.d.ts → WorkSet.d.ts} +6 -6
- package/lib/WorkSet.js +6 -7
- package/lib/{types/cluster.d.ts → cluster.d.ts} +0 -0
- package/lib/cluster.js +19 -19
- package/lib/{types/formatter → formatter}/codeframeFormatter.d.ts +0 -0
- package/lib/formatter/codeframeFormatter.js +17 -16
- package/lib/{types/formatter → formatter}/defaultFormatter.d.ts +0 -0
- package/lib/formatter/defaultFormatter.js +9 -9
- package/lib/index.d.ts +98 -0
- package/lib/index.js +183 -192
- package/lib/{types/service.d.ts → service.d.ts} +0 -0
- package/lib/service.js +11 -11
- package/package.json +14 -18
- package/lib/types/IncrementalChecker.d.ts +0 -43
- package/lib/types/index.d.ts +0 -101
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
## v0.5.2
|
|
2
|
+
|
|
3
|
+
* [Fix erroneous error on diagnostics at 0 line; remove deprecated fs.existsSync](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/190) (#190)
|
|
4
|
+
|
|
5
|
+
## v0.5.1
|
|
6
|
+
|
|
7
|
+
* [Make the checker compile with TypeScript 3.2](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/189)
|
|
8
|
+
|
|
9
|
+
## 0.5.0
|
|
10
|
+
|
|
11
|
+
* Removed unused dependency `resolve`.
|
|
12
|
+
* Replace `lodash` usage with native calls.
|
|
13
|
+
* ** Breaking Changes**:
|
|
14
|
+
* Removed all getters from `NormalizedMessage`, use direct property access instead.
|
|
15
|
+
* **Internal**:
|
|
16
|
+
* Test against ts-loader v5
|
|
17
|
+
* Enable all strict type checks
|
|
18
|
+
* Update dev dependencies
|
|
19
|
+
|
|
20
|
+
## v0.4.15
|
|
21
|
+
|
|
22
|
+
* [Add `tslintAutoFix` option to be passed on to tslint to auto format typescript files](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/174) (#174)
|
|
23
|
+
|
|
1
24
|
## v0.4.14
|
|
2
25
|
|
|
3
26
|
* [Add support for `reportFiles` option](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/179) (#179)
|
package/README.md
CHANGED
|
@@ -66,6 +66,9 @@ Allows overriding TypeScript options. Should be specified in the same format as
|
|
|
66
66
|
* **tslint** `string | true`:
|
|
67
67
|
Path to *tslint.json* file or `true`. If `true`, uses `path.resolve(compiler.options.context, './tslint.json')`. Default: `undefined`.
|
|
68
68
|
|
|
69
|
+
* **tslintAutoFix** `boolean `:
|
|
70
|
+
Passes on `--fix` flag while running `tslint` to auto fix linting errors. Default: false.
|
|
71
|
+
|
|
69
72
|
* **watch** `string | string[]`:
|
|
70
73
|
Directories or files to watch by service. Not necessary but improves performance (reduces number of `fs.stat` calls).
|
|
71
74
|
|
|
@@ -3,10 +3,10 @@ interface CancellationTokenData {
|
|
|
3
3
|
cancellationFileName: string;
|
|
4
4
|
}
|
|
5
5
|
export declare class CancellationToken {
|
|
6
|
-
isCancelled
|
|
7
|
-
cancellationFileName
|
|
8
|
-
lastCancellationCheckTime
|
|
9
|
-
constructor(cancellationFileName
|
|
6
|
+
private isCancelled;
|
|
7
|
+
private cancellationFileName;
|
|
8
|
+
private lastCancellationCheckTime;
|
|
9
|
+
constructor(cancellationFileName?: string, isCancelled?: boolean);
|
|
10
10
|
static createFromJSON(json: CancellationTokenData): CancellationToken;
|
|
11
11
|
toJSON(): {
|
|
12
12
|
cancellationFileName: string;
|
package/lib/CancellationToken.js
CHANGED
|
@@ -1,57 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const crypto = require("crypto");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const ts = require("typescript");
|
|
8
|
+
const FsHelper_1 = require("./FsHelper");
|
|
9
|
+
class CancellationToken {
|
|
10
|
+
constructor(cancellationFileName, isCancelled) {
|
|
10
11
|
this.isCancelled = !!isCancelled;
|
|
11
12
|
this.cancellationFileName =
|
|
12
13
|
cancellationFileName || crypto.randomBytes(64).toString('hex');
|
|
13
14
|
this.lastCancellationCheckTime = 0;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
static createFromJSON(json) {
|
|
16
17
|
return new CancellationToken(json.cancellationFileName, json.isCancelled);
|
|
17
|
-
}
|
|
18
|
-
|
|
18
|
+
}
|
|
19
|
+
toJSON() {
|
|
19
20
|
return {
|
|
20
21
|
cancellationFileName: this.cancellationFileName,
|
|
21
22
|
isCancelled: this.isCancelled
|
|
22
23
|
};
|
|
23
|
-
}
|
|
24
|
-
|
|
24
|
+
}
|
|
25
|
+
getCancellationFilePath() {
|
|
25
26
|
return path.join(os.tmpdir(), this.cancellationFileName);
|
|
26
|
-
}
|
|
27
|
-
|
|
27
|
+
}
|
|
28
|
+
isCancellationRequested() {
|
|
28
29
|
if (this.isCancelled) {
|
|
29
30
|
return true;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const time = Date.now();
|
|
33
|
+
const duration = Math.abs(time - this.lastCancellationCheckTime);
|
|
33
34
|
if (duration > 10) {
|
|
34
35
|
// check no more than once every 10ms
|
|
35
36
|
this.lastCancellationCheckTime = time;
|
|
36
|
-
this.isCancelled =
|
|
37
|
+
this.isCancelled = FsHelper_1.FsHelper.existsSync(this.getCancellationFilePath());
|
|
37
38
|
}
|
|
38
39
|
return this.isCancelled;
|
|
39
|
-
}
|
|
40
|
-
|
|
40
|
+
}
|
|
41
|
+
throwIfCancellationRequested() {
|
|
41
42
|
if (this.isCancellationRequested()) {
|
|
42
43
|
throw new ts.OperationCanceledException();
|
|
43
44
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
45
|
+
}
|
|
46
|
+
requestCancellation() {
|
|
46
47
|
fs.writeFileSync(this.getCancellationFilePath(), '');
|
|
47
48
|
this.isCancelled = true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (this.isCancelled &&
|
|
49
|
+
}
|
|
50
|
+
cleanupCancellation() {
|
|
51
|
+
if (this.isCancelled &&
|
|
52
|
+
FsHelper_1.FsHelper.existsSync(this.getCancellationFilePath())) {
|
|
51
53
|
fs.unlinkSync(this.getCancellationFilePath());
|
|
52
54
|
this.isCancelled = false;
|
|
53
55
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}());
|
|
56
|
+
}
|
|
57
|
+
}
|
|
57
58
|
exports.CancellationToken = CancellationToken;
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { RuleFailure } from 'tslint';
|
|
3
|
+
export interface DataShape {
|
|
4
|
+
source?: ts.SourceFile;
|
|
4
5
|
linted: boolean;
|
|
5
|
-
lints:
|
|
6
|
+
lints: RuleFailure[];
|
|
6
7
|
}
|
|
7
8
|
export declare class FilesRegister {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
data: DataShape;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
dataFactory: (_data?: any) => DataShape;
|
|
15
|
-
constructor(dataFactory: (_data?: any) => DataShape);
|
|
9
|
+
private dataFactory;
|
|
10
|
+
private files;
|
|
11
|
+
constructor(dataFactory: (_data?: DataShape) => DataShape);
|
|
16
12
|
keys(): string[];
|
|
17
13
|
add(filePath: string): void;
|
|
18
14
|
remove(filePath: string): void;
|
|
19
15
|
has(filePath: string): boolean;
|
|
20
16
|
get(filePath: string): {
|
|
21
|
-
mtime
|
|
17
|
+
mtime?: number | undefined;
|
|
22
18
|
data: DataShape;
|
|
23
19
|
};
|
|
24
20
|
ensure(filePath: string): void;
|
|
25
21
|
getData(filePath: string): DataShape;
|
|
26
22
|
mutateData(filePath: string, mutator: (data: DataShape) => void): void;
|
|
27
|
-
getMtime(filePath: string): number;
|
|
23
|
+
getMtime(filePath: string): number | undefined;
|
|
28
24
|
setMtime(filePath: string, mtime: number): void;
|
|
29
25
|
}
|
|
30
|
-
export {};
|
package/lib/FilesRegister.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
class FilesRegister {
|
|
4
|
+
constructor(dataFactory) {
|
|
5
|
+
this.dataFactory = dataFactory;
|
|
5
6
|
this.files = {};
|
|
6
7
|
this.dataFactory = dataFactory;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
keys() {
|
|
9
10
|
return Object.keys(this.files);
|
|
10
|
-
}
|
|
11
|
-
|
|
11
|
+
}
|
|
12
|
+
add(filePath) {
|
|
12
13
|
this.files[filePath] = {
|
|
13
14
|
mtime: undefined,
|
|
14
15
|
data: this.dataFactory(undefined)
|
|
15
16
|
};
|
|
16
|
-
}
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
remove(filePath) {
|
|
18
19
|
if (this.has(filePath)) {
|
|
19
20
|
delete this.files[filePath];
|
|
20
21
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
22
|
+
}
|
|
23
|
+
has(filePath) {
|
|
23
24
|
return this.files.hasOwnProperty(filePath);
|
|
24
|
-
}
|
|
25
|
-
|
|
25
|
+
}
|
|
26
|
+
get(filePath) {
|
|
26
27
|
if (!this.has(filePath)) {
|
|
27
28
|
throw new Error('File "' + filePath + '" not found in register.');
|
|
28
29
|
}
|
|
29
30
|
return this.files[filePath];
|
|
30
|
-
}
|
|
31
|
-
|
|
31
|
+
}
|
|
32
|
+
ensure(filePath) {
|
|
32
33
|
if (!this.has(filePath)) {
|
|
33
34
|
this.add(filePath);
|
|
34
35
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
36
|
+
}
|
|
37
|
+
getData(filePath) {
|
|
37
38
|
return this.get(filePath).data;
|
|
38
|
-
}
|
|
39
|
-
|
|
39
|
+
}
|
|
40
|
+
mutateData(filePath, mutator) {
|
|
40
41
|
this.ensure(filePath);
|
|
41
42
|
mutator(this.files[filePath].data);
|
|
42
|
-
}
|
|
43
|
-
|
|
43
|
+
}
|
|
44
|
+
getMtime(filePath) {
|
|
44
45
|
return this.get(filePath).mtime;
|
|
45
|
-
}
|
|
46
|
-
|
|
46
|
+
}
|
|
47
|
+
setMtime(filePath, mtime) {
|
|
47
48
|
this.ensure(filePath);
|
|
48
49
|
if (this.files[filePath].mtime !== mtime) {
|
|
49
50
|
this.files[filePath].mtime = mtime;
|
|
50
51
|
// file has been changed - we have to reset data
|
|
51
52
|
this.files[filePath].data = this.dataFactory(this.files[filePath].data);
|
|
52
53
|
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
56
|
exports.FilesRegister = FilesRegister;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import * as chokidar from 'chokidar';
|
|
2
1
|
export declare class FilesWatcher {
|
|
3
|
-
watchPaths
|
|
4
|
-
watchExtensions
|
|
5
|
-
watchers
|
|
6
|
-
listeners
|
|
7
|
-
[eventName: string]: Function[];
|
|
8
|
-
};
|
|
2
|
+
private watchPaths;
|
|
3
|
+
private watchExtensions;
|
|
4
|
+
private watchers;
|
|
5
|
+
private listeners;
|
|
9
6
|
constructor(watchPaths: string[], watchExtensions: string[]);
|
|
10
7
|
isFileSupported(filePath: string): boolean;
|
|
11
8
|
watch(): void;
|
package/lib/FilesWatcher.js
CHANGED
|
@@ -1,61 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function FilesWatcher(watchPaths, watchExtensions) {
|
|
3
|
+
const chokidar = require("chokidar");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
class FilesWatcher {
|
|
6
|
+
constructor(watchPaths, watchExtensions) {
|
|
8
7
|
this.watchPaths = watchPaths;
|
|
9
8
|
this.watchExtensions = watchExtensions;
|
|
9
|
+
this.watchExtensions = watchExtensions;
|
|
10
10
|
this.watchers = [];
|
|
11
11
|
this.listeners = {};
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
isFileSupported(filePath) {
|
|
14
14
|
return this.watchExtensions.indexOf(path.extname(filePath)) !== -1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var _this = this;
|
|
15
|
+
}
|
|
16
|
+
watch() {
|
|
18
17
|
if (this.isWatching()) {
|
|
19
18
|
throw new Error('Cannot watch again - already watching.');
|
|
20
19
|
}
|
|
21
|
-
this.watchers = this.watchPaths.map(
|
|
20
|
+
this.watchers = this.watchPaths.map((watchPath) => {
|
|
22
21
|
return chokidar
|
|
23
22
|
.watch(watchPath, { persistent: true, alwaysStat: true })
|
|
24
|
-
.on('change',
|
|
25
|
-
if (
|
|
26
|
-
(
|
|
23
|
+
.on('change', (filePath, stats) => {
|
|
24
|
+
if (this.isFileSupported(filePath)) {
|
|
25
|
+
(this.listeners['change'] || []).forEach(changeListener => {
|
|
27
26
|
changeListener(filePath, stats);
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
29
|
})
|
|
31
|
-
.on('unlink',
|
|
32
|
-
if (
|
|
33
|
-
(
|
|
30
|
+
.on('unlink', (filePath) => {
|
|
31
|
+
if (this.isFileSupported(filePath)) {
|
|
32
|
+
(this.listeners['unlink'] || []).forEach(unlinkListener => {
|
|
34
33
|
unlinkListener(filePath);
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
37
|
});
|
|
39
|
-
}
|
|
40
|
-
|
|
38
|
+
}
|
|
39
|
+
isWatchingFile(filePath) {
|
|
41
40
|
return (this.isWatching() &&
|
|
42
41
|
this.isFileSupported(filePath) &&
|
|
43
|
-
this.watchPaths.some(
|
|
44
|
-
}
|
|
45
|
-
|
|
42
|
+
this.watchPaths.some(watchPath => filePath.startsWith(watchPath)));
|
|
43
|
+
}
|
|
44
|
+
isWatching() {
|
|
46
45
|
return this.watchers.length > 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
46
|
+
}
|
|
47
|
+
on(event, listener) {
|
|
49
48
|
if (!this.listeners[event]) {
|
|
50
49
|
this.listeners[event] = [];
|
|
51
50
|
}
|
|
52
51
|
this.listeners[event].push(listener);
|
|
53
|
-
}
|
|
54
|
-
|
|
52
|
+
}
|
|
53
|
+
off(event, listener) {
|
|
55
54
|
if (this.listeners[event]) {
|
|
56
|
-
this.listeners[event] = this.listeners[event].filter(
|
|
55
|
+
this.listeners[event] = this.listeners[event].filter(oldListener => oldListener !== listener);
|
|
57
56
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
61
59
|
exports.FilesWatcher = FilesWatcher;
|
package/lib/FsHelper.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
class FsHelper {
|
|
5
|
+
static existsSync(filePath) {
|
|
6
|
+
try {
|
|
7
|
+
fs.statSync(filePath);
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
if (err.code === 'ENOENT') {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
throw err;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.FsHelper = FsHelper;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import { NormalizedMessage } from './NormalizedMessage';
|
|
3
|
+
import { CancellationToken } from './CancellationToken';
|
|
4
|
+
import * as minimatch from 'minimatch';
|
|
5
|
+
export declare class IncrementalChecker {
|
|
6
|
+
private programConfigFile;
|
|
7
|
+
private compilerOptions;
|
|
8
|
+
private linterConfigFile;
|
|
9
|
+
private linterAutoFix;
|
|
10
|
+
private watchPaths;
|
|
11
|
+
private workNumber;
|
|
12
|
+
private workDivision;
|
|
13
|
+
private checkSyntacticErrors;
|
|
14
|
+
private vue;
|
|
15
|
+
private files;
|
|
16
|
+
private linter?;
|
|
17
|
+
private linterConfig?;
|
|
18
|
+
private linterExclusions;
|
|
19
|
+
private program?;
|
|
20
|
+
private programConfig?;
|
|
21
|
+
private watcher?;
|
|
22
|
+
constructor(programConfigFile: string, compilerOptions: object, linterConfigFile: string | false, linterAutoFix: boolean, watchPaths: string[], workNumber?: number, workDivision?: number, checkSyntacticErrors?: boolean, vue?: boolean);
|
|
23
|
+
static loadProgramConfig(configFile: string, compilerOptions: object): ts.ParsedCommandLine;
|
|
24
|
+
private static loadLinterConfig;
|
|
25
|
+
private static createProgram;
|
|
26
|
+
private createLinter;
|
|
27
|
+
hasLinter(): boolean;
|
|
28
|
+
static isFileExcluded(filePath: string, linterExclusions: minimatch.IMinimatch[]): boolean;
|
|
29
|
+
nextIteration(): void;
|
|
30
|
+
private loadVueProgram;
|
|
31
|
+
private loadDefaultProgram;
|
|
32
|
+
getDiagnostics(cancellationToken: CancellationToken): NormalizedMessage[];
|
|
33
|
+
getLints(cancellationToken: CancellationToken): NormalizedMessage[];
|
|
34
|
+
}
|