Skip to content

Commit ed08bf5

Browse files
committed
feat: add format-generated Makefile rule with ESLint flat config
1 parent 5716934 commit ed08bf5

File tree

4 files changed

+154
-4
lines changed

4 files changed

+154
-4
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ format:
1414
format-check:
1515
pnpm run format:check
1616

17+
format-generated:
18+
pnpm eslint --config eslint.config.generated.mjs --fix packages_generated/**/*.ts
19+
pnpm biome check --linter-enabled=false --write packages_generated/
20+
1721
typing:
1822
pnpm run typecheck
1923

eslint.config.generated.mjs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// ESLint flat config for GENERATED code (packages_generated/)
2+
// More permissive rules suitable for generated TypeScript files
3+
4+
import typescriptParser from '@typescript-eslint/parser'
5+
import typescriptPlugin from '@typescript-eslint/eslint-plugin'
6+
import importPlugin from 'eslint-plugin-import'
7+
import unusedImports from 'eslint-plugin-unused-imports'
8+
9+
export default [
10+
{
11+
files: ['packages_generated/**/*.ts'],
12+
ignores: [
13+
'packages_generated/**/vite.config.ts',
14+
'packages_generated/**/dist/**',
15+
],
16+
languageOptions: {
17+
parser: typescriptParser,
18+
parserOptions: {
19+
ecmaVersion: 'latest',
20+
sourceType: 'module',
21+
},
22+
},
23+
plugins: {
24+
'@typescript-eslint': typescriptPlugin,
25+
'import': importPlugin,
26+
'unused-imports': unusedImports,
27+
},
28+
settings: {
29+
'import/resolver': {
30+
node: {
31+
extensions: ['.ts', '.tsx', '.js', '.jsx'],
32+
},
33+
},
34+
},
35+
rules: {
36+
// CRITICAL: Disable base rules first (required for unused-imports plugin)
37+
'no-unused-vars': 'off',
38+
'@typescript-eslint/no-unused-vars': 'off',
39+
40+
// Code optimization
41+
'object-shorthand': ['error', 'always'],
42+
'arrow-body-style': ['error', 'as-needed'],
43+
44+
// Import management (unused-imports plugin)
45+
'unused-imports/no-unused-imports': 'error',
46+
'unused-imports/no-unused-vars': ['warn', {
47+
vars: 'all',
48+
args: 'all',
49+
argsIgnorePattern: 'defaults|request',
50+
}],
51+
'sort-imports': ['error', {
52+
ignoreDeclarationSort: true,
53+
}],
54+
'import/order': ['error', {
55+
alphabetize: { order: 'asc' },
56+
}],
57+
58+
// Disable strict rules for generated code
59+
'@typescript-eslint/ban-types': 'off',
60+
'@typescript-eslint/no-empty-interface': 'off',
61+
'@typescript-eslint/no-unused-vars': 'off',
62+
'@typescript-eslint/no-explicit-any': 'off',
63+
'no-useless-escape': 'off',
64+
'import/no-unresolved': 'off',
65+
},
66+
},
67+
]
68+

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@
7474
"cz-conventional-changelog": "3.3.0",
7575
"esbuild-plugin-browserslist": "1.0.1",
7676
"eslint": "9.33.0",
77+
"eslint-plugin-import": "^2.32.0",
7778
"eslint-plugin-tsdoc": "0.4.0",
79+
"eslint-plugin-unused-imports": "^4.2.0",
7880
"husky": "9.1.7",
7981
"jsdom": "26.1.0",
8082
"lerna": "8.2.3",

pnpm-lock.yaml

Lines changed: 80 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)