@tsslint/config 0.0.5 → 0.0.7

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
@@ -4,4 +4,3 @@ export * from './lib/tslint';
4
4
  export * from './lib/types';
5
5
  import type { Config } from './lib/types';
6
6
  export declare function defineConfig(config: Config): Config;
7
- //# sourceMappingURL=index.d.ts.map
package/lib/build.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  import type { Config } from './types';
2
2
  export declare function buildConfigFile(configFilePath: string): Promise<Config>;
3
- //# sourceMappingURL=build.d.ts.map
package/lib/tslint.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import * as TSLint from 'tslint';
1
+ import type * as TSLint from 'tslint';
2
2
  import type { Rule } from './types';
3
3
  export declare function parseTSLintRules(rules: TSLint.IRule[]): Record<string, Rule>;
4
4
  export declare function parseTSLintRule(rule: TSLint.IRule): Rule;
5
- //# sourceMappingURL=tslint.d.ts.map
package/lib/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CodeFixAction, Diagnostic, FileTextChanges, LanguageService, LanguageServiceHost, SourceFile } from 'typescript/lib/tsserverlibrary';
1
+ import type { CodeFixAction, DiagnosticWithLocation, FileTextChanges, LanguageService, LanguageServiceHost, SourceFile } from 'typescript/lib/tsserverlibrary';
2
2
  export interface ProjectContext {
3
3
  configFile: string;
4
4
  typescript: typeof import('typescript/lib/tsserverlibrary.js');
@@ -12,13 +12,12 @@ export interface Config {
12
12
  plugins?: Plugin[];
13
13
  }
14
14
  export interface Plugin {
15
- (projectContext: ProjectContext): PluginInstance | Promise<PluginInstance>;
15
+ (projectContext: ProjectContext): PluginInstance;
16
16
  }
17
17
  export interface PluginInstance {
18
- lint?(sourceFile: SourceFile, rules: Rules): Diagnostic[];
19
- getFixes?(fileName: string, start: number, end: number, diagnostics?: Diagnostic[]): CodeFixAction[];
20
18
  resolveRules?(rules: Rules): Rules;
21
- resolveDiagnostics?(results: Diagnostic[]): Diagnostic[];
19
+ resolveDiagnostics?(fileName: string, results: DiagnosticWithLocation[]): DiagnosticWithLocation[];
20
+ resolveCodeFixes?(fileName: string, results: CodeFixAction[]): CodeFixAction[];
22
21
  }
23
22
  export interface Rules {
24
23
  [name: string]: Rule;
@@ -40,4 +39,3 @@ export interface Reporter {
40
39
  withUnnecessary(): Reporter;
41
40
  withFix(title: string, getChanges: () => FileTextChanges[]): Reporter;
42
41
  }
43
- //# sourceMappingURL=types.d.ts.map
package/lib/watch.d.ts CHANGED
@@ -12,4 +12,3 @@ export declare function watchConfigFile(configFilePath: string, onBuild: (config
12
12
  setup(build: esbuild.PluginBuild): void;
13
13
  }[];
14
14
  }>>;
15
- //# sourceMappingURL=watch.d.ts.map
package/lib/watch.js CHANGED
@@ -7,6 +7,19 @@ async function watchConfigFile(configFilePath, onBuild, watch = true) {
7
7
  const outDir = path.resolve(__dirname, '..', '..', '.tsslint');
8
8
  const outFileName = btoa(path.relative(outDir, configFilePath)) + '.cjs';
9
9
  const outFile = path.join(outDir, outFileName);
10
+ const resultHandler = (result) => {
11
+ let config;
12
+ if (!result.errors.length) {
13
+ try {
14
+ config = require(outFile).default;
15
+ delete require.cache[outFile];
16
+ }
17
+ catch (e) {
18
+ result.errors.push({ text: String(e) });
19
+ }
20
+ }
21
+ onBuild(config, result);
22
+ };
10
23
  const ctx = await esbuild.context({
11
24
  entryPoints: [configFilePath],
12
25
  bundle: true,
@@ -30,19 +43,9 @@ async function watchConfigFile(configFilePath, onBuild, watch = true) {
30
43
  }
31
44
  return {};
32
45
  });
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
+ if (watch) {
47
+ build.onEnd(resultHandler);
48
+ }
46
49
  },
47
50
  }],
48
51
  });
@@ -50,7 +53,9 @@ async function watchConfigFile(configFilePath, onBuild, watch = true) {
50
53
  await ctx.watch();
51
54
  }
52
55
  else {
53
- await ctx.rebuild();
56
+ const result = await ctx.rebuild();
57
+ await ctx.dispose();
58
+ resultHandler(result);
54
59
  }
55
60
  return ctx;
56
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/config",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -14,13 +14,8 @@
14
14
  "dependencies": {
15
15
  "esbuild": "^0.19.0"
16
16
  },
17
- "peerDependencies": {
18
- "tslint": "*"
17
+ "devDependencies": {
18
+ "tslint": "latest"
19
19
  },
20
- "peerDependenciesMeta": {
21
- "tslint": {
22
- "optional": true
23
- }
24
- },
25
- "gitHead": "0522e03f552e0ac5bb27124ef923ff093ff02cdc"
20
+ "gitHead": "ed1086b1f11469e0a9d6a14199c7e027eb28b488"
26
21
  }