@travetto/eslint 5.0.0-rc.1 → 5.0.0-rc.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/README.md CHANGED
@@ -34,7 +34,7 @@ This is the file the linter will use, and any other tooling (e.g. IDEs).
34
34
  process.env.TRV_MANIFEST = './.trv/output/node_modules/@travetto/eslint';
35
35
 
36
36
  const { buildConfig } = require('./.trv/output/node_modules/@travetto/eslint/support/bin/eslint-config.js');
37
- const { RuntimeIndex } = require('./.trv/output/node_modules/@travetto/manifest/__index__.js');
37
+ const { RuntimeIndex } = require('./.trv/output/node_modules/@travetto/runtime/__index__.js');
38
38
 
39
39
  const pluginFiles = RuntimeIndex.find({ folder: f => f === 'support', file: f => /support\/eslint[.]/.test(f) });
40
40
  const plugins = pluginFiles.map(x => require(x.outputFile));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/eslint",
3
- "version": "5.0.0-rc.1",
3
+ "version": "5.0.0-rc.2",
4
4
  "description": "ES Linting Rules",
5
5
  "keywords": [
6
6
  "eslint",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@eslint/js": "^8.56.0",
28
- "@travetto/base": "^5.0.0-rc.1",
28
+ "@travetto/runtime": "^5.0.0-rc.2",
29
29
  "@types/eslint": "^8.56.10",
30
30
  "@types/eslint__js": "^8.42.3",
31
31
  "@typescript-eslint/eslint-plugin": "^7.15.0",
@@ -34,7 +34,7 @@
34
34
  "eslint-plugin-unused-imports": "^3.2.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@travetto/cli": "^5.0.0-rc.1"
37
+ "@travetto/cli": "^5.0.0-rc.2"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@travetto/cli": {
@@ -1,7 +1,7 @@
1
1
  process.env.TRV_MANIFEST = '%MANIFEST_FILE%';
2
2
 
3
3
  const { buildConfig } = require('@travetto/eslint/support/bin/eslint-config');
4
- const { RuntimeIndex } = require('@travetto/manifest/__index__');
4
+ const { RuntimeIndex } = require('@travetto/runtime/__index__');
5
5
 
6
6
  const pluginFiles = RuntimeIndex.find({ folder: f => f === 'support', file: f => /support\/eslint[.]/.test(f) });
7
7
  const plugins = pluginFiles.map(x => require(x.outputFile));
@@ -1,7 +1,7 @@
1
1
  process.env.TRV_MANIFEST = '%MANIFEST_FILE%';
2
2
 
3
3
  const { buildConfig } = await import('@travetto/eslint/support/bin/eslint-config');
4
- const { RuntimeIndex } = await import('@travetto/manifest/__index__');
4
+ const { RuntimeIndex } = await import('@travetto/runtime/__index__');
5
5
 
6
6
  const pluginFiles = RuntimeIndex.find({ folder: f => f === 'support', file: f => /support\/eslint[.]/.test(f) });
7
7
  const plugins = await Promise.all(pluginFiles.map(x => import(x.outputFile)))
@@ -1,11 +1,11 @@
1
1
  import * as parser from '@typescript-eslint/parser';
2
2
 
3
- import { RuntimeContext } from '@travetto/base';
3
+ import { Runtime } from '@travetto/runtime';
4
4
 
5
5
  export const RULE_COMMON = {
6
6
  languageOptions: {
7
7
  ecmaVersion: 'latest',
8
- sourceType: RuntimeContext.workspace.type,
8
+ sourceType: Runtime.workspace.type,
9
9
  globals: {
10
10
  AbortController: false,
11
11
  AbortSignal: false,
@@ -1,12 +1,11 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
 
4
- import { RuntimeContext } from '@travetto/base';
5
- import { RuntimeIndex } from '@travetto/manifest';
4
+ import { Runtime, RuntimeIndex } from '@travetto/runtime';
6
5
 
7
6
  export async function buildEslintConfig(): Promise<string> {
8
7
  const root = RuntimeIndex.getModule('@travetto/eslint')!.sourcePath;
9
- const ext = RuntimeContext.workspace.type === 'commonjs' ? '.cjs' : '.mjs';
8
+ const ext = Runtime.workspace.type === 'commonjs' ? '.cjs' : '.mjs';
10
9
  const tpl = await fs.readFile(path.resolve(root, 'resources', `eslint-config-file${ext}`), 'utf8');
11
10
 
12
11
  return tpl
@@ -5,7 +5,7 @@ import unused from 'eslint-plugin-unused-imports';
5
5
  import { configs } from '@eslint/js';
6
6
  import tsEslintPlugin from '@typescript-eslint/eslint-plugin';
7
7
 
8
- import { RuntimeContext } from '@travetto/base';
8
+ import { Runtime } from '@travetto/runtime';
9
9
 
10
10
  import { IGNORES, RULE_COMMON } from './eslint-common';
11
11
  import { STD_RULES } from './eslint-std-rules';
@@ -20,7 +20,7 @@ export function buildConfig(pluginMaps: Record<string, TrvEslintPlugin>[]): read
20
20
  }
21
21
  }
22
22
 
23
- const overrides = RuntimeContext.workspaceRelative('eslint-overrides.json');
23
+ const overrides = Runtime.workspaceRelative('eslint-overrides.json');
24
24
 
25
25
  const extra: (typeof STD_RULES)[] = existsSync(overrides) ? JSON.parse(readFileSync(overrides, 'utf8')) : [];
26
26
 
@@ -1,6 +1,6 @@
1
1
  import { spawn } from 'node:child_process';
2
2
 
3
- import { Env, ExecUtil, RuntimeContext } from '@travetto/base';
3
+ import { Env, ExecUtil, Runtime } from '@travetto/runtime';
4
4
  import { CliCommandShape, CliCommand, CliModuleUtil, CliScmUtil } from '@travetto/cli';
5
5
 
6
6
  /**
@@ -27,23 +27,30 @@ export class LintCommand implements CliCommandShape {
27
27
 
28
28
  async main(): Promise<void> {
29
29
  let files: string[];
30
- if (this.since) {
31
- files = (await CliScmUtil.findChangedFiles(this.since, 'HEAD', true))
32
- .filter(x => !x.endsWith('package.json') && !x.endsWith('package-lock.json'));
33
- } else {
34
- const mods = await CliModuleUtil.findModules(this.changed ? 'changed' : 'all', undefined, 'HEAD', true);
35
- files = mods.filter(x => x.workspace).map(x => x.sourcePath);
30
+ try {
31
+ if (this.since) {
32
+ files = (await CliScmUtil.findChangedFiles(this.since, 'HEAD'))
33
+ .filter(x => !x.endsWith('package.json') && !x.endsWith('package-lock.json'));
34
+ } else {
35
+ const mods = await CliModuleUtil.findModules(this.changed ? 'changed' : 'all', undefined, 'HEAD');
36
+ files = mods.filter(x => x.workspace).map(x => x.sourcePath);
37
+ }
38
+ } catch (err) {
39
+ if (err instanceof Error) {
40
+ console.error(err.message);
41
+ }
42
+ files = [];
36
43
  }
37
44
 
38
45
  const res = await ExecUtil.getResult(spawn('npx', [
39
46
  'eslint',
40
47
  '--cache',
41
- '--cache-location', RuntimeContext.toolPath('.eslintcache'),
48
+ '--cache-location', Runtime.toolPath('.eslintcache'),
42
49
  ...(this.format ? ['--format', this.format] : []),
43
50
  ...(this.fix ? ['--fix'] : []),
44
51
  ...files
45
52
  ], {
46
- cwd: RuntimeContext.workspace.path,
53
+ cwd: Runtime.workspace.path,
47
54
  stdio: 'inherit',
48
55
  shell: false
49
56
  }), { catch: true });
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs/promises';
2
2
 
3
3
  import { CliCommandShape, CliCommand } from '@travetto/cli';
4
- import { RuntimeContext } from '@travetto/base';
4
+ import { Runtime } from '@travetto/runtime';
5
5
 
6
6
  import { buildEslintConfig } from './bin/eslint-config-file';
7
7
 
@@ -13,8 +13,8 @@ export class LintConfigureCommand implements CliCommandShape {
13
13
 
14
14
  async main(): Promise<void> {
15
15
  const content = await buildEslintConfig();
16
- const output = RuntimeContext.workspaceRelative('eslint.config.js');
17
- await fs.writeFile(output, content.replaceAll(RuntimeContext.workspace.path, '.').trim());
16
+ const output = Runtime.workspaceRelative('eslint.config.js');
17
+ await fs.writeFile(output, content.replaceAll(Runtime.workspace.path, '.').trim());
18
18
 
19
19
  console.log(`Wrote eslint config to ${output}`);
20
20
  }