-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheslint.config.js
159 lines (144 loc) · 3.59 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
const { resolve } = require('node:path');
const globals = require('globals');
const pluginNext = require('@next/eslint-plugin-next');
const pluginReact = require('eslint-plugin-react');
const pluginReactHooks = require('eslint-plugin-react-hooks');
const parserTypeScript = require('@typescript-eslint/parser');
const pluginImport = require('eslint-plugin-import');
const pluginPrettier = require('eslint-plugin-prettier/recommended');
const pluginTypeScript = require('@typescript-eslint/eslint-plugin');
const tsconfigPath = resolve(process.cwd(), 'tsconfig.json');
/** @type {Array<import('eslint').Linter.FlatConfig>} */
module.exports = [
{
ignores: ['**/.next', '**/out/', '**/*.{js,json,md,mjs,scss}'],
},
{
plugins: {
'@typescript-eslint': pluginTypeScript,
'import': pluginImport,
},
},
{
languageOptions: {
parser: parserTypeScript,
parserOptions: {
project: tsconfigPath,
},
},
settings: {
'import/resolver': {
typescript: {
project: tsconfigPath,
},
},
},
},
{
files: ['**/*.{ts,tsx}'],
rules: {
// Enforce consistent usage of type imports
'@typescript-eslint/consistent-type-imports': 'error',
// Enforce shorthand boolean component properties
'react/jsx-boolean-value': ['error', 'never'],
// Ensure component properties are alphabetically sorted with callbacks being last
'react/jsx-sort-props': [
'error',
{
callbacksLast: true,
},
],
// Ensure the `type` keyword is always outside the import braces
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
// Enforce consistent import order
'import/order': [
'error',
{
'alphabetize': {
caseInsensitive: true,
order: 'asc',
},
'groups': [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
],
'pathGroups': [
{
pattern: '{.,..}/types',
group: 'object',
position: 'after',
},
{
pattern: '*.{jpg,jpeg,gif,png,svg}',
group: 'object',
patternOptions: {
matchBase: true,
},
position: 'after',
},
{
pattern: '*.{css,scss}',
group: 'object',
patternOptions: {
matchBase: true,
},
position: 'after',
},
],
'newlines-between': 'never',
},
],
},
},
{
languageOptions: {
globals: {
...globals.es2021,
...globals.jest,
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
},
{
languageOptions: {
globals: {
...globals.es2021,
...globals.jest,
...globals.node,
},
},
},
{
plugins: {
'react-hooks': pluginReactHooks,
},
rules: pluginReactHooks.configs.recommended.rules,
},
{
plugins: {
react: pluginReact,
},
rules: pluginReact.configs['jsx-runtime'].rules,
},
{
plugins: {
'@next/next': pluginNext,
},
rules: {
...pluginNext.configs.recommended.rules,
...pluginNext.configs['core-web-vitals'].rules,
'@next/next/no-img-element': 'off',
},
},
// Include Prettier validation in the linting pipeline
pluginPrettier,
];