forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.changed.config.mjs
More file actions
111 lines (102 loc) · 4.46 KB
/
eslint.changed.config.mjs
File metadata and controls
111 lines (102 loc) · 4.46 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
import {defineConfig} from 'eslint/config';
import mainConfig from './eslint.config.mjs';
const restrictedIconImportPaths = [
{
name: '@components/Icon/Illustrations',
message:
'Direct imports from @components/Icon/Illustrations are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyIllustrations` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details.',
},
{
name: '@components/Icon/Expensicons',
message:
'Direct imports from @components/Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details.',
},
];
const restrictedIconImportPatterns = [
{
group: ['**/Icon/Illustrations', '**/components/Icon/Illustrations'],
message:
'Direct imports from Icon/Illustrations are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyIllustrations` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details.',
},
{
group: ['**/Icon/Expensicons', '**/components/Icon/Expensicons'],
message:
'Direct imports from Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details.',
},
];
const restrictedReportNameImportPatterns = [
{
group: ['**/ReportNameUtils', '**/libs/ReportNameUtils'],
importNames: ['computeReportName'],
message: 'Do not import computeReportName. Use getReportName instead, which properly uses derived report attributes.',
},
];
const config = defineConfig([
...mainConfig,
{
files: ['**/*.ts', '**/*.tsx'],
rules: {
'@typescript-eslint/no-deprecated': 'error',
'rulesdir/no-default-id-values': 'error',
'rulesdir/no-unstable-hook-defaults': 'error',
'no-restricted-syntax': [
'error',
{
selector: 'ImportNamespaceSpecifier[parent.source.value=/^@libs/]',
message: 'Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"',
},
{
selector: 'ImportNamespaceSpecifier[parent.source.value=/^@userActions/]',
message: 'Namespace imports from @userActions are not allowed. Use named imports instead. Example: import { action } from "@userActions/module"',
},
{
selector:
'JSXElement[openingElement.name.name=/^Pressable(WithoutFeedback|WithFeedback|WithDelayToggle|WithoutFocus)$/]:not(:has(JSXAttribute[name.name="sentryLabel"]))',
message: 'All Pressable components must include sentryLabel prop for Sentry tracking. Example: <PressableWithoutFeedback sentryLabel="MoreMenu-ExportFile" />',
},
],
},
},
{
files: ['**/*.ts', '**/*.tsx'],
ignores: ['**/libs/**/*.{ts,tsx}'],
rules: {
'no-restricted-imports': [
'warn',
{
paths: restrictedIconImportPaths,
patterns: restrictedIconImportPatterns,
},
],
},
},
{
files: ['**/*.ts', '**/*.tsx'],
ignores: ['src/libs/actions/OnyxDerived/configs/reportAttributes.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: restrictedReportNameImportPatterns,
},
],
},
},
{
files: ['**/libs/**/*.{ts,tsx}'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: 'ImportNamespaceSpecifier[parent.source.value=/^\\.\\./]',
message: 'Namespace imports are not allowed. Use named imports instead. Example: import { method } from "../libs/module"',
},
{
selector: 'ImportNamespaceSpecifier[parent.source.value=/^\\./]',
message: 'Namespace imports are not allowed. Use named imports instead. Example: import { method } from "./libs/module"',
},
],
},
},
]);
export default config;