@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 +0 -1
- package/lib/build.d.ts +0 -1
- package/lib/tslint.d.ts +1 -2
- package/lib/types.d.ts +4 -6
- package/lib/watch.d.ts +0 -1
- package/lib/watch.js +19 -14
- package/package.json +4 -9
package/index.d.ts
CHANGED
package/lib/build.d.ts
CHANGED
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,
|
|
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
|
|
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:
|
|
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
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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.
|
|
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
|
-
"
|
|
18
|
-
"tslint": "
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"tslint": "latest"
|
|
19
19
|
},
|
|
20
|
-
"
|
|
21
|
-
"tslint": {
|
|
22
|
-
"optional": true
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"gitHead": "0522e03f552e0ac5bb27124ef923ff093ff02cdc"
|
|
20
|
+
"gitHead": "ed1086b1f11469e0a9d6a14199c7e027eb28b488"
|
|
26
21
|
}
|