@tsslint/config 0.0.7 → 0.0.9

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,6 +1,3 @@
1
1
  export * from './lib/build';
2
2
  export * from './lib/watch';
3
- export * from './lib/tslint';
4
3
  export * from './lib/types';
5
- import type { Config } from './lib/types';
6
- export declare function defineConfig(config: Config): Config;
package/index.js CHANGED
@@ -14,13 +14,7 @@ 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 = void 0;
18
17
  __exportStar(require("./lib/build"), exports);
19
18
  __exportStar(require("./lib/watch"), exports);
20
- __exportStar(require("./lib/tslint"), exports);
21
19
  __exportStar(require("./lib/types"), exports);
22
- function defineConfig(config) {
23
- return config;
24
- }
25
- exports.defineConfig = defineConfig;
26
20
  //# sourceMappingURL=index.js.map
package/lib/build.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Config } from './types';
2
- export declare function buildConfigFile(configFilePath: string): Promise<Config>;
2
+ export declare function buildConfigFile(configFilePath: string, createHash?: (path: string) => string): Promise<Config>;
package/lib/build.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildConfigFile = void 0;
4
4
  const watch_1 = require("./watch");
5
- async function buildConfigFile(configFilePath) {
5
+ async function buildConfigFile(configFilePath, createHash) {
6
6
  return new Promise((resolve, reject) => {
7
7
  (0, watch_1.watchConfigFile)(configFilePath, (config, result) => {
8
8
  if (config) {
@@ -11,7 +11,7 @@ async function buildConfigFile(configFilePath) {
11
11
  else {
12
12
  reject(result);
13
13
  }
14
- }, false);
14
+ }, false, createHash);
15
15
  });
16
16
  }
17
17
  exports.buildConfigFile = buildConfigFile;
package/lib/watch.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import esbuild = require('esbuild');
2
2
  import type { Config } from './types';
3
- export declare function watchConfigFile(configFilePath: string, onBuild: (config: Config | undefined, result: esbuild.BuildResult) => void, watch?: boolean): Promise<esbuild.BuildContext<{
3
+ export declare function watchConfigFile(configFilePath: string, onBuild: (config: Config | undefined, result: esbuild.BuildResult) => void, watch?: boolean, createHash?: (path: string) => string): Promise<esbuild.BuildContext<{
4
4
  entryPoints: string[];
5
5
  bundle: true;
6
6
  sourcemap: true;
package/lib/watch.js CHANGED
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.watchConfigFile = void 0;
4
4
  const esbuild = require("esbuild");
5
5
  const path = require("path");
6
- async function watchConfigFile(configFilePath, onBuild, watch = true) {
7
- const outDir = path.resolve(__dirname, '..', '..', '.tsslint');
8
- const outFileName = btoa(path.relative(outDir, configFilePath)) + '.cjs';
6
+ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash = btoa) {
7
+ const outDir = path.resolve(__dirname, '..', '..', '.tsl');
8
+ const outFileName = createHash(path.relative(outDir, configFilePath)) + '.cjs';
9
9
  const outFile = path.join(outDir, outFileName);
10
10
  const resultHandler = (result) => {
11
11
  let config;
@@ -28,7 +28,7 @@ async function watchConfigFile(configFilePath, onBuild, watch = true) {
28
28
  format: 'cjs',
29
29
  platform: 'node',
30
30
  plugins: [{
31
- name: 'tsslint',
31
+ name: 'tsl',
32
32
  setup(build) {
33
33
  build.onResolve({ filter: /.*/ }, args => {
34
34
  if (!args.path.endsWith('.ts')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/config",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -14,8 +14,5 @@
14
14
  "dependencies": {
15
15
  "esbuild": "^0.19.0"
16
16
  },
17
- "devDependencies": {
18
- "tslint": "latest"
19
- },
20
- "gitHead": "ed1086b1f11469e0a9d6a14199c7e027eb28b488"
17
+ "gitHead": "ee84b80bac5dab5fad732e4265e2164c6a0724a6"
21
18
  }
package/lib/find.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function findConfigFile(dir: string): string | undefined;
2
- //# sourceMappingURL=find.d.ts.map
package/lib/find.js DELETED
@@ -1,20 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- export declare function findConfigFile(dir: string): string | undefined;
2
- //# sourceMappingURL=findConfigFile.d.ts.map
@@ -1,20 +0,0 @@
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=findConfigFile.js.map
@@ -1,20 +0,0 @@
1
- import type { Config } from './types';
2
- import esbuild = require('/Users/johnsonchu/Desktop/GitHub/tsslint/node_modules/.pnpm/esbuild@0.19.9/node_modules/esbuild/lib/main.js');
3
- export interface LoadConfigResult {
4
- config: Config | undefined;
5
- errors: esbuild.Message[];
6
- warnings: esbuild.Message[];
7
- }
8
- export declare function findConfigFile(dir: string): string | undefined;
9
- export declare function watchConfig(tsConfigPath: string, onBuild: (result: LoadConfigResult) => void): Promise<esbuild.BuildContext<{
10
- entryPoints: string[];
11
- bundle: true;
12
- outfile: string;
13
- format: "cjs";
14
- platform: "node";
15
- plugins: {
16
- name: string;
17
- setup(build: esbuild.PluginBuild): void;
18
- }[];
19
- }>>;
20
- //# sourceMappingURL=loadConfig.d.ts.map
package/lib/loadConfig.js DELETED
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.watchConfig = exports.findConfigFile = void 0;
4
- const path = require("path");
5
- const esbuild = require("/Users/johnsonchu/Desktop/GitHub/tsslint/node_modules/.pnpm/esbuild@0.19.9/node_modules/esbuild/lib/main.js");
6
- function findConfigFile(dir) {
7
- const dirs = [dir];
8
- let upDir;
9
- while ((upDir = path.resolve(dir, '..')) !== dirs[dirs.length - 1]) {
10
- dirs.push(upDir);
11
- dir = upDir;
12
- }
13
- for (const dir of dirs) {
14
- try {
15
- return require.resolve('./tsslint.config.ts', { paths: [dir] });
16
- }
17
- catch { }
18
- }
19
- }
20
- exports.findConfigFile = findConfigFile;
21
- async function watchConfig(tsConfigPath, onBuild) {
22
- const jsConfigPath = tsConfigPath.slice(0, -'.ts'.length) + '.cjs';
23
- const ctx = await esbuild.context({
24
- entryPoints: [tsConfigPath],
25
- bundle: true,
26
- outfile: jsConfigPath,
27
- format: 'cjs',
28
- platform: 'node',
29
- plugins: [{
30
- name: 'tsslint',
31
- setup(build) {
32
- build.onEnd(result => {
33
- let config;
34
- if (!result.errors.length) {
35
- delete require.cache[jsConfigPath];
36
- try {
37
- config = require(jsConfigPath).default;
38
- }
39
- catch (e) {
40
- result.errors.push({ text: String(e) });
41
- }
42
- }
43
- onBuild({
44
- config: config,
45
- errors: result.errors,
46
- warnings: result.warnings,
47
- });
48
- });
49
- },
50
- }],
51
- });
52
- await ctx.watch();
53
- return ctx;
54
- }
55
- exports.watchConfig = watchConfig;
56
- //# sourceMappingURL=loadConfig.js.map
package/lib/tslint.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type * as TSLint from 'tslint';
2
- import type { Rule } from './types';
3
- export declare function parseTSLintRules(rules: TSLint.IRule[]): Record<string, Rule>;
4
- export declare function parseTSLintRule(rule: TSLint.IRule): Rule;
package/lib/tslint.js DELETED
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseTSLintRule = exports.parseTSLintRules = void 0;
4
- function parseTSLintRules(rules) {
5
- const result = {};
6
- for (const rule of rules) {
7
- const { ruleName } = rule.getOptions();
8
- result[ruleName] = parseTSLintRule(rule);
9
- }
10
- return result;
11
- }
12
- exports.parseTSLintRules = parseTSLintRules;
13
- function parseTSLintRule(rule) {
14
- return ({ sourceFile, reportError, reportWarning }) => {
15
- const { ruleSeverity } = rule.getOptions();
16
- if (ruleSeverity === 'off') {
17
- return;
18
- }
19
- const failures = rule.apply(sourceFile);
20
- for (const failure of failures) {
21
- failure.setRuleSeverity(ruleSeverity);
22
- const report = failure.getRuleSeverity() === 'error' ? reportError : reportWarning;
23
- const reporter = report(failure.getFailure(), failure.getStartPosition().getPosition(), failure.getEndPosition().getPosition(), false);
24
- for (let i = 0; i < failures.length; i++) {
25
- const failure = failures[i];
26
- if (failure.hasFix()) {
27
- const fix = failure.getFix();
28
- const replaces = Array.isArray(fix) ? fix : [fix];
29
- for (const replace of replaces) {
30
- if (replace) {
31
- reporter.withFix('Replace with ' + replace.text, () => [{
32
- fileName: sourceFile.fileName,
33
- textChanges: [{
34
- newText: replace.text,
35
- span: {
36
- start: replace.start,
37
- length: replace.length,
38
- },
39
- }],
40
- }]);
41
- }
42
- }
43
- }
44
- }
45
- }
46
- };
47
- }
48
- exports.parseTSLintRule = parseTSLintRule;
49
- //# sourceMappingURL=tslint.js.map
@@ -1,15 +0,0 @@
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%20copy.d.ts.map
@@ -1,53 +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
- 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%20copy.js.map