-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
105 lines (104 loc) · 2.94 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
import tsEslint from 'typescript-eslint';
import eslint from '@eslint/js';
import importPlugin from 'eslint-plugin-import';
import configPrettier from 'eslint-config-prettier';
import globals from 'globals';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import tanstackQueryPlugin from '@tanstack/eslint-plugin-query';
import boundariesPlugin from 'eslint-plugin-boundaries';
export default tsEslint.config(
{ ignores: ['build', 'dist', 'eslint.config.js'] },
{
extends: [
eslint.configs.recommended,
...tsEslint.configs.recommended,
importPlugin.flatConfigs.recommended,
configPrettier,
],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2023,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooksPlugin,
'@tanstack/query': tanstackQueryPlugin,
boundaries: boundariesPlugin,
},
settings: {
'boundaries/elements': [
{
type: 'global',
pattern: 'src/!(features)/**',
mode: 'full',
},
{
type: 'publicFeature',
pattern: 'src/features/*/index.*',
mode: 'full',
capture: ['featureName'],
},
{
type: 'privateFeature',
pattern: 'src/features/*/!(index.*)/**',
mode: 'full',
capture: ['featureName'],
},
],
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.app.json',
},
},
},
/**
* Here you can impose custom eslint rules that you want to be followed across the app.
* The following rules are the minimum that I would recommend.
*/
rules: {
...reactHooksPlugin.configs.recommended.rules,
...tanstackQueryPlugin.configs.recommended.rules,
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['axios'],
message: 'Please use axiosProvider.',
},
{
group: ['**/./**', '**/../**', '!./*.scss'],
message: 'Relative imports are not allowed.',
},
],
},
],
'boundaries/element-types': [
2,
{
default: 'allow',
rules: [
{
from: ['global'],
disallow: ['privateFeature'],
message: 'Cannot import private modules from a feature. Use the public export.',
},
{
from: ['publicFeature', 'privateFeature'],
disallow: [['privateFeature', { featureName: '!${featureName}' }]],
message: 'Cannot import private modules from a different feature. Use the public export.',
},
],
},
],
'no-restricted-syntax': [
'error',
{
selector: 'ExportDefaultDeclaration',
message: 'Please use named exports',
},
],
},
},
);