-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
90 lines (87 loc) · 2.54 KB
/
eslint.config.mjs
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
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { includeIgnoreFile } from '@eslint/compat'
import eslint from '@eslint/js'
import jsxA11y from 'eslint-plugin-jsx-a11y'
import pluginReact from 'eslint-plugin-react'
import pluginSimpleImportSort from 'eslint-plugin-simple-import-sort'
import globals from 'globals'
import tseslint from 'typescript-eslint'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const gitignorePath = path.resolve(__dirname, '.gitignore')
const importSortConfig = [
'warn',
{
groups: [
// Packages `node` or `react` related packages come first.
['^node:', '^react-?(dom|native)?$', '^@?\\w'],
// Internal packages.
['^@/(screens|navigation|containers)(/.*|$)'],
['^@/modules(/.*|$)'],
['^@/components(/.*|$)'],
['^@/(lib|utils)(/.*|$)'],
['^@(/.*|$)'],
// Side effect imports.
['^\\u0000'],
// Parent imports. Put `..` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
// Other relative imports. Put same-folder imports and `.` last.
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// Style imports.
['^.+\\.?(css)$'],
],
},
]
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export default [
includeIgnoreFile(gitignorePath),
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
globals: globals.browser,
parserOptions: {
projectService: true,
ecmaFeatures: { jsx: true },
tsconfigRootDir: import.meta.dirname,
},
},
settings: {
react: {
version: 'detect',
},
},
},
jsxA11y.flatConfigs.strict,
pluginReact.configs.flat['jsx-runtime'],
{
rules: {
'no-magic-numbers': ['warn', { ignore: [-1, 0, 1, 2] }],
'no-console': 'warn',
'react/jsx-no-useless-fragment': 'warn',
'react/jsx-key': 'error',
'react/jsx-boolean-value': ['warn', 'never'],
'react/jsx-no-leaked-render': 'error',
'react/function-component-definition': [
'warn',
{ namedComponents: 'function-declaration' },
],
'@typescript-eslint/no-misused-promises': [
'error',
{ checksVoidReturn: false },
],
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{ fixStyle: 'separate-type-imports' },
],
'simple-import-sort/imports': importSortConfig,
},
plugins: {
'simple-import-sort': pluginSimpleImportSort,
},
},
]