@devapoo-dev/eslint-config 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +248 -0
  2. package/package.json +5 -11
package/index.mjs ADDED
@@ -0,0 +1,248 @@
1
+ import antfu from '@antfu/eslint-config';
2
+ import checkFile from 'eslint-plugin-check-file';
3
+ import prettier from 'eslint-plugin-prettier/recommended';
4
+ import tailwindcss from 'eslint-plugin-tailwindcss';
5
+
6
+ /** @doc Glob Tester: https://globster.xyz/ */
7
+ export const JS_GLOB = '**/*.{,m,c}js{,x}';
8
+ export const TS_GLOB = '**/*.{,d.}{,m,c}ts{,x}';
9
+
10
+ export const DIR_TEST_GLOB = '**/__tests__/**/*.[jt]s?(x)';
11
+ export const FILE_TEST_GLOB = '**/?(*.)+(spec|test).[jt]s?(x)';
12
+ export const TEST_GLOBS = [DIR_TEST_GLOB, FILE_TEST_GLOB];
13
+
14
+ export function createConfig(options, ...userConfigs) {
15
+ return antfu(
16
+ {
17
+ type: 'app',
18
+ typescript: true,
19
+ lessOpinionated: true,
20
+ yaml: false,
21
+ plugins: {
22
+ 'check-file': checkFile,
23
+ ...options?.plugins,
24
+ },
25
+ ...(options?.react && {
26
+ react: true,
27
+ jsx: { a11y: true },
28
+ }),
29
+ ...options,
30
+ },
31
+ prettier,
32
+ {
33
+ rules: {
34
+ // antfu
35
+ 'antfu/consistent-chaining': 'off',
36
+
37
+ // node
38
+ 'no-console': 'warn',
39
+ 'node/prefer-global/process': 'off',
40
+ 'node/no-process-env': 'off',
41
+
42
+ // typescript
43
+ 'ts/no-use-before-define': [
44
+ 'error',
45
+ {
46
+ functions: false,
47
+ classes: false,
48
+ variables: false,
49
+ typedefs: false,
50
+ },
51
+ ],
52
+ /** Uses typescript-eslint checks instead */
53
+ 'no-unused-vars': 'off',
54
+ 'unused-imports/no-unused-vars': 'off',
55
+ 'ts/no-unused-vars': [
56
+ 'warn',
57
+ {
58
+ args: 'all',
59
+ argsIgnorePattern: '^_',
60
+ caughtErrors: 'all',
61
+ caughtErrorsIgnorePattern: '^_',
62
+ destructuredArrayIgnorePattern: '^_',
63
+ varsIgnorePattern: '^_',
64
+ ignoreRestSiblings: true,
65
+ },
66
+ ],
67
+
68
+ // stylistic
69
+ 'style/semi': ['error', 'always'],
70
+ 'style/arrow-parens': ['error', 'always'],
71
+ 'style/quotes': ['error', 'single', { avoidEscape: true }],
72
+ 'style/quote-props': ['error', 'as-needed'],
73
+ 'style/brace-style': ['error', '1tbs'],
74
+ 'style/object-curly-spacing': ['error', 'always'],
75
+
76
+ // perfectionist
77
+ 'perfectionist/sort-imports': [
78
+ 'error',
79
+ {
80
+ // Rewrite antfu's internal to add new lines between groups
81
+ groups: [
82
+ 'type-import',
83
+ ['type-parent', 'type-sibling', 'type-index', 'type-internal'],
84
+
85
+ 'value-builtin',
86
+ 'value-external',
87
+ 'value-internal',
88
+ ['value-parent', 'value-sibling', 'value-index'],
89
+
90
+ 'side-effect',
91
+ 'ts-equals-import',
92
+ 'unknown',
93
+ ],
94
+ newlinesBetween: 1,
95
+ newlinesInside: 0,
96
+ },
97
+ ],
98
+ 'perfectionist/sort-interfaces': [
99
+ 'error',
100
+ {
101
+ type: 'alphabetical',
102
+ order: 'asc',
103
+ ignoreCase: true,
104
+ },
105
+ ],
106
+ 'perfectionist/sort-object-types': [
107
+ 'error',
108
+ {
109
+ type: 'alphabetical',
110
+ order: 'asc',
111
+ ignoreCase: true,
112
+ },
113
+ ],
114
+ 'perfectionist/sort-enums': [
115
+ 'error',
116
+ {
117
+ type: 'alphabetical',
118
+ order: 'asc',
119
+ ignoreCase: true,
120
+ },
121
+ ],
122
+
123
+ // react
124
+ ...(options?.react && {
125
+ 'perfectionist/sort-jsx-props': 'error',
126
+ 'react/no-array-index-key': 'off', // Off to enable composable keys
127
+
128
+ // check-file
129
+ 'check-file/filename-naming-convention': [
130
+ 'error',
131
+ { [JS_GLOB]: 'KEBAB_CASE', [TS_GLOB]: 'KEBAB_CASE' },
132
+ { ignoreMiddleExtensions: true },
133
+ ],
134
+ 'check-file/folder-naming-convention': [
135
+ 'error',
136
+ { [JS_GLOB]: 'KEBAB_CASE', [TS_GLOB]: 'KEBAB_CASE' },
137
+ { ignoreMiddleExtensions: true },
138
+ ],
139
+ }),
140
+
141
+ ...options?.rules,
142
+ },
143
+ },
144
+ /**
145
+ * React Routter 7 | Remix.run rules
146
+ */
147
+ {
148
+ ...(options?.remix && {
149
+ rules: {
150
+ // preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
151
+ 'react-refresh/only-export-components': [
152
+ 'error',
153
+ {
154
+ allowExportNames: [
155
+ 'meta',
156
+ 'links',
157
+ 'headers',
158
+ 'loader',
159
+ 'action',
160
+ 'clientLoader',
161
+ 'clientAction',
162
+ 'handle',
163
+ 'middleware',
164
+ 'shouldRevalidate',
165
+ ],
166
+ },
167
+ ],
168
+ },
169
+ }),
170
+ },
171
+ {
172
+ ...(options?.remix && {
173
+ files: [
174
+ '**/root.tsx',
175
+ '**/routes/**/*.{ts,tsx}',
176
+ '**/middlewares/**/*.{ts,tsx}',
177
+ ],
178
+ rules: {
179
+ 'react-naming-convention/context-name': 'off',
180
+ },
181
+ }),
182
+ },
183
+ /**
184
+ * Tailwind CSS
185
+ */
186
+ ...tailwindcss.configs['flat/recommended'],
187
+ {
188
+ settings: {
189
+ tailwindcss: {
190
+ config: false, // Rule for TailwindCSS v4
191
+ },
192
+ },
193
+ rules: {
194
+ 'tailwindcss/no-custom-classname': 'off',
195
+ },
196
+ },
197
+ /**
198
+ * Vitest (keep as reference file:blob)
199
+ */
200
+ {
201
+ files: TEST_GLOBS,
202
+ rules: {
203
+ 'test/prefer-lowercase-title': [
204
+ 'error',
205
+ {
206
+ allowedPrefixes: ['GIVEN', 'WHEN', 'THEN', 'AND', 'BUT'],
207
+ },
208
+ ],
209
+ 'react/no-create-ref': 'off',
210
+ },
211
+ },
212
+ /**
213
+ * File-specific rule overrides for markdown and YAML files
214
+ */
215
+ {
216
+ files: ['**/*.md', '**/*.yml', '**/*.yaml'],
217
+ rules: {
218
+ 'style/max-len': 'off',
219
+ },
220
+ },
221
+ {
222
+ // All code blocks in .md files
223
+ files: ['**/*.md/*.js?(x)', '**/*.md/*.ts?(x)'],
224
+ rules: {
225
+ 'no-unreachable': 'off',
226
+ 'no-unused-expressions': 'off',
227
+ 'no-unused-labels': 'off',
228
+ 'no-unused-vars': 'off',
229
+ 'prefer-const': 'warn',
230
+ 'jsx-a11y/alt-text': 'off',
231
+ 'jsx-a11y/anchor-has-content': 'off',
232
+ 'prefer-let/prefer-let': 'off',
233
+ 'react/jsx-no-comment-textnodes': 'off',
234
+ 'react/jsx-no-undef': 'off',
235
+ },
236
+ },
237
+ {
238
+ // All ```ts & ```tsx code blocks in .md files
239
+ files: ['**/*.md/*.ts?(x)'],
240
+ rules: {
241
+ 'import/no-duplicates': 'off',
242
+ '@typescript-eslint/no-unused-expressions': 'off',
243
+ '@typescript-eslint/no-unused-vars': 'off',
244
+ },
245
+ },
246
+ ...userConfigs,
247
+ );
248
+ }
package/package.json CHANGED
@@ -1,17 +1,11 @@
1
1
  {
2
2
  "name": "@devapoo-dev/eslint-config",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "type": "module",
5
- "main": "./src/create-config.js",
6
- "types": "./src/create-config.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./src/create-config.d.ts",
10
- "default": "./src/create-config.js"
11
- }
12
- },
5
+ "main": "index.mjs",
6
+ "types": "index.d.ts",
13
7
  "dependencies": {
14
- "@antfu/eslint-config": "^8.2.0",
8
+ "@antfu/eslint-config": "^7.7.3",
15
9
  "eslint": "9",
16
10
  "eslint-config-prettier": "^10.1.8",
17
11
  "eslint-plugin-check-file": "^3.3.1",
@@ -20,7 +14,7 @@
20
14
  "tailwindcss": "^4.2.2"
21
15
  },
22
16
  "devDependencies": {
23
- "@devapoo-dev/tsconfig": "0.0.7"
17
+ "@devapoo-dev/tsconfig": "0.0.8"
24
18
  },
25
19
  "scripts": {
26
20
  "lint": "eslint .",