@dhzh/eslint-config 0.3.0 → 0.4.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/dist/index.cjs CHANGED
@@ -60,6 +60,7 @@ __export(src_exports, {
60
60
  StylisticConfigDefaults: () => StylisticConfigDefaults,
61
61
  astro: () => astro,
62
62
  combine: () => combine,
63
+ command: () => command,
63
64
  comments: () => comments,
64
65
  default: () => src_default,
65
66
  defaultPluginRenaming: () => defaultPluginRenaming,
@@ -103,33 +104,6 @@ var import_node_fs = __toESM(require("fs"), 1);
103
104
  var import_local_pkg4 = require("local-pkg");
104
105
  var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
105
106
 
106
- // src/plugins.ts
107
- var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
108
- var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
109
- var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
110
- var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
111
- var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
112
- var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
113
- var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
114
-
115
- // src/configs/comments.ts
116
- async function comments() {
117
- return [
118
- {
119
- name: "antfu/eslint-comments/rules",
120
- plugins: {
121
- "eslint-comments": import_eslint_plugin_eslint_comments.default
122
- },
123
- rules: {
124
- "eslint-comments/no-aggregating-enable": "error",
125
- "eslint-comments/no-duplicate-disable": "error",
126
- "eslint-comments/no-unlimited-disable": "error",
127
- "eslint-comments/no-unused-enable": "error"
128
- }
129
- }
130
- ];
131
- }
132
-
133
107
  // src/globs.ts
134
108
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
135
109
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
@@ -205,873 +179,960 @@ var GLOB_EXCLUDE = [
205
179
  "**/components.d.ts"
206
180
  ];
207
181
 
208
- // src/configs/ignores.ts
209
- async function ignores() {
210
- return [
211
- {
212
- ignores: GLOB_EXCLUDE
213
- // Awaits https://github.com/humanwhocodes/config-array/pull/131
214
- // name: 'antfu/ignores',
182
+ // src/utils.ts
183
+ var import_node_process = __toESM(require("process"), 1);
184
+ var import_local_pkg = require("local-pkg");
185
+ var parserPlain = {
186
+ meta: {
187
+ name: "parser-plain"
188
+ },
189
+ parseForESLint: (code) => ({
190
+ ast: {
191
+ body: [],
192
+ comments: [],
193
+ loc: { end: code.length, start: 0 },
194
+ range: [0, code.length],
195
+ tokens: [],
196
+ type: "Program"
197
+ },
198
+ scopeManager: null,
199
+ services: { isPlain: true },
200
+ visitorKeys: {
201
+ Program: []
215
202
  }
216
- ];
203
+ })
204
+ };
205
+ async function combine(...configs) {
206
+ const resolved = await Promise.all(configs);
207
+ return resolved.flat();
208
+ }
209
+ function renameRules(rules, map) {
210
+ return Object.fromEntries(
211
+ Object.entries(rules).map(([key, value]) => {
212
+ for (const [from, to] of Object.entries(map)) {
213
+ if (key.startsWith(`${from}/`)) {
214
+ return [to + key.slice(from.length), value];
215
+ }
216
+ }
217
+ return [key, value];
218
+ })
219
+ );
220
+ }
221
+ function renamePluginInConfigs(configs, map) {
222
+ return configs.map((i) => {
223
+ const clone = { ...i };
224
+ if (clone.rules) {
225
+ clone.rules = renameRules(clone.rules, map);
226
+ }
227
+ if (clone.plugins) {
228
+ clone.plugins = Object.fromEntries(
229
+ Object.entries(clone.plugins).map(([key, value]) => {
230
+ if (key in map) {
231
+ return [map[key], value];
232
+ }
233
+ return [key, value];
234
+ })
235
+ );
236
+ }
237
+ return clone;
238
+ });
239
+ }
240
+ function toArray(value) {
241
+ return Array.isArray(value) ? value : [value];
242
+ }
243
+ async function interopDefault(m) {
244
+ const resolved = await m;
245
+ return resolved.default || resolved;
246
+ }
247
+ async function ensurePackages(packages) {
248
+ if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false) {
249
+ return;
250
+ }
251
+ const nonExistingPackages = packages.filter((i) => i && !(0, import_local_pkg.isPackageExists)(i));
252
+ if (nonExistingPackages.length === 0) {
253
+ return;
254
+ }
255
+ const p = await import("@clack/prompts");
256
+ const result = await p.confirm({
257
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
258
+ });
259
+ if (result) {
260
+ await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
261
+ }
217
262
  }
218
263
 
219
- // src/configs/imports.ts
220
- async function imports(options = {}) {
264
+ // src/configs/astro.ts
265
+ async function astro(options = {}) {
221
266
  const {
267
+ files = [GLOB_ASTRO],
268
+ overrides = {},
222
269
  stylistic: stylistic2 = true
223
270
  } = options;
271
+ const [
272
+ pluginAstro,
273
+ parserAstro,
274
+ parserTs
275
+ ] = await Promise.all([
276
+ interopDefault(import("eslint-plugin-astro")),
277
+ interopDefault(import("astro-eslint-parser")),
278
+ interopDefault(import("@typescript-eslint/parser"))
279
+ ]);
224
280
  return [
225
281
  {
226
- name: "antfu/imports/rules",
282
+ name: "antfu/astro/setup",
227
283
  plugins: {
228
- antfu: import_eslint_plugin_antfu.default,
229
- import: pluginImport
230
- },
231
- rules: {
232
- "antfu/import-dedupe": "error",
233
- "antfu/no-import-dist": "error",
234
- "antfu/no-import-node-modules-by-path": "error",
235
- "import/first": "error",
236
- "import/no-duplicates": "error",
237
- "import/no-mutable-exports": "error",
238
- "import/no-named-default": "error",
239
- "import/no-self-import": "error",
240
- "import/no-webpack-loader-syntax": "error",
241
- "import/order": "error",
242
- ...stylistic2 ? {
243
- "import/newline-after-import": ["error", { count: 1 }]
244
- } : {}
284
+ astro: pluginAstro
245
285
  }
246
286
  },
247
287
  {
248
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
249
- name: "antfu/imports/disables/bin",
288
+ files,
289
+ languageOptions: {
290
+ parser: parserAstro,
291
+ parserOptions: {
292
+ extraFileExtensions: [".astro"],
293
+ parser: parserTs
294
+ }
295
+ },
296
+ name: "antfu/astro/rules",
250
297
  rules: {
251
- "antfu/no-import-dist": "off",
252
- "antfu/no-import-node-modules-by-path": "off"
298
+ "astro/no-set-html-directive": "off",
299
+ "astro/semi": "off",
300
+ ...stylistic2 ? {
301
+ "style/indent": "off",
302
+ "style/jsx-closing-tag-location": "off",
303
+ "style/jsx-indent": "off",
304
+ "style/jsx-one-expression-per-line": "off",
305
+ "style/no-multiple-empty-lines": "off"
306
+ } : {},
307
+ ...overrides
253
308
  }
254
309
  }
255
310
  ];
256
311
  }
257
312
 
258
- // src/configs/javascript.ts
259
- var import_globals = __toESM(require("globals"), 1);
260
- async function javascript(options = {}) {
261
- const {
262
- isInEditor = false,
263
- overrides = {}
264
- } = options;
313
+ // src/configs/command.ts
314
+ var import_config = __toESM(require("eslint-plugin-command/config"), 1);
315
+ async function command() {
265
316
  return [
266
317
  {
267
- languageOptions: {
268
- ecmaVersion: 2022,
269
- globals: {
270
- ...import_globals.default.browser,
271
- ...import_globals.default.es2021,
272
- ...import_globals.default.node,
273
- document: "readonly",
274
- navigator: "readonly",
275
- window: "readonly"
276
- },
277
- parserOptions: {
278
- ecmaFeatures: {
279
- jsx: true
280
- },
281
- ecmaVersion: 2022,
282
- sourceType: "module"
283
- },
284
- sourceType: "module"
285
- },
286
- linterOptions: {
287
- reportUnusedDisableDirectives: true
288
- },
289
- name: "antfu/javascript/rules",
318
+ ...(0, import_config.default)(),
319
+ name: "antfu/command/rules"
320
+ }
321
+ ];
322
+ }
323
+
324
+ // src/plugins.ts
325
+ var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
326
+ var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
327
+ var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
328
+ var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
329
+ var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
330
+ var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
331
+ var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
332
+
333
+ // src/configs/comments.ts
334
+ async function comments() {
335
+ return [
336
+ {
337
+ name: "antfu/eslint-comments/rules",
290
338
  plugins: {
291
- "antfu": import_eslint_plugin_antfu.default,
292
- "unused-imports": import_eslint_plugin_unused_imports.default
339
+ "eslint-comments": import_eslint_plugin_eslint_comments.default
293
340
  },
294
341
  rules: {
295
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
296
- "array-callback-return": "error",
297
- "block-scoped-var": "error",
298
- "constructor-super": "error",
299
- "default-case-last": "error",
300
- "dot-notation": ["error", { allowKeywords: true }],
301
- "eqeqeq": ["error", "smart"],
302
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
303
- "no-alert": "error",
304
- "no-array-constructor": "error",
305
- "no-async-promise-executor": "error",
306
- "no-caller": "error",
307
- "no-case-declarations": "error",
308
- "no-class-assign": "error",
309
- "no-compare-neg-zero": "error",
310
- "no-cond-assign": ["error", "always"],
311
- "no-console": ["error", { allow: ["warn", "error"] }],
312
- "no-const-assign": "error",
313
- "no-control-regex": "error",
314
- "no-debugger": "error",
315
- "no-delete-var": "error",
316
- "no-dupe-args": "error",
317
- "no-dupe-class-members": "error",
318
- "no-dupe-keys": "error",
319
- "no-duplicate-case": "error",
320
- "no-empty": ["error", { allowEmptyCatch: true }],
321
- "no-empty-character-class": "error",
322
- "no-empty-pattern": "error",
323
- "no-eval": "error",
324
- "no-ex-assign": "error",
325
- "no-extend-native": "error",
326
- "no-extra-bind": "error",
327
- "no-extra-boolean-cast": "error",
328
- "no-fallthrough": "error",
329
- "no-func-assign": "error",
330
- "no-global-assign": "error",
331
- "no-implied-eval": "error",
332
- "no-import-assign": "error",
333
- "no-invalid-regexp": "error",
334
- "no-irregular-whitespace": "error",
335
- "no-iterator": "error",
336
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
337
- "no-lone-blocks": "error",
338
- "no-loss-of-precision": "error",
339
- "no-misleading-character-class": "error",
340
- "no-multi-str": "error",
341
- "no-new": "error",
342
- "no-new-func": "error",
343
- "no-new-native-nonconstructor": "error",
344
- "no-new-wrappers": "error",
345
- "no-obj-calls": "error",
346
- "no-octal": "error",
347
- "no-octal-escape": "error",
348
- "no-proto": "error",
349
- "no-prototype-builtins": "error",
350
- "no-redeclare": ["error", { builtinGlobals: false }],
351
- "no-regex-spaces": "error",
352
- "no-restricted-globals": [
353
- "error",
354
- { message: "Use `globalThis` instead.", name: "global" },
355
- { message: "Use `globalThis` instead.", name: "self" }
356
- ],
357
- "no-restricted-properties": [
358
- "error",
359
- { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
360
- { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
361
- { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
362
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
363
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
364
- ],
365
- "no-restricted-syntax": [
366
- "error",
367
- "DebuggerStatement",
368
- "LabeledStatement",
369
- "WithStatement",
370
- "TSEnumDeclaration[const=true]",
371
- "TSExportAssignment"
372
- ],
373
- "no-self-assign": ["error", { props: true }],
374
- "no-self-compare": "error",
375
- "no-sequences": "error",
376
- "no-shadow-restricted-names": "error",
377
- "no-sparse-arrays": "error",
378
- "no-template-curly-in-string": "error",
379
- "no-this-before-super": "error",
380
- "no-throw-literal": "error",
381
- "no-undef": "error",
382
- "no-undef-init": "error",
383
- "no-unexpected-multiline": "error",
384
- "no-unmodified-loop-condition": "error",
385
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
386
- "no-unreachable": "error",
387
- "no-unreachable-loop": "error",
388
- "no-unsafe-finally": "error",
389
- "no-unsafe-negation": "error",
390
- "no-unused-expressions": ["error", {
391
- allowShortCircuit: true,
392
- allowTaggedTemplates: true,
393
- allowTernary: true
394
- }],
395
- "no-unused-vars": ["error", {
396
- args: "none",
397
- caughtErrors: "none",
398
- ignoreRestSiblings: true,
399
- vars: "all"
400
- }],
401
- "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
402
- "no-useless-backreference": "error",
403
- "no-useless-call": "error",
404
- "no-useless-catch": "error",
405
- "no-useless-computed-key": "error",
406
- "no-useless-constructor": "error",
407
- "no-useless-rename": "error",
408
- "no-useless-return": "error",
409
- "no-var": "error",
410
- "no-with": "error",
411
- "object-shorthand": [
412
- "error",
413
- "always",
414
- {
415
- avoidQuotes: true,
416
- ignoreConstructors: false
417
- }
418
- ],
419
- "one-var": ["error", { initialized: "never" }],
420
- "prefer-arrow-callback": [
421
- "error",
422
- {
423
- allowNamedFunctions: false,
424
- allowUnboundThis: true
425
- }
426
- ],
427
- "prefer-const": [
428
- "error",
429
- {
430
- destructuring: "all",
431
- ignoreReadBeforeAssign: true
432
- }
433
- ],
434
- "prefer-exponentiation-operator": "error",
435
- "prefer-promise-reject-errors": "error",
436
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
437
- "prefer-rest-params": "error",
438
- "prefer-spread": "error",
439
- "prefer-template": "error",
440
- "sort-imports": [
441
- "error",
442
- {
443
- allowSeparatedGroups: false,
444
- ignoreCase: false,
445
- ignoreDeclarationSort: true,
446
- ignoreMemberSort: false,
447
- memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
448
- }
449
- ],
450
- "symbol-description": "error",
451
- "unicode-bom": ["error", "never"],
452
- "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
453
- "unused-imports/no-unused-vars": [
454
- "error",
455
- {
456
- args: "after-used",
457
- argsIgnorePattern: "^_",
458
- ignoreRestSiblings: true,
459
- vars: "all",
460
- varsIgnorePattern: "^_"
461
- }
462
- ],
463
- "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
464
- "valid-typeof": ["error", { requireStringLiterals: true }],
465
- "vars-on-top": "error",
466
- "yoda": ["error", "never"],
467
- ...overrides
342
+ "eslint-comments/no-aggregating-enable": "error",
343
+ "eslint-comments/no-duplicate-disable": "error",
344
+ "eslint-comments/no-unlimited-disable": "error",
345
+ "eslint-comments/no-unused-enable": "error"
468
346
  }
469
- },
347
+ }
348
+ ];
349
+ }
350
+
351
+ // src/configs/formatters.ts
352
+ var import_local_pkg2 = require("local-pkg");
353
+
354
+ // src/configs/stylistic.ts
355
+ var StylisticConfigDefaults = {
356
+ indent: 2,
357
+ jsx: true,
358
+ quotes: "single",
359
+ semi: true
360
+ };
361
+ async function stylistic(options = {}) {
362
+ const {
363
+ indent,
364
+ jsx,
365
+ lessOpinionated = false,
366
+ overrides = {},
367
+ quotes,
368
+ semi
369
+ } = {
370
+ ...StylisticConfigDefaults,
371
+ ...options
372
+ };
373
+ const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
374
+ const config = pluginStylistic.configs.customize({
375
+ arrowParens: true,
376
+ braceStyle: "1tbs",
377
+ flat: true,
378
+ indent,
379
+ jsx,
380
+ pluginName: "style",
381
+ quotes,
382
+ semi
383
+ });
384
+ return [
470
385
  {
471
- files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
472
- name: "antfu/javascript/disables/cli",
386
+ name: "antfu/stylistic/rules",
387
+ plugins: {
388
+ antfu: import_eslint_plugin_antfu.default,
389
+ style: pluginStylistic
390
+ },
473
391
  rules: {
474
- "no-console": "off"
392
+ ...config.rules,
393
+ "antfu/consistent-list-newline": "error",
394
+ ...lessOpinionated ? {
395
+ curly: ["error", "all"]
396
+ } : {
397
+ "antfu/if-newline": "error",
398
+ "antfu/top-level-function": "off",
399
+ "curly": ["error", "all"]
400
+ },
401
+ ...overrides
475
402
  }
476
403
  }
477
404
  ];
478
405
  }
479
406
 
480
- // src/utils.ts
481
- var import_node_process = __toESM(require("process"), 1);
482
- var import_local_pkg = require("local-pkg");
483
- var parserPlain = {
484
- meta: {
485
- name: "parser-plain"
486
- },
487
- parseForESLint: (code) => ({
488
- ast: {
489
- body: [],
490
- comments: [],
491
- loc: { end: code.length, start: 0 },
492
- range: [0, code.length],
493
- tokens: [],
494
- type: "Program"
407
+ // src/configs/formatters.ts
408
+ async function formatters(options = {}, stylistic2 = {}) {
409
+ if (options === true) {
410
+ options = {
411
+ astro: (0, import_local_pkg2.isPackageExists)("astro"),
412
+ css: true,
413
+ graphql: true,
414
+ html: true,
415
+ markdown: true,
416
+ slidev: (0, import_local_pkg2.isPackageExists)("@slidev/cli")
417
+ };
418
+ }
419
+ await ensurePackages([
420
+ "eslint-plugin-format",
421
+ options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
422
+ options.astro ? "prettier-plugin-astro" : void 0
423
+ ]);
424
+ if (options.slidev && options.markdown !== true && options.markdown !== "prettier") {
425
+ throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
426
+ }
427
+ const {
428
+ indent,
429
+ quotes,
430
+ semi
431
+ } = {
432
+ ...StylisticConfigDefaults,
433
+ ...stylistic2
434
+ };
435
+ const prettierOptions = Object.assign(
436
+ {
437
+ endOfLine: "auto",
438
+ semi,
439
+ singleQuote: quotes === "single",
440
+ tabWidth: typeof indent === "number" ? indent : 2,
441
+ trailingComma: "all",
442
+ useTabs: indent === "tab"
495
443
  },
496
- scopeManager: null,
497
- services: { isPlain: true },
498
- visitorKeys: {
499
- Program: []
444
+ options.prettierOptions || {}
445
+ );
446
+ const dprintOptions = Object.assign(
447
+ {
448
+ indentWidth: typeof indent === "number" ? indent : 2,
449
+ quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
450
+ useTabs: indent === "tab"
451
+ },
452
+ options.dprintOptions || {}
453
+ );
454
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
455
+ const configs = [
456
+ {
457
+ name: "antfu/formatter/setup",
458
+ plugins: {
459
+ format: pluginFormat
460
+ }
500
461
  }
501
- })
502
- };
503
- async function combine(...configs) {
504
- const resolved = await Promise.all(configs);
505
- return resolved.flat();
506
- }
507
- function renameRules(rules, map) {
508
- return Object.fromEntries(
509
- Object.entries(rules).map(([key, value]) => {
510
- for (const [from, to] of Object.entries(map)) {
511
- if (key.startsWith(`${from}/`)) {
512
- return [to + key.slice(from.length), value];
462
+ ];
463
+ if (options.css) {
464
+ configs.push(
465
+ {
466
+ files: [GLOB_CSS, GLOB_POSTCSS],
467
+ languageOptions: {
468
+ parser: parserPlain
469
+ },
470
+ name: "antfu/formatter/css",
471
+ rules: {
472
+ "format/prettier": [
473
+ "error",
474
+ {
475
+ ...prettierOptions,
476
+ parser: "css"
477
+ }
478
+ ]
479
+ }
480
+ },
481
+ {
482
+ files: [GLOB_SCSS],
483
+ languageOptions: {
484
+ parser: parserPlain
485
+ },
486
+ name: "antfu/formatter/scss",
487
+ rules: {
488
+ "format/prettier": [
489
+ "error",
490
+ {
491
+ ...prettierOptions,
492
+ parser: "scss"
493
+ }
494
+ ]
495
+ }
496
+ },
497
+ {
498
+ files: [GLOB_LESS],
499
+ languageOptions: {
500
+ parser: parserPlain
501
+ },
502
+ name: "antfu/formatter/less",
503
+ rules: {
504
+ "format/prettier": [
505
+ "error",
506
+ {
507
+ ...prettierOptions,
508
+ parser: "less"
509
+ }
510
+ ]
513
511
  }
514
512
  }
515
- return [key, value];
516
- })
517
- );
518
- }
519
- function renamePluginInConfigs(configs, map) {
520
- return configs.map((i) => {
521
- const clone = { ...i };
522
- if (clone.rules) {
523
- clone.rules = renameRules(clone.rules, map);
524
- }
525
- if (clone.plugins) {
526
- clone.plugins = Object.fromEntries(
527
- Object.entries(clone.plugins).map(([key, value]) => {
528
- if (key in map) {
529
- return [map[key], value];
513
+ );
514
+ }
515
+ if (options.html) {
516
+ configs.push({
517
+ files: [GLOB_HTML],
518
+ languageOptions: {
519
+ parser: parserPlain
520
+ },
521
+ name: "antfu/formatter/html",
522
+ rules: {
523
+ "format/prettier": [
524
+ "error",
525
+ {
526
+ ...prettierOptions,
527
+ parser: "html"
530
528
  }
531
- return [key, value];
532
- })
533
- );
534
- }
535
- return clone;
536
- });
537
- }
538
- function toArray(value) {
539
- return Array.isArray(value) ? value : [value];
540
- }
541
- async function interopDefault(m) {
542
- const resolved = await m;
543
- return resolved.default || resolved;
544
- }
545
- async function ensurePackages(packages) {
546
- if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false) {
547
- return;
529
+ ]
530
+ }
531
+ });
548
532
  }
549
- const nonExistingPackages = packages.filter((i) => i && !(0, import_local_pkg.isPackageExists)(i));
550
- if (nonExistingPackages.length === 0) {
551
- return;
533
+ if (options.markdown) {
534
+ const formater = options.markdown === true ? "prettier" : options.markdown;
535
+ const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
536
+ configs.push({
537
+ files: [GLOB_MARKDOWN],
538
+ ignores: GLOB_SLIDEV,
539
+ languageOptions: {
540
+ parser: parserPlain
541
+ },
542
+ name: "antfu/formatter/markdown",
543
+ rules: {
544
+ [`format/${formater}`]: [
545
+ "error",
546
+ formater === "prettier" ? {
547
+ printWidth: 120,
548
+ ...prettierOptions,
549
+ embeddedLanguageFormatting: "off",
550
+ parser: "markdown"
551
+ } : {
552
+ ...dprintOptions,
553
+ language: "markdown"
554
+ }
555
+ ]
556
+ }
557
+ });
558
+ if (options.slidev) {
559
+ configs.push({
560
+ files: GLOB_SLIDEV,
561
+ languageOptions: {
562
+ parser: parserPlain
563
+ },
564
+ name: "antfu/formatter/slidev",
565
+ rules: {
566
+ "format/prettier": [
567
+ "error",
568
+ {
569
+ printWidth: 120,
570
+ ...prettierOptions,
571
+ embeddedLanguageFormatting: "off",
572
+ parser: "slidev",
573
+ plugins: [
574
+ "prettier-plugin-slidev"
575
+ ]
576
+ }
577
+ ]
578
+ }
579
+ });
580
+ }
552
581
  }
553
- const p = await import("@clack/prompts");
554
- const result = await p.confirm({
555
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
556
- });
557
- if (result) {
558
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
582
+ if (options.astro) {
583
+ configs.push({
584
+ files: [GLOB_ASTRO],
585
+ languageOptions: {
586
+ parser: parserPlain
587
+ },
588
+ name: "antfu/formatter/astro",
589
+ rules: {
590
+ "format/prettier": [
591
+ "error",
592
+ {
593
+ ...prettierOptions,
594
+ parser: "astro",
595
+ plugins: [
596
+ "prettier-plugin-astro"
597
+ ]
598
+ }
599
+ ]
600
+ }
601
+ });
559
602
  }
560
- }
561
-
562
- // src/configs/jsdoc.ts
563
- async function jsdoc(options = {}) {
564
- const {
565
- stylistic: stylistic2 = true
566
- } = options;
567
- return [
568
- {
569
- name: "antfu/jsdoc/rules",
570
- plugins: {
571
- jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
603
+ if (options.graphql) {
604
+ configs.push({
605
+ files: [GLOB_GRAPHQL],
606
+ languageOptions: {
607
+ parser: parserPlain
572
608
  },
609
+ name: "antfu/formatter/graphql",
573
610
  rules: {
574
- "jsdoc/check-access": "warn",
575
- "jsdoc/check-param-names": "warn",
576
- "jsdoc/check-property-names": "warn",
577
- "jsdoc/check-types": "warn",
578
- "jsdoc/empty-tags": "warn",
579
- "jsdoc/implements-on-classes": "warn",
580
- "jsdoc/no-defaults": "warn",
581
- "jsdoc/no-multi-asterisks": "warn",
582
- "jsdoc/require-param-name": "warn",
583
- "jsdoc/require-property": "warn",
584
- "jsdoc/require-property-description": "warn",
585
- "jsdoc/require-property-name": "warn",
586
- "jsdoc/require-returns-check": "warn",
587
- "jsdoc/require-returns-description": "warn",
588
- "jsdoc/require-yields-check": "warn",
589
- ...stylistic2 ? {
590
- "jsdoc/check-alignment": "warn",
591
- "jsdoc/multiline-blocks": "warn"
592
- } : {}
611
+ "format/prettier": [
612
+ "error",
613
+ {
614
+ ...prettierOptions,
615
+ parser: "graphql"
616
+ }
617
+ ]
593
618
  }
594
- }
595
- ];
619
+ });
620
+ }
621
+ return configs;
596
622
  }
597
623
 
598
- // src/configs/jsonc.ts
599
- async function jsonc(options = {}) {
600
- const {
601
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
602
- overrides = {},
603
- stylistic: stylistic2 = true
604
- } = options;
605
- const {
606
- indent = 2
607
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
608
- const [
609
- pluginJsonc,
610
- parserJsonc
611
- ] = await Promise.all([
612
- interopDefault(import("eslint-plugin-jsonc")),
613
- interopDefault(import("jsonc-eslint-parser"))
614
- ]);
624
+ // src/configs/ignores.ts
625
+ async function ignores() {
615
626
  return [
616
627
  {
617
- name: "antfu/jsonc/setup",
618
- plugins: {
619
- jsonc: pluginJsonc
620
- }
621
- },
622
- {
623
- files,
624
- languageOptions: {
625
- parser: parserJsonc
626
- },
627
- name: "antfu/jsonc/rules",
628
- rules: {
629
- "jsonc/no-bigint-literals": "error",
630
- "jsonc/no-binary-expression": "error",
631
- "jsonc/no-binary-numeric-literals": "error",
632
- "jsonc/no-dupe-keys": "error",
633
- "jsonc/no-escape-sequence-in-identifier": "error",
634
- "jsonc/no-floating-decimal": "error",
635
- "jsonc/no-hexadecimal-numeric-literals": "error",
636
- "jsonc/no-infinity": "error",
637
- "jsonc/no-multi-str": "error",
638
- "jsonc/no-nan": "error",
639
- "jsonc/no-number-props": "error",
640
- "jsonc/no-numeric-separators": "error",
641
- "jsonc/no-octal": "error",
642
- "jsonc/no-octal-escape": "error",
643
- "jsonc/no-octal-numeric-literals": "error",
644
- "jsonc/no-parenthesized": "error",
645
- "jsonc/no-plus-sign": "error",
646
- "jsonc/no-regexp-literals": "error",
647
- "jsonc/no-sparse-arrays": "error",
648
- "jsonc/no-template-literals": "error",
649
- "jsonc/no-undefined-value": "error",
650
- "jsonc/no-unicode-codepoint-escapes": "error",
651
- "jsonc/no-useless-escape": "error",
652
- "jsonc/space-unary-ops": "error",
653
- "jsonc/valid-json-number": "error",
654
- "jsonc/vue-custom-block/no-parsing-error": "error",
655
- ...stylistic2 ? {
656
- "jsonc/array-bracket-spacing": ["error", "never"],
657
- "jsonc/comma-dangle": ["error", "never"],
658
- "jsonc/comma-style": ["error", "last"],
659
- "jsonc/indent": ["error", indent],
660
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
661
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
662
- "jsonc/object-curly-spacing": ["error", "always"],
663
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
664
- "jsonc/quote-props": "error",
665
- "jsonc/quotes": "error"
666
- } : {},
667
- ...overrides
668
- }
628
+ ignores: GLOB_EXCLUDE
629
+ // Awaits https://github.com/humanwhocodes/config-array/pull/131
630
+ // name: 'antfu/ignores',
669
631
  }
670
632
  ];
671
633
  }
672
634
 
673
- // src/configs/markdown.ts
674
- var import_eslint_merge_processors = require("eslint-merge-processors");
675
- async function markdown(options = {}) {
635
+ // src/configs/imports.ts
636
+ async function imports(options = {}) {
676
637
  const {
677
- componentExts = [],
678
- files = [GLOB_MARKDOWN],
679
- overrides = {}
638
+ stylistic: stylistic2 = true
680
639
  } = options;
681
- const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
682
640
  return [
683
641
  {
684
- name: "antfu/markdown/setup",
642
+ name: "antfu/imports/rules",
685
643
  plugins: {
686
- markdown: markdown2
687
- }
688
- },
689
- {
690
- files,
691
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
692
- name: "antfu/markdown/processor",
693
- // `eslint-plugin-markdown` only creates virtual files for code blocks,
694
- // but not the markdown file itself. We use `eslint-merge-processors` to
695
- // add a pass-through processor for the markdown file itself.
696
- processor: (0, import_eslint_merge_processors.mergeProcessors)([
697
- markdown2.processors.markdown,
698
- import_eslint_merge_processors.processorPassThrough
699
- ])
700
- },
701
- {
702
- files,
703
- languageOptions: {
704
- parser: parserPlain
705
- },
706
- name: "antfu/markdown/parser"
707
- },
708
- {
709
- files: [
710
- GLOB_MARKDOWN_CODE,
711
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
712
- ],
713
- languageOptions: {
714
- parserOptions: {
715
- ecmaFeatures: {
716
- impliedStrict: true
717
- }
718
- }
644
+ antfu: import_eslint_plugin_antfu.default,
645
+ import: pluginImport
719
646
  },
720
- name: "antfu/markdown/disables",
721
647
  rules: {
722
- "import/newline-after-import": "off",
723
- "no-alert": "off",
724
- "no-console": "off",
725
- "no-labels": "off",
726
- "no-lone-blocks": "off",
727
- "no-restricted-syntax": "off",
728
- "no-undef": "off",
729
- "no-unused-expressions": "off",
730
- "no-unused-labels": "off",
731
- "no-unused-vars": "off",
732
- "node/prefer-global/process": "off",
733
- "style/comma-dangle": "off",
734
- "style/eol-last": "off",
735
- "ts/consistent-type-imports": "off",
736
- "ts/no-namespace": "off",
737
- "ts/no-redeclare": "off",
738
- "ts/no-require-imports": "off",
739
- "ts/no-unused-vars": "off",
740
- "ts/no-use-before-define": "off",
741
- "ts/no-var-requires": "off",
742
- "unicode-bom": "off",
743
- "unused-imports/no-unused-imports": "off",
744
- "unused-imports/no-unused-vars": "off",
745
- // Type aware rules
746
- ...{
747
- "ts/await-thenable": "off",
748
- "ts/dot-notation": "off",
749
- "ts/no-floating-promises": "off",
750
- "ts/no-for-in-array": "off",
751
- "ts/no-implied-eval": "off",
752
- "ts/no-misused-promises": "off",
753
- "ts/no-throw-literal": "off",
754
- "ts/no-unnecessary-type-assertion": "off",
755
- "ts/no-unsafe-argument": "off",
756
- "ts/no-unsafe-assignment": "off",
757
- "ts/no-unsafe-call": "off",
758
- "ts/no-unsafe-member-access": "off",
759
- "ts/no-unsafe-return": "off",
760
- "ts/restrict-plus-operands": "off",
761
- "ts/restrict-template-expressions": "off",
762
- "ts/unbound-method": "off"
763
- },
764
- ...overrides
648
+ "antfu/import-dedupe": "error",
649
+ "antfu/no-import-dist": "error",
650
+ "antfu/no-import-node-modules-by-path": "error",
651
+ "import/first": "error",
652
+ "import/no-duplicates": "error",
653
+ "import/no-mutable-exports": "error",
654
+ "import/no-named-default": "error",
655
+ "import/no-self-import": "error",
656
+ "import/no-webpack-loader-syntax": "error",
657
+ "import/order": "error",
658
+ ...stylistic2 ? {
659
+ "import/newline-after-import": ["error", { count: 1 }]
660
+ } : {}
661
+ }
662
+ },
663
+ {
664
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
665
+ name: "antfu/imports/disables/bin",
666
+ rules: {
667
+ "antfu/no-import-dist": "off",
668
+ "antfu/no-import-node-modules-by-path": "off"
765
669
  }
766
670
  }
767
671
  ];
768
672
  }
769
673
 
770
- // src/configs/node.ts
771
- async function node() {
674
+ // src/configs/javascript.ts
675
+ var import_globals = __toESM(require("globals"), 1);
676
+ async function javascript(options = {}) {
677
+ const {
678
+ isInEditor = false,
679
+ overrides = {}
680
+ } = options;
772
681
  return [
773
682
  {
774
- name: "antfu/node/rules",
683
+ languageOptions: {
684
+ ecmaVersion: 2022,
685
+ globals: {
686
+ ...import_globals.default.browser,
687
+ ...import_globals.default.es2021,
688
+ ...import_globals.default.node,
689
+ document: "readonly",
690
+ navigator: "readonly",
691
+ window: "readonly"
692
+ },
693
+ parserOptions: {
694
+ ecmaFeatures: {
695
+ jsx: true
696
+ },
697
+ ecmaVersion: 2022,
698
+ sourceType: "module"
699
+ },
700
+ sourceType: "module"
701
+ },
702
+ linterOptions: {
703
+ reportUnusedDisableDirectives: true
704
+ },
705
+ name: "antfu/javascript/rules",
775
706
  plugins: {
776
- node: import_eslint_plugin_n.default
707
+ "antfu": import_eslint_plugin_antfu.default,
708
+ "unused-imports": import_eslint_plugin_unused_imports.default
777
709
  },
778
710
  rules: {
779
- "node/handle-callback-err": ["error", "^(err|error)$"],
780
- "node/no-deprecated-api": "error",
781
- "node/no-exports-assign": "error",
782
- "node/no-new-require": "error",
783
- "node/no-path-concat": "error",
784
- "node/prefer-global/buffer": ["error", "never"],
785
- "node/prefer-global/process": ["error", "never"],
786
- "node/process-exit-as-throw": "error"
711
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
712
+ "array-callback-return": "error",
713
+ "block-scoped-var": "error",
714
+ "constructor-super": "error",
715
+ "default-case-last": "error",
716
+ "dot-notation": ["error", { allowKeywords: true }],
717
+ "eqeqeq": ["error", "smart"],
718
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
719
+ "no-alert": "error",
720
+ "no-array-constructor": "error",
721
+ "no-async-promise-executor": "error",
722
+ "no-caller": "error",
723
+ "no-case-declarations": "error",
724
+ "no-class-assign": "error",
725
+ "no-compare-neg-zero": "error",
726
+ "no-cond-assign": ["error", "always"],
727
+ "no-console": ["error", { allow: ["warn", "error"] }],
728
+ "no-const-assign": "error",
729
+ "no-control-regex": "error",
730
+ "no-debugger": "error",
731
+ "no-delete-var": "error",
732
+ "no-dupe-args": "error",
733
+ "no-dupe-class-members": "error",
734
+ "no-dupe-keys": "error",
735
+ "no-duplicate-case": "error",
736
+ "no-empty": ["error", { allowEmptyCatch: true }],
737
+ "no-empty-character-class": "error",
738
+ "no-empty-pattern": "error",
739
+ "no-eval": "error",
740
+ "no-ex-assign": "error",
741
+ "no-extend-native": "error",
742
+ "no-extra-bind": "error",
743
+ "no-extra-boolean-cast": "error",
744
+ "no-fallthrough": "error",
745
+ "no-func-assign": "error",
746
+ "no-global-assign": "error",
747
+ "no-implied-eval": "error",
748
+ "no-import-assign": "error",
749
+ "no-invalid-regexp": "error",
750
+ "no-irregular-whitespace": "error",
751
+ "no-iterator": "error",
752
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
753
+ "no-lone-blocks": "error",
754
+ "no-loss-of-precision": "error",
755
+ "no-misleading-character-class": "error",
756
+ "no-multi-str": "error",
757
+ "no-new": "error",
758
+ "no-new-func": "error",
759
+ "no-new-native-nonconstructor": "error",
760
+ "no-new-wrappers": "error",
761
+ "no-obj-calls": "error",
762
+ "no-octal": "error",
763
+ "no-octal-escape": "error",
764
+ "no-proto": "error",
765
+ "no-prototype-builtins": "error",
766
+ "no-redeclare": ["error", { builtinGlobals: false }],
767
+ "no-regex-spaces": "error",
768
+ "no-restricted-globals": [
769
+ "error",
770
+ { message: "Use `globalThis` instead.", name: "global" },
771
+ { message: "Use `globalThis` instead.", name: "self" }
772
+ ],
773
+ "no-restricted-properties": [
774
+ "error",
775
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
776
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
777
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
778
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
779
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
780
+ ],
781
+ "no-restricted-syntax": [
782
+ "error",
783
+ "DebuggerStatement",
784
+ "LabeledStatement",
785
+ "WithStatement",
786
+ "TSEnumDeclaration[const=true]",
787
+ "TSExportAssignment"
788
+ ],
789
+ "no-self-assign": ["error", { props: true }],
790
+ "no-self-compare": "error",
791
+ "no-sequences": "error",
792
+ "no-shadow-restricted-names": "error",
793
+ "no-sparse-arrays": "error",
794
+ "no-template-curly-in-string": "error",
795
+ "no-this-before-super": "error",
796
+ "no-throw-literal": "error",
797
+ "no-undef": "error",
798
+ "no-undef-init": "error",
799
+ "no-unexpected-multiline": "error",
800
+ "no-unmodified-loop-condition": "error",
801
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
802
+ "no-unreachable": "error",
803
+ "no-unreachable-loop": "error",
804
+ "no-unsafe-finally": "error",
805
+ "no-unsafe-negation": "error",
806
+ "no-unused-expressions": ["error", {
807
+ allowShortCircuit: true,
808
+ allowTaggedTemplates: true,
809
+ allowTernary: true
810
+ }],
811
+ "no-unused-vars": ["error", {
812
+ args: "none",
813
+ caughtErrors: "none",
814
+ ignoreRestSiblings: true,
815
+ vars: "all"
816
+ }],
817
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
818
+ "no-useless-backreference": "error",
819
+ "no-useless-call": "error",
820
+ "no-useless-catch": "error",
821
+ "no-useless-computed-key": "error",
822
+ "no-useless-constructor": "error",
823
+ "no-useless-rename": "error",
824
+ "no-useless-return": "error",
825
+ "no-var": "error",
826
+ "no-with": "error",
827
+ "object-shorthand": [
828
+ "error",
829
+ "always",
830
+ {
831
+ avoidQuotes: true,
832
+ ignoreConstructors: false
833
+ }
834
+ ],
835
+ "one-var": ["error", { initialized: "never" }],
836
+ "prefer-arrow-callback": [
837
+ "error",
838
+ {
839
+ allowNamedFunctions: false,
840
+ allowUnboundThis: true
841
+ }
842
+ ],
843
+ "prefer-const": [
844
+ "error",
845
+ {
846
+ destructuring: "all",
847
+ ignoreReadBeforeAssign: true
848
+ }
849
+ ],
850
+ "prefer-exponentiation-operator": "error",
851
+ "prefer-promise-reject-errors": "error",
852
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
853
+ "prefer-rest-params": "error",
854
+ "prefer-spread": "error",
855
+ "prefer-template": "error",
856
+ "sort-imports": [
857
+ "error",
858
+ {
859
+ allowSeparatedGroups: false,
860
+ ignoreCase: false,
861
+ ignoreDeclarationSort: true,
862
+ ignoreMemberSort: false,
863
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
864
+ }
865
+ ],
866
+ "symbol-description": "error",
867
+ "unicode-bom": ["error", "never"],
868
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
869
+ "unused-imports/no-unused-vars": [
870
+ "error",
871
+ {
872
+ args: "after-used",
873
+ argsIgnorePattern: "^_",
874
+ ignoreRestSiblings: true,
875
+ vars: "all",
876
+ varsIgnorePattern: "^_"
877
+ }
878
+ ],
879
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
880
+ "valid-typeof": ["error", { requireStringLiterals: true }],
881
+ "vars-on-top": "error",
882
+ "yoda": ["error", "never"],
883
+ ...overrides
884
+ }
885
+ },
886
+ {
887
+ files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
888
+ name: "antfu/javascript/disables/cli",
889
+ rules: {
890
+ "no-console": "off"
787
891
  }
788
892
  }
789
893
  ];
790
894
  }
791
895
 
792
- // src/configs/perfectionist.ts
793
- async function perfectionist() {
896
+ // src/configs/jsdoc.ts
897
+ async function jsdoc(options = {}) {
898
+ const {
899
+ stylistic: stylistic2 = true
900
+ } = options;
794
901
  return [
795
902
  {
796
- name: "antfu/perfectionist/setup",
903
+ name: "antfu/jsdoc/rules",
797
904
  plugins: {
798
- perfectionist: import_eslint_plugin_perfectionist.default
905
+ jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
906
+ },
907
+ rules: {
908
+ "jsdoc/check-access": "warn",
909
+ "jsdoc/check-param-names": "warn",
910
+ "jsdoc/check-property-names": "warn",
911
+ "jsdoc/check-types": "warn",
912
+ "jsdoc/empty-tags": "warn",
913
+ "jsdoc/implements-on-classes": "warn",
914
+ "jsdoc/no-defaults": "warn",
915
+ "jsdoc/no-multi-asterisks": "warn",
916
+ "jsdoc/require-param-name": "warn",
917
+ "jsdoc/require-property": "warn",
918
+ "jsdoc/require-property-description": "warn",
919
+ "jsdoc/require-property-name": "warn",
920
+ "jsdoc/require-returns-check": "warn",
921
+ "jsdoc/require-returns-description": "warn",
922
+ "jsdoc/require-yields-check": "warn",
923
+ ...stylistic2 ? {
924
+ "jsdoc/check-alignment": "warn",
925
+ "jsdoc/multiline-blocks": "warn"
926
+ } : {}
799
927
  }
800
928
  }
801
929
  ];
802
930
  }
803
931
 
804
- // src/configs/formatters.ts
805
- var import_local_pkg2 = require("local-pkg");
806
-
807
- // src/configs/stylistic.ts
808
- var StylisticConfigDefaults = {
809
- indent: 2,
810
- jsx: true,
811
- quotes: "single",
812
- semi: true
813
- };
814
- async function stylistic(options = {}) {
932
+ // src/configs/jsonc.ts
933
+ async function jsonc(options = {}) {
815
934
  const {
816
- indent,
817
- jsx,
818
- lessOpinionated = false,
935
+ files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
819
936
  overrides = {},
820
- quotes,
821
- semi
822
- } = {
823
- ...StylisticConfigDefaults,
824
- ...options
825
- };
826
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
827
- const config = pluginStylistic.configs.customize({
828
- arrowParens: true,
829
- braceStyle: "1tbs",
830
- flat: true,
831
- indent,
832
- jsx,
833
- pluginName: "style",
834
- quotes,
835
- semi
836
- });
937
+ stylistic: stylistic2 = true
938
+ } = options;
939
+ const {
940
+ indent = 2
941
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
942
+ const [
943
+ pluginJsonc,
944
+ parserJsonc
945
+ ] = await Promise.all([
946
+ interopDefault(import("eslint-plugin-jsonc")),
947
+ interopDefault(import("jsonc-eslint-parser"))
948
+ ]);
837
949
  return [
838
950
  {
839
- name: "antfu/stylistic/rules",
951
+ name: "antfu/jsonc/setup",
840
952
  plugins: {
841
- antfu: import_eslint_plugin_antfu.default,
842
- style: pluginStylistic
953
+ jsonc: pluginJsonc
954
+ }
955
+ },
956
+ {
957
+ files,
958
+ languageOptions: {
959
+ parser: parserJsonc
843
960
  },
961
+ name: "antfu/jsonc/rules",
844
962
  rules: {
845
- ...config.rules,
846
- "antfu/consistent-list-newline": "error",
847
- ...lessOpinionated ? {
848
- curly: ["error", "all"]
849
- } : {
850
- "antfu/if-newline": "error",
851
- "antfu/top-level-function": "off",
852
- "curly": ["error", "all"]
853
- },
963
+ "jsonc/no-bigint-literals": "error",
964
+ "jsonc/no-binary-expression": "error",
965
+ "jsonc/no-binary-numeric-literals": "error",
966
+ "jsonc/no-dupe-keys": "error",
967
+ "jsonc/no-escape-sequence-in-identifier": "error",
968
+ "jsonc/no-floating-decimal": "error",
969
+ "jsonc/no-hexadecimal-numeric-literals": "error",
970
+ "jsonc/no-infinity": "error",
971
+ "jsonc/no-multi-str": "error",
972
+ "jsonc/no-nan": "error",
973
+ "jsonc/no-number-props": "error",
974
+ "jsonc/no-numeric-separators": "error",
975
+ "jsonc/no-octal": "error",
976
+ "jsonc/no-octal-escape": "error",
977
+ "jsonc/no-octal-numeric-literals": "error",
978
+ "jsonc/no-parenthesized": "error",
979
+ "jsonc/no-plus-sign": "error",
980
+ "jsonc/no-regexp-literals": "error",
981
+ "jsonc/no-sparse-arrays": "error",
982
+ "jsonc/no-template-literals": "error",
983
+ "jsonc/no-undefined-value": "error",
984
+ "jsonc/no-unicode-codepoint-escapes": "error",
985
+ "jsonc/no-useless-escape": "error",
986
+ "jsonc/space-unary-ops": "error",
987
+ "jsonc/valid-json-number": "error",
988
+ "jsonc/vue-custom-block/no-parsing-error": "error",
989
+ ...stylistic2 ? {
990
+ "jsonc/array-bracket-spacing": ["error", "never"],
991
+ "jsonc/comma-dangle": ["error", "never"],
992
+ "jsonc/comma-style": ["error", "last"],
993
+ "jsonc/indent": ["error", indent],
994
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
995
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
996
+ "jsonc/object-curly-spacing": ["error", "always"],
997
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
998
+ "jsonc/quote-props": "error",
999
+ "jsonc/quotes": "error"
1000
+ } : {},
854
1001
  ...overrides
855
1002
  }
856
1003
  }
857
1004
  ];
858
1005
  }
859
1006
 
860
- // src/configs/formatters.ts
861
- async function formatters(options = {}, stylistic2 = {}) {
862
- if (options === true) {
863
- options = {
864
- astro: (0, import_local_pkg2.isPackageExists)("astro"),
865
- css: true,
866
- graphql: true,
867
- html: true,
868
- markdown: true,
869
- slidev: (0, import_local_pkg2.isPackageExists)("@slidev/cli")
870
- };
871
- }
872
- await ensurePackages([
873
- "eslint-plugin-format",
874
- options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
875
- options.astro ? "prettier-plugin-astro" : void 0
876
- ]);
877
- if (options.slidev && options.markdown !== true && options.markdown !== "prettier") {
878
- throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
879
- }
1007
+ // src/configs/markdown.ts
1008
+ var import_eslint_merge_processors = require("eslint-merge-processors");
1009
+ async function markdown(options = {}) {
880
1010
  const {
881
- indent,
882
- quotes,
883
- semi
884
- } = {
885
- ...StylisticConfigDefaults,
886
- ...stylistic2
887
- };
888
- const prettierOptions = Object.assign(
889
- {
890
- endOfLine: "auto",
891
- semi,
892
- singleQuote: quotes === "single",
893
- tabWidth: typeof indent === "number" ? indent : 2,
894
- trailingComma: "all",
895
- useTabs: indent === "tab"
896
- },
897
- options.prettierOptions || {}
898
- );
899
- const dprintOptions = Object.assign(
900
- {
901
- indentWidth: typeof indent === "number" ? indent : 2,
902
- quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
903
- useTabs: indent === "tab"
904
- },
905
- options.dprintOptions || {}
906
- );
907
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
908
- const configs = [
909
- {
910
- name: "antfu/formatter/setup",
911
- plugins: {
912
- format: pluginFormat
913
- }
914
- }
915
- ];
916
- if (options.css) {
917
- configs.push(
918
- {
919
- files: [GLOB_CSS, GLOB_POSTCSS],
920
- languageOptions: {
921
- parser: parserPlain
922
- },
923
- name: "antfu/formatter/css",
924
- rules: {
925
- "format/prettier": [
926
- "error",
927
- {
928
- ...prettierOptions,
929
- parser: "css"
930
- }
931
- ]
932
- }
933
- },
934
- {
935
- files: [GLOB_SCSS],
936
- languageOptions: {
937
- parser: parserPlain
938
- },
939
- name: "antfu/formatter/scss",
940
- rules: {
941
- "format/prettier": [
942
- "error",
943
- {
944
- ...prettierOptions,
945
- parser: "scss"
946
- }
947
- ]
948
- }
949
- },
950
- {
951
- files: [GLOB_LESS],
952
- languageOptions: {
953
- parser: parserPlain
954
- },
955
- name: "antfu/formatter/less",
956
- rules: {
957
- "format/prettier": [
958
- "error",
959
- {
960
- ...prettierOptions,
961
- parser: "less"
962
- }
963
- ]
964
- }
965
- }
966
- );
967
- }
968
- if (options.html) {
969
- configs.push({
970
- files: [GLOB_HTML],
971
- languageOptions: {
972
- parser: parserPlain
973
- },
974
- name: "antfu/formatter/html",
975
- rules: {
976
- "format/prettier": [
977
- "error",
978
- {
979
- ...prettierOptions,
980
- parser: "html"
981
- }
982
- ]
1011
+ componentExts = [],
1012
+ files = [GLOB_MARKDOWN],
1013
+ overrides = {}
1014
+ } = options;
1015
+ const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
1016
+ return [
1017
+ {
1018
+ name: "antfu/markdown/setup",
1019
+ plugins: {
1020
+ markdown: markdown2
983
1021
  }
984
- });
985
- }
986
- if (options.markdown) {
987
- const formater = options.markdown === true ? "prettier" : options.markdown;
988
- const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
989
- configs.push({
990
- files: [GLOB_MARKDOWN],
991
- ignores: GLOB_SLIDEV,
1022
+ },
1023
+ {
1024
+ files,
1025
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1026
+ name: "antfu/markdown/processor",
1027
+ // `eslint-plugin-markdown` only creates virtual files for code blocks,
1028
+ // but not the markdown file itself. We use `eslint-merge-processors` to
1029
+ // add a pass-through processor for the markdown file itself.
1030
+ processor: (0, import_eslint_merge_processors.mergeProcessors)([
1031
+ markdown2.processors.markdown,
1032
+ import_eslint_merge_processors.processorPassThrough
1033
+ ])
1034
+ },
1035
+ {
1036
+ files,
992
1037
  languageOptions: {
993
1038
  parser: parserPlain
994
1039
  },
995
- name: "antfu/formatter/markdown",
996
- rules: {
997
- [`format/${formater}`]: [
998
- "error",
999
- formater === "prettier" ? {
1000
- printWidth: 120,
1001
- ...prettierOptions,
1002
- embeddedLanguageFormatting: "off",
1003
- parser: "markdown"
1004
- } : {
1005
- ...dprintOptions,
1006
- language: "markdown"
1040
+ name: "antfu/markdown/parser"
1041
+ },
1042
+ {
1043
+ files: [
1044
+ GLOB_MARKDOWN_CODE,
1045
+ ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
1046
+ ],
1047
+ languageOptions: {
1048
+ parserOptions: {
1049
+ ecmaFeatures: {
1050
+ impliedStrict: true
1007
1051
  }
1008
- ]
1009
- }
1010
- });
1011
- if (options.slidev) {
1012
- configs.push({
1013
- files: GLOB_SLIDEV,
1014
- languageOptions: {
1015
- parser: parserPlain
1016
- },
1017
- name: "antfu/formatter/slidev",
1018
- rules: {
1019
- "format/prettier": [
1020
- "error",
1021
- {
1022
- printWidth: 120,
1023
- ...prettierOptions,
1024
- embeddedLanguageFormatting: "off",
1025
- parser: "slidev",
1026
- plugins: [
1027
- "prettier-plugin-slidev"
1028
- ]
1029
- }
1030
- ]
1031
1052
  }
1032
- });
1033
- }
1034
- }
1035
- if (options.astro) {
1036
- configs.push({
1037
- files: [GLOB_ASTRO],
1038
- languageOptions: {
1039
- parser: parserPlain
1040
1053
  },
1041
- name: "antfu/formatter/astro",
1054
+ name: "antfu/markdown/disables",
1042
1055
  rules: {
1043
- "format/prettier": [
1044
- "error",
1045
- {
1046
- ...prettierOptions,
1047
- parser: "astro",
1048
- plugins: [
1049
- "prettier-plugin-astro"
1050
- ]
1051
- }
1052
- ]
1056
+ "import/newline-after-import": "off",
1057
+ "no-alert": "off",
1058
+ "no-console": "off",
1059
+ "no-labels": "off",
1060
+ "no-lone-blocks": "off",
1061
+ "no-restricted-syntax": "off",
1062
+ "no-undef": "off",
1063
+ "no-unused-expressions": "off",
1064
+ "no-unused-labels": "off",
1065
+ "no-unused-vars": "off",
1066
+ "node/prefer-global/process": "off",
1067
+ "style/comma-dangle": "off",
1068
+ "style/eol-last": "off",
1069
+ "ts/consistent-type-imports": "off",
1070
+ "ts/no-namespace": "off",
1071
+ "ts/no-redeclare": "off",
1072
+ "ts/no-require-imports": "off",
1073
+ "ts/no-unused-vars": "off",
1074
+ "ts/no-use-before-define": "off",
1075
+ "ts/no-var-requires": "off",
1076
+ "unicode-bom": "off",
1077
+ "unused-imports/no-unused-imports": "off",
1078
+ "unused-imports/no-unused-vars": "off",
1079
+ // Type aware rules
1080
+ ...{
1081
+ "ts/await-thenable": "off",
1082
+ "ts/dot-notation": "off",
1083
+ "ts/no-floating-promises": "off",
1084
+ "ts/no-for-in-array": "off",
1085
+ "ts/no-implied-eval": "off",
1086
+ "ts/no-misused-promises": "off",
1087
+ "ts/no-throw-literal": "off",
1088
+ "ts/no-unnecessary-type-assertion": "off",
1089
+ "ts/no-unsafe-argument": "off",
1090
+ "ts/no-unsafe-assignment": "off",
1091
+ "ts/no-unsafe-call": "off",
1092
+ "ts/no-unsafe-member-access": "off",
1093
+ "ts/no-unsafe-return": "off",
1094
+ "ts/restrict-plus-operands": "off",
1095
+ "ts/restrict-template-expressions": "off",
1096
+ "ts/unbound-method": "off"
1097
+ },
1098
+ ...overrides
1053
1099
  }
1054
- });
1055
- }
1056
- if (options.graphql) {
1057
- configs.push({
1058
- files: [GLOB_GRAPHQL],
1059
- languageOptions: {
1060
- parser: parserPlain
1100
+ }
1101
+ ];
1102
+ }
1103
+
1104
+ // src/configs/node.ts
1105
+ async function node() {
1106
+ return [
1107
+ {
1108
+ name: "antfu/node/rules",
1109
+ plugins: {
1110
+ node: import_eslint_plugin_n.default
1061
1111
  },
1062
- name: "antfu/formatter/graphql",
1063
1112
  rules: {
1064
- "format/prettier": [
1065
- "error",
1066
- {
1067
- ...prettierOptions,
1068
- parser: "graphql"
1069
- }
1070
- ]
1113
+ "node/handle-callback-err": ["error", "^(err|error)$"],
1114
+ "node/no-deprecated-api": "error",
1115
+ "node/no-exports-assign": "error",
1116
+ "node/no-new-require": "error",
1117
+ "node/no-path-concat": "error",
1118
+ "node/prefer-global/buffer": ["error", "never"],
1119
+ "node/prefer-global/process": ["error", "never"],
1120
+ "node/process-exit-as-throw": "error"
1071
1121
  }
1072
- });
1073
- }
1074
- return configs;
1122
+ }
1123
+ ];
1124
+ }
1125
+
1126
+ // src/configs/perfectionist.ts
1127
+ async function perfectionist() {
1128
+ return [
1129
+ {
1130
+ name: "antfu/perfectionist/setup",
1131
+ plugins: {
1132
+ perfectionist: import_eslint_plugin_perfectionist.default
1133
+ }
1134
+ }
1135
+ ];
1075
1136
  }
1076
1137
 
1077
1138
  // src/configs/react.ts
@@ -1079,6 +1140,15 @@ var import_local_pkg3 = require("local-pkg");
1079
1140
  var ReactRefreshAllowConstantExportPackages = [
1080
1141
  "vite"
1081
1142
  ];
1143
+ var RemixPackages = [
1144
+ "@remix-run/node",
1145
+ "@remix-run/react",
1146
+ "@remix-run/serve",
1147
+ "@remix-run/dev"
1148
+ ];
1149
+ var NextJsPackages = [
1150
+ "next"
1151
+ ];
1082
1152
  async function react(options = {}) {
1083
1153
  const {
1084
1154
  files = [GLOB_TS, GLOB_TSX],
@@ -1102,9 +1172,9 @@ async function react(options = {}) {
1102
1172
  interopDefault(import("eslint-plugin-react-refresh")),
1103
1173
  interopDefault(import("@typescript-eslint/parser"))
1104
1174
  ]);
1105
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1106
- (i) => (0, import_local_pkg3.isPackageExists)(i)
1107
- );
1175
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, import_local_pkg3.isPackageExists)(i));
1176
+ const isUsingRemix = RemixPackages.some((i) => (0, import_local_pkg3.isPackageExists)(i));
1177
+ const isUsingNext = NextJsPackages.some((i) => (0, import_local_pkg3.isPackageExists)(i));
1108
1178
  const plugins = pluginReact.configs.all.plugins;
1109
1179
  return [
1110
1180
  {
@@ -1150,7 +1220,26 @@ async function react(options = {}) {
1150
1220
  // react refresh
1151
1221
  "react-refresh/only-export-components": [
1152
1222
  "warn",
1153
- { allowConstantExport: isAllowConstantExport }
1223
+ {
1224
+ allowConstantExport: isAllowConstantExport,
1225
+ allowExportNames: [
1226
+ ...isUsingNext ? [
1227
+ "config",
1228
+ "generateStaticParams",
1229
+ "metadata",
1230
+ "generateMetadata",
1231
+ "viewport",
1232
+ "generateViewport"
1233
+ ] : [],
1234
+ ...isUsingRemix ? [
1235
+ "meta",
1236
+ "links",
1237
+ "headers",
1238
+ "loader",
1239
+ "action"
1240
+ ] : []
1241
+ ]
1242
+ }
1154
1243
  ],
1155
1244
  // recommended rules from @eslint-react
1156
1245
  "react/ensure-forward-ref-using-ref": "warn",
@@ -1199,6 +1288,82 @@ async function react(options = {}) {
1199
1288
  ];
1200
1289
  }
1201
1290
 
1291
+ // src/configs/solid.ts
1292
+ async function solid(options = {}) {
1293
+ const {
1294
+ files = [GLOB_JSX, GLOB_TSX],
1295
+ overrides = {},
1296
+ typescript: typescript2 = true
1297
+ } = options;
1298
+ await ensurePackages([
1299
+ "eslint-plugin-solid"
1300
+ ]);
1301
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1302
+ const isTypeAware = !!tsconfigPath;
1303
+ const [
1304
+ pluginSolid,
1305
+ parserTs
1306
+ ] = await Promise.all([
1307
+ interopDefault(import("eslint-plugin-solid")),
1308
+ interopDefault(import("@typescript-eslint/parser"))
1309
+ ]);
1310
+ return [
1311
+ {
1312
+ name: "antfu/solid/setup",
1313
+ plugins: {
1314
+ solid: pluginSolid
1315
+ }
1316
+ },
1317
+ {
1318
+ files,
1319
+ languageOptions: {
1320
+ parser: parserTs,
1321
+ parserOptions: {
1322
+ ecmaFeatures: {
1323
+ jsx: true
1324
+ },
1325
+ ...isTypeAware ? { project: tsconfigPath } : {}
1326
+ },
1327
+ sourceType: "module"
1328
+ },
1329
+ name: "antfu/solid/rules",
1330
+ rules: {
1331
+ // reactivity
1332
+ "solid/components-return-once": "warn",
1333
+ "solid/event-handlers": ["error", {
1334
+ // if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
1335
+ ignoreCase: false,
1336
+ // if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
1337
+ warnOnSpread: false
1338
+ }],
1339
+ // these rules are mostly style suggestions
1340
+ "solid/imports": "error",
1341
+ // identifier usage is important
1342
+ "solid/jsx-no-duplicate-props": "error",
1343
+ "solid/jsx-no-script-url": "error",
1344
+ "solid/jsx-no-undef": "error",
1345
+ "solid/jsx-uses-vars": "error",
1346
+ "solid/no-destructure": "error",
1347
+ // security problems
1348
+ "solid/no-innerhtml": ["error", { allowStatic: true }],
1349
+ "solid/no-react-deps": "error",
1350
+ "solid/no-react-specific-props": "error",
1351
+ "solid/no-unknown-namespaces": "error",
1352
+ "solid/prefer-for": "error",
1353
+ "solid/reactivity": "warn",
1354
+ "solid/self-closing-comp": "error",
1355
+ "solid/style-prop": ["error", { styleProps: ["style", "css"] }],
1356
+ ...typescript2 ? {
1357
+ "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
1358
+ "solid/no-unknown-namespaces": "off"
1359
+ } : {},
1360
+ // overrides
1361
+ ...overrides
1362
+ }
1363
+ }
1364
+ ];
1365
+ }
1366
+
1202
1367
  // src/configs/sort.ts
1203
1368
  async function sortPackageJson() {
1204
1369
  return [
@@ -1570,6 +1735,65 @@ async function test(options = {}) {
1570
1735
  ];
1571
1736
  }
1572
1737
 
1738
+ // src/configs/toml.ts
1739
+ async function toml(options = {}) {
1740
+ const {
1741
+ files = [GLOB_TOML],
1742
+ overrides = {},
1743
+ stylistic: stylistic2 = true
1744
+ } = options;
1745
+ const {
1746
+ indent = 2
1747
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1748
+ const [
1749
+ pluginToml,
1750
+ parserToml
1751
+ ] = await Promise.all([
1752
+ interopDefault(import("eslint-plugin-toml")),
1753
+ interopDefault(import("toml-eslint-parser"))
1754
+ ]);
1755
+ return [
1756
+ {
1757
+ name: "antfu/toml/setup",
1758
+ plugins: {
1759
+ toml: pluginToml
1760
+ }
1761
+ },
1762
+ {
1763
+ files,
1764
+ languageOptions: {
1765
+ parser: parserToml
1766
+ },
1767
+ name: "antfu/toml/rules",
1768
+ rules: {
1769
+ "style/spaced-comment": "off",
1770
+ "toml/comma-style": "error",
1771
+ "toml/keys-order": "error",
1772
+ "toml/no-space-dots": "error",
1773
+ "toml/no-unreadable-number-separator": "error",
1774
+ "toml/precision-of-fractional-seconds": "error",
1775
+ "toml/precision-of-integer": "error",
1776
+ "toml/tables-order": "error",
1777
+ "toml/vue-custom-block/no-parsing-error": "error",
1778
+ ...stylistic2 ? {
1779
+ "toml/array-bracket-newline": "error",
1780
+ "toml/array-bracket-spacing": "error",
1781
+ "toml/array-element-newline": "error",
1782
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1783
+ "toml/inline-table-curly-spacing": "error",
1784
+ "toml/key-spacing": "error",
1785
+ "toml/padding-line-between-pairs": "error",
1786
+ "toml/padding-line-between-tables": "error",
1787
+ "toml/quoted-keys": "error",
1788
+ "toml/spaced-comment": "error",
1789
+ "toml/table-bracket-spacing": "error"
1790
+ } : {},
1791
+ ...overrides
1792
+ }
1793
+ }
1794
+ ];
1795
+ }
1796
+
1573
1797
  // src/configs/typescript.ts
1574
1798
  var import_node_process2 = __toESM(require("process"), 1);
1575
1799
  async function typescript(options = {}) {
@@ -2023,190 +2247,6 @@ async function yaml(options = {}) {
2023
2247
  ];
2024
2248
  }
2025
2249
 
2026
- // src/configs/toml.ts
2027
- async function toml(options = {}) {
2028
- const {
2029
- files = [GLOB_TOML],
2030
- overrides = {},
2031
- stylistic: stylistic2 = true
2032
- } = options;
2033
- const {
2034
- indent = 2
2035
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
2036
- const [
2037
- pluginToml,
2038
- parserToml
2039
- ] = await Promise.all([
2040
- interopDefault(import("eslint-plugin-toml")),
2041
- interopDefault(import("toml-eslint-parser"))
2042
- ]);
2043
- return [
2044
- {
2045
- name: "antfu/toml/setup",
2046
- plugins: {
2047
- toml: pluginToml
2048
- }
2049
- },
2050
- {
2051
- files,
2052
- languageOptions: {
2053
- parser: parserToml
2054
- },
2055
- name: "antfu/toml/rules",
2056
- rules: {
2057
- "style/spaced-comment": "off",
2058
- "toml/comma-style": "error",
2059
- "toml/keys-order": "error",
2060
- "toml/no-space-dots": "error",
2061
- "toml/no-unreadable-number-separator": "error",
2062
- "toml/precision-of-fractional-seconds": "error",
2063
- "toml/precision-of-integer": "error",
2064
- "toml/tables-order": "error",
2065
- "toml/vue-custom-block/no-parsing-error": "error",
2066
- ...stylistic2 ? {
2067
- "toml/array-bracket-newline": "error",
2068
- "toml/array-bracket-spacing": "error",
2069
- "toml/array-element-newline": "error",
2070
- "toml/indent": ["error", indent === "tab" ? 2 : indent],
2071
- "toml/inline-table-curly-spacing": "error",
2072
- "toml/key-spacing": "error",
2073
- "toml/padding-line-between-pairs": "error",
2074
- "toml/padding-line-between-tables": "error",
2075
- "toml/quoted-keys": "error",
2076
- "toml/spaced-comment": "error",
2077
- "toml/table-bracket-spacing": "error"
2078
- } : {},
2079
- ...overrides
2080
- }
2081
- }
2082
- ];
2083
- }
2084
-
2085
- // src/configs/astro.ts
2086
- async function astro(options = {}) {
2087
- const {
2088
- files = [GLOB_ASTRO],
2089
- overrides = {},
2090
- stylistic: stylistic2 = true
2091
- } = options;
2092
- const [
2093
- pluginAstro,
2094
- parserAstro,
2095
- parserTs
2096
- ] = await Promise.all([
2097
- interopDefault(import("eslint-plugin-astro")),
2098
- interopDefault(import("astro-eslint-parser")),
2099
- interopDefault(import("@typescript-eslint/parser"))
2100
- ]);
2101
- return [
2102
- {
2103
- name: "antfu/astro/setup",
2104
- plugins: {
2105
- astro: pluginAstro
2106
- }
2107
- },
2108
- {
2109
- files,
2110
- languageOptions: {
2111
- parser: parserAstro,
2112
- parserOptions: {
2113
- extraFileExtensions: [".astro"],
2114
- parser: parserTs
2115
- }
2116
- },
2117
- name: "antfu/astro/rules",
2118
- rules: {
2119
- "astro/no-set-html-directive": "off",
2120
- "astro/semi": "off",
2121
- ...stylistic2 ? {
2122
- "style/indent": "off",
2123
- "style/jsx-closing-tag-location": "off",
2124
- "style/jsx-indent": "off",
2125
- "style/jsx-one-expression-per-line": "off",
2126
- "style/no-multiple-empty-lines": "off"
2127
- } : {},
2128
- ...overrides
2129
- }
2130
- }
2131
- ];
2132
- }
2133
-
2134
- // src/configs/solid.ts
2135
- async function solid(options = {}) {
2136
- const {
2137
- files = [GLOB_JSX, GLOB_TSX],
2138
- overrides = {},
2139
- typescript: typescript2 = true
2140
- } = options;
2141
- await ensurePackages([
2142
- "eslint-plugin-solid"
2143
- ]);
2144
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
2145
- const isTypeAware = !!tsconfigPath;
2146
- const [
2147
- pluginSolid,
2148
- parserTs
2149
- ] = await Promise.all([
2150
- interopDefault(import("eslint-plugin-solid")),
2151
- interopDefault(import("@typescript-eslint/parser"))
2152
- ]);
2153
- return [
2154
- {
2155
- name: "antfu/solid/setup",
2156
- plugins: {
2157
- solid: pluginSolid
2158
- }
2159
- },
2160
- {
2161
- files,
2162
- languageOptions: {
2163
- parser: parserTs,
2164
- parserOptions: {
2165
- ecmaFeatures: {
2166
- jsx: true
2167
- },
2168
- ...isTypeAware ? { project: tsconfigPath } : {}
2169
- },
2170
- sourceType: "module"
2171
- },
2172
- name: "antfu/solid/rules",
2173
- rules: {
2174
- // reactivity
2175
- "solid/components-return-once": "warn",
2176
- "solid/event-handlers": ["error", {
2177
- // if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
2178
- ignoreCase: false,
2179
- // if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
2180
- warnOnSpread: false
2181
- }],
2182
- // these rules are mostly style suggestions
2183
- "solid/imports": "error",
2184
- // identifier usage is important
2185
- "solid/jsx-no-duplicate-props": "error",
2186
- "solid/jsx-no-script-url": "error",
2187
- "solid/jsx-no-undef": "error",
2188
- "solid/jsx-uses-vars": "error",
2189
- "solid/no-destructure": "error",
2190
- // security problems
2191
- "solid/no-innerhtml": ["error", { allowStatic: true }],
2192
- "solid/no-react-deps": "error",
2193
- "solid/no-react-specific-props": "error",
2194
- "solid/no-unknown-namespaces": "error",
2195
- "solid/prefer-for": "error",
2196
- "solid/reactivity": "warn",
2197
- "solid/self-closing-comp": "error",
2198
- "solid/style-prop": ["error", { styleProps: ["style", "css"] }],
2199
- ...typescript2 ? {
2200
- "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
2201
- "solid/no-unknown-namespaces": "off"
2202
- } : {},
2203
- // overrides
2204
- ...overrides
2205
- }
2206
- }
2207
- ];
2208
- }
2209
-
2210
2250
  // src/factory.ts
2211
2251
  var flatConfigProps = [
2212
2252
  "name",
@@ -2280,6 +2320,7 @@ function dhzh(options = {}, ...userConfigs) {
2280
2320
  stylistic: stylisticOptions
2281
2321
  }),
2282
2322
  unicorn(),
2323
+ command(),
2283
2324
  // Optional plugins (installed but not enabled by default)
2284
2325
  perfectionist()
2285
2326
  );
@@ -2448,6 +2489,7 @@ var src_default = dhzh;
2448
2489
  StylisticConfigDefaults,
2449
2490
  astro,
2450
2491
  combine,
2492
+ command,
2451
2493
  comments,
2452
2494
  defaultPluginRenaming,
2453
2495
  dhzh,