@tsslint/cli 2.0.6 → 3.0.0-alpha.0

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
@@ -2,10 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ts = require("typescript");
4
4
  const path = require("path");
5
- const core = require("@tsslint/core");
6
5
  const cache = require("./lib/cache.js");
7
6
  const worker = require("./lib/worker.js");
8
- const glob = require("glob");
9
7
  const fs = require("fs");
10
8
  const os = require("os");
11
9
  const minimatch = require("minimatch");
@@ -108,7 +106,6 @@ class Project {
108
106
  }
109
107
  }
110
108
  (async () => {
111
- const builtConfigs = new Map();
112
109
  const clack = await import('@clack/prompts');
113
110
  const processFiles = new Set();
114
111
  const tsconfigAndLanguages = new Map();
@@ -176,7 +173,7 @@ class Project {
176
173
  if (clack.isCancel(language)) {
177
174
  process.exit(1);
178
175
  }
179
- const tsconfigOptions = glob.sync('**/{tsconfig.json,tsconfig.*.json,jsconfig.json}');
176
+ const tsconfigOptions = fs.globSync('**/{tsconfig.json,tsconfig.*.json,jsconfig.json}');
180
177
  let options = await Promise.all(tsconfigOptions.map(async (tsconfigOption) => {
181
178
  const tsconfig = require.resolve(tsconfigOption.startsWith('.') ? tsconfigOption : `./${tsconfigOption}`, { paths: [process.cwd()] });
182
179
  try {
@@ -261,7 +258,7 @@ class Project {
261
258
  }
262
259
  foundArg = true;
263
260
  const searchGlob = process.argv[i];
264
- const tsconfigs = glob.sync(searchGlob);
261
+ const tsconfigs = fs.globSync(searchGlob);
265
262
  if (!tsconfigs.length) {
266
263
  clack.log.error(red(`No projects found for ${projectFlag} ${searchGlob}.`));
267
264
  process.exit(1);
@@ -312,10 +309,7 @@ class Project {
312
309
  spinner?.start();
313
310
  projects = projects.filter(project => !!project.configFile);
314
311
  projects = projects.filter(project => !!project.fileNames.length);
315
- for (const project of projects) {
316
- project.builtConfig = await getBuiltConfig(project.configFile);
317
- }
318
- projects = projects.filter(project => !!project.builtConfig);
312
+ projects = projects.filter(project => !!project.configFile);
319
313
  for (const project of projects) {
320
314
  allFilesNum += project.fileNames.length;
321
315
  }
@@ -373,7 +367,7 @@ class Project {
373
367
  return;
374
368
  }
375
369
  project.worker = linterWorker;
376
- const setupSuccess = await linterWorker.setup(project.tsconfig, project.languages, project.configFile, project.builtConfig, project.rawFileNames, project.options);
370
+ const setupSuccess = await linterWorker.setup(project.tsconfig, project.languages, project.configFile, project.rawFileNames, project.options);
377
371
  if (!setupSuccess) {
378
372
  projects = projects.filter(p => p !== project);
379
373
  startWorker(linterWorker);
@@ -458,12 +452,6 @@ class Project {
458
452
  cache.saveCache(project.tsconfig, project.configFile, project.cache, ts.sys.createHash);
459
453
  await startWorker(linterWorker);
460
454
  }
461
- async function getBuiltConfig(configFile) {
462
- if (!builtConfigs.has(configFile)) {
463
- builtConfigs.set(configFile, core.buildConfig(configFile, ts.sys.createHash, spinner, (s, code) => log(gray(s), code)));
464
- }
465
- return await builtConfigs.get(configFile);
466
- }
467
455
  function addProcessFile(fileName) {
468
456
  processFiles.add(fileName);
469
457
  updateSpinner();
package/lib/cache.js CHANGED
@@ -2,11 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadCache = loadCache;
4
4
  exports.saveCache = saveCache;
5
- const core = require("@tsslint/core");
6
5
  const path = require("path");
7
6
  const fs = require("fs");
8
7
  function loadCache(tsconfig, configFilePath, createHash = btoa) {
9
- const outDir = core.getDotTsslintPath(configFilePath);
8
+ const outDir = getDotTsslintPath(configFilePath);
10
9
  const cacheFileName = createHash(path.relative(outDir, configFilePath)) + '_' + createHash(JSON.stringify(process.argv)) + '_' + createHash(path.relative(outDir, tsconfig)) + '.cache.json';
11
10
  const cacheFilePath = path.join(outDir, cacheFileName);
12
11
  const cacheFileStat = fs.statSync(cacheFilePath, { throwIfNoEntry: false });
@@ -22,9 +21,13 @@ function loadCache(tsconfig, configFilePath, createHash = btoa) {
22
21
  return {};
23
22
  }
24
23
  function saveCache(tsconfig, configFilePath, cache, createHash = btoa) {
25
- const outDir = core.getDotTsslintPath(configFilePath);
24
+ const outDir = getDotTsslintPath(configFilePath);
26
25
  const cacheFileName = createHash(path.relative(outDir, configFilePath)) + '_' + createHash(JSON.stringify(process.argv)) + '_' + createHash(path.relative(outDir, tsconfig)) + '.cache.json';
27
26
  const cacheFilePath = path.join(outDir, cacheFileName);
27
+ fs.mkdirSync(outDir, { recursive: true });
28
28
  fs.writeFileSync(cacheFilePath, JSON.stringify(cache));
29
29
  }
30
+ function getDotTsslintPath(configFilePath) {
31
+ return path.resolve(configFilePath, '..', 'node_modules', '.tsslint');
32
+ }
30
33
  //# sourceMappingURL=cache.js.map
package/lib/worker.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import ts = require('typescript');
2
2
  import core = require('@tsslint/core');
3
3
  export declare function createLocal(): {
4
- setup(tsconfig: string, languages: string[], configFile: string, builtConfig: string, _fileNames: string[], _options: ts.CompilerOptions): Promise<boolean>;
4
+ setup(tsconfig: string, languages: string[], configFile: string, _fileNames: string[], _options: ts.CompilerOptions): Promise<boolean>;
5
5
  lint(fileName: string, fix: boolean, fileCache: core.FileLintCache): ts.DiagnosticWithLocation[];
6
6
  hasCodeFixes(fileName: string): boolean;
7
7
  hasRules(fileName: string, minimatchCache: Record<string, boolean>): boolean;
8
8
  };
9
9
  export declare function create(): {
10
- setup(tsconfig: string, languages: string[], configFile: string, builtConfig: string, _fileNames: string[], _options: ts.CompilerOptions): Promise<boolean>;
10
+ setup(tsconfig: string, languages: string[], configFile: string, _fileNames: string[], _options: ts.CompilerOptions): Promise<boolean>;
11
11
  lint(fileName: string, fix: boolean, fileCache: core.FileLintCache): Promise<ts.DiagnosticWithLocation[]>;
12
12
  hasCodeFixes(fileName: string): Promise<boolean>;
13
13
  hasRules(fileName: string, minimatchCache: Record<string, boolean>): Promise<boolean>;
14
14
  };
15
- declare function setup(tsconfig: string, languages: string[], configFile: string, builtConfig: string, _fileNames: string[], _options: ts.CompilerOptions): Promise<boolean>;
15
+ declare function setup(tsconfig: string, languages: string[], configFile: string, _fileNames: string[], _options: ts.CompilerOptions): Promise<boolean>;
16
16
  declare function lint(fileName: string, fix: boolean, fileCache: core.FileLintCache): readonly [ts.DiagnosticWithLocation[], core.FileLintCache];
17
17
  declare function hasCodeFixes(fileName: string): boolean;
18
18
  declare function hasRules(fileName: string, minimatchCache: core.FileLintCache[2]): readonly [boolean, Record<string, boolean>];
package/lib/worker.js CHANGED
@@ -127,11 +127,11 @@ const handlers = {
127
127
  hasCodeFixes,
128
128
  hasRules,
129
129
  };
130
- async function setup(tsconfig, languages, configFile, builtConfig, _fileNames, _options) {
130
+ async function setup(tsconfig, languages, configFile, _fileNames, _options) {
131
131
  const clack = await import('@clack/prompts');
132
132
  let config;
133
133
  try {
134
- config = (await import(url.pathToFileURL(builtConfig).toString())).default;
134
+ config = (await import(url.pathToFileURL(configFile).toString())).default;
135
135
  }
136
136
  catch (err) {
137
137
  if (err instanceof Error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/cli",
3
- "version": "2.0.6",
3
+ "version": "3.0.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "tsslint": "./bin/tsslint.js"
@@ -16,21 +16,15 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@clack/prompts": "^0.8.2",
19
- "@tsslint/config": "2.0.6",
20
- "@tsslint/core": "2.0.6",
19
+ "@tsslint/config": "3.0.0-alpha.0",
20
+ "@tsslint/core": "3.0.0-alpha.0",
21
21
  "@volar/language-core": "~2.4.0",
22
22
  "@volar/language-hub": "0.0.1",
23
23
  "@volar/typescript": "~2.4.0",
24
- "glob": "^10.4.1",
25
- "json5": "^2.2.3",
26
24
  "minimatch": "^10.0.1"
27
25
  },
28
26
  "peerDependencies": {
29
27
  "typescript": "*"
30
28
  },
31
- "devDependencies": {
32
- "@vue-vine/language-service": "latest",
33
- "@vue/language-core": "latest"
34
- },
35
- "gitHead": "b5914c99cb269150c2518f0f7b097ad2a996296d"
29
+ "gitHead": "ec683ca05f4360fac720bd8c567f4d9460d255e1"
36
30
  }