@travetto/eslint 6.0.0-rc.0 → 6.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
@@ -24,14 +24,14 @@ In a new project, the first thing that will need to be done, post installation,
24
24
  ```bash
25
25
  $ trv lint:register
26
26
 
27
- Wrote eslint config to <workspace-root>/eslint.config.js
27
+ Wrote eslint config to <workspace-root>/eslint.config.cjs
28
28
  ```
29
29
 
30
30
  This is the file the linter will use, and any other tooling (e.g. IDEs).
31
31
 
32
32
  **Code: Sample configuration**
33
33
  ```javascript
34
- process.env.TRV_MANIFEST = './.trv/output/node_modules/@travetto/eslint';
34
+ process.env.TRV_MANIFEST = './.trv/output/node_modules/@travetto/mono-repo';
35
35
 
36
36
  const { buildConfig } = require('./.trv/output/node_modules/@travetto/eslint/support/bin/eslint-config.js');
37
37
  const { RuntimeIndex } = require('./.trv/output/node_modules/@travetto/runtime/__index__.js');
package/__index__.ts CHANGED
@@ -1 +1 @@
1
- export * from './support/bin/types';
1
+ export * from './support/bin/types.ts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/eslint",
3
- "version": "6.0.0-rc.0",
3
+ "version": "6.0.0-rc.2",
4
4
  "description": "ES Linting Rules",
5
5
  "keywords": [
6
6
  "eslint",
@@ -24,17 +24,17 @@
24
24
  "directory": "module/eslint"
25
25
  },
26
26
  "dependencies": {
27
- "@eslint/js": "^9.13.0",
28
- "@stylistic/eslint-plugin": "^2.13.0",
29
- "@travetto/runtime": "^6.0.0-rc.0",
27
+ "@eslint/js": "^9.25.1",
28
+ "@stylistic/eslint-plugin": "^4.2.0",
29
+ "@travetto/runtime": "^6.0.0-rc.2",
30
30
  "@types/eslint": "^9.6.1",
31
- "@types/eslint__js": "^8.42.3",
32
- "@typescript-eslint/eslint-plugin": "^8.20.0",
33
- "@typescript-eslint/parser": "^8.20.0",
34
- "eslint": "^9.18.0"
31
+ "@typescript-eslint/eslint-plugin": "^8.31.0",
32
+ "@typescript-eslint/parser": "^8.31.0",
33
+ "eslint": "^9.25.1",
34
+ "eslint-plugin-unused-imports": "^4.1.4"
35
35
  },
36
36
  "peerDependencies": {
37
- "@travetto/cli": "^6.0.0-rc.0"
37
+ "@travetto/cli": "^6.0.0-rc.2"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@travetto/cli": {
@@ -8,7 +8,15 @@ export async function buildEslintConfig(): Promise<string> {
8
8
  const ext = Runtime.workspace.type === 'commonjs' ? '.cjs' : '.mjs';
9
9
  const tpl = await fs.readFile(path.resolve(root, 'resources', `eslint-config-file${ext}`), 'utf8');
10
10
 
11
+ // Get path to repo-root output
12
+ const outputPath = path.join(
13
+ Runtime.workspace.path,
14
+ RuntimeIndex.manifest.build.outputFolder,
15
+ 'node_modules',
16
+ Runtime.workspace.name
17
+ );
18
+
11
19
  return tpl
12
20
  .replace(/'(@travetto\/[^']+)'/g, (_, v) => `'${RuntimeIndex.resolveFileImport(v)}'`)
13
- .replace('%MANIFEST_FILE%', RuntimeIndex.mainModule.outputPath);
21
+ .replace('%MANIFEST_FILE%', outputPath);
14
22
  }
@@ -3,12 +3,13 @@ import { existsSync, readFileSync } from 'node:fs';
3
3
  import { configs } from '@eslint/js';
4
4
  import tsEslintPlugin from '@typescript-eslint/eslint-plugin';
5
5
  import stylisticPlugin from '@stylistic/eslint-plugin';
6
+ import unusedImports from 'eslint-plugin-unused-imports';
6
7
 
7
8
  import { Runtime } from '@travetto/runtime';
8
9
 
9
- import { IGNORES, GLOBALS, TS_OPTIONS } from './eslint-common';
10
- import { STD_RULES } from './eslint-std-rules';
11
- import { TrvEslintPlugin } from './types';
10
+ import { IGNORES, GLOBALS, TS_OPTIONS } from './eslint-common.ts';
11
+ import { STD_RULES } from './eslint-std-rules.ts';
12
+ import { TrvEslintPlugin } from './types.ts';
12
13
 
13
14
  export function buildConfig(pluginMaps: Record<string, TrvEslintPlugin>[]): readonly unknown[] {
14
15
  const plugins: TrvEslintPlugin[] = pluginMaps.map(Object.values).flat();
@@ -36,6 +37,7 @@ export function buildConfig(pluginMaps: Record<string, TrvEslintPlugin>[]): read
36
37
  '@typescript-eslint': {
37
38
  rules: tsEslintPlugin.rules,
38
39
  },
40
+ 'unused-imports': unusedImports,
39
41
  ...(Object.fromEntries(plugins.map(x => [x.name, x])))
40
42
  },
41
43
  rules: {
@@ -52,7 +54,8 @@ export function buildConfig(pluginMaps: Record<string, TrvEslintPlugin>[]): read
52
54
  plugins: {
53
55
  '@stylistic': {
54
56
  rules: stylisticPlugin.rules
55
- }
57
+ },
58
+ 'unused-imports': unusedImports,
56
59
  },
57
60
  rules: {
58
61
  ...Object.fromEntries(Object.entries(STD_RULES).filter(x => !x[0].startsWith('@typescript'))),
@@ -70,6 +73,7 @@ export function buildConfig(pluginMaps: Record<string, TrvEslintPlugin>[]): read
70
73
  rules: {
71
74
  'max-len': 0,
72
75
  'no-unused-private-class-members': 0,
76
+ '@typescript-eslint/no-unused-vars': 0,
73
77
  '@typescript-eslint/explicit-function-return-type': 0
74
78
  }
75
79
  },
@@ -87,6 +91,7 @@ export function buildConfig(pluginMaps: Record<string, TrvEslintPlugin>[]): read
87
91
  files: ['**/test/**/*.ts', '**/test/**/*.tsx', '**/support/test/**/*.ts', '**/support/test/**/*.tsx'],
88
92
  ignores: [...IGNORES, 'module/test/src/**'],
89
93
  rules: {
94
+ '@typescript-eslint/no-unused-vars': 0,
90
95
  '@typescript-eslint/explicit-function-return-type': 0
91
96
  }
92
97
  },
@@ -63,7 +63,11 @@ export const STD_RULES = {
63
63
  'require-atomic-updates': 0,
64
64
  '@typescript-eslint/no-unused-vars': [
65
65
  'error',
66
- { varsIgnorePattern: '^(_|[A-Z])[A-Za-z0-9]*', args: 'none' }
66
+ {
67
+ varsIgnorePattern: '^(_|[A-Z])[A-Za-z0-9]*',
68
+ argsIgnorePattern: '^_',
69
+ args: 'after-used'
70
+ }
67
71
  ],
68
72
  '@stylistic/quotes': [
69
73
  'error',
@@ -203,6 +207,7 @@ export const STD_RULES = {
203
207
  'no-useless-escape': 0,
204
208
  'no-unused-expressions': 0,
205
209
  'no-unused-labels': 'error',
210
+ 'unused-imports/no-unused-imports': 'error',
206
211
  'no-var': 'error',
207
212
  'object-shorthand': 'error',
208
213
  'prefer-const': 'error',
@@ -42,7 +42,7 @@ export class LintCommand implements CliCommandShape {
42
42
  files = [];
43
43
  }
44
44
 
45
- const res = await ExecUtil.getResult(spawn('npx', [
45
+ const result = await ExecUtil.getResult(spawn('npx', [
46
46
  'eslint',
47
47
  '--cache',
48
48
  '--cache-location', Runtime.toolPath('.eslintcache'),
@@ -55,6 +55,6 @@ export class LintCommand implements CliCommandShape {
55
55
  shell: false
56
56
  }), { catch: true });
57
57
 
58
- process.exitCode = res.code;
58
+ process.exitCode = result.code;
59
59
  }
60
60
  }
@@ -3,19 +3,19 @@ import fs from 'node:fs/promises';
3
3
  import { CliCommandShape, CliCommand } from '@travetto/cli';
4
4
  import { Runtime } from '@travetto/runtime';
5
5
 
6
- import { buildEslintConfig } from './bin/eslint-config-file';
6
+ import { buildEslintConfig } from './bin/eslint-config-file.ts';
7
7
 
8
8
  /**
9
9
  * Writes the lint configuration file
10
10
  */
11
- @CliCommand()
11
+ @CliCommand({})
12
12
  export class LintConfigureCommand implements CliCommandShape {
13
13
 
14
14
  async main(): Promise<void> {
15
15
  const content = await buildEslintConfig();
16
- const output = Runtime.workspaceRelative('eslint.config.js');
16
+ const ext = Runtime.workspace.type === 'commonjs' ? '.cjs' : '.mjs';
17
+ const output = Runtime.workspaceRelative(`eslint.config${ext}`);
17
18
  await fs.writeFile(output, content.replaceAll(Runtime.workspace.path, '.').trim());
18
-
19
19
  console.log(`Wrote eslint config to ${output}`);
20
20
  }
21
21
  }