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/lib/LinkedList.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var HeadNode = /** @class */ (function () {
|
|
4
|
+
function HeadNode() {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
5
6
|
this.next = new TailNode(this);
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
return HeadNode;
|
|
9
|
+
}());
|
|
8
10
|
exports.HeadNode = HeadNode;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
constructor(head) {
|
|
11
|
+
var TailNode = /** @class */ (function () {
|
|
12
|
+
function TailNode(head) {
|
|
12
13
|
this.previous = head;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
return TailNode;
|
|
16
|
+
}());
|
|
15
17
|
exports.TailNode = TailNode;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
constructor(item) {
|
|
18
|
+
var LinkedListNode = /** @class */ (function () {
|
|
19
|
+
function LinkedListNode(item) {
|
|
19
20
|
this.next = null;
|
|
20
21
|
this.previous = null;
|
|
21
22
|
this.item = item;
|
|
22
23
|
}
|
|
23
|
-
detachSelf() {
|
|
24
|
+
LinkedListNode.prototype.detachSelf = function () {
|
|
24
25
|
if (!this.next && !this.previous) {
|
|
25
26
|
throw new Error('node is not attached');
|
|
26
27
|
}
|
|
@@ -32,8 +33,8 @@ class LinkedListNode {
|
|
|
32
33
|
}
|
|
33
34
|
this.next = null;
|
|
34
35
|
this.previous = null;
|
|
35
|
-
}
|
|
36
|
-
attachAfter(node) {
|
|
36
|
+
};
|
|
37
|
+
LinkedListNode.prototype.attachAfter = function (node) {
|
|
37
38
|
if (this.next || this.previous) {
|
|
38
39
|
throw new Error('Node is inserted elsewhere');
|
|
39
40
|
}
|
|
@@ -43,54 +44,55 @@ class LinkedListNode {
|
|
|
43
44
|
node.next.previous = this;
|
|
44
45
|
}
|
|
45
46
|
node.next = this;
|
|
46
|
-
}
|
|
47
|
-
attachBefore(node) {
|
|
47
|
+
};
|
|
48
|
+
LinkedListNode.prototype.attachBefore = function (node) {
|
|
48
49
|
if (!node.previous) {
|
|
49
50
|
throw new Error('no previous node found.');
|
|
50
51
|
}
|
|
51
52
|
this.attachAfter(node.previous);
|
|
52
|
-
}
|
|
53
|
-
|
|
53
|
+
};
|
|
54
|
+
return LinkedListNode;
|
|
55
|
+
}());
|
|
54
56
|
exports.LinkedListNode = LinkedListNode;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
constructor() {
|
|
57
|
+
var LinkedList = /** @class */ (function () {
|
|
58
|
+
function LinkedList() {
|
|
58
59
|
this.head = new HeadNode();
|
|
59
60
|
this.tail = this.head.next;
|
|
60
61
|
}
|
|
61
|
-
add(item) {
|
|
62
|
-
|
|
62
|
+
LinkedList.prototype.add = function (item) {
|
|
63
|
+
var newNode = new LinkedListNode(item);
|
|
63
64
|
newNode.attachAfter(this.tail.previous);
|
|
64
65
|
return newNode;
|
|
65
|
-
}
|
|
66
|
-
getItems() {
|
|
67
|
-
|
|
68
|
-
this.forEach(item
|
|
66
|
+
};
|
|
67
|
+
LinkedList.prototype.getItems = function () {
|
|
68
|
+
var result = [];
|
|
69
|
+
this.forEach(function (item) {
|
|
69
70
|
result.push(item);
|
|
70
71
|
});
|
|
71
72
|
return result;
|
|
72
|
-
}
|
|
73
|
-
forEach(callback) {
|
|
74
|
-
|
|
73
|
+
};
|
|
74
|
+
LinkedList.prototype.forEach = function (callback) {
|
|
75
|
+
var current = this.head.next;
|
|
75
76
|
while (current !== this.tail) {
|
|
76
77
|
// if item is not tail it is always a node
|
|
77
|
-
|
|
78
|
+
var item = current;
|
|
78
79
|
callback(item.item, item);
|
|
79
80
|
if (!item.next) {
|
|
80
81
|
throw new Error('badly attached item found.');
|
|
81
82
|
}
|
|
82
83
|
current = item.next;
|
|
83
84
|
}
|
|
84
|
-
}
|
|
85
|
-
hasItems() {
|
|
85
|
+
};
|
|
86
|
+
LinkedList.prototype.hasItems = function () {
|
|
86
87
|
return this.head.next !== this.tail;
|
|
87
|
-
}
|
|
88
|
-
getLastItem() {
|
|
88
|
+
};
|
|
89
|
+
LinkedList.prototype.getLastItem = function () {
|
|
89
90
|
if (!this.hasItems()) {
|
|
90
91
|
throw new Error('no items in list.');
|
|
91
92
|
}
|
|
92
93
|
return this.head.next;
|
|
93
|
-
}
|
|
94
|
-
|
|
94
|
+
};
|
|
95
|
+
return LinkedList;
|
|
96
|
+
}());
|
|
95
97
|
exports.LinkedList = LinkedList;
|
|
96
98
|
//# sourceMappingURL=LinkedList.js.map
|
package/lib/LinkedList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkedList.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"LinkedList.js","sourceRoot":"./","sources":["LinkedList.ts"],"names":[],"mappings":";;AAAA;IAGE;QACE,mEAAmE;QACnE,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACH,eAAC;AAAD,CAAC,AAPD,IAOC;AAPY,4BAAQ;AASrB;IAGE,kBAAY,IAAiB;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IACH,eAAC;AAAD,CAAC,AAND,IAMC;AANY,4BAAQ;AAOrB;IAKE,wBAAY,IAAO;QAJZ,SAAI,GAA2C,IAAI,CAAC;QACpD,aAAQ,GAA2C,IAAI,CAAC;QAI7D,IAAI,CAAC,IAAI,GAAG,IAAI,CA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/lib/Message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"Message.js","sourceRoot":"./","sources":["Message.ts"],"names":[],"mappings":""}
|
package/lib/RpcTypes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcTypes.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"RpcTypes.js","sourceRoot":"./","sources":["RpcTypes.ts"],"names":[],"mappings":";;AAGa,QAAA,GAAG,GAAG,KAAK,CAAC"}
|
package/lib/VueProgram.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare class VueProgram {
|
|
|
16
16
|
*/
|
|
17
17
|
static resolveNonTsModuleName(moduleName: string, containingFile: string, basedir: string, options: ts.CompilerOptions): string;
|
|
18
18
|
static isVue(filePath: string): boolean;
|
|
19
|
-
static createProgram(typescript: typeof ts, programConfig: ts.ParsedCommandLine, basedir: string, files: FilesRegister, oldProgram: ts.Program, userResolveModuleName: ResolveModuleName | undefined, userResolveTypeReferenceDirective: ResolveTypeReferenceDirective | undefined, vueOptions: VueOptions): ts.Program;
|
|
19
|
+
static createProgram(typescript: typeof ts, programConfig: ts.ParsedCommandLine, basedir: string, files: FilesRegister, oldProgram: ts.Program | undefined, userResolveModuleName: ResolveModuleName | undefined, userResolveTypeReferenceDirective: ResolveTypeReferenceDirective | undefined, vueOptions: VueOptions): ts.Program;
|
|
20
20
|
private static getScriptKindByLang;
|
|
21
21
|
static resolveScriptBlock(typescript: typeof ts, content: string, compiler: string): ResolvedScript;
|
|
22
22
|
}
|
package/lib/VueProgram.js
CHANGED
|
@@ -1,39 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
14
|
+
if (mod && mod.__esModule) return mod;
|
|
15
|
+
var result = {};
|
|
16
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
17
|
+
result["default"] = mod;
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
2
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
21
|
+
var fs = __importStar(require("fs"));
|
|
22
|
+
var path = __importStar(require("path"));
|
|
23
|
+
var resolution_1 = require("./resolution");
|
|
24
|
+
var VueProgram = /** @class */ (function () {
|
|
25
|
+
function VueProgram() {
|
|
26
|
+
}
|
|
27
|
+
VueProgram.loadProgramConfig = function (typescript, configFile, compilerOptions) {
|
|
28
|
+
var extraExtensions = ['vue'];
|
|
29
|
+
var parseConfigHost = {
|
|
10
30
|
fileExists: typescript.sys.fileExists,
|
|
11
31
|
readFile: typescript.sys.readFile,
|
|
12
32
|
useCaseSensitiveFileNames: typescript.sys.useCaseSensitiveFileNames,
|
|
13
|
-
readDirectory: (rootDir, extensions, excludes, includes, depth)
|
|
33
|
+
readDirectory: function (rootDir, extensions, excludes, includes, depth) {
|
|
14
34
|
return typescript.sys.readDirectory(rootDir, extensions.concat(extraExtensions), excludes, includes, depth);
|
|
15
35
|
}
|
|
16
36
|
};
|
|
17
|
-
|
|
37
|
+
var tsconfig = typescript.readConfigFile(configFile, typescript.sys.readFile).config;
|
|
18
38
|
tsconfig.compilerOptions = tsconfig.compilerOptions || {};
|
|
19
|
-
tsconfig.compilerOptions =
|
|
20
|
-
|
|
39
|
+
tsconfig.compilerOptions = __assign({}, tsconfig.compilerOptions, compilerOptions);
|
|
40
|
+
var parsed = typescript.parseJsonConfigFileContent(tsconfig, parseConfigHost, path.dirname(configFile));
|
|
21
41
|
parsed.options.allowNonTsExtensions = true;
|
|
22
42
|
return parsed;
|
|
23
|
-
}
|
|
43
|
+
};
|
|
24
44
|
/**
|
|
25
45
|
* Search for default wildcard or wildcard from options, we only search for that in tsconfig CompilerOptions.paths.
|
|
26
46
|
* The path is resolved with thie given substitution and includes the CompilerOptions.baseUrl (if given).
|
|
27
47
|
* If no paths given in tsconfig, then the default substitution is '[tsconfig directory]/src'.
|
|
28
48
|
* (This is a fast, simplified inspiration of what's described here: https://github.com/Microsoft/TypeScript/issues/5039)
|
|
29
49
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
50
|
+
VueProgram.resolveNonTsModuleName = function (moduleName, containingFile, basedir, options) {
|
|
51
|
+
var baseUrl = options.baseUrl ? options.baseUrl : basedir;
|
|
52
|
+
var discardedSymbols = ['.', '..', '/'];
|
|
53
|
+
var wildcards = [];
|
|
34
54
|
if (options.paths) {
|
|
35
|
-
Object.keys(options.paths).forEach(key
|
|
36
|
-
|
|
55
|
+
Object.keys(options.paths).forEach(function (key) {
|
|
56
|
+
var pathSymbol = key[0];
|
|
37
57
|
if (discardedSymbols.indexOf(pathSymbol) < 0 &&
|
|
38
58
|
wildcards.indexOf(pathSymbol) < 0) {
|
|
39
59
|
wildcards.push(pathSymbol);
|
|
@@ -43,19 +63,20 @@ class VueProgram {
|
|
|
43
63
|
else {
|
|
44
64
|
wildcards.push('@');
|
|
45
65
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
wildcards.forEach(wildcard
|
|
49
|
-
if (moduleName.substr(0, 2) ===
|
|
66
|
+
var isRelative = !path.isAbsolute(moduleName);
|
|
67
|
+
var correctWildcard;
|
|
68
|
+
wildcards.forEach(function (wildcard) {
|
|
69
|
+
if (moduleName.substr(0, 2) === wildcard + "/") {
|
|
50
70
|
correctWildcard = wildcard;
|
|
51
71
|
}
|
|
52
72
|
});
|
|
53
73
|
if (correctWildcard) {
|
|
54
|
-
|
|
55
|
-
? options.paths[
|
|
74
|
+
var pattern = options.paths
|
|
75
|
+
? options.paths[correctWildcard + "/*"]
|
|
56
76
|
: undefined;
|
|
57
|
-
|
|
58
|
-
?
|
|
77
|
+
var substitution = pattern
|
|
78
|
+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
79
|
+
options.paths[correctWildcard + "/*"][0].replace('*', '')
|
|
59
80
|
: 'src';
|
|
60
81
|
moduleName = path.resolve(baseUrl, substitution, moduleName.substr(2));
|
|
61
82
|
}
|
|
@@ -63,28 +84,28 @@ class VueProgram {
|
|
|
63
84
|
moduleName = path.resolve(path.dirname(containingFile), moduleName);
|
|
64
85
|
}
|
|
65
86
|
return moduleName;
|
|
66
|
-
}
|
|
67
|
-
|
|
87
|
+
};
|
|
88
|
+
VueProgram.isVue = function (filePath) {
|
|
68
89
|
return path.extname(filePath) === '.vue';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
host.resolveModuleNames = (moduleNames, containingFile)
|
|
75
|
-
return moduleNames.map(moduleName
|
|
90
|
+
};
|
|
91
|
+
VueProgram.createProgram = function (typescript, programConfig, basedir, files, oldProgram, userResolveModuleName, userResolveTypeReferenceDirective, vueOptions) {
|
|
92
|
+
var host = typescript.createCompilerHost(programConfig.options);
|
|
93
|
+
var realGetSourceFile = host.getSourceFile;
|
|
94
|
+
var _a = resolution_1.makeResolutionFunctions(userResolveModuleName, userResolveTypeReferenceDirective), resolveModuleName = _a.resolveModuleName, resolveTypeReferenceDirective = _a.resolveTypeReferenceDirective;
|
|
95
|
+
host.resolveModuleNames = function (moduleNames, containingFile) {
|
|
96
|
+
return moduleNames.map(function (moduleName) {
|
|
76
97
|
return resolveModuleName(typescript, moduleName, containingFile, programConfig.options, host).resolvedModule;
|
|
77
98
|
});
|
|
78
99
|
};
|
|
79
|
-
host.resolveTypeReferenceDirectives = (typeDirectiveNames, containingFile)
|
|
80
|
-
return typeDirectiveNames.map(typeDirectiveName
|
|
100
|
+
host.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) {
|
|
101
|
+
return typeDirectiveNames.map(function (typeDirectiveName) {
|
|
81
102
|
return resolveTypeReferenceDirective(typescript, typeDirectiveName, containingFile, programConfig.options, host).resolvedTypeReferenceDirective;
|
|
82
103
|
});
|
|
83
104
|
};
|
|
84
105
|
// We need a host that can parse Vue SFCs (single file components).
|
|
85
|
-
host.getSourceFile = (filePath, languageVersion, onError)
|
|
106
|
+
host.getSourceFile = function (filePath, languageVersion, onError) {
|
|
86
107
|
try {
|
|
87
|
-
|
|
108
|
+
var stats = fs.statSync(filePath);
|
|
88
109
|
files.setMtime(filePath, stats.mtime.valueOf());
|
|
89
110
|
}
|
|
90
111
|
catch (e) {
|
|
@@ -93,25 +114,26 @@ class VueProgram {
|
|
|
93
114
|
}
|
|
94
115
|
// get source file only if there is no source in files register
|
|
95
116
|
if (!files.has(filePath) || !files.getData(filePath).source) {
|
|
96
|
-
files.mutateData(filePath, data
|
|
117
|
+
files.mutateData(filePath, function (data) {
|
|
97
118
|
data.source = realGetSourceFile(filePath, languageVersion, onError);
|
|
98
119
|
});
|
|
99
120
|
}
|
|
100
|
-
|
|
121
|
+
var source = files.getData(filePath).source;
|
|
101
122
|
// get typescript contents from Vue file
|
|
102
123
|
if (source && VueProgram.isVue(filePath)) {
|
|
103
|
-
|
|
124
|
+
var resolved = VueProgram.resolveScriptBlock(typescript, source.text, vueOptions.compiler);
|
|
104
125
|
source = typescript.createSourceFile(filePath, resolved.content, languageVersion, true, resolved.scriptKind);
|
|
105
126
|
}
|
|
106
127
|
return source;
|
|
107
128
|
};
|
|
108
129
|
// We need a host with special module resolution for Vue files.
|
|
109
|
-
host.resolveModuleNames = (moduleNames, containingFile)
|
|
110
|
-
|
|
111
|
-
for (
|
|
130
|
+
host.resolveModuleNames = function (moduleNames, containingFile) {
|
|
131
|
+
var resolvedModules = [];
|
|
132
|
+
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
133
|
+
var moduleName = moduleNames_1[_i];
|
|
112
134
|
// Try to use standard resolution.
|
|
113
|
-
|
|
114
|
-
fileExists(fileName) {
|
|
135
|
+
var resolvedModule = typescript.resolveModuleName(moduleName, containingFile, programConfig.options, {
|
|
136
|
+
fileExists: function (fileName) {
|
|
115
137
|
if (fileName.endsWith('.vue.ts')) {
|
|
116
138
|
return (host.fileExists(fileName.slice(0, -3)) ||
|
|
117
139
|
host.fileExists(fileName));
|
|
@@ -120,7 +142,7 @@ class VueProgram {
|
|
|
120
142
|
return host.fileExists(fileName);
|
|
121
143
|
}
|
|
122
144
|
},
|
|
123
|
-
readFile(fileName) {
|
|
145
|
+
readFile: function (fileName) {
|
|
124
146
|
// This implementation is not necessary. Just for consistent behavior.
|
|
125
147
|
if (fileName.endsWith('.vue.ts') && !host.fileExists(fileName)) {
|
|
126
148
|
return host.readFile(fileName.slice(0, -3));
|
|
@@ -129,7 +151,7 @@ class VueProgram {
|
|
|
129
151
|
return host.readFile(fileName);
|
|
130
152
|
}
|
|
131
153
|
}
|
|
132
|
-
});
|
|
154
|
+
}).resolvedModule;
|
|
133
155
|
if (resolvedModule) {
|
|
134
156
|
if (resolvedModule.resolvedFileName.endsWith('.vue.ts') &&
|
|
135
157
|
!host.fileExists(resolvedModule.resolvedFileName)) {
|
|
@@ -139,7 +161,7 @@ class VueProgram {
|
|
|
139
161
|
}
|
|
140
162
|
else {
|
|
141
163
|
// For non-ts extensions.
|
|
142
|
-
|
|
164
|
+
var absolutePath = VueProgram.resolveNonTsModuleName(moduleName, containingFile, basedir, programConfig.options);
|
|
143
165
|
if (VueProgram.isVue(moduleName)) {
|
|
144
166
|
resolvedModules.push({
|
|
145
167
|
resolvedFileName: absolutePath,
|
|
@@ -161,8 +183,8 @@ class VueProgram {
|
|
|
161
183
|
};
|
|
162
184
|
return typescript.createProgram(programConfig.fileNames, programConfig.options, host, oldProgram // re-use old program
|
|
163
185
|
);
|
|
164
|
-
}
|
|
165
|
-
|
|
186
|
+
};
|
|
187
|
+
VueProgram.getScriptKindByLang = function (typescript, lang) {
|
|
166
188
|
if (lang === 'ts') {
|
|
167
189
|
return typescript.ScriptKind.TS;
|
|
168
190
|
}
|
|
@@ -176,57 +198,56 @@ class VueProgram {
|
|
|
176
198
|
// when lang is "js" or no lang specified
|
|
177
199
|
return typescript.ScriptKind.JS;
|
|
178
200
|
}
|
|
179
|
-
}
|
|
180
|
-
|
|
201
|
+
};
|
|
202
|
+
VueProgram.resolveScriptBlock = function (typescript, content, compiler) {
|
|
181
203
|
// We need to import template compiler for vue lazily because it cannot be included it
|
|
182
204
|
// as direct dependency because it is an optional dependency of fork-ts-checker-webpack-plugin.
|
|
183
205
|
// Since its version must not mismatch with user-installed Vue.js,
|
|
184
206
|
// we should let the users install template compiler for vue by themselves.
|
|
185
|
-
|
|
207
|
+
var parser;
|
|
186
208
|
try {
|
|
187
|
-
// tslint:disable-next-line
|
|
188
209
|
parser = require(compiler);
|
|
189
210
|
}
|
|
190
211
|
catch (err) {
|
|
191
212
|
throw new Error('When you use `vue` option, make sure to install `' + compiler + '`.');
|
|
192
213
|
}
|
|
193
|
-
|
|
214
|
+
var script = parser.parseComponent(content, {
|
|
194
215
|
pad: 'space'
|
|
195
|
-
});
|
|
216
|
+
}).script;
|
|
196
217
|
// No <script> block
|
|
197
218
|
if (!script) {
|
|
198
219
|
return {
|
|
199
220
|
scriptKind: typescript.ScriptKind.JS,
|
|
200
|
-
content: '
|
|
221
|
+
content: 'export default {};\n'
|
|
201
222
|
};
|
|
202
223
|
}
|
|
203
|
-
|
|
224
|
+
var scriptKind = VueProgram.getScriptKindByLang(typescript, script.lang);
|
|
204
225
|
// There is src attribute
|
|
205
226
|
if (script.attrs.src) {
|
|
206
227
|
// import path cannot be end with '.ts[x]'
|
|
207
|
-
|
|
228
|
+
var src = script.attrs.src.replace(/\.tsx?$/i, '');
|
|
208
229
|
return {
|
|
209
|
-
scriptKind,
|
|
230
|
+
scriptKind: scriptKind,
|
|
210
231
|
// For now, ignore the error when the src file is not found
|
|
211
232
|
// since it will produce incorrect code location.
|
|
212
233
|
// It's not a large problem since it's handled on webpack side.
|
|
213
|
-
content: '
|
|
234
|
+
content: '// @ts-ignore\n' +
|
|
235
|
+
("export { default } from '" + src + "';\n") +
|
|
214
236
|
'// @ts-ignore\n' +
|
|
215
|
-
|
|
216
|
-
'// @ts-ignore\n' +
|
|
217
|
-
`export * from '${src}';\n`
|
|
237
|
+
("export * from '" + src + "';\n")
|
|
218
238
|
};
|
|
219
239
|
}
|
|
220
240
|
// Pad blank lines to retain diagnostics location
|
|
221
241
|
// We need to prepend `//` for each line to avoid
|
|
222
242
|
// false positive of no-consecutive-blank-lines TSLint rule
|
|
223
|
-
|
|
224
|
-
|
|
243
|
+
var offset = content.slice(0, script.start).split(/\r?\n/g).length;
|
|
244
|
+
var paddedContent = Array(offset).join('//\n') + script.content.slice(script.start);
|
|
225
245
|
return {
|
|
226
|
-
scriptKind,
|
|
246
|
+
scriptKind: scriptKind,
|
|
227
247
|
content: paddedContent
|
|
228
248
|
};
|
|
229
|
-
}
|
|
230
|
-
|
|
249
|
+
};
|
|
250
|
+
return VueProgram;
|
|
251
|
+
}());
|
|
231
252
|
exports.VueProgram = VueProgram;
|
|
232
253
|
//# sourceMappingURL=VueProgram.js.map
|
package/lib/VueProgram.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VueProgram.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"VueProgram.js","sourceRoot":"./","sources":["VueProgram.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAG7B,2CAIsB;AAStB;IAAA;IA2VA,CAAC;IA1Ve,4BAAiB,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;oBACrC,iBAAiB;qBACjB,oBAAkB,GAAG,SAAM,CAAA;aAC9B,CAAC;SACH;QAED,iDAAiD;QACjD,iDAAiD;QACjD,2DAA2D;QAC3D,IAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;QACrE,IAAM,aAAa,GACjB,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAElE,OAAO;YACL,UAAU,YAAA;YACV,OAAO,EAAE,aAAa;SACvB,CAAC;IACJ,CAAC;IACH,iBAAC;AAAD,CAAC,AA3VD,IA2VC;AA3VY,gCAAU"}
|
package/lib/createEslinter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { LintReport } from './types/eslint';
|
|
2
2
|
export declare function createEslinter(eslintOptions: object): {
|
|
3
|
-
getReport: (filepath: string) =>
|
|
3
|
+
getReport: (filepath: string) => LintReport | undefined;
|
|
4
4
|
};
|
package/lib/createEslinter.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
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
|
-
|
|
10
|
+
var path = __importStar(require("path"));
|
|
11
|
+
var FsHelper_1 = require("./FsHelper");
|
|
5
12
|
function createEslinter(eslintOptions) {
|
|
6
|
-
//
|
|
7
|
-
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
14
|
+
var CLIEngine = require('eslint').CLIEngine;
|
|
8
15
|
// See https://eslint.org/docs/1.0.0/developer-guide/nodejs-api#cliengine
|
|
9
|
-
|
|
16
|
+
var eslinter = new CLIEngine(eslintOptions);
|
|
10
17
|
function getReport(filepath) {
|
|
11
18
|
try {
|
|
12
19
|
if (eslinter.isPathIgnored(filepath) ||
|
|
@@ -22,7 +29,7 @@ function createEslinter(eslintOptions) {
|
|
|
22
29
|
}
|
|
23
30
|
return undefined;
|
|
24
31
|
}
|
|
25
|
-
return { getReport };
|
|
32
|
+
return { getReport: getReport };
|
|
26
33
|
}
|
|
27
34
|
exports.createEslinter = createEslinter;
|
|
28
35
|
//# sourceMappingURL=createEslinter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEslinter.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"createEslinter.js","sourceRoot":"./","sources":["createEslinter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAA6B;AAG7B,uCAA6D;AAE7D,SAAgB,cAAc,CAAC,aAAqB;IAClD,8DAA8D;IACtD,IAAA,uCAAS,CAAuB;IAExC,yEAAyE;IACzE,IAAM,QAAQ,GAAG,IAAI,SAAS,CAAC,aAAa,CAAC,CAAC;IAE9C,SAAS,SAAS,CAAC,QAAgB;QACjC,IAAI;YACF,IACE,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE;oBACvD,WAAW,EAAE,QAAQ;iBACtB,CAAC,KAAK,CAAC,EACR;gBACA,OAAO,SAAS,CAAC;aAClB;YAED,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;SAC5C;QAAC,OAAO,CAAC,EAAE;YACV,0CAA+B,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;SAC9C;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,EAAE,SAAS,WAAA,EAAE,CAAC;AACvB,CAAC;AA1BD,wCA0BC"}
|
|
@@ -1,15 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
14
|
+
if (mod && mod.__esModule) return mod;
|
|
15
|
+
var result = {};
|
|
16
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
17
|
+
result["default"] = mod;
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
2
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
24
|
+
var os = __importStar(require("os"));
|
|
25
|
+
var fs = __importStar(require("fs"));
|
|
26
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
27
|
+
var FsHelper_1 = require("../FsHelper");
|
|
28
|
+
var issue_1 = require("../issue");
|
|
29
|
+
var InternalFormatter_1 = require("./InternalFormatter");
|
|
30
|
+
var babel_code_frame_1 = __importDefault(require("babel-code-frame"));
|
|
10
31
|
function createCodeframeFormatter(options) {
|
|
11
32
|
return function codeframeFormatter(issue) {
|
|
12
|
-
|
|
33
|
+
var color = {
|
|
13
34
|
message: issue.severity === issue_1.IssueSeverity.WARNING
|
|
14
35
|
? chalk_1.default.bold.yellow
|
|
15
36
|
: chalk_1.default.bold.red,
|
|
@@ -18,19 +39,22 @@ function createCodeframeFormatter(options) {
|
|
|
18
39
|
if (issue.origin === issue_1.IssueOrigin.INTERNAL) {
|
|
19
40
|
return InternalFormatter_1.createInternalFormatter()(issue);
|
|
20
41
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
42
|
+
var file = issue.file;
|
|
43
|
+
var source = file && FsHelper_1.fileExistsSync(file) && fs.readFileSync(file, 'utf-8');
|
|
44
|
+
var frame = '';
|
|
24
45
|
if (source) {
|
|
25
|
-
frame =
|
|
26
|
-
|
|
46
|
+
frame = babel_code_frame_1.default(source,
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
48
|
+
issue.line, // Assertion: `codeFrame` allows passing undefined, typings are incorrect
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50
|
+
issue.character, __assign({ highlightCode: true }, (options || {})))
|
|
27
51
|
.split('\n')
|
|
28
|
-
.map((line)
|
|
52
|
+
.map(function (line) { return ' ' + line; })
|
|
29
53
|
.join(os.EOL);
|
|
30
54
|
}
|
|
31
|
-
|
|
32
|
-
color.message(
|
|
33
|
-
color.position(
|
|
55
|
+
var lines = [
|
|
56
|
+
color.message(issue.severity.toUpperCase() + " in " + issue.file + "(" + issue.line + "," + issue.character + "):"),
|
|
57
|
+
color.position(issue.line + ":" + issue.character + " " + issue.message)
|
|
34
58
|
];
|
|
35
59
|
if (frame) {
|
|
36
60
|
lines.push(frame);
|