Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
121 lines (116 loc) · 3.29 KB
/
Copy patheslint.config.js
File metadata and controls
121 lines (116 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// @ts-check
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked.map((config) => ({
...config,
files: ['**/src/**/*.ts', '**/src/**/*.tsx'],
})),
{
files: ['**/*.ts', '**/*.tsx'],
plugins: {
'@typescript-eslint': tseslint.plugin,
},
languageOptions: {
parser: tseslint.parser,
},
},
{
files: ['**/src/**/*.ts', '**/src/**/*.tsx'],
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
},
},
{
rules: {
// Imports / package boundaries
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['../../../*'],
message: 'Avoid deep relative imports across package boundaries. Use workspace package imports.',
},
],
},
],
// Code quality
'no-console': ['warn', { allow: ['warn', 'error'] }],
},
},
{
// Rules applied to all TypeScript files (non-type-aware)
files: ['**/*.ts', '**/*.tsx'],
rules: {
// Correctness
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
'no-unused-vars': 'off',
'no-undef': 'off',
// Code quality
'@typescript-eslint/consistent-type-imports': ['warn', { prefer: 'type-imports', fixStyle: 'inline-type-imports' }],
'prefer-const': 'warn',
},
},
{
// Type-aware rules applied only to TypeScript source files under src/
files: ['**/src/**/*.ts', '**/src/**/*.tsx'],
rules: {
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/await-thenable': 'warn',
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/consistent-type-exports': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/only-throw-error': 'off',
},
},
{
// Test files — relax some rules
files: ['**/*.test.ts', '**/*.spec.ts', '**/test/**/*.ts', 'tests/**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-unused-vars': 'off',
'no-console': 'off',
},
},
{
// Scripts — relax type-checked rules
files: ['scripts/**/*.mjs', 'scripts/**/*.js'],
...tseslint.configs.disableTypeChecked,
languageOptions: {
globals: {
console: 'readonly',
process: 'readonly',
},
},
rules: {
'no-console': 'off',
},
},
{
// Ignore generated/build output
ignores: [
'**/dist/**',
'**/.ranu/**',
'**/.vercel/**',
'**/coverage/**',
'**/node_modules/**',
'**/*.d.ts',
'pnpm-lock.yaml',
],
},
);