|
1 | | -// Flat ESLint config (ESLint v9+). Replaces the old .eslintrc + `--ext` flow, |
2 | | -// which ESLint v9 removed. TypeScript is linted via the typescript-eslint |
3 | | -// plugin's `flat/recommended` preset, which bundles the parser, the plugin, and |
4 | | -// a non-type-checked rule set (fast, low false-positive noise). |
5 | | -import tseslint from '@typescript-eslint/eslint-plugin'; |
6 | | -import tsparser from '@typescript-eslint/parser'; |
| 1 | +// ESLint flat config for the backend (Bun + Hono + TypeScript). |
| 2 | +// |
| 3 | +// ESLint 9+ no longer reads `.eslintrc.*`; this flat config is the replacement. |
| 4 | +// The package is CommonJS (no `"type": "module"`), so this file uses the `.mjs` |
| 5 | +// extension to be loaded as ESM. |
| 6 | +import tseslint from '@typescript-eslint/eslint-plugin' |
7 | 7 |
|
8 | 8 | export default [ |
9 | | - // Only application source is linted (mirrors the previous `eslint src` scope). |
10 | | - { |
11 | | - ignores: ['dist/**', 'node_modules/**', '*.config.*', 'coverage/**'], |
12 | | - }, |
| 9 | + // Build artifacts, compiled binaries, and generated output are never linted. |
| 10 | + { ignores: ['dist/**', 'build/**', 'coverage/**'] }, |
13 | 11 |
|
14 | | - // typescript-eslint's flat/recommended turns off core rules that clash with |
15 | | - // TS (e.g. no-undef), wires up the parser, and enables the recommended rules. |
| 12 | + // typescript-eslint's recommended flat config wires up the TS parser, the |
| 13 | + // `@typescript-eslint` plugin, and a sensible rule set. It also turns off |
| 14 | + // core rules (e.g. `no-undef`) that TypeScript already enforces, so we don't |
| 15 | + // need the `globals` package for Node/Bun globals like `process` or `Bun`. |
16 | 16 | ...tseslint.configs['flat/recommended'], |
17 | 17 |
|
18 | 18 | { |
19 | | - files: ['src/**/*.ts'], |
20 | | - languageOptions: { |
21 | | - parser: tsparser, |
22 | | - ecmaVersion: 'latest', |
23 | | - sourceType: 'module', |
24 | | - }, |
| 19 | + files: ['**/*.ts'], |
25 | 20 | rules: { |
26 | | - // Pre-existing debt: this codebase predates any ESLint config (the v8→v10 |
27 | | - // bump first introduced one), so `recommended` surfaces ~120 historical |
28 | | - // violations of these two rules — none in newly-written code. Demote them |
29 | | - // to warnings so lint is green and CI-usable today, while still surfacing |
30 | | - // the backlog for incremental burndown. Promote back to "error" once the |
31 | | - // existing hits are cleared. |
32 | | - '@typescript-eslint/no-explicit-any': 'warn', |
33 | | - '@typescript-eslint/no-unused-vars': 'warn', |
| 21 | + // Allow intentionally-unused identifiers when prefixed with `_` |
| 22 | + // (e.g. unused function params kept for signature/positional reasons). |
| 23 | + '@typescript-eslint/no-unused-vars': [ |
| 24 | + 'error', |
| 25 | + { |
| 26 | + argsIgnorePattern: '^_', |
| 27 | + varsIgnorePattern: '^_', |
| 28 | + caughtErrorsIgnorePattern: '^_', |
| 29 | + }, |
| 30 | + ], |
34 | 31 | }, |
35 | 32 | }, |
36 | | -]; |
| 33 | +] |
0 commit comments