forked from langgenius/dify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
147 lines (143 loc) · 4.11 KB
/
eslint.config.mjs
File metadata and controls
147 lines (143 loc) · 4.11 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
136
137
138
139
140
141
142
143
144
145
146
147
// @ts-check
import antfu from '@antfu/eslint-config'
import pluginQuery from '@tanstack/eslint-plugin-query'
import sonar from 'eslint-plugin-sonarjs'
import storybook from 'eslint-plugin-storybook'
import tailwind from 'eslint-plugin-tailwindcss'
import difyI18n from './eslint-rules/index.js'
export default antfu(
{
react: {
// This react compiler rules are pretty slow
// We can wait for https://github.com/Rel1cx/eslint-react/issues/1237
reactCompiler: false,
overrides: {
'react/no-context-provider': 'off',
'react/no-forward-ref': 'off',
'react/no-use-context': 'off',
// prefer react-hooks-extra/no-direct-set-state-in-use-effect
'react-hooks/set-state-in-effect': 'off',
'react-hooks-extra/no-direct-set-state-in-use-effect': 'error',
},
},
nextjs: true,
ignores: ['public', 'types/doc-paths.ts'],
typescript: {
overrides: {
'ts/consistent-type-definitions': ['error', 'type'],
'ts/no-explicit-any': 'error',
},
},
test: {
overrides: {
'test/prefer-lowercase-title': 'off',
},
},
stylistic: {
overrides: {
'antfu/top-level-function': 'off',
},
},
},
{
rules: {
'node/prefer-global/process': 'off',
},
},
{
files: ['**/*.ts', '**/*.tsx'],
settings: {
'react-x': {
additionalStateHooks: '/^use\\w*State(?:s)?|useAtom$/u',
},
},
},
storybook.configs['flat/recommended'],
...pluginQuery.configs['flat/recommended'],
// sonar
{
rules: {
// Manually pick rules that are actually useful and not slow.
// Or we can just drop the plugin entirely.
},
plugins: {
sonarjs: sonar,
},
},
tailwind.configs['flat/recommended'],
{
settings: {
tailwindcss: {
// These are the default values but feel free to customize
callees: ['classnames', 'clsx', 'ctl', 'cn', 'classNames'],
config: 'tailwind.config.js', // returned from `loadConfig()` utility if not provided
cssFiles: [
'**/*.css',
'!**/node_modules',
'!**/.*',
'!**/dist',
'!**/build',
'!**/.storybook',
'!**/.next',
'!**/.public',
],
cssFilesRefreshRate: 5_000,
removeDuplicates: true,
skipClassAttribute: false,
whitelist: [],
tags: [], // can be set to e.g. ['tw'] for use in tw`bg-blue`
classRegex: '^class(Name)?$', // can be modified to support custom attributes. E.g. "^tw$" for `twin.macro`
},
},
rules: {
// due to 1k lines of tailwind config, these rule have performance issue
'tailwindcss/no-contradicting-classname': 'off',
'tailwindcss/enforces-shorthand': 'off',
'tailwindcss/no-custom-classname': 'off',
'tailwindcss/no-unnecessary-arbitrary-value': 'off',
'tailwindcss/no-arbitrary-value': 'off',
'tailwindcss/classnames-order': 'warn',
'tailwindcss/enforces-negative-arbitrary-values': 'warn',
'tailwindcss/migration-from-tailwind-2': 'warn',
},
},
// dify i18n namespace migration
// {
// files: ['**/*.ts', '**/*.tsx'],
// ignores: ['eslint-rules/**', 'i18n/**', 'i18n-config/**'],
// plugins: {
// 'dify-i18n': difyI18n,
// },
// rules: {
// // 'dify-i18n/no-as-any-in-t': ['error', { mode: 'all' }],
// 'dify-i18n/no-as-any-in-t': 'error',
// // 'dify-i18n/no-legacy-namespace-prefix': 'error',
// // 'dify-i18n/require-ns-option': 'error',
// },
// },
// i18n JSON validation rules
{
files: ['i18n/**/*.json'],
plugins: {
'dify-i18n': difyI18n,
},
rules: {
'sonarjs/max-lines': 'off',
'max-lines': 'off',
'jsonc/sort-keys': 'error',
'dify-i18n/valid-i18n-keys': 'error',
'dify-i18n/no-extra-keys': 'error',
'dify-i18n/consistent-placeholders': 'error',
},
},
// package.json version prefix validation
{
files: ['**/package.json'],
plugins: {
'dify-i18n': difyI18n,
},
rules: {
'dify-i18n/no-version-prefix': 'error',
},
},
)