@tsslint/config 0.0.1 → 0.0.2

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,5 @@
1
- export * from './lib/findConfigFile';
1
+ export * from './lib/find';
2
+ export * from './lib/watch';
2
3
  export * from './lib/tslint';
3
4
  export * from './lib/types';
4
5
  import type { Config } from './lib/types';
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/findConfigFile"), exports);
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
@@ -0,0 +1,2 @@
1
+ export declare function findConfigFile(dir: string): string | undefined;
2
+ //# sourceMappingURL=find.d.ts.map
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
@@ -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
  }
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.1",
3
+ "version": "0.0.2",
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": "8a11cfe2ad196e8df0566d798c71bb40e3a2a6a0"
25
+ "gitHead": "bdca2792d8b64a11c7c1632c80a2bf25b4985c15"
23
26
  }