-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy patheslint.config.mjs
More file actions
127 lines (121 loc) · 3.08 KB
/
eslint.config.mjs
File metadata and controls
127 lines (121 loc) · 3.08 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
122
123
124
125
126
127
import globals from 'globals';
import pluginJs from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';
import path from 'path';
import { fileURLToPath } from 'url';
import prettier from 'eslint-plugin-prettier';
import prettierConfig from 'eslint-config-prettier';
import noUnknownValuedMapsRule from './.eslint-rules/no-unknown-valued-maps.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: pluginJs.configs.recommended,
});
const localRulesPlugin = {
rules: {
'no-unknown-valued-maps': noUnknownValuedMapsRule,
},
};
/** @type {import('eslint').Linter.Config[]} */
export default [
// Base config for all JS files
{
languageOptions: {
globals: { ...globals.browser, ...globals.node },
ecmaVersion: 2021,
sourceType: 'module',
parser: '@typescript-eslint/parser',
parserOptions: {
projectService: true,
tsconfigRootDir: __dirname,
},
},
},
// JS recommended configs
pluginJs.configs.recommended,
// Use the compatibility layer to load the TypeScript plugin and recommended rules
...compat.extends('plugin:@typescript-eslint/recommended-type-checked'),
// Disable ESLint rules that conflict with Prettier
prettierConfig,
// Add Prettier plugin
{
plugins: {
prettier,
local: localRulesPlugin,
},
rules: {
'prettier/prettier': [
'error',
{
trailingComma: 'all',
tabWidth: 2,
semi: true,
singleQuote: true,
useTabs: true,
printWidth: 120,
bracketSpacing: true,
arrowParens: 'always',
endOfLine: 'lf',
},
],
},
},
// Add custom rules for TypeScript
{
files: ['src/**/*.ts'],
rules: {
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-explicit-any': ['off'],
'@typescript-eslint/no-unsafe-assignment': ['error'],
'@typescript-eslint/no-unsafe-argument': ['error'],
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
'@typescript-eslint/require-await': ['off'],
'local/no-unknown-valued-maps': ['error'],
'no-restricted-syntax': [
'error',
{
selector: 'TSImportType',
message: 'Inline import() types are not allowed. Use a top-level import statement instead.',
},
],
},
},
// Add Jest environment for test files
{
files: ['src/**/*.spec.ts', 'src/**/*.test.ts', 'tests/**/*.ts', 'jest.e2e.config.ts'],
languageOptions: {
globals: {
...globals.jest,
describe: 'readonly',
it: 'readonly',
expect: 'readonly',
jest: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
global: 'readonly',
},
},
},
// Ignores
{
ignores: [
'.eslint-rules/**',
'src/**/*.spec.ts',
'src/**/*.test.ts',
'tests/**/*.ts',
'jest.e2e.config.ts',
'**/node_modules/**',
'dist/*',
'smart-contracts/*',
'frontend/*',
'eslint.config.mjs',
'frontend/*',
'commitlint.config.js',
'jest.config.ts',
'prisma/*',
],
},
];