-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.js
132 lines (129 loc) · 3.79 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
const { resolve } = require('node:path');
const { JAVASCRIPT_FILES } = require('@vercel/style-guide/eslint/constants');
const project = resolve(__dirname, 'tsconfig.json');
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
extends: [
require.resolve('@vercel/style-guide/eslint/browser'),
require.resolve('@vercel/style-guide/eslint/node'),
require.resolve('@vercel/style-guide/eslint/react'),
require.resolve('@vercel/style-guide/eslint/next'),
require.resolve('@vercel/style-guide/eslint/typescript'),
],
parserOptions: { project },
plugins: ['react-compiler'],
settings: {
'import/resolver': { typescript: { project } },
/**
* enable MUI Joy components to be checked
* @see {@link https://github.com/jsx-eslint/eslint-plugin-jsx-a11y?tab=readme-ov-file#configurations}
*/
'jsx-a11y': {
polymorphicPropName: 'component',
components: {
Button: 'button',
IconButton: 'button',
Image: 'img',
Input: 'input',
Link: 'a',
List: 'ul',
ListDivider: 'li',
ListItem: 'li',
ListItemButton: 'button',
NextImage: 'img',
NextLink: 'a',
Textarea: 'textarea',
},
},
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-confusing-void-expression': [
'error',
{ ignoreArrowShorthand: true },
],
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/no-misused-promises': [
'error',
{ checksVoidReturn: { attributes: false } },
],
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowAny: false,
allowBoolean: false,
allowNullish: false,
allowRegExp: false,
allowNever: false,
},
],
'react/function-component-definition': [
'warn',
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],
'react/jsx-sort-props': [
'warn',
{
callbacksLast: true,
shorthandFirst: true,
multiline: 'last',
reservedFirst: true,
},
],
'react-compiler/react-compiler': 'error',
// sort import statements
'import/order': [
'warn',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
],
'newlines-between': 'always',
alphabetize: { order: 'asc' },
},
],
// sort named imports within an import statement
'sort-imports': ['warn', { ignoreDeclarationSort: true }],
},
overrides: [
/**
* JS files are using @babel/eslint-parser, so typed linting doesn't work there.
* @see {@link https://github.com/vercel/style-guide/blob/canary/eslint/_base.js}
* @see {@link https://typescript-eslint.io/linting/typed-linting#how-can-i-disable-type-aware-linting-for-a-subset-of-files}
*/
{
files: JAVASCRIPT_FILES,
extends: ['plugin:@typescript-eslint/disable-type-checked'],
},
// Varies file convention from libraries, e.g. Next.js App Router and Prettier
// Must use default export
{
files: [
'*.config.{mjs,ts}',
'src/app/**/{page,layout,not-found,*error,opengraph-image,apple-icon}.tsx',
'src/app/**/{sitemap,robots}.ts',
],
rules: {
'import/no-default-export': 'off',
'import/prefer-default-export': ['error', { target: 'any' }],
},
},
{
files: ['**/*.d.ts', 'src/components/emails/*.tsx'],
rules: { 'import/no-default-export': 'off' },
},
{
files: ['src/app/**/apple-icon.tsx', 'src/app/**/opengraph-image.tsx'],
rules: { '@next/next/no-img-element': 'off', 'jsx-a11y/alt-text': 'off' },
},
],
};