-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
147 lines (143 loc) · 4.45 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
import path from 'path';
import { fileURLToPath } from 'url';
import eslintComments from '@eslint-community/eslint-plugin-eslint-comments/configs';
import { FlatCompat } from '@eslint/eslintrc';
import eslint from '@eslint/js';
import nextPlugin from '@next/eslint-plugin-next';
import prettierConfig from 'eslint-config-prettier';
import eslintPluginImportX from 'eslint-plugin-import-x';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import react from '@eslint-react/eslint-plugin';
import reactHooks from 'eslint-plugin-react-hooks';
import tailwind from 'eslint-plugin-tailwindcss';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import perfectionist from 'eslint-plugin-perfectionist';
import jsdoc from 'eslint-plugin-jsdoc';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import vitest from '@vitest/eslint-plugin';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
export default tseslint.config(
{
ignores: [
'next-env.d.ts',
'.next/**',
'coverage/**',
'node_modules/**',
'eslint.config.js',
'lingui.config.js',
'next.config.mjs',
'postcss.config.mjs',
'src/infrastructure/database/models/database.types.ts', // This file is generated by Supabase
],
},
perfectionist.configs['recommended-natural'],
jsdoc.configs['flat/recommended-typescript-error'],
eslint.configs.recommended,
eslintComments.recommended,
eslintPluginImportX.flatConfigs.recommended,
eslintPluginImportX.flatConfigs.typescript,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
prettierConfig,
...tailwind.configs['flat/recommended'],
{
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
...react.configs.recommendedTypeChecked,
plugins: {
'@typescript-eslint': tseslint.plugin,
react,
'react-hooks': reactHooks,
'jsx-a11y': jsxA11y,
'@next/next': nextPlugin,
unicorn: eslintPluginUnicorn,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: import.meta.dirname,
},
globals: {
...globals.builtin,
...globals.browser,
},
ecmaVersion: 'latest',
sourceType: 'module',
},
settings: {
vitest: {
typecheck: true,
},
react: {
version: 'detect',
},
'import-x/parsers': {
'@typescript-eslint/parser': ['.ts', '.mts', '.cts', '.tsx', '.d.ts'],
},
'import-x/resolver': {
'eslint-import-resolver-node': {
name: 'node',
options: {
extensions: [
'.js',
'.mjs',
'.cjs',
'.jsx',
'.mjsx',
'.ts',
'.tsx',
'.mtsx',
],
},
},
'eslint-import-resolver-typescript': {
name: 'typescript',
options: {
alwaysTryTypes: true,
},
},
},
},
rules: {
...eslintPluginUnicorn.configs['flat/recommended'].rules,
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs['core-web-vitals'].rules,
...jsxA11y.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
// Allow custom CSS classes, we barely use them and they come from shadcn.
'tailwindcss/no-custom-classname': 0,
// Allow using null, as it is a valid value in TypeScript and is standard in multiple libraries.
'unicorn/no-null': 0,
// Require an explanation for disabled rules.
'@eslint-community/eslint-comments/require-description': 2,
// There's a tendency to just repeat the names of parameters in JSDoc comments, so check for that.
'jsdoc/informative-docs': 2,
// Try to enforce a consistent order for JSDoc descriptions.
'jsdoc/require-description-complete-sentence': 2,
// We use arrow functions to handle form submissions, and moving them out of the component breaks the submission.
'unicorn/consistent-function-scoping': [
2,
{ checkArrowFunctions: false },
],
},
},
{
files: ['**/components/ui/*.tsx'],
rules: {},
},
{
// Rules for test files.
files: ['**/*.spec.{js,ts}'],
plugins: {
vitest,
},
rules: {
...vitest.configs.recommended.rules,
},
},
);