-
Notifications
You must be signed in to change notification settings - Fork 9
/
.eslintrc.js
160 lines (151 loc) · 3.74 KB
/
.eslintrc.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
160
/* eslint-disable @typescript-eslint/no-require-imports */
const jestVersion = require('jest/package.json').version
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'next/core-web-vitals',
'plugin:@typescript-eslint/recommended',
'plugin:@tanstack/eslint-plugin-query/recommended',
'prettier',
],
plugins: ['unicorn'],
settings: {
'import/internal-regex': '^(@app-|~)',
jest: {
version: jestVersion,
},
},
rules: {
// Base
'no-shadow': 'error',
'no-warning-comments': 'off',
'no-console': 'warn', // doesn't seem to be enabled in any preset
'no-restricted-imports': [
'error',
{
name: '@testing-library/react',
message: 'Please import from `test-utils` instead.',
},
{
name: 'next/router',
message: 'Please import from `next/navigation` instead.',
},
{
name: '@chakra-ui/next-js',
importNames: ['Link'],
message: 'Please import from `ChakraNextLink` instead.',
},
],
// React
'react/self-closing-comp': 'error',
'react/react-in-jsx-scope': 'off',
'react/jsx-boolean-value': 'error',
'react/no-unknown-property': 'off', // started to report many weird errors recently
// Import
'import/newline-after-import': 'error',
'import/order': [
'error',
{
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: false,
},
pathGroups: [
{
pattern: '@/**',
group: 'external',
position: 'after',
},
],
},
],
'import/group-exports': 'error',
'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
// Unicorn
'unicorn/no-for-loop': 'error',
'unicorn/no-array-for-each': 'error',
'unicorn/no-array-reduce': 'error',
},
overrides: [
// TypeScript
{
files: ['**/*.ts?(x)'],
parserOptions: {
tsconfigRootDir: __dirname,
projectService: {
allowDefaultProject: ['*.js'],
defaultProject: './tsconfig.json',
},
},
/*
* Linting with Type Information only for TS files:
* https://typescript-eslint.io/docs/linting/typed-linting/#i-get-errors-telling-me-the-file-must-be-included-in-at-least-one-of-the-projects-provided
*/
extends: [
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
],
rules: {
'@typescript-eslint/array-type': [
'warn',
{
default: 'generic',
},
],
'@typescript-eslint/consistent-type-exports': [
'error',
{
fixMixedExportsWithInlineTypeSpecifier: true,
},
],
'@typescript-eslint/consistent-type-imports': [
'error',
{
fixStyle: 'inline-type-imports',
},
],
// Disabling because of index errors on interfaces,
// which works fine in type aliases:
// https://bobbyhadz.com/blog/typescript-index-signature-for-type-is-missing-in-type
'@typescript-eslint/consistent-type-definitions': 'off',
// Disabling because it's too strict:
// we are interested in using || operator multiple times to avoid empty strings.
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/unbound-method': 'off',
},
},
// Next.js
{
files: ['src/app/**/*.[jt]s?(x)'],
rules: {
'import/group-exports': 'off',
},
},
// Jest
{
files: [
'src/**/__tests__/**/*.[jt]s?(x)',
'src/**/?(*.)+(spec|test).[jt]s?(x)',
'src/setup-tests.ts',
],
extends: [
'plugin:jest/recommended',
'plugin:jest/style',
'plugin:jest-formatting/recommended',
],
rules: {
'jest/consistent-test-it': 'warn',
},
},
// Cypress
{
files: ['cypress/**/*.[jt]s'],
extends: ['plugin:cypress/recommended'],
rules: {
'jest/no-focused-tests': 'error',
},
},
],
}