@tsslint/config 0.0.1 → 0.0.3
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 +2 -1
- package/index.js +2 -1
- package/lib/find.d.ts +2 -0
- package/lib/find.js +20 -0
- package/lib/tslint.js +1 -1
- package/lib/types.d.ts +3 -3
- package/lib/watch.d.ts +15 -0
- package/lib/watch.js +53 -0
- package/package.json +5 -2
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -15,7 +15,8 @@ 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/find"), exports);
|
|
19
|
+
__exportStar(require("./lib/watch"), exports);
|
|
19
20
|
__exportStar(require("./lib/tslint"), exports);
|
|
20
21
|
__exportStar(require("./lib/types"), exports);
|
|
21
22
|
function defineConfig(config) {
|
package/lib/find.d.ts
ADDED
package/lib/find.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findConfigFile = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
function findConfigFile(dir) {
|
|
6
|
+
const dirs = [dir];
|
|
7
|
+
let upDir;
|
|
8
|
+
while ((upDir = path.resolve(dir, '..')) !== dirs[dirs.length - 1]) {
|
|
9
|
+
dirs.push(upDir);
|
|
10
|
+
dir = upDir;
|
|
11
|
+
}
|
|
12
|
+
for (const dir of dirs) {
|
|
13
|
+
try {
|
|
14
|
+
return require.resolve('./tsslint.config.ts', { paths: [dir] });
|
|
15
|
+
}
|
|
16
|
+
catch { }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.findConfigFile = findConfigFile;
|
|
20
|
+
//# sourceMappingURL=find.js.map
|
package/lib/tslint.js
CHANGED
|
@@ -20,9 +20,9 @@ function parseTSLintRule(rule) {
|
|
|
20
20
|
for (const failure of failures) {
|
|
21
21
|
failure.setRuleSeverity(ruleSeverity);
|
|
22
22
|
const report = failure.getRuleSeverity() === 'error' ? reportError : reportWarning;
|
|
23
|
+
const reporter = report(failure.getFailure(), failure.getStartPosition().getPosition(), failure.getEndPosition().getPosition(), false);
|
|
23
24
|
for (let i = 0; i < failures.length; i++) {
|
|
24
25
|
const failure = failures[i];
|
|
25
|
-
const reporter = report(failure.getFailure(), failure.getStartPosition().getPosition(), failure.getEndPosition().getPosition(), false);
|
|
26
26
|
if (failure.hasFix()) {
|
|
27
27
|
const fix = failure.getFix();
|
|
28
28
|
const replaces = Array.isArray(fix) ? fix : [fix];
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileTextChanges, LanguageService, LanguageServiceHost, SourceFile
|
|
1
|
+
import type { CodeFixAction, Diagnostic, 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');
|
|
@@ -7,6 +7,7 @@ export interface ProjectContext {
|
|
|
7
7
|
tsconfig?: string;
|
|
8
8
|
}
|
|
9
9
|
export interface Config {
|
|
10
|
+
debug?: boolean;
|
|
10
11
|
rules?: Rules;
|
|
11
12
|
plugins?: Plugin[];
|
|
12
13
|
}
|
|
@@ -15,8 +16,7 @@ export interface Plugin {
|
|
|
15
16
|
}
|
|
16
17
|
export interface PluginInstance {
|
|
17
18
|
lint?(sourceFile: SourceFile, rules: Rules): Diagnostic[];
|
|
18
|
-
getFixes?(
|
|
19
|
-
fix?(sourceFile: SourceFile, refactorName: string, actionName: string): FileTextChanges[] | undefined;
|
|
19
|
+
getFixes?(fileName: string, start: number, end: number, errorCodes: readonly number[]): CodeFixAction[];
|
|
20
20
|
resolveRules?(rules: Rules): Rules;
|
|
21
21
|
resolveResult?(results: Diagnostic[]): Diagnostic[];
|
|
22
22
|
}
|
package/lib/watch.d.ts
ADDED
|
@@ -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.d.ts.map
|
package/lib/watch.js
ADDED
|
@@ -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.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"url": "https://github.com/johnsoncodehk/tsslint.git",
|
|
12
12
|
"directory": "packages/config"
|
|
13
13
|
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"esbuild": "^0.19.0"
|
|
16
|
+
},
|
|
14
17
|
"peerDependencies": {
|
|
15
18
|
"tslint": "*"
|
|
16
19
|
},
|
|
@@ -19,5 +22,5 @@
|
|
|
19
22
|
"optional": true
|
|
20
23
|
}
|
|
21
24
|
},
|
|
22
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "13557d614907865f38ad32fd3582c9f198fb9ffa"
|
|
23
26
|
}
|