@tsslint/config 0.0.3 → 0.0.5

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 CHANGED
@@ -1,4 +1,4 @@
1
- export * from './lib/find';
1
+ export * from './lib/build';
2
2
  export * from './lib/watch';
3
3
  export * from './lib/tslint';
4
4
  export * from './lib/types';
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/find"), exports);
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
@@ -0,0 +1,3 @@
1
+ import type { Config } from './types';
2
+ export declare function buildConfigFile(configFilePath: string): Promise<Config>;
3
+ //# sourceMappingURL=build.d.ts.map
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?: string;
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, errorCodes: readonly number[]): CodeFixAction[];
19
+ getFixes?(fileName: string, start: number, end: number, diagnostics?: Diagnostic[]): CodeFixAction[];
20
20
  resolveRules?(rules: Rules): Rules;
21
- resolveResult?(results: Diagnostic[]): Diagnostic[];
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(tsConfigPath: string, onBuild: (config: Config | undefined, result: esbuild.BuildResult) => void): Promise<esbuild.BuildContext<{
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(tsConfigPath, onBuild) {
6
+ async function watchConfigFile(configFilePath, onBuild, watch = true) {
7
7
  const outDir = path.resolve(__dirname, '..', '..', '.tsslint');
8
- const outFileName = btoa(path.relative(outDir, tsConfigPath)) + '.cjs';
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: [tsConfigPath],
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
- await ctx.watch();
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",
3
+ "version": "0.0.5",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -22,5 +22,5 @@
22
22
  "optional": true
23
23
  }
24
24
  },
25
- "gitHead": "13557d614907865f38ad32fd3582c9f198fb9ffa"
25
+ "gitHead": "0522e03f552e0ac5bb27124ef923ff093ff02cdc"
26
26
  }