@tsslint/config 1.0.13 → 1.0.15

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.js CHANGED
@@ -14,18 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.defineConfig = exports.definePlugin = exports.defineRule = void 0;
17
+ exports.defineRule = defineRule;
18
+ exports.definePlugin = definePlugin;
19
+ exports.defineConfig = defineConfig;
18
20
  __exportStar(require("@tsslint/types"), exports);
19
21
  function defineRule(rule) {
20
22
  return rule;
21
23
  }
22
- exports.defineRule = defineRule;
23
24
  function definePlugin(plugin) {
24
25
  return plugin;
25
26
  }
26
- exports.definePlugin = definePlugin;
27
27
  function defineConfig(config) {
28
28
  return config;
29
29
  }
30
- exports.defineConfig = defineConfig;
31
30
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/config",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,8 +12,7 @@
12
12
  "directory": "packages/config"
13
13
  },
14
14
  "dependencies": {
15
- "@tsslint/types": "1.0.13",
16
- "esbuild": "^0.21.4"
15
+ "@tsslint/types": "1.0.15"
17
16
  },
18
- "gitHead": "47f0f4bdbb68d8343c2967d46bd4b7bf9fb00e7e"
17
+ "gitHead": "58de9acb2cb7a1d7e93a5fb983fec54bf083f7b9"
19
18
  }
package/lib/build.d.ts DELETED
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import type { Config } from '@tsslint/types';
4
- export declare function buildConfigFile(configFilePath: string, createHash?: (path: string) => string, logger?: Pick<typeof console, 'log' | 'warn' | 'error'>): Promise<Config>;
package/lib/build.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildConfigFile = void 0;
4
- const watch_1 = require("./watch");
5
- function buildConfigFile(configFilePath, createHash, logger) {
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, createHash, logger);
15
- });
16
- }
17
- exports.buildConfigFile = buildConfigFile;
18
- //# sourceMappingURL=build.js.map
package/lib/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/lib/watch.d.ts DELETED
@@ -1,16 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import esbuild = require('esbuild');
4
- import type { Config } from '@tsslint/types';
5
- export declare function watchConfigFile(configFilePath: string, onBuild: (config: Config | undefined, result: esbuild.BuildResult) => void, watch?: boolean, createHash?: (path: string) => string, logger?: Pick<typeof console, 'log' | 'warn' | 'error'>): Promise<esbuild.BuildContext<{
6
- entryPoints: string[];
7
- bundle: true;
8
- sourcemap: true;
9
- outfile: string;
10
- format: "esm";
11
- platform: "node";
12
- plugins: {
13
- name: string;
14
- setup(build: esbuild.PluginBuild): void;
15
- }[];
16
- }>>;
package/lib/watch.js DELETED
@@ -1,96 +0,0 @@
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
- const fs = require("fs");
7
- async function watchConfigFile(configFilePath, onBuild, watch = true, createHash = btoa, logger = console) {
8
- let start;
9
- const outDir = _path.resolve(configFilePath, '..', 'node_modules', '.tsslint');
10
- const outFileName = createHash(_path.relative(outDir, configFilePath)) + '.mjs';
11
- const outFile = _path.join(outDir, outFileName);
12
- const resultHandler = async (result) => {
13
- let config;
14
- if (!result.errors.length) {
15
- try {
16
- config = (await import(outFile)).default;
17
- delete require.cache[outFile];
18
- }
19
- catch (e) {
20
- result.errors.push({ text: String(e) });
21
- }
22
- }
23
- logger.log(`Built ${_path.relative(process.cwd(), configFilePath)} in ${Date.now() - start}ms`);
24
- onBuild(config, result);
25
- };
26
- const cacheDir = _path.resolve(outDir, 'http_resources');
27
- const cachePathToOriginalPath = new Map();
28
- const ctx = await esbuild.context({
29
- entryPoints: [configFilePath],
30
- bundle: true,
31
- sourcemap: true,
32
- outfile: outFile,
33
- format: 'esm',
34
- platform: 'node',
35
- plugins: [{
36
- name: 'tsslint',
37
- setup(build) {
38
- build.onStart(() => {
39
- start = Date.now();
40
- });
41
- build.onResolve({ filter: /^https?:\/\// }, ({ path }) => {
42
- const cachePath = _path.join(cacheDir, createHash(path));
43
- cachePathToOriginalPath.set(cachePath, path);
44
- return { path: cachePath, namespace: 'http-url' };
45
- });
46
- build.onResolve({ filter: /.*/ }, ({ path, resolveDir }) => {
47
- if (!path.endsWith('.ts')) {
48
- try {
49
- const jsPath = require.resolve(path, { paths: [resolveDir] });
50
- return {
51
- path: jsPath,
52
- external: true,
53
- };
54
- }
55
- catch { }
56
- }
57
- return {};
58
- });
59
- build.onLoad({ filter: /.*/, namespace: 'http-url' }, async ({ path: cachePath }) => {
60
- const path = cachePathToOriginalPath.get(cachePath);
61
- if (fs.existsSync(cachePath)) {
62
- return {
63
- contents: fs.readFileSync(cachePath, 'utf8'),
64
- loader: 'ts',
65
- };
66
- }
67
- const response = await fetch(path);
68
- if (!response.ok) {
69
- throw new Error(`Failed to load ${path}`);
70
- }
71
- const text = await response.text();
72
- fs.mkdirSync(cacheDir, { recursive: true });
73
- fs.writeFileSync(cachePath, text, 'utf8');
74
- return {
75
- contents: text,
76
- loader: path.substring(path.lastIndexOf('.') + 1),
77
- };
78
- });
79
- if (watch) {
80
- build.onEnd(resultHandler);
81
- }
82
- },
83
- }],
84
- });
85
- if (watch) {
86
- await ctx.watch();
87
- }
88
- else {
89
- const result = await ctx.rebuild();
90
- await ctx.dispose();
91
- resultHandler(result);
92
- }
93
- return ctx;
94
- }
95
- exports.watchConfigFile = watchConfigFile;
96
- //# sourceMappingURL=watch.js.map