@tsslint/config 0.0.3 → 0.0.4
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/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/build.d.ts +3 -0
- package/lib/build.js +18 -0
- package/lib/types.d.ts +3 -3
- package/lib/watch copy.d.ts +15 -0
- package/lib/watch copy.js +53 -0
- package/lib/watch.d.ts +1 -1
- package/lib/watch.js +9 -4
- package/package.json +2 -2
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.defineConfig = void 0;
|
|
18
|
-
__exportStar(require("./lib/
|
|
18
|
+
__exportStar(require("./lib/build"), exports);
|
|
19
19
|
__exportStar(require("./lib/watch"), exports);
|
|
20
20
|
__exportStar(require("./lib/tslint"), exports);
|
|
21
21
|
__exportStar(require("./lib/types"), exports);
|
package/lib/build.d.ts
ADDED
package/lib/build.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildConfigFile = void 0;
|
|
4
|
+
const watch_1 = require("./watch");
|
|
5
|
+
async function buildConfigFile(configFilePath) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
(0, watch_1.watchConfigFile)(configFilePath, (config, result) => {
|
|
8
|
+
if (config) {
|
|
9
|
+
resolve(config);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
reject(result);
|
|
13
|
+
}
|
|
14
|
+
}, false);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.buildConfigFile = buildConfigFile;
|
|
18
|
+
//# sourceMappingURL=build.js.map
|
package/lib/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface ProjectContext {
|
|
|
4
4
|
typescript: typeof import('typescript/lib/tsserverlibrary.js');
|
|
5
5
|
languageServiceHost: LanguageServiceHost;
|
|
6
6
|
languageService: LanguageService;
|
|
7
|
-
tsconfig
|
|
7
|
+
tsconfig: string;
|
|
8
8
|
}
|
|
9
9
|
export interface Config {
|
|
10
10
|
debug?: boolean;
|
|
@@ -16,9 +16,9 @@ export interface Plugin {
|
|
|
16
16
|
}
|
|
17
17
|
export interface PluginInstance {
|
|
18
18
|
lint?(sourceFile: SourceFile, rules: Rules): Diagnostic[];
|
|
19
|
-
getFixes?(fileName: string, start: number, end: number,
|
|
19
|
+
getFixes?(fileName: string, start: number, end: number, diagnostics?: Diagnostic[]): CodeFixAction[];
|
|
20
20
|
resolveRules?(rules: Rules): Rules;
|
|
21
|
-
|
|
21
|
+
resolveDiagnostics?(results: Diagnostic[]): Diagnostic[];
|
|
22
22
|
}
|
|
23
23
|
export interface Rules {
|
|
24
24
|
[name: string]: Rule;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import esbuild = require('esbuild');
|
|
2
|
+
import type { Config } from './types';
|
|
3
|
+
export declare function watchConfigFile(tsConfigPath: string, onBuild: (config: Config | undefined, result: esbuild.BuildResult) => void): Promise<esbuild.BuildContext<{
|
|
4
|
+
entryPoints: string[];
|
|
5
|
+
bundle: true;
|
|
6
|
+
sourcemap: true;
|
|
7
|
+
outfile: string;
|
|
8
|
+
format: "cjs";
|
|
9
|
+
platform: "node";
|
|
10
|
+
plugins: {
|
|
11
|
+
name: string;
|
|
12
|
+
setup(build: esbuild.PluginBuild): void;
|
|
13
|
+
}[];
|
|
14
|
+
}>>;
|
|
15
|
+
//# sourceMappingURL=watch%20copy.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.watchConfigFile = void 0;
|
|
4
|
+
const esbuild = require("esbuild");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
async function watchConfigFile(tsConfigPath, onBuild) {
|
|
7
|
+
const outDir = path.resolve(__dirname, '..', '..', '.tsslint');
|
|
8
|
+
const outFileName = btoa(path.relative(outDir, tsConfigPath)) + '.cjs';
|
|
9
|
+
const outFile = path.join(outDir, outFileName);
|
|
10
|
+
const ctx = await esbuild.context({
|
|
11
|
+
entryPoints: [tsConfigPath],
|
|
12
|
+
bundle: true,
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
outfile: outFile,
|
|
15
|
+
format: 'cjs',
|
|
16
|
+
platform: 'node',
|
|
17
|
+
plugins: [{
|
|
18
|
+
name: 'tsslint',
|
|
19
|
+
setup(build) {
|
|
20
|
+
build.onResolve({ filter: /.*/ }, args => {
|
|
21
|
+
if (!args.path.endsWith('.ts')) {
|
|
22
|
+
try {
|
|
23
|
+
const jsPath = require.resolve(args.path, { paths: [args.resolveDir] });
|
|
24
|
+
return {
|
|
25
|
+
path: jsPath,
|
|
26
|
+
external: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
catch { }
|
|
30
|
+
}
|
|
31
|
+
return {};
|
|
32
|
+
});
|
|
33
|
+
build.onEnd(result => {
|
|
34
|
+
let config;
|
|
35
|
+
if (!result.errors.length) {
|
|
36
|
+
try {
|
|
37
|
+
config = require(outFile).default;
|
|
38
|
+
delete require.cache[outFile];
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
result.errors.push({ text: String(e) });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
onBuild(config, result);
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
}],
|
|
48
|
+
});
|
|
49
|
+
await ctx.watch();
|
|
50
|
+
return ctx;
|
|
51
|
+
}
|
|
52
|
+
exports.watchConfigFile = watchConfigFile;
|
|
53
|
+
//# sourceMappingURL=watch%20copy.js.map
|
package/lib/watch.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import esbuild = require('esbuild');
|
|
2
2
|
import type { Config } from './types';
|
|
3
|
-
export declare function watchConfigFile(
|
|
3
|
+
export declare function watchConfigFile(configFilePath: string, onBuild: (config: Config | undefined, result: esbuild.BuildResult) => void, watch?: boolean): Promise<esbuild.BuildContext<{
|
|
4
4
|
entryPoints: string[];
|
|
5
5
|
bundle: true;
|
|
6
6
|
sourcemap: true;
|
package/lib/watch.js
CHANGED
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.watchConfigFile = void 0;
|
|
4
4
|
const esbuild = require("esbuild");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
async function watchConfigFile(
|
|
6
|
+
async function watchConfigFile(configFilePath, onBuild, watch = true) {
|
|
7
7
|
const outDir = path.resolve(__dirname, '..', '..', '.tsslint');
|
|
8
|
-
const outFileName = btoa(path.relative(outDir,
|
|
8
|
+
const outFileName = btoa(path.relative(outDir, configFilePath)) + '.cjs';
|
|
9
9
|
const outFile = path.join(outDir, outFileName);
|
|
10
10
|
const ctx = await esbuild.context({
|
|
11
|
-
entryPoints: [
|
|
11
|
+
entryPoints: [configFilePath],
|
|
12
12
|
bundle: true,
|
|
13
13
|
sourcemap: true,
|
|
14
14
|
outfile: outFile,
|
|
@@ -46,7 +46,12 @@ async function watchConfigFile(tsConfigPath, onBuild) {
|
|
|
46
46
|
},
|
|
47
47
|
}],
|
|
48
48
|
});
|
|
49
|
-
|
|
49
|
+
if (watch) {
|
|
50
|
+
await ctx.watch();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
await ctx.rebuild();
|
|
54
|
+
}
|
|
50
55
|
return ctx;
|
|
51
56
|
}
|
|
52
57
|
exports.watchConfigFile = watchConfigFile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"optional": true
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "7012413ccd5eb949f8bcc599daddc16b4c316b57"
|
|
26
26
|
}
|