@bfra.me/eslint-config 0.1.0
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.
- package/lib/index.d.ts +4051 -0
- package/lib/index.js +534 -0
- package/package.json +100 -0
- package/readme.md +37 -0
- package/src/configs/command.ts +11 -0
- package/src/configs/epilogue.ts +16 -0
- package/src/configs/eslint-comments.ts +19 -0
- package/src/configs/ignores.ts +11 -0
- package/src/configs/imports.ts +22 -0
- package/src/configs/index.ts +10 -0
- package/src/configs/javascript.ts +61 -0
- package/src/configs/jsdoc.ts +27 -0
- package/src/configs/perfectionist.ts +21 -0
- package/src/configs/typescript.ts +139 -0
- package/src/configs/vitest.ts +46 -0
- package/src/define-config.ts +227 -0
- package/src/env.ts +36 -0
- package/src/globs.ts +48 -0
- package/src/index.ts +9 -0
- package/src/plugins.ts +16 -0
- package/src/types.d.ts +3903 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/define-config.ts
|
|
5
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
6
|
+
import { isPackageExists } from "local-pkg";
|
|
7
|
+
|
|
8
|
+
// src/configs/command.ts
|
|
9
|
+
import config from "eslint-plugin-command/config";
|
|
10
|
+
async function command() {
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
...config(),
|
|
14
|
+
name: "@bfra.me/command"
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
__name(command, "command");
|
|
19
|
+
|
|
20
|
+
// src/configs/epilogue.ts
|
|
21
|
+
async function epilogue() {
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: "@bfra.me/epilogue/dts",
|
|
25
|
+
files: [
|
|
26
|
+
"**/*.d.?([cm])ts"
|
|
27
|
+
],
|
|
28
|
+
rules: {
|
|
29
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
30
|
+
"import/no-duplicates": "off",
|
|
31
|
+
"no-restricted-syntax": "off",
|
|
32
|
+
"unused-imports/no-unused-vars": "off"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
__name(epilogue, "epilogue");
|
|
38
|
+
|
|
39
|
+
// src/plugins.ts
|
|
40
|
+
import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
|
|
41
|
+
import { default as default3 } from "eslint-plugin-import-x";
|
|
42
|
+
import { default as default4 } from "eslint-plugin-jsdoc";
|
|
43
|
+
import { default as default5 } from "eslint-plugin-perfectionist";
|
|
44
|
+
import { default as default6 } from "eslint-plugin-unused-imports";
|
|
45
|
+
// @__NO_SIDE_EFFECTS__
|
|
46
|
+
async function interopDefault(m) {
|
|
47
|
+
const resolved = await m;
|
|
48
|
+
return resolved.default || resolved;
|
|
49
|
+
}
|
|
50
|
+
__name(interopDefault, "interopDefault");
|
|
51
|
+
|
|
52
|
+
// src/configs/eslint-comments.ts
|
|
53
|
+
async function eslintComments() {
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
name: "@bfra.me/eslint-comments/rules",
|
|
57
|
+
plugins: {
|
|
58
|
+
"eslint-comments": default2
|
|
59
|
+
},
|
|
60
|
+
rules: {
|
|
61
|
+
"eslint-comments/disable-enable-pair": [
|
|
62
|
+
"error",
|
|
63
|
+
{
|
|
64
|
+
allowWholeFile: true
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"eslint-comments/no-aggregating-enable": "error",
|
|
68
|
+
"eslint-comments/no-duplicate-disable": "error",
|
|
69
|
+
"eslint-comments/no-unlimited-disable": "error",
|
|
70
|
+
"eslint-comments/no-unused-disable": "error",
|
|
71
|
+
"eslint-comments/no-unused-enable": "error"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
__name(eslintComments, "eslintComments");
|
|
77
|
+
|
|
78
|
+
// src/globs.ts
|
|
79
|
+
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
80
|
+
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
81
|
+
var GLOB_TS = "**/*.?([cm])ts";
|
|
82
|
+
var GLOB_TSX = "**/*.tsx";
|
|
83
|
+
var GLOB_EXCLUDE = [
|
|
84
|
+
"**/node_modules",
|
|
85
|
+
"**/dist",
|
|
86
|
+
"**/coverage",
|
|
87
|
+
"**/out",
|
|
88
|
+
"**/temp",
|
|
89
|
+
"**/.idea",
|
|
90
|
+
"**/.next",
|
|
91
|
+
"**/.nuxt",
|
|
92
|
+
"**/.output",
|
|
93
|
+
"**/.svelte-kit",
|
|
94
|
+
"**/.tsup",
|
|
95
|
+
"**/.vercel",
|
|
96
|
+
"**/.vitepress/cache",
|
|
97
|
+
"**/.vite-inspect",
|
|
98
|
+
"**/.yarn",
|
|
99
|
+
"**/__snapshots__",
|
|
100
|
+
"**/test/fixtures",
|
|
101
|
+
"**/auto-import?(s).d.ts",
|
|
102
|
+
"**/.changeset/*.md",
|
|
103
|
+
"**/CHANGELOG*.md",
|
|
104
|
+
"**/changelog*.md",
|
|
105
|
+
"**/components.d.ts",
|
|
106
|
+
"**/devcontainer-lock.json",
|
|
107
|
+
"**/LICENSE*",
|
|
108
|
+
"**/license*",
|
|
109
|
+
"**/*.min.*",
|
|
110
|
+
"**/package-lock.json",
|
|
111
|
+
"**/pnpm-lock.yaml",
|
|
112
|
+
"**/typed-router.d.ts",
|
|
113
|
+
"**/yarn.lock",
|
|
114
|
+
"**/bun.lockb"
|
|
115
|
+
];
|
|
116
|
+
var GLOB_TESTS = [
|
|
117
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
118
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
119
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
120
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
121
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
// src/configs/ignores.ts
|
|
125
|
+
async function ignores(ignores1 = []) {
|
|
126
|
+
return [
|
|
127
|
+
{
|
|
128
|
+
name: "@bfra.me/ignores",
|
|
129
|
+
ignores: [
|
|
130
|
+
...GLOB_EXCLUDE,
|
|
131
|
+
...ignores1
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
__name(ignores, "ignores");
|
|
137
|
+
|
|
138
|
+
// src/configs/imports.ts
|
|
139
|
+
async function imports() {
|
|
140
|
+
return [
|
|
141
|
+
{
|
|
142
|
+
name: "@bfra.me/imports",
|
|
143
|
+
plugins: {
|
|
144
|
+
"import-x": default3
|
|
145
|
+
},
|
|
146
|
+
rules: {
|
|
147
|
+
"import-x/first": "error",
|
|
148
|
+
"import-x/no-duplicates": "error",
|
|
149
|
+
"import-x/no-mutable-exports": "error",
|
|
150
|
+
"import-x/no-named-default": "error",
|
|
151
|
+
"import-x/no-self-import": "error",
|
|
152
|
+
"import-x/no-useless-path-segments": "error",
|
|
153
|
+
"import-x/no-webpack-loader-syntax": "error"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
__name(imports, "imports");
|
|
159
|
+
|
|
160
|
+
// src/configs/javascript.ts
|
|
161
|
+
import globals from "globals";
|
|
162
|
+
async function javascript(options = {}) {
|
|
163
|
+
const { isInEditor: isInEditor2 = false, overrides = {} } = options;
|
|
164
|
+
return [
|
|
165
|
+
{
|
|
166
|
+
name: "@bfra.me/javascript/options",
|
|
167
|
+
languageOptions: {
|
|
168
|
+
ecmaVersion: 2022,
|
|
169
|
+
globals: {
|
|
170
|
+
...globals.browser,
|
|
171
|
+
...globals.es2021,
|
|
172
|
+
...globals.node
|
|
173
|
+
},
|
|
174
|
+
parserOptions: {
|
|
175
|
+
ecmaFeatures: {
|
|
176
|
+
jsx: true
|
|
177
|
+
},
|
|
178
|
+
ecmaVersion: 2022,
|
|
179
|
+
sourceType: "module"
|
|
180
|
+
},
|
|
181
|
+
sourceType: "module"
|
|
182
|
+
},
|
|
183
|
+
linterOptions: {
|
|
184
|
+
reportUnusedDisableDirectives: true
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: "@bfra.me/javascript/rules",
|
|
189
|
+
plugins: {
|
|
190
|
+
"unused-imports": default6
|
|
191
|
+
},
|
|
192
|
+
rules: {
|
|
193
|
+
camelcase: "off",
|
|
194
|
+
"no-unused-vars": "off",
|
|
195
|
+
"unused-imports/no-unused-imports": isInEditor2 ? "off" : "error",
|
|
196
|
+
"unused-imports/no-unused-vars": [
|
|
197
|
+
"error",
|
|
198
|
+
{
|
|
199
|
+
args: "after-used",
|
|
200
|
+
argsIgnorePattern: "^_",
|
|
201
|
+
ignoreRestSiblings: true,
|
|
202
|
+
vars: "all",
|
|
203
|
+
varsIgnorePattern: "^_"
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
...overrides
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
__name(javascript, "javascript");
|
|
212
|
+
|
|
213
|
+
// src/configs/jsdoc.ts
|
|
214
|
+
async function jsdoc() {
|
|
215
|
+
return [
|
|
216
|
+
{
|
|
217
|
+
plugins: {
|
|
218
|
+
jsdoc: default4
|
|
219
|
+
},
|
|
220
|
+
rules: {
|
|
221
|
+
"jsdoc/check-access": "warn",
|
|
222
|
+
"jsdoc/check-param-names": "warn",
|
|
223
|
+
"jsdoc/check-property-names": "warn",
|
|
224
|
+
"jsdoc/check-types": "warn",
|
|
225
|
+
"jsdoc/empty-tags": "warn",
|
|
226
|
+
"jsdoc/implements-on-classes": "warn",
|
|
227
|
+
"jsdoc/no-defaults": "warn",
|
|
228
|
+
"jsdoc/no-multi-asterisks": "warn",
|
|
229
|
+
"jsdoc/require-param-name": "warn",
|
|
230
|
+
"jsdoc/require-property": "warn",
|
|
231
|
+
"jsdoc/require-property-description": "warn",
|
|
232
|
+
"jsdoc/require-property-name": "warn",
|
|
233
|
+
"jsdoc/require-returns-check": "warn",
|
|
234
|
+
"jsdoc/require-returns-description": "warn",
|
|
235
|
+
"jsdoc/require-yields-check": "warn"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
];
|
|
239
|
+
}
|
|
240
|
+
__name(jsdoc, "jsdoc");
|
|
241
|
+
|
|
242
|
+
// src/configs/perfectionist.ts
|
|
243
|
+
async function perfectionist() {
|
|
244
|
+
return [
|
|
245
|
+
{
|
|
246
|
+
name: "@bfra.me/perfectionist",
|
|
247
|
+
plugins: {
|
|
248
|
+
perfectionist: default5
|
|
249
|
+
},
|
|
250
|
+
rules: {
|
|
251
|
+
"perfectionist/sort-exports": [
|
|
252
|
+
"error",
|
|
253
|
+
{
|
|
254
|
+
type: "natural"
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
];
|
|
260
|
+
}
|
|
261
|
+
__name(perfectionist, "perfectionist");
|
|
262
|
+
|
|
263
|
+
// src/configs/typescript.ts
|
|
264
|
+
import process from "node:process";
|
|
265
|
+
var TypeAwareRules = {
|
|
266
|
+
"@typescript-eslint/await-thenable": "error",
|
|
267
|
+
"@typescript-eslint/dot-notation": [
|
|
268
|
+
"error",
|
|
269
|
+
{
|
|
270
|
+
allowKeywords: true
|
|
271
|
+
}
|
|
272
|
+
],
|
|
273
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
274
|
+
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
275
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
276
|
+
"@typescript-eslint/prefer-includes": "error",
|
|
277
|
+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
|
278
|
+
"@typescript-eslint/promise-function-async": "error",
|
|
279
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
280
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
281
|
+
"@typescript-eslint/unbound-method": "error"
|
|
282
|
+
};
|
|
283
|
+
async function typescript(options = {}) {
|
|
284
|
+
const { overrides = {}, parserOptions = {}, typeAware = {
|
|
285
|
+
overrides: {}
|
|
286
|
+
} } = options;
|
|
287
|
+
const files = options.files ?? [
|
|
288
|
+
GLOB_TS,
|
|
289
|
+
GLOB_TSX
|
|
290
|
+
];
|
|
291
|
+
const typeAwareFiles = typeAware.files ?? [
|
|
292
|
+
GLOB_TS,
|
|
293
|
+
GLOB_TSX
|
|
294
|
+
];
|
|
295
|
+
const typeAwareIgnores = typeAware.ignores ?? [
|
|
296
|
+
"**/*.md/**",
|
|
297
|
+
"**/*.astro/*.ts"
|
|
298
|
+
];
|
|
299
|
+
const tsconfigPath = options.tsconfigPath ?? void 0;
|
|
300
|
+
const isTypeAware = Boolean(tsconfigPath);
|
|
301
|
+
const tselint = await interopDefault(import("typescript-eslint"));
|
|
302
|
+
const generateTsConfig = /* @__PURE__ */ __name((kind, files2, ignores2) => ({
|
|
303
|
+
name: `@bfra.me/typescript/${kind === "type-aware" ? "type-aware-" : ""}parser`,
|
|
304
|
+
files: files2,
|
|
305
|
+
...ignores2 ? {
|
|
306
|
+
ignores: ignores2
|
|
307
|
+
} : {},
|
|
308
|
+
languageOptions: {
|
|
309
|
+
parser: tselint.parser,
|
|
310
|
+
parserOptions: {
|
|
311
|
+
sourceType: "module",
|
|
312
|
+
...kind === "type-aware" ? {
|
|
313
|
+
projectService: {
|
|
314
|
+
allowDefaultProject: [
|
|
315
|
+
"./*.js"
|
|
316
|
+
],
|
|
317
|
+
defaultProject: tsconfigPath
|
|
318
|
+
},
|
|
319
|
+
tsconfigRootDir: process.cwd()
|
|
320
|
+
} : {},
|
|
321
|
+
...parserOptions
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}), "generateTsConfig");
|
|
325
|
+
return [
|
|
326
|
+
{
|
|
327
|
+
name: "@bfra.me/typescript/plugins",
|
|
328
|
+
plugins: {
|
|
329
|
+
"@typescript-eslint": tselint.plugin
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
...isTypeAware ? [
|
|
333
|
+
generateTsConfig("default", files),
|
|
334
|
+
generateTsConfig("type-aware", typeAwareFiles, typeAwareIgnores)
|
|
335
|
+
] : [
|
|
336
|
+
generateTsConfig("default", files)
|
|
337
|
+
],
|
|
338
|
+
{
|
|
339
|
+
name: "@bfra.me/typescript/rules",
|
|
340
|
+
files,
|
|
341
|
+
rules: {
|
|
342
|
+
...tselint.configs.eslintRecommended.rules,
|
|
343
|
+
"@typescript-eslint/array-type": "error",
|
|
344
|
+
"@typescript-eslint/ban-ts-comment": [
|
|
345
|
+
"error",
|
|
346
|
+
{
|
|
347
|
+
"ts-expect-error": "allow-with-description"
|
|
348
|
+
}
|
|
349
|
+
],
|
|
350
|
+
"@typescript-eslint/consistent-type-assertions": "error",
|
|
351
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
352
|
+
"error",
|
|
353
|
+
{
|
|
354
|
+
disallowTypeAnnotations: false,
|
|
355
|
+
fixStyle: "inline-type-imports"
|
|
356
|
+
}
|
|
357
|
+
],
|
|
358
|
+
"@typescript-eslint/explicit-function-return-type": [
|
|
359
|
+
"error",
|
|
360
|
+
{
|
|
361
|
+
allowExpressions: true,
|
|
362
|
+
allowHigherOrderFunctions: true,
|
|
363
|
+
allowIIFEs: true
|
|
364
|
+
}
|
|
365
|
+
],
|
|
366
|
+
"@typescript-eslint/explicit-member-accessibility": [
|
|
367
|
+
"error",
|
|
368
|
+
{
|
|
369
|
+
accessibility: "no-public"
|
|
370
|
+
}
|
|
371
|
+
],
|
|
372
|
+
"@typescript-eslint/no-array-constructor": "error",
|
|
373
|
+
"@typescript-eslint/no-empty-object-type": [
|
|
374
|
+
"error",
|
|
375
|
+
{
|
|
376
|
+
allowInterfaces: "always"
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
380
|
+
"@typescript-eslint/no-extraneous-class": "error",
|
|
381
|
+
"@typescript-eslint/no-inferrable-types": "error",
|
|
382
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
383
|
+
"@typescript-eslint/no-namespace": "error",
|
|
384
|
+
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
385
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
386
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
387
|
+
"@typescript-eslint/no-useless-constructor": "error",
|
|
388
|
+
"@typescript-eslint/prefer-for-of": "warn",
|
|
389
|
+
"@typescript-eslint/prefer-function-type": "warn",
|
|
390
|
+
...overrides
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
...isTypeAware ? [
|
|
394
|
+
{
|
|
395
|
+
name: "@bfra.me/typescript/type-aware-rules",
|
|
396
|
+
files: typeAwareFiles,
|
|
397
|
+
ignores: typeAwareIgnores,
|
|
398
|
+
rules: {
|
|
399
|
+
...TypeAwareRules,
|
|
400
|
+
...typeAware?.overrides
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
] : []
|
|
404
|
+
];
|
|
405
|
+
}
|
|
406
|
+
__name(typescript, "typescript");
|
|
407
|
+
|
|
408
|
+
// src/configs/vitest.ts
|
|
409
|
+
async function vitest(options = {}) {
|
|
410
|
+
const { files = GLOB_TESTS, isInEditor: isInEditor2 = false, overrides = {} } = options;
|
|
411
|
+
const [vitestPlugin, noOnlyTests] = await Promise.all([
|
|
412
|
+
interopDefault(import("@vitest/eslint-plugin")),
|
|
413
|
+
// @ts-expect-error - No types
|
|
414
|
+
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
415
|
+
]);
|
|
416
|
+
return [
|
|
417
|
+
{
|
|
418
|
+
name: "@bfra.me/vitest/plugin",
|
|
419
|
+
plugins: {
|
|
420
|
+
vitest: {
|
|
421
|
+
...vitestPlugin,
|
|
422
|
+
rules: {
|
|
423
|
+
...vitestPlugin.rules,
|
|
424
|
+
...noOnlyTests.rules
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: "@bfra.me/vitest/rules",
|
|
431
|
+
files,
|
|
432
|
+
rules: {
|
|
433
|
+
// ...vitestPlugin.configs.recommended.rules,
|
|
434
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
435
|
+
"no-unused-expressions": "off",
|
|
436
|
+
"vitest/no-only-tests": isInEditor2 ? "warn" : "error",
|
|
437
|
+
...overrides
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
];
|
|
441
|
+
}
|
|
442
|
+
__name(vitest, "vitest");
|
|
443
|
+
|
|
444
|
+
// src/env.ts
|
|
445
|
+
import { env } from "node:process";
|
|
446
|
+
import isInCI from "is-in-ci";
|
|
447
|
+
var isInGitLifecycle = !!(env.GIT_PARAMS || env.VSCODE_GIT_COMMAND || env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
448
|
+
var isInEditor = !isInCI && !isInGitLifecycle && !!(env.VSCODE_PID || env.VSCODE_CWD || env.JETBRAINS_IDE || env.VIM || env.NVIM);
|
|
449
|
+
|
|
450
|
+
// src/define-config.ts
|
|
451
|
+
var AllowedConfigPropertiesForOptions = Object.keys({});
|
|
452
|
+
async function defineConfig(options = {}, ...userConfigs) {
|
|
453
|
+
const { gitignore: enableGitignore = true, typescript: enableTypeScript = isPackageExists("typescript") } = options;
|
|
454
|
+
const isInEditor2 = options.isInEditor ?? isInEditor;
|
|
455
|
+
if (isInEditor2) console.log("[@bfra.me/eslint-config] Editor specific config is enabled. Some rules may be disabled.");
|
|
456
|
+
const configs = [];
|
|
457
|
+
if (enableGitignore) {
|
|
458
|
+
const gitignoreOptions = typeof enableGitignore !== "boolean" ? enableGitignore : {
|
|
459
|
+
strict: false
|
|
460
|
+
};
|
|
461
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((p) => [
|
|
462
|
+
p({
|
|
463
|
+
name: "@bfra.me/gitignore",
|
|
464
|
+
...gitignoreOptions
|
|
465
|
+
})
|
|
466
|
+
]));
|
|
467
|
+
}
|
|
468
|
+
configs.push(ignores(options.ignores), javascript({
|
|
469
|
+
isInEditor: isInEditor2,
|
|
470
|
+
overrides: getOverrides(options, "javascript")
|
|
471
|
+
}), eslintComments(), jsdoc(), imports(), command(), perfectionist());
|
|
472
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
473
|
+
if (enableTypeScript) {
|
|
474
|
+
configs.push(typescript({
|
|
475
|
+
...typescriptOptions,
|
|
476
|
+
overrides: getOverrides(options, "typescript")
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
if (options.vitest) {
|
|
480
|
+
configs.push(vitest({
|
|
481
|
+
overrides: getOverrides(options, "vitest")
|
|
482
|
+
}));
|
|
483
|
+
}
|
|
484
|
+
configs.push(epilogue());
|
|
485
|
+
const optionsConfig = AllowedConfigPropertiesForOptions.reduce((config2, key) => {
|
|
486
|
+
if (key in options) {
|
|
487
|
+
config2[key] = options[key];
|
|
488
|
+
}
|
|
489
|
+
return config2;
|
|
490
|
+
}, {});
|
|
491
|
+
if (Object.keys(optionsConfig).length) {
|
|
492
|
+
configs.push([
|
|
493
|
+
optionsConfig
|
|
494
|
+
]);
|
|
495
|
+
}
|
|
496
|
+
const composer = new FlatConfigComposer().append(...configs, ...userConfigs);
|
|
497
|
+
return composer;
|
|
498
|
+
}
|
|
499
|
+
__name(defineConfig, "defineConfig");
|
|
500
|
+
function resolveSubOptions(options, key) {
|
|
501
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
502
|
+
}
|
|
503
|
+
__name(resolveSubOptions, "resolveSubOptions");
|
|
504
|
+
function getOverrides(options, key) {
|
|
505
|
+
const sub = resolveSubOptions(options, key);
|
|
506
|
+
return "overrides" in sub ? sub.overrides : {};
|
|
507
|
+
}
|
|
508
|
+
__name(getOverrides, "getOverrides");
|
|
509
|
+
|
|
510
|
+
// src/index.ts
|
|
511
|
+
var src_default = defineConfig();
|
|
512
|
+
export {
|
|
513
|
+
GLOB_EXCLUDE,
|
|
514
|
+
GLOB_SRC,
|
|
515
|
+
GLOB_SRC_EXT,
|
|
516
|
+
GLOB_TESTS,
|
|
517
|
+
GLOB_TS,
|
|
518
|
+
GLOB_TSX,
|
|
519
|
+
command,
|
|
520
|
+
src_default as default,
|
|
521
|
+
defineConfig,
|
|
522
|
+
epilogue,
|
|
523
|
+
eslintComments,
|
|
524
|
+
ignores,
|
|
525
|
+
imports,
|
|
526
|
+
isInEditor,
|
|
527
|
+
isInGitLifecycle,
|
|
528
|
+
javascript,
|
|
529
|
+
jsdoc,
|
|
530
|
+
perfectionist,
|
|
531
|
+
typescript,
|
|
532
|
+
vitest
|
|
533
|
+
};
|
|
534
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bfra.me/eslint-config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared ESLint configuration for bfra.me",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"bfra.me",
|
|
7
|
+
"config",
|
|
8
|
+
"eslint",
|
|
9
|
+
"eslint-config",
|
|
10
|
+
"shared",
|
|
11
|
+
"typescript",
|
|
12
|
+
"works"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/bfra-me/works/tree/main/packages/eslint-config#readme",
|
|
15
|
+
"bugs": "https://github.com/bfra-me/works/issues",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/bfra-me/works.git",
|
|
19
|
+
"directory": "packages/eslint-config"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "Marcus R. Brown <contact@bfra.me>",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./lib/index.d.ts",
|
|
27
|
+
"source": "./src/index.ts",
|
|
28
|
+
"import": "./lib/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"main": "./lib/index.js",
|
|
33
|
+
"types": "./lib/index.d.ts",
|
|
34
|
+
"files": [
|
|
35
|
+
"src",
|
|
36
|
+
"lib",
|
|
37
|
+
"!**/*.map"
|
|
38
|
+
],
|
|
39
|
+
"prettier": "@bfra.me/prettier-config",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@eslint-community/eslint-plugin-eslint-comments": "4.4.0",
|
|
42
|
+
"eslint-config-flat-gitignore": "0.3.0",
|
|
43
|
+
"eslint-flat-config-utils": "0.4.0",
|
|
44
|
+
"eslint-plugin-command": "0.2.5",
|
|
45
|
+
"eslint-plugin-import-x": "4.2.1",
|
|
46
|
+
"eslint-plugin-jsdoc": "50.2.3",
|
|
47
|
+
"eslint-plugin-perfectionist": "3.6.0",
|
|
48
|
+
"eslint-plugin-unused-imports": "4.1.4",
|
|
49
|
+
"globals": "15.9.0",
|
|
50
|
+
"is-in-ci": "1.0.0",
|
|
51
|
+
"local-pkg": "0.5.0",
|
|
52
|
+
"typescript-eslint": "8.5.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@eslint/config-inspector": "0.5.4",
|
|
56
|
+
"@eslint/js": "9.10.0",
|
|
57
|
+
"@types/eslint__js": "8.42.3",
|
|
58
|
+
"@types/fs-extra": "11.0.4",
|
|
59
|
+
"@types/node": "20.16.1",
|
|
60
|
+
"@vitest/eslint-plugin": "1.1.4",
|
|
61
|
+
"eslint": "9.11.0",
|
|
62
|
+
"eslint-plugin-no-only-tests": "3.3.0",
|
|
63
|
+
"eslint-typegen": "0.3.2",
|
|
64
|
+
"execa": "9.4.0",
|
|
65
|
+
"fast-glob": "3.3.2",
|
|
66
|
+
"fs-extra": "11.2.0",
|
|
67
|
+
"jiti": "1.21.6",
|
|
68
|
+
"prettier": "3.3.3",
|
|
69
|
+
"tsup": "8.3.0",
|
|
70
|
+
"tsx": "4.19.1",
|
|
71
|
+
"type-fest": "4.26.0",
|
|
72
|
+
"vitest": "2.1.0",
|
|
73
|
+
"@bfra.me/eslint-config": "0.1.0",
|
|
74
|
+
"@bfra.me/prettier-config": "0.7.3",
|
|
75
|
+
"@bfra.me/tsconfig": "0.8.1"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"@vitest/eslint-plugin": "^1.1.4",
|
|
79
|
+
"eslint": "^9.10.0",
|
|
80
|
+
"eslint-plugin-no-only-tests": "^3.3.0"
|
|
81
|
+
},
|
|
82
|
+
"peerDependenciesMeta": {
|
|
83
|
+
"@vitest/eslint-plugin": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
86
|
+
"eslint-plugin-no-only-tests": {
|
|
87
|
+
"optional": true
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"publishConfig": {
|
|
91
|
+
"access": "public",
|
|
92
|
+
"provenance": true
|
|
93
|
+
},
|
|
94
|
+
"scripts": {
|
|
95
|
+
"build": "pnpm run generate-types && tsup",
|
|
96
|
+
"dev": "eslint-config-inspector --config ./inspector/eslint.config.ts",
|
|
97
|
+
"generate-types": "tsx ./scripts/generate-types.ts",
|
|
98
|
+
"test": "vitest"
|
|
99
|
+
}
|
|
100
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @bfra.me/eslint-config
|
|
2
|
+
|
|
3
|
+
> Shared ESLint configuration for bfra.me.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
### NPM
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install --save-dev @bfra.me/eslint-config eslint
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### PNPM
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pnpm add --save-dev @bfra.me/eslint-config eslint
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Yarn
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
yarn add --dev @bfra.me/eslint-config eslint
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Add or update your `eslint.config.js` file to include the following:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import preset from "@bfra.me/eslint-config"
|
|
31
|
+
|
|
32
|
+
export default preset()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
[MIT](../../LICENSE.md)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type {Config} from '../types'
|
|
2
|
+
|
|
3
|
+
export async function epilogue(): Promise<Config[]> {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
name: '@bfra.me/epilogue/dts',
|
|
7
|
+
files: ['**/*.d.?([cm])ts'],
|
|
8
|
+
rules: {
|
|
9
|
+
'eslint-comments/no-unlimited-disable': 'off',
|
|
10
|
+
'import/no-duplicates': 'off',
|
|
11
|
+
'no-restricted-syntax': 'off',
|
|
12
|
+
'unused-imports/no-unused-vars': 'off',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
]
|
|
16
|
+
}
|