-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
135 lines (125 loc) · 3.28 KB
/
Copy patheslint.config.js
File metadata and controls
135 lines (125 loc) · 3.28 KB
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
import { includeIgnoreFile } from '@eslint/compat';
import tsParser from '@typescript-eslint/parser';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import importPlugin from 'eslint-plugin-import';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import noRelativeImportPaths from 'eslint-plugin-no-relative-import-paths';
import pluginReact from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import tseslint from 'typescript-eslint';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, '.gitignore');
export default tseslint.config([
// Ignore files
includeIgnoreFile(gitignorePath),
{
ignores: ['eslint.config.js'],
},
// Typescript config
{
files: ['**/*.{ts,tsx}'],
extends: [tseslint.configs.recommendedTypeChecked],
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ['*.js'],
},
tsconfigRootDir: import.meta.dirname,
},
parser: tsParser,
},
rules: {
'prefer-promise-reject-errors': ['error'],
'no-console': 'warn',
'no-else-return': 'error',
'@typescript-eslint/only-throw-error': [
'error',
{
allow: ['Response'],
},
],
'@typescript-eslint/no-non-null-assertion': ['error'],
'@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
},
},
// React
{
files: ['**/*.{ts,tsx}'],
extends: [
pluginReact.configs.flat.recommended,
pluginReact.configs.flat['jsx-runtime'],
],
settings: { react: { version: 'detect' } },
languageOptions: { globals: globals.browser },
rules: {
'react/prop-types': 'off',
'react/no-unknown-property': [
'error',
{ ignore: ['vaul-drawer-wrapper'] },
],
},
},
// React Hooks
{
files: ['**/*.{ts,tsx}'],
plugins: {
'react-hooks': reactHooks,
},
rules: {
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
// Node
{
files: ['server.js', 'entry.server.tsx'],
languageOptions: {
globals: globals.node,
parser: tsParser,
},
},
// Imports resolve correctly
{
files: ['**/*.{ts,tsx,js}'],
extends: [
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.react,
importPlugin.flatConfigs.typescript,
],
settings: {
'import/resolver': {
typescript: {
project: path.resolve(__dirname, 'tsconfig.json'),
},
node: {
paths: ['.', '.react-router/types'],
},
},
},
rules: {
'import/no-unresolved': ['error', { ignore: ['^~icons/', '^virtual:'] }],
},
},
// A11y
{
files: ['**/*.{ts,tsx}'],
extends: [jsxA11y.flatConfigs.recommended],
},
// No relative import paths
{
files: ['**/*.{ts,tsx,js}'],
plugins: {
'no-relative-import-paths': noRelativeImportPaths,
},
rules: {
'no-relative-import-paths/no-relative-import-paths': 'error',
},
},
// Prettier
eslintConfigPrettier,
]);