-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
eslint.config.js
138 lines (130 loc) · 5.27 KB
/
eslint.config.js
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
128
129
130
131
132
133
134
135
136
137
138
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import eslint from '@eslint/js';
import nextPlugin from '@next/eslint-plugin-next';
import reactPlugin from 'eslint-plugin-react';
import sonarjs from 'eslint-plugin-sonarjs';
import unicorn from 'eslint-plugin-unicorn';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import tseslint from 'typescript-eslint';
// mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname
});
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs['recommendedTypeChecked'],
...compat.plugins('import', 'react-hooks', 'simple-import-sort'),
unicorn.configs['flat/recommended'],
sonarjs.configs.recommended,
...compat.extends('plugin:import/recommended'),
...compat.extends('plugin:import/typescript'),
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'],
{
plugins: {
'@next/next': fixupPluginRules(nextPlugin)
},
settings: {
react: {
version: 'detect'
},
'import/resolver': {
typescript: true
},
next: {
rootDir: ['/builds', '/golf', '/paste', '/main-site']
}
},
languageOptions: {
ecmaVersion: 2024,
sourceType: 'module',
parser: tseslint.parser,
parserOptions: {
projectService: true
}
},
rules: {
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs['core-web-vitals'].rules,
...fixupConfigRules(
compat.extends('plugin:react-hooks/recommended')[0]
).rules,
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// React
'react/prop-types': 'off',
'react/no-unescaped-entities': 'off',
'react/no-unstable-nested-components': 'error',
'react/no-object-type-as-default-prop': 'error',
// TypeScript
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/no-var-requires': 'warn',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' }
],
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' }
],
'@typescript-eslint/consistent-type-exports': [
'error',
{ fixMixedExportsWithInlineTypeSpecifier: true }
],
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/unbound-method': 'off',
// Imports
'import/no-duplicates': 'error',
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'import/namespace': 'off',
'import/default': 'off',
'simple-import-sort/imports': [
'error',
{
groups: [
// Side effect imports.
[String.raw`^\u0000`],
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
[String.raw`^@?\w`],
// Local imports.
['@enginehub/'],
// Relative imports.
[String.raw`^\.`]
]
}
],
'sonarjs/no-duplicate-string': 'off',
// Unicorn rules
'unicorn/filename-case': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/prefer-add-event-listener': 'off',
'unicorn/prefer-ternary': 'off',
'unicorn/no-null': 'off',
'unicorn/prefer-node-protocol': 'off',
'unicorn/catch-error-name': 'off',
'unicorn/prefer-module': 'off',
'unicorn/no-empty-file': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/no-useless-undefined': 'warn',
'unicorn/prefer-string-replace-all': 'error',
'unicorn/no-abusive-eslint-disable': 'off',
'unicorn/no-array-reduce': 'off'
}
}
);