@dhzh/eslint-config 0.3.1 → 0.4.1

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.js CHANGED
@@ -4,33 +4,6 @@ import fs from "node:fs";
4
4
  import { isPackageExists as isPackageExists4 } from "local-pkg";
5
5
  import { FlatConfigComposer } from "eslint-flat-config-utils";
6
6
 
7
- // src/plugins.ts
8
- import { default as default2 } from "eslint-plugin-antfu";
9
- import { default as default3 } from "eslint-plugin-eslint-comments";
10
- import * as pluginImport from "eslint-plugin-import-x";
11
- import { default as default4 } from "eslint-plugin-n";
12
- import { default as default5 } from "eslint-plugin-unicorn";
13
- import { default as default6 } from "eslint-plugin-unused-imports";
14
- import { default as default7 } from "eslint-plugin-perfectionist";
15
-
16
- // src/configs/comments.ts
17
- async function comments() {
18
- return [
19
- {
20
- name: "antfu/eslint-comments/rules",
21
- plugins: {
22
- "eslint-comments": default3
23
- },
24
- rules: {
25
- "eslint-comments/no-aggregating-enable": "error",
26
- "eslint-comments/no-duplicate-disable": "error",
27
- "eslint-comments/no-unlimited-disable": "error",
28
- "eslint-comments/no-unused-enable": "error"
29
- }
30
- }
31
- ];
32
- }
33
-
34
7
  // src/globs.ts
35
8
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
36
9
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
@@ -106,873 +79,960 @@ var GLOB_EXCLUDE = [
106
79
  "**/components.d.ts"
107
80
  ];
108
81
 
109
- // src/configs/ignores.ts
110
- async function ignores() {
111
- return [
112
- {
113
- ignores: GLOB_EXCLUDE
114
- // Awaits https://github.com/humanwhocodes/config-array/pull/131
115
- // name: 'antfu/ignores',
82
+ // src/utils.ts
83
+ import process from "node:process";
84
+ import { isPackageExists } from "local-pkg";
85
+ var parserPlain = {
86
+ meta: {
87
+ name: "parser-plain"
88
+ },
89
+ parseForESLint: (code) => ({
90
+ ast: {
91
+ body: [],
92
+ comments: [],
93
+ loc: { end: code.length, start: 0 },
94
+ range: [0, code.length],
95
+ tokens: [],
96
+ type: "Program"
97
+ },
98
+ scopeManager: null,
99
+ services: { isPlain: true },
100
+ visitorKeys: {
101
+ Program: []
116
102
  }
117
- ];
103
+ })
104
+ };
105
+ async function combine(...configs) {
106
+ const resolved = await Promise.all(configs);
107
+ return resolved.flat();
108
+ }
109
+ function renameRules(rules, map) {
110
+ return Object.fromEntries(
111
+ Object.entries(rules).map(([key, value]) => {
112
+ for (const [from, to] of Object.entries(map)) {
113
+ if (key.startsWith(`${from}/`)) {
114
+ return [to + key.slice(from.length), value];
115
+ }
116
+ }
117
+ return [key, value];
118
+ })
119
+ );
120
+ }
121
+ function renamePluginInConfigs(configs, map) {
122
+ return configs.map((i) => {
123
+ const clone = { ...i };
124
+ if (clone.rules) {
125
+ clone.rules = renameRules(clone.rules, map);
126
+ }
127
+ if (clone.plugins) {
128
+ clone.plugins = Object.fromEntries(
129
+ Object.entries(clone.plugins).map(([key, value]) => {
130
+ if (key in map) {
131
+ return [map[key], value];
132
+ }
133
+ return [key, value];
134
+ })
135
+ );
136
+ }
137
+ return clone;
138
+ });
139
+ }
140
+ function toArray(value) {
141
+ return Array.isArray(value) ? value : [value];
142
+ }
143
+ async function interopDefault(m) {
144
+ const resolved = await m;
145
+ return resolved.default || resolved;
146
+ }
147
+ async function ensurePackages(packages) {
148
+ if (process.env.CI || process.stdout.isTTY === false) {
149
+ return;
150
+ }
151
+ const nonExistingPackages = packages.filter((i) => i && !isPackageExists(i));
152
+ if (nonExistingPackages.length === 0) {
153
+ return;
154
+ }
155
+ const p = await import("@clack/prompts");
156
+ const result = await p.confirm({
157
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
158
+ });
159
+ if (result) {
160
+ await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
161
+ }
118
162
  }
119
163
 
120
- // src/configs/imports.ts
121
- async function imports(options = {}) {
164
+ // src/configs/astro.ts
165
+ async function astro(options = {}) {
122
166
  const {
167
+ files = [GLOB_ASTRO],
168
+ overrides = {},
123
169
  stylistic: stylistic2 = true
124
170
  } = options;
171
+ const [
172
+ pluginAstro,
173
+ parserAstro,
174
+ parserTs
175
+ ] = await Promise.all([
176
+ interopDefault(import("eslint-plugin-astro")),
177
+ interopDefault(import("astro-eslint-parser")),
178
+ interopDefault(import("@typescript-eslint/parser"))
179
+ ]);
125
180
  return [
126
181
  {
127
- name: "antfu/imports/rules",
182
+ name: "antfu/astro/setup",
128
183
  plugins: {
129
- antfu: default2,
130
- import: pluginImport
131
- },
132
- rules: {
133
- "antfu/import-dedupe": "error",
134
- "antfu/no-import-dist": "error",
135
- "antfu/no-import-node-modules-by-path": "error",
136
- "import/first": "error",
137
- "import/no-duplicates": "error",
138
- "import/no-mutable-exports": "error",
139
- "import/no-named-default": "error",
140
- "import/no-self-import": "error",
141
- "import/no-webpack-loader-syntax": "error",
142
- "import/order": "error",
143
- ...stylistic2 ? {
144
- "import/newline-after-import": ["error", { count: 1 }]
145
- } : {}
184
+ astro: pluginAstro
146
185
  }
147
186
  },
148
187
  {
149
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
150
- name: "antfu/imports/disables/bin",
188
+ files,
189
+ languageOptions: {
190
+ parser: parserAstro,
191
+ parserOptions: {
192
+ extraFileExtensions: [".astro"],
193
+ parser: parserTs
194
+ }
195
+ },
196
+ name: "antfu/astro/rules",
151
197
  rules: {
152
- "antfu/no-import-dist": "off",
153
- "antfu/no-import-node-modules-by-path": "off"
198
+ "astro/no-set-html-directive": "off",
199
+ "astro/semi": "off",
200
+ ...stylistic2 ? {
201
+ "style/indent": "off",
202
+ "style/jsx-closing-tag-location": "off",
203
+ "style/jsx-indent": "off",
204
+ "style/jsx-one-expression-per-line": "off",
205
+ "style/no-multiple-empty-lines": "off"
206
+ } : {},
207
+ ...overrides
154
208
  }
155
209
  }
156
210
  ];
157
211
  }
158
212
 
159
- // src/configs/javascript.ts
160
- import globals from "globals";
161
- async function javascript(options = {}) {
162
- const {
163
- isInEditor = false,
164
- overrides = {}
165
- } = options;
213
+ // src/configs/command.ts
214
+ import createCommand from "eslint-plugin-command/config";
215
+ async function command() {
166
216
  return [
167
217
  {
168
- languageOptions: {
169
- ecmaVersion: 2022,
170
- globals: {
171
- ...globals.browser,
172
- ...globals.es2021,
173
- ...globals.node,
174
- document: "readonly",
175
- navigator: "readonly",
176
- window: "readonly"
177
- },
178
- parserOptions: {
179
- ecmaFeatures: {
180
- jsx: true
181
- },
182
- ecmaVersion: 2022,
183
- sourceType: "module"
184
- },
185
- sourceType: "module"
186
- },
187
- linterOptions: {
188
- reportUnusedDisableDirectives: true
189
- },
190
- name: "antfu/javascript/rules",
218
+ ...createCommand(),
219
+ name: "antfu/command/rules"
220
+ }
221
+ ];
222
+ }
223
+
224
+ // src/plugins.ts
225
+ import { default as default2 } from "eslint-plugin-antfu";
226
+ import { default as default3 } from "eslint-plugin-eslint-comments";
227
+ import * as pluginImport from "eslint-plugin-import-x";
228
+ import { default as default4 } from "eslint-plugin-n";
229
+ import { default as default5 } from "eslint-plugin-unicorn";
230
+ import { default as default6 } from "eslint-plugin-unused-imports";
231
+ import { default as default7 } from "eslint-plugin-perfectionist";
232
+
233
+ // src/configs/comments.ts
234
+ async function comments() {
235
+ return [
236
+ {
237
+ name: "antfu/eslint-comments/rules",
191
238
  plugins: {
192
- "antfu": default2,
193
- "unused-imports": default6
239
+ "eslint-comments": default3
194
240
  },
195
241
  rules: {
196
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
197
- "array-callback-return": "error",
198
- "block-scoped-var": "error",
199
- "constructor-super": "error",
200
- "default-case-last": "error",
201
- "dot-notation": ["error", { allowKeywords: true }],
202
- "eqeqeq": ["error", "smart"],
203
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
204
- "no-alert": "error",
205
- "no-array-constructor": "error",
206
- "no-async-promise-executor": "error",
207
- "no-caller": "error",
208
- "no-case-declarations": "error",
209
- "no-class-assign": "error",
210
- "no-compare-neg-zero": "error",
211
- "no-cond-assign": ["error", "always"],
212
- "no-console": ["error", { allow: ["warn", "error"] }],
213
- "no-const-assign": "error",
214
- "no-control-regex": "error",
215
- "no-debugger": "error",
216
- "no-delete-var": "error",
217
- "no-dupe-args": "error",
218
- "no-dupe-class-members": "error",
219
- "no-dupe-keys": "error",
220
- "no-duplicate-case": "error",
221
- "no-empty": ["error", { allowEmptyCatch: true }],
222
- "no-empty-character-class": "error",
223
- "no-empty-pattern": "error",
224
- "no-eval": "error",
225
- "no-ex-assign": "error",
226
- "no-extend-native": "error",
227
- "no-extra-bind": "error",
228
- "no-extra-boolean-cast": "error",
229
- "no-fallthrough": "error",
230
- "no-func-assign": "error",
231
- "no-global-assign": "error",
232
- "no-implied-eval": "error",
233
- "no-import-assign": "error",
234
- "no-invalid-regexp": "error",
235
- "no-irregular-whitespace": "error",
236
- "no-iterator": "error",
237
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
238
- "no-lone-blocks": "error",
239
- "no-loss-of-precision": "error",
240
- "no-misleading-character-class": "error",
241
- "no-multi-str": "error",
242
- "no-new": "error",
243
- "no-new-func": "error",
244
- "no-new-native-nonconstructor": "error",
245
- "no-new-wrappers": "error",
246
- "no-obj-calls": "error",
247
- "no-octal": "error",
248
- "no-octal-escape": "error",
249
- "no-proto": "error",
250
- "no-prototype-builtins": "error",
251
- "no-redeclare": ["error", { builtinGlobals: false }],
252
- "no-regex-spaces": "error",
253
- "no-restricted-globals": [
254
- "error",
255
- { message: "Use `globalThis` instead.", name: "global" },
256
- { message: "Use `globalThis` instead.", name: "self" }
257
- ],
258
- "no-restricted-properties": [
259
- "error",
260
- { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
261
- { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
262
- { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
263
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
264
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
265
- ],
266
- "no-restricted-syntax": [
267
- "error",
268
- "DebuggerStatement",
269
- "LabeledStatement",
270
- "WithStatement",
271
- "TSEnumDeclaration[const=true]",
272
- "TSExportAssignment"
273
- ],
274
- "no-self-assign": ["error", { props: true }],
275
- "no-self-compare": "error",
276
- "no-sequences": "error",
277
- "no-shadow-restricted-names": "error",
278
- "no-sparse-arrays": "error",
279
- "no-template-curly-in-string": "error",
280
- "no-this-before-super": "error",
281
- "no-throw-literal": "error",
282
- "no-undef": "error",
283
- "no-undef-init": "error",
284
- "no-unexpected-multiline": "error",
285
- "no-unmodified-loop-condition": "error",
286
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
287
- "no-unreachable": "error",
288
- "no-unreachable-loop": "error",
289
- "no-unsafe-finally": "error",
290
- "no-unsafe-negation": "error",
291
- "no-unused-expressions": ["error", {
292
- allowShortCircuit: true,
293
- allowTaggedTemplates: true,
294
- allowTernary: true
295
- }],
296
- "no-unused-vars": ["error", {
297
- args: "none",
298
- caughtErrors: "none",
299
- ignoreRestSiblings: true,
300
- vars: "all"
301
- }],
302
- "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
303
- "no-useless-backreference": "error",
304
- "no-useless-call": "error",
305
- "no-useless-catch": "error",
306
- "no-useless-computed-key": "error",
307
- "no-useless-constructor": "error",
308
- "no-useless-rename": "error",
309
- "no-useless-return": "error",
310
- "no-var": "error",
311
- "no-with": "error",
312
- "object-shorthand": [
313
- "error",
314
- "always",
315
- {
316
- avoidQuotes: true,
317
- ignoreConstructors: false
318
- }
319
- ],
320
- "one-var": ["error", { initialized: "never" }],
321
- "prefer-arrow-callback": [
322
- "error",
323
- {
324
- allowNamedFunctions: false,
325
- allowUnboundThis: true
326
- }
327
- ],
328
- "prefer-const": [
329
- "error",
330
- {
331
- destructuring: "all",
332
- ignoreReadBeforeAssign: true
333
- }
334
- ],
335
- "prefer-exponentiation-operator": "error",
336
- "prefer-promise-reject-errors": "error",
337
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
338
- "prefer-rest-params": "error",
339
- "prefer-spread": "error",
340
- "prefer-template": "error",
341
- "sort-imports": [
342
- "error",
343
- {
344
- allowSeparatedGroups: false,
345
- ignoreCase: false,
346
- ignoreDeclarationSort: true,
347
- ignoreMemberSort: false,
348
- memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
349
- }
350
- ],
351
- "symbol-description": "error",
352
- "unicode-bom": ["error", "never"],
353
- "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
354
- "unused-imports/no-unused-vars": [
355
- "error",
356
- {
357
- args: "after-used",
358
- argsIgnorePattern: "^_",
359
- ignoreRestSiblings: true,
360
- vars: "all",
361
- varsIgnorePattern: "^_"
362
- }
363
- ],
364
- "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
365
- "valid-typeof": ["error", { requireStringLiterals: true }],
366
- "vars-on-top": "error",
367
- "yoda": ["error", "never"],
368
- ...overrides
242
+ "eslint-comments/no-aggregating-enable": "error",
243
+ "eslint-comments/no-duplicate-disable": "error",
244
+ "eslint-comments/no-unlimited-disable": "error",
245
+ "eslint-comments/no-unused-enable": "error"
369
246
  }
370
- },
247
+ }
248
+ ];
249
+ }
250
+
251
+ // src/configs/formatters.ts
252
+ import { isPackageExists as isPackageExists2 } from "local-pkg";
253
+
254
+ // src/configs/stylistic.ts
255
+ var StylisticConfigDefaults = {
256
+ indent: 2,
257
+ jsx: true,
258
+ quotes: "single",
259
+ semi: true
260
+ };
261
+ async function stylistic(options = {}) {
262
+ const {
263
+ indent,
264
+ jsx,
265
+ lessOpinionated = false,
266
+ overrides = {},
267
+ quotes,
268
+ semi
269
+ } = {
270
+ ...StylisticConfigDefaults,
271
+ ...options
272
+ };
273
+ const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
274
+ const config = pluginStylistic.configs.customize({
275
+ arrowParens: true,
276
+ braceStyle: "1tbs",
277
+ flat: true,
278
+ indent,
279
+ jsx,
280
+ pluginName: "style",
281
+ quotes,
282
+ semi
283
+ });
284
+ return [
371
285
  {
372
- files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
373
- name: "antfu/javascript/disables/cli",
286
+ name: "antfu/stylistic/rules",
287
+ plugins: {
288
+ antfu: default2,
289
+ style: pluginStylistic
290
+ },
374
291
  rules: {
375
- "no-console": "off"
292
+ ...config.rules,
293
+ "antfu/consistent-list-newline": "error",
294
+ ...lessOpinionated ? {
295
+ curly: ["error", "all"]
296
+ } : {
297
+ "antfu/if-newline": "error",
298
+ "antfu/top-level-function": "off",
299
+ "curly": ["error", "all"]
300
+ },
301
+ ...overrides
376
302
  }
377
303
  }
378
304
  ];
379
305
  }
380
306
 
381
- // src/utils.ts
382
- import process from "node:process";
383
- import { isPackageExists } from "local-pkg";
384
- var parserPlain = {
385
- meta: {
386
- name: "parser-plain"
387
- },
388
- parseForESLint: (code) => ({
389
- ast: {
390
- body: [],
391
- comments: [],
392
- loc: { end: code.length, start: 0 },
393
- range: [0, code.length],
394
- tokens: [],
395
- type: "Program"
307
+ // src/configs/formatters.ts
308
+ async function formatters(options = {}, stylistic2 = {}) {
309
+ if (options === true) {
310
+ options = {
311
+ astro: isPackageExists2("astro"),
312
+ css: true,
313
+ graphql: true,
314
+ html: true,
315
+ markdown: true,
316
+ slidev: isPackageExists2("@slidev/cli")
317
+ };
318
+ }
319
+ await ensurePackages([
320
+ "eslint-plugin-format",
321
+ options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
322
+ options.astro ? "prettier-plugin-astro" : void 0
323
+ ]);
324
+ if (options.slidev && options.markdown !== true && options.markdown !== "prettier") {
325
+ throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
326
+ }
327
+ const {
328
+ indent,
329
+ quotes,
330
+ semi
331
+ } = {
332
+ ...StylisticConfigDefaults,
333
+ ...stylistic2
334
+ };
335
+ const prettierOptions = Object.assign(
336
+ {
337
+ endOfLine: "auto",
338
+ semi,
339
+ singleQuote: quotes === "single",
340
+ tabWidth: typeof indent === "number" ? indent : 2,
341
+ trailingComma: "all",
342
+ useTabs: indent === "tab"
396
343
  },
397
- scopeManager: null,
398
- services: { isPlain: true },
399
- visitorKeys: {
400
- Program: []
344
+ options.prettierOptions || {}
345
+ );
346
+ const dprintOptions = Object.assign(
347
+ {
348
+ indentWidth: typeof indent === "number" ? indent : 2,
349
+ quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
350
+ useTabs: indent === "tab"
351
+ },
352
+ options.dprintOptions || {}
353
+ );
354
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
355
+ const configs = [
356
+ {
357
+ name: "antfu/formatter/setup",
358
+ plugins: {
359
+ format: pluginFormat
360
+ }
401
361
  }
402
- })
403
- };
404
- async function combine(...configs) {
405
- const resolved = await Promise.all(configs);
406
- return resolved.flat();
407
- }
408
- function renameRules(rules, map) {
409
- return Object.fromEntries(
410
- Object.entries(rules).map(([key, value]) => {
411
- for (const [from, to] of Object.entries(map)) {
412
- if (key.startsWith(`${from}/`)) {
413
- return [to + key.slice(from.length), value];
362
+ ];
363
+ if (options.css) {
364
+ configs.push(
365
+ {
366
+ files: [GLOB_CSS, GLOB_POSTCSS],
367
+ languageOptions: {
368
+ parser: parserPlain
369
+ },
370
+ name: "antfu/formatter/css",
371
+ rules: {
372
+ "format/prettier": [
373
+ "error",
374
+ {
375
+ ...prettierOptions,
376
+ parser: "css"
377
+ }
378
+ ]
379
+ }
380
+ },
381
+ {
382
+ files: [GLOB_SCSS],
383
+ languageOptions: {
384
+ parser: parserPlain
385
+ },
386
+ name: "antfu/formatter/scss",
387
+ rules: {
388
+ "format/prettier": [
389
+ "error",
390
+ {
391
+ ...prettierOptions,
392
+ parser: "scss"
393
+ }
394
+ ]
395
+ }
396
+ },
397
+ {
398
+ files: [GLOB_LESS],
399
+ languageOptions: {
400
+ parser: parserPlain
401
+ },
402
+ name: "antfu/formatter/less",
403
+ rules: {
404
+ "format/prettier": [
405
+ "error",
406
+ {
407
+ ...prettierOptions,
408
+ parser: "less"
409
+ }
410
+ ]
414
411
  }
415
412
  }
416
- return [key, value];
417
- })
418
- );
419
- }
420
- function renamePluginInConfigs(configs, map) {
421
- return configs.map((i) => {
422
- const clone = { ...i };
423
- if (clone.rules) {
424
- clone.rules = renameRules(clone.rules, map);
425
- }
426
- if (clone.plugins) {
427
- clone.plugins = Object.fromEntries(
428
- Object.entries(clone.plugins).map(([key, value]) => {
429
- if (key in map) {
430
- return [map[key], value];
413
+ );
414
+ }
415
+ if (options.html) {
416
+ configs.push({
417
+ files: [GLOB_HTML],
418
+ languageOptions: {
419
+ parser: parserPlain
420
+ },
421
+ name: "antfu/formatter/html",
422
+ rules: {
423
+ "format/prettier": [
424
+ "error",
425
+ {
426
+ ...prettierOptions,
427
+ parser: "html"
431
428
  }
432
- return [key, value];
433
- })
434
- );
435
- }
436
- return clone;
437
- });
438
- }
439
- function toArray(value) {
440
- return Array.isArray(value) ? value : [value];
441
- }
442
- async function interopDefault(m) {
443
- const resolved = await m;
444
- return resolved.default || resolved;
445
- }
446
- async function ensurePackages(packages) {
447
- if (process.env.CI || process.stdout.isTTY === false) {
448
- return;
429
+ ]
430
+ }
431
+ });
449
432
  }
450
- const nonExistingPackages = packages.filter((i) => i && !isPackageExists(i));
451
- if (nonExistingPackages.length === 0) {
452
- return;
433
+ if (options.markdown) {
434
+ const formater = options.markdown === true ? "prettier" : options.markdown;
435
+ const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
436
+ configs.push({
437
+ files: [GLOB_MARKDOWN],
438
+ ignores: GLOB_SLIDEV,
439
+ languageOptions: {
440
+ parser: parserPlain
441
+ },
442
+ name: "antfu/formatter/markdown",
443
+ rules: {
444
+ [`format/${formater}`]: [
445
+ "error",
446
+ formater === "prettier" ? {
447
+ printWidth: 120,
448
+ ...prettierOptions,
449
+ embeddedLanguageFormatting: "off",
450
+ parser: "markdown"
451
+ } : {
452
+ ...dprintOptions,
453
+ language: "markdown"
454
+ }
455
+ ]
456
+ }
457
+ });
458
+ if (options.slidev) {
459
+ configs.push({
460
+ files: GLOB_SLIDEV,
461
+ languageOptions: {
462
+ parser: parserPlain
463
+ },
464
+ name: "antfu/formatter/slidev",
465
+ rules: {
466
+ "format/prettier": [
467
+ "error",
468
+ {
469
+ printWidth: 120,
470
+ ...prettierOptions,
471
+ embeddedLanguageFormatting: "off",
472
+ parser: "slidev",
473
+ plugins: [
474
+ "prettier-plugin-slidev"
475
+ ]
476
+ }
477
+ ]
478
+ }
479
+ });
480
+ }
453
481
  }
454
- const p = await import("@clack/prompts");
455
- const result = await p.confirm({
456
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
457
- });
458
- if (result) {
459
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
482
+ if (options.astro) {
483
+ configs.push({
484
+ files: [GLOB_ASTRO],
485
+ languageOptions: {
486
+ parser: parserPlain
487
+ },
488
+ name: "antfu/formatter/astro",
489
+ rules: {
490
+ "format/prettier": [
491
+ "error",
492
+ {
493
+ ...prettierOptions,
494
+ parser: "astro",
495
+ plugins: [
496
+ "prettier-plugin-astro"
497
+ ]
498
+ }
499
+ ]
500
+ }
501
+ });
460
502
  }
461
- }
462
-
463
- // src/configs/jsdoc.ts
464
- async function jsdoc(options = {}) {
465
- const {
466
- stylistic: stylistic2 = true
467
- } = options;
468
- return [
469
- {
470
- name: "antfu/jsdoc/rules",
471
- plugins: {
472
- jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
503
+ if (options.graphql) {
504
+ configs.push({
505
+ files: [GLOB_GRAPHQL],
506
+ languageOptions: {
507
+ parser: parserPlain
473
508
  },
509
+ name: "antfu/formatter/graphql",
474
510
  rules: {
475
- "jsdoc/check-access": "warn",
476
- "jsdoc/check-param-names": "warn",
477
- "jsdoc/check-property-names": "warn",
478
- "jsdoc/check-types": "warn",
479
- "jsdoc/empty-tags": "warn",
480
- "jsdoc/implements-on-classes": "warn",
481
- "jsdoc/no-defaults": "warn",
482
- "jsdoc/no-multi-asterisks": "warn",
483
- "jsdoc/require-param-name": "warn",
484
- "jsdoc/require-property": "warn",
485
- "jsdoc/require-property-description": "warn",
486
- "jsdoc/require-property-name": "warn",
487
- "jsdoc/require-returns-check": "warn",
488
- "jsdoc/require-returns-description": "warn",
489
- "jsdoc/require-yields-check": "warn",
490
- ...stylistic2 ? {
491
- "jsdoc/check-alignment": "warn",
492
- "jsdoc/multiline-blocks": "warn"
493
- } : {}
511
+ "format/prettier": [
512
+ "error",
513
+ {
514
+ ...prettierOptions,
515
+ parser: "graphql"
516
+ }
517
+ ]
494
518
  }
495
- }
496
- ];
519
+ });
520
+ }
521
+ return configs;
497
522
  }
498
523
 
499
- // src/configs/jsonc.ts
500
- async function jsonc(options = {}) {
501
- const {
502
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
503
- overrides = {},
504
- stylistic: stylistic2 = true
505
- } = options;
506
- const {
507
- indent = 2
508
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
509
- const [
510
- pluginJsonc,
511
- parserJsonc
512
- ] = await Promise.all([
513
- interopDefault(import("eslint-plugin-jsonc")),
514
- interopDefault(import("jsonc-eslint-parser"))
515
- ]);
524
+ // src/configs/ignores.ts
525
+ async function ignores() {
516
526
  return [
517
527
  {
518
- name: "antfu/jsonc/setup",
519
- plugins: {
520
- jsonc: pluginJsonc
521
- }
522
- },
523
- {
524
- files,
525
- languageOptions: {
526
- parser: parserJsonc
527
- },
528
- name: "antfu/jsonc/rules",
529
- rules: {
530
- "jsonc/no-bigint-literals": "error",
531
- "jsonc/no-binary-expression": "error",
532
- "jsonc/no-binary-numeric-literals": "error",
533
- "jsonc/no-dupe-keys": "error",
534
- "jsonc/no-escape-sequence-in-identifier": "error",
535
- "jsonc/no-floating-decimal": "error",
536
- "jsonc/no-hexadecimal-numeric-literals": "error",
537
- "jsonc/no-infinity": "error",
538
- "jsonc/no-multi-str": "error",
539
- "jsonc/no-nan": "error",
540
- "jsonc/no-number-props": "error",
541
- "jsonc/no-numeric-separators": "error",
542
- "jsonc/no-octal": "error",
543
- "jsonc/no-octal-escape": "error",
544
- "jsonc/no-octal-numeric-literals": "error",
545
- "jsonc/no-parenthesized": "error",
546
- "jsonc/no-plus-sign": "error",
547
- "jsonc/no-regexp-literals": "error",
548
- "jsonc/no-sparse-arrays": "error",
549
- "jsonc/no-template-literals": "error",
550
- "jsonc/no-undefined-value": "error",
551
- "jsonc/no-unicode-codepoint-escapes": "error",
552
- "jsonc/no-useless-escape": "error",
553
- "jsonc/space-unary-ops": "error",
554
- "jsonc/valid-json-number": "error",
555
- "jsonc/vue-custom-block/no-parsing-error": "error",
556
- ...stylistic2 ? {
557
- "jsonc/array-bracket-spacing": ["error", "never"],
558
- "jsonc/comma-dangle": ["error", "never"],
559
- "jsonc/comma-style": ["error", "last"],
560
- "jsonc/indent": ["error", indent],
561
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
562
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
563
- "jsonc/object-curly-spacing": ["error", "always"],
564
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
565
- "jsonc/quote-props": "error",
566
- "jsonc/quotes": "error"
567
- } : {},
568
- ...overrides
569
- }
528
+ ignores: GLOB_EXCLUDE
529
+ // Awaits https://github.com/humanwhocodes/config-array/pull/131
530
+ // name: 'antfu/ignores',
570
531
  }
571
532
  ];
572
533
  }
573
534
 
574
- // src/configs/markdown.ts
575
- import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
576
- async function markdown(options = {}) {
535
+ // src/configs/imports.ts
536
+ async function imports(options = {}) {
577
537
  const {
578
- componentExts = [],
579
- files = [GLOB_MARKDOWN],
580
- overrides = {}
538
+ stylistic: stylistic2 = true
581
539
  } = options;
582
- const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
583
540
  return [
584
541
  {
585
- name: "antfu/markdown/setup",
542
+ name: "antfu/imports/rules",
586
543
  plugins: {
587
- markdown: markdown2
588
- }
589
- },
590
- {
591
- files,
592
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
593
- name: "antfu/markdown/processor",
594
- // `eslint-plugin-markdown` only creates virtual files for code blocks,
595
- // but not the markdown file itself. We use `eslint-merge-processors` to
596
- // add a pass-through processor for the markdown file itself.
597
- processor: mergeProcessors([
598
- markdown2.processors.markdown,
599
- processorPassThrough
600
- ])
601
- },
602
- {
603
- files,
604
- languageOptions: {
605
- parser: parserPlain
606
- },
607
- name: "antfu/markdown/parser"
608
- },
609
- {
610
- files: [
611
- GLOB_MARKDOWN_CODE,
612
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
613
- ],
614
- languageOptions: {
615
- parserOptions: {
616
- ecmaFeatures: {
617
- impliedStrict: true
618
- }
619
- }
544
+ antfu: default2,
545
+ import: pluginImport
620
546
  },
621
- name: "antfu/markdown/disables",
622
547
  rules: {
623
- "import/newline-after-import": "off",
624
- "no-alert": "off",
625
- "no-console": "off",
626
- "no-labels": "off",
627
- "no-lone-blocks": "off",
628
- "no-restricted-syntax": "off",
629
- "no-undef": "off",
630
- "no-unused-expressions": "off",
631
- "no-unused-labels": "off",
632
- "no-unused-vars": "off",
633
- "node/prefer-global/process": "off",
634
- "style/comma-dangle": "off",
635
- "style/eol-last": "off",
636
- "ts/consistent-type-imports": "off",
637
- "ts/no-namespace": "off",
638
- "ts/no-redeclare": "off",
639
- "ts/no-require-imports": "off",
640
- "ts/no-unused-vars": "off",
641
- "ts/no-use-before-define": "off",
642
- "ts/no-var-requires": "off",
643
- "unicode-bom": "off",
644
- "unused-imports/no-unused-imports": "off",
645
- "unused-imports/no-unused-vars": "off",
646
- // Type aware rules
647
- ...{
648
- "ts/await-thenable": "off",
649
- "ts/dot-notation": "off",
650
- "ts/no-floating-promises": "off",
651
- "ts/no-for-in-array": "off",
652
- "ts/no-implied-eval": "off",
653
- "ts/no-misused-promises": "off",
654
- "ts/no-throw-literal": "off",
655
- "ts/no-unnecessary-type-assertion": "off",
656
- "ts/no-unsafe-argument": "off",
657
- "ts/no-unsafe-assignment": "off",
658
- "ts/no-unsafe-call": "off",
659
- "ts/no-unsafe-member-access": "off",
660
- "ts/no-unsafe-return": "off",
661
- "ts/restrict-plus-operands": "off",
662
- "ts/restrict-template-expressions": "off",
663
- "ts/unbound-method": "off"
664
- },
665
- ...overrides
548
+ "antfu/import-dedupe": "error",
549
+ "antfu/no-import-dist": "error",
550
+ "antfu/no-import-node-modules-by-path": "error",
551
+ "import/first": "error",
552
+ "import/no-duplicates": "error",
553
+ "import/no-mutable-exports": "error",
554
+ "import/no-named-default": "error",
555
+ "import/no-self-import": "error",
556
+ "import/no-webpack-loader-syntax": "error",
557
+ "import/order": "error",
558
+ ...stylistic2 ? {
559
+ "import/newline-after-import": ["error", { count: 1 }]
560
+ } : {}
561
+ }
562
+ },
563
+ {
564
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
565
+ name: "antfu/imports/disables/bin",
566
+ rules: {
567
+ "antfu/no-import-dist": "off",
568
+ "antfu/no-import-node-modules-by-path": "off"
666
569
  }
667
570
  }
668
571
  ];
669
572
  }
670
573
 
671
- // src/configs/node.ts
672
- async function node() {
574
+ // src/configs/javascript.ts
575
+ import globals from "globals";
576
+ async function javascript(options = {}) {
577
+ const {
578
+ isInEditor = false,
579
+ overrides = {}
580
+ } = options;
673
581
  return [
674
582
  {
675
- name: "antfu/node/rules",
583
+ languageOptions: {
584
+ ecmaVersion: 2022,
585
+ globals: {
586
+ ...globals.browser,
587
+ ...globals.es2021,
588
+ ...globals.node,
589
+ document: "readonly",
590
+ navigator: "readonly",
591
+ window: "readonly"
592
+ },
593
+ parserOptions: {
594
+ ecmaFeatures: {
595
+ jsx: true
596
+ },
597
+ ecmaVersion: 2022,
598
+ sourceType: "module"
599
+ },
600
+ sourceType: "module"
601
+ },
602
+ linterOptions: {
603
+ reportUnusedDisableDirectives: true
604
+ },
605
+ name: "antfu/javascript/rules",
676
606
  plugins: {
677
- node: default4
607
+ "antfu": default2,
608
+ "unused-imports": default6
678
609
  },
679
610
  rules: {
680
- "node/handle-callback-err": ["error", "^(err|error)$"],
681
- "node/no-deprecated-api": "error",
682
- "node/no-exports-assign": "error",
683
- "node/no-new-require": "error",
684
- "node/no-path-concat": "error",
685
- "node/prefer-global/buffer": ["error", "never"],
686
- "node/prefer-global/process": ["error", "never"],
687
- "node/process-exit-as-throw": "error"
611
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
612
+ "array-callback-return": "error",
613
+ "block-scoped-var": "error",
614
+ "constructor-super": "error",
615
+ "default-case-last": "error",
616
+ "dot-notation": ["error", { allowKeywords: true }],
617
+ "eqeqeq": ["error", "smart"],
618
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
619
+ "no-alert": "error",
620
+ "no-array-constructor": "error",
621
+ "no-async-promise-executor": "error",
622
+ "no-caller": "error",
623
+ "no-case-declarations": "error",
624
+ "no-class-assign": "error",
625
+ "no-compare-neg-zero": "error",
626
+ "no-cond-assign": ["error", "always"],
627
+ "no-console": ["error", { allow: ["warn", "error"] }],
628
+ "no-const-assign": "error",
629
+ "no-control-regex": "error",
630
+ "no-debugger": "error",
631
+ "no-delete-var": "error",
632
+ "no-dupe-args": "error",
633
+ "no-dupe-class-members": "error",
634
+ "no-dupe-keys": "error",
635
+ "no-duplicate-case": "error",
636
+ "no-empty": ["error", { allowEmptyCatch: true }],
637
+ "no-empty-character-class": "error",
638
+ "no-empty-pattern": "error",
639
+ "no-eval": "error",
640
+ "no-ex-assign": "error",
641
+ "no-extend-native": "error",
642
+ "no-extra-bind": "error",
643
+ "no-extra-boolean-cast": "error",
644
+ "no-fallthrough": "error",
645
+ "no-func-assign": "error",
646
+ "no-global-assign": "error",
647
+ "no-implied-eval": "error",
648
+ "no-import-assign": "error",
649
+ "no-invalid-regexp": "error",
650
+ "no-irregular-whitespace": "error",
651
+ "no-iterator": "error",
652
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
653
+ "no-lone-blocks": "error",
654
+ "no-loss-of-precision": "error",
655
+ "no-misleading-character-class": "error",
656
+ "no-multi-str": "error",
657
+ "no-new": "error",
658
+ "no-new-func": "error",
659
+ "no-new-native-nonconstructor": "error",
660
+ "no-new-wrappers": "error",
661
+ "no-obj-calls": "error",
662
+ "no-octal": "error",
663
+ "no-octal-escape": "error",
664
+ "no-proto": "error",
665
+ "no-prototype-builtins": "error",
666
+ "no-redeclare": ["error", { builtinGlobals: false }],
667
+ "no-regex-spaces": "error",
668
+ "no-restricted-globals": [
669
+ "error",
670
+ { message: "Use `globalThis` instead.", name: "global" },
671
+ { message: "Use `globalThis` instead.", name: "self" }
672
+ ],
673
+ "no-restricted-properties": [
674
+ "error",
675
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
676
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
677
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
678
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
679
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
680
+ ],
681
+ "no-restricted-syntax": [
682
+ "error",
683
+ "DebuggerStatement",
684
+ "LabeledStatement",
685
+ "WithStatement",
686
+ "TSEnumDeclaration[const=true]",
687
+ "TSExportAssignment"
688
+ ],
689
+ "no-self-assign": ["error", { props: true }],
690
+ "no-self-compare": "error",
691
+ "no-sequences": "error",
692
+ "no-shadow-restricted-names": "error",
693
+ "no-sparse-arrays": "error",
694
+ "no-template-curly-in-string": "error",
695
+ "no-this-before-super": "error",
696
+ "no-throw-literal": "error",
697
+ "no-undef": "error",
698
+ "no-undef-init": "error",
699
+ "no-unexpected-multiline": "error",
700
+ "no-unmodified-loop-condition": "error",
701
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
702
+ "no-unreachable": "error",
703
+ "no-unreachable-loop": "error",
704
+ "no-unsafe-finally": "error",
705
+ "no-unsafe-negation": "error",
706
+ "no-unused-expressions": ["error", {
707
+ allowShortCircuit: true,
708
+ allowTaggedTemplates: true,
709
+ allowTernary: true
710
+ }],
711
+ "no-unused-vars": ["error", {
712
+ args: "none",
713
+ caughtErrors: "none",
714
+ ignoreRestSiblings: true,
715
+ vars: "all"
716
+ }],
717
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
718
+ "no-useless-backreference": "error",
719
+ "no-useless-call": "error",
720
+ "no-useless-catch": "error",
721
+ "no-useless-computed-key": "error",
722
+ "no-useless-constructor": "error",
723
+ "no-useless-rename": "error",
724
+ "no-useless-return": "error",
725
+ "no-var": "error",
726
+ "no-with": "error",
727
+ "object-shorthand": [
728
+ "error",
729
+ "always",
730
+ {
731
+ avoidQuotes: true,
732
+ ignoreConstructors: false
733
+ }
734
+ ],
735
+ "one-var": ["error", { initialized: "never" }],
736
+ "prefer-arrow-callback": [
737
+ "error",
738
+ {
739
+ allowNamedFunctions: false,
740
+ allowUnboundThis: true
741
+ }
742
+ ],
743
+ "prefer-const": [
744
+ "error",
745
+ {
746
+ destructuring: "all",
747
+ ignoreReadBeforeAssign: true
748
+ }
749
+ ],
750
+ "prefer-exponentiation-operator": "error",
751
+ "prefer-promise-reject-errors": "error",
752
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
753
+ "prefer-rest-params": "error",
754
+ "prefer-spread": "error",
755
+ "prefer-template": "error",
756
+ "sort-imports": [
757
+ "error",
758
+ {
759
+ allowSeparatedGroups: false,
760
+ ignoreCase: false,
761
+ ignoreDeclarationSort: true,
762
+ ignoreMemberSort: false,
763
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
764
+ }
765
+ ],
766
+ "symbol-description": "error",
767
+ "unicode-bom": ["error", "never"],
768
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
769
+ "unused-imports/no-unused-vars": [
770
+ "error",
771
+ {
772
+ args: "after-used",
773
+ argsIgnorePattern: "^_",
774
+ ignoreRestSiblings: true,
775
+ vars: "all",
776
+ varsIgnorePattern: "^_"
777
+ }
778
+ ],
779
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
780
+ "valid-typeof": ["error", { requireStringLiterals: true }],
781
+ "vars-on-top": "error",
782
+ "yoda": ["error", "never"],
783
+ ...overrides
784
+ }
785
+ },
786
+ {
787
+ files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
788
+ name: "antfu/javascript/disables/cli",
789
+ rules: {
790
+ "no-console": "off"
688
791
  }
689
792
  }
690
793
  ];
691
794
  }
692
795
 
693
- // src/configs/perfectionist.ts
694
- async function perfectionist() {
796
+ // src/configs/jsdoc.ts
797
+ async function jsdoc(options = {}) {
798
+ const {
799
+ stylistic: stylistic2 = true
800
+ } = options;
695
801
  return [
696
802
  {
697
- name: "antfu/perfectionist/setup",
803
+ name: "antfu/jsdoc/rules",
698
804
  plugins: {
699
- perfectionist: default7
805
+ jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
806
+ },
807
+ rules: {
808
+ "jsdoc/check-access": "warn",
809
+ "jsdoc/check-param-names": "warn",
810
+ "jsdoc/check-property-names": "warn",
811
+ "jsdoc/check-types": "warn",
812
+ "jsdoc/empty-tags": "warn",
813
+ "jsdoc/implements-on-classes": "warn",
814
+ "jsdoc/no-defaults": "warn",
815
+ "jsdoc/no-multi-asterisks": "warn",
816
+ "jsdoc/require-param-name": "warn",
817
+ "jsdoc/require-property": "warn",
818
+ "jsdoc/require-property-description": "warn",
819
+ "jsdoc/require-property-name": "warn",
820
+ "jsdoc/require-returns-check": "warn",
821
+ "jsdoc/require-returns-description": "warn",
822
+ "jsdoc/require-yields-check": "warn",
823
+ ...stylistic2 ? {
824
+ "jsdoc/check-alignment": "warn",
825
+ "jsdoc/multiline-blocks": "warn"
826
+ } : {}
700
827
  }
701
828
  }
702
829
  ];
703
830
  }
704
831
 
705
- // src/configs/formatters.ts
706
- import { isPackageExists as isPackageExists2 } from "local-pkg";
707
-
708
- // src/configs/stylistic.ts
709
- var StylisticConfigDefaults = {
710
- indent: 2,
711
- jsx: true,
712
- quotes: "single",
713
- semi: true
714
- };
715
- async function stylistic(options = {}) {
832
+ // src/configs/jsonc.ts
833
+ async function jsonc(options = {}) {
716
834
  const {
717
- indent,
718
- jsx,
719
- lessOpinionated = false,
835
+ files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
720
836
  overrides = {},
721
- quotes,
722
- semi
723
- } = {
724
- ...StylisticConfigDefaults,
725
- ...options
726
- };
727
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
728
- const config = pluginStylistic.configs.customize({
729
- arrowParens: true,
730
- braceStyle: "1tbs",
731
- flat: true,
732
- indent,
733
- jsx,
734
- pluginName: "style",
735
- quotes,
736
- semi
737
- });
837
+ stylistic: stylistic2 = true
838
+ } = options;
839
+ const {
840
+ indent = 2
841
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
842
+ const [
843
+ pluginJsonc,
844
+ parserJsonc
845
+ ] = await Promise.all([
846
+ interopDefault(import("eslint-plugin-jsonc")),
847
+ interopDefault(import("jsonc-eslint-parser"))
848
+ ]);
738
849
  return [
739
850
  {
740
- name: "antfu/stylistic/rules",
851
+ name: "antfu/jsonc/setup",
741
852
  plugins: {
742
- antfu: default2,
743
- style: pluginStylistic
853
+ jsonc: pluginJsonc
854
+ }
855
+ },
856
+ {
857
+ files,
858
+ languageOptions: {
859
+ parser: parserJsonc
744
860
  },
861
+ name: "antfu/jsonc/rules",
745
862
  rules: {
746
- ...config.rules,
747
- "antfu/consistent-list-newline": "error",
748
- ...lessOpinionated ? {
749
- curly: ["error", "all"]
750
- } : {
751
- "antfu/if-newline": "error",
752
- "antfu/top-level-function": "off",
753
- "curly": ["error", "all"]
754
- },
863
+ "jsonc/no-bigint-literals": "error",
864
+ "jsonc/no-binary-expression": "error",
865
+ "jsonc/no-binary-numeric-literals": "error",
866
+ "jsonc/no-dupe-keys": "error",
867
+ "jsonc/no-escape-sequence-in-identifier": "error",
868
+ "jsonc/no-floating-decimal": "error",
869
+ "jsonc/no-hexadecimal-numeric-literals": "error",
870
+ "jsonc/no-infinity": "error",
871
+ "jsonc/no-multi-str": "error",
872
+ "jsonc/no-nan": "error",
873
+ "jsonc/no-number-props": "error",
874
+ "jsonc/no-numeric-separators": "error",
875
+ "jsonc/no-octal": "error",
876
+ "jsonc/no-octal-escape": "error",
877
+ "jsonc/no-octal-numeric-literals": "error",
878
+ "jsonc/no-parenthesized": "error",
879
+ "jsonc/no-plus-sign": "error",
880
+ "jsonc/no-regexp-literals": "error",
881
+ "jsonc/no-sparse-arrays": "error",
882
+ "jsonc/no-template-literals": "error",
883
+ "jsonc/no-undefined-value": "error",
884
+ "jsonc/no-unicode-codepoint-escapes": "error",
885
+ "jsonc/no-useless-escape": "error",
886
+ "jsonc/space-unary-ops": "error",
887
+ "jsonc/valid-json-number": "error",
888
+ "jsonc/vue-custom-block/no-parsing-error": "error",
889
+ ...stylistic2 ? {
890
+ "jsonc/array-bracket-spacing": ["error", "never"],
891
+ "jsonc/comma-dangle": ["error", "never"],
892
+ "jsonc/comma-style": ["error", "last"],
893
+ "jsonc/indent": ["error", indent],
894
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
895
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
896
+ "jsonc/object-curly-spacing": ["error", "always"],
897
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
898
+ "jsonc/quote-props": "error",
899
+ "jsonc/quotes": "error"
900
+ } : {},
755
901
  ...overrides
756
902
  }
757
903
  }
758
904
  ];
759
905
  }
760
906
 
761
- // src/configs/formatters.ts
762
- async function formatters(options = {}, stylistic2 = {}) {
763
- if (options === true) {
764
- options = {
765
- astro: isPackageExists2("astro"),
766
- css: true,
767
- graphql: true,
768
- html: true,
769
- markdown: true,
770
- slidev: isPackageExists2("@slidev/cli")
771
- };
772
- }
773
- await ensurePackages([
774
- "eslint-plugin-format",
775
- options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
776
- options.astro ? "prettier-plugin-astro" : void 0
777
- ]);
778
- if (options.slidev && options.markdown !== true && options.markdown !== "prettier") {
779
- throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
780
- }
907
+ // src/configs/markdown.ts
908
+ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
909
+ async function markdown(options = {}) {
781
910
  const {
782
- indent,
783
- quotes,
784
- semi
785
- } = {
786
- ...StylisticConfigDefaults,
787
- ...stylistic2
788
- };
789
- const prettierOptions = Object.assign(
790
- {
791
- endOfLine: "auto",
792
- semi,
793
- singleQuote: quotes === "single",
794
- tabWidth: typeof indent === "number" ? indent : 2,
795
- trailingComma: "all",
796
- useTabs: indent === "tab"
797
- },
798
- options.prettierOptions || {}
799
- );
800
- const dprintOptions = Object.assign(
801
- {
802
- indentWidth: typeof indent === "number" ? indent : 2,
803
- quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
804
- useTabs: indent === "tab"
805
- },
806
- options.dprintOptions || {}
807
- );
808
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
809
- const configs = [
810
- {
811
- name: "antfu/formatter/setup",
812
- plugins: {
813
- format: pluginFormat
814
- }
815
- }
816
- ];
817
- if (options.css) {
818
- configs.push(
819
- {
820
- files: [GLOB_CSS, GLOB_POSTCSS],
821
- languageOptions: {
822
- parser: parserPlain
823
- },
824
- name: "antfu/formatter/css",
825
- rules: {
826
- "format/prettier": [
827
- "error",
828
- {
829
- ...prettierOptions,
830
- parser: "css"
831
- }
832
- ]
833
- }
834
- },
835
- {
836
- files: [GLOB_SCSS],
837
- languageOptions: {
838
- parser: parserPlain
839
- },
840
- name: "antfu/formatter/scss",
841
- rules: {
842
- "format/prettier": [
843
- "error",
844
- {
845
- ...prettierOptions,
846
- parser: "scss"
847
- }
848
- ]
849
- }
850
- },
851
- {
852
- files: [GLOB_LESS],
853
- languageOptions: {
854
- parser: parserPlain
855
- },
856
- name: "antfu/formatter/less",
857
- rules: {
858
- "format/prettier": [
859
- "error",
860
- {
861
- ...prettierOptions,
862
- parser: "less"
863
- }
864
- ]
865
- }
866
- }
867
- );
868
- }
869
- if (options.html) {
870
- configs.push({
871
- files: [GLOB_HTML],
872
- languageOptions: {
873
- parser: parserPlain
874
- },
875
- name: "antfu/formatter/html",
876
- rules: {
877
- "format/prettier": [
878
- "error",
879
- {
880
- ...prettierOptions,
881
- parser: "html"
882
- }
883
- ]
911
+ componentExts = [],
912
+ files = [GLOB_MARKDOWN],
913
+ overrides = {}
914
+ } = options;
915
+ const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
916
+ return [
917
+ {
918
+ name: "antfu/markdown/setup",
919
+ plugins: {
920
+ markdown: markdown2
884
921
  }
885
- });
886
- }
887
- if (options.markdown) {
888
- const formater = options.markdown === true ? "prettier" : options.markdown;
889
- const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
890
- configs.push({
891
- files: [GLOB_MARKDOWN],
892
- ignores: GLOB_SLIDEV,
922
+ },
923
+ {
924
+ files,
925
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
926
+ name: "antfu/markdown/processor",
927
+ // `eslint-plugin-markdown` only creates virtual files for code blocks,
928
+ // but not the markdown file itself. We use `eslint-merge-processors` to
929
+ // add a pass-through processor for the markdown file itself.
930
+ processor: mergeProcessors([
931
+ markdown2.processors.markdown,
932
+ processorPassThrough
933
+ ])
934
+ },
935
+ {
936
+ files,
893
937
  languageOptions: {
894
938
  parser: parserPlain
895
939
  },
896
- name: "antfu/formatter/markdown",
897
- rules: {
898
- [`format/${formater}`]: [
899
- "error",
900
- formater === "prettier" ? {
901
- printWidth: 120,
902
- ...prettierOptions,
903
- embeddedLanguageFormatting: "off",
904
- parser: "markdown"
905
- } : {
906
- ...dprintOptions,
907
- language: "markdown"
940
+ name: "antfu/markdown/parser"
941
+ },
942
+ {
943
+ files: [
944
+ GLOB_MARKDOWN_CODE,
945
+ ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
946
+ ],
947
+ languageOptions: {
948
+ parserOptions: {
949
+ ecmaFeatures: {
950
+ impliedStrict: true
908
951
  }
909
- ]
910
- }
911
- });
912
- if (options.slidev) {
913
- configs.push({
914
- files: GLOB_SLIDEV,
915
- languageOptions: {
916
- parser: parserPlain
917
- },
918
- name: "antfu/formatter/slidev",
919
- rules: {
920
- "format/prettier": [
921
- "error",
922
- {
923
- printWidth: 120,
924
- ...prettierOptions,
925
- embeddedLanguageFormatting: "off",
926
- parser: "slidev",
927
- plugins: [
928
- "prettier-plugin-slidev"
929
- ]
930
- }
931
- ]
932
952
  }
933
- });
934
- }
935
- }
936
- if (options.astro) {
937
- configs.push({
938
- files: [GLOB_ASTRO],
939
- languageOptions: {
940
- parser: parserPlain
941
953
  },
942
- name: "antfu/formatter/astro",
954
+ name: "antfu/markdown/disables",
943
955
  rules: {
944
- "format/prettier": [
945
- "error",
946
- {
947
- ...prettierOptions,
948
- parser: "astro",
949
- plugins: [
950
- "prettier-plugin-astro"
951
- ]
952
- }
953
- ]
956
+ "import/newline-after-import": "off",
957
+ "no-alert": "off",
958
+ "no-console": "off",
959
+ "no-labels": "off",
960
+ "no-lone-blocks": "off",
961
+ "no-restricted-syntax": "off",
962
+ "no-undef": "off",
963
+ "no-unused-expressions": "off",
964
+ "no-unused-labels": "off",
965
+ "no-unused-vars": "off",
966
+ "node/prefer-global/process": "off",
967
+ "style/comma-dangle": "off",
968
+ "style/eol-last": "off",
969
+ "ts/consistent-type-imports": "off",
970
+ "ts/no-namespace": "off",
971
+ "ts/no-redeclare": "off",
972
+ "ts/no-require-imports": "off",
973
+ "ts/no-unused-vars": "off",
974
+ "ts/no-use-before-define": "off",
975
+ "ts/no-var-requires": "off",
976
+ "unicode-bom": "off",
977
+ "unused-imports/no-unused-imports": "off",
978
+ "unused-imports/no-unused-vars": "off",
979
+ // Type aware rules
980
+ ...{
981
+ "ts/await-thenable": "off",
982
+ "ts/dot-notation": "off",
983
+ "ts/no-floating-promises": "off",
984
+ "ts/no-for-in-array": "off",
985
+ "ts/no-implied-eval": "off",
986
+ "ts/no-misused-promises": "off",
987
+ "ts/no-throw-literal": "off",
988
+ "ts/no-unnecessary-type-assertion": "off",
989
+ "ts/no-unsafe-argument": "off",
990
+ "ts/no-unsafe-assignment": "off",
991
+ "ts/no-unsafe-call": "off",
992
+ "ts/no-unsafe-member-access": "off",
993
+ "ts/no-unsafe-return": "off",
994
+ "ts/restrict-plus-operands": "off",
995
+ "ts/restrict-template-expressions": "off",
996
+ "ts/unbound-method": "off"
997
+ },
998
+ ...overrides
954
999
  }
955
- });
956
- }
957
- if (options.graphql) {
958
- configs.push({
959
- files: [GLOB_GRAPHQL],
960
- languageOptions: {
961
- parser: parserPlain
1000
+ }
1001
+ ];
1002
+ }
1003
+
1004
+ // src/configs/node.ts
1005
+ async function node() {
1006
+ return [
1007
+ {
1008
+ name: "antfu/node/rules",
1009
+ plugins: {
1010
+ node: default4
962
1011
  },
963
- name: "antfu/formatter/graphql",
964
1012
  rules: {
965
- "format/prettier": [
966
- "error",
967
- {
968
- ...prettierOptions,
969
- parser: "graphql"
970
- }
971
- ]
1013
+ "node/handle-callback-err": ["error", "^(err|error)$"],
1014
+ "node/no-deprecated-api": "error",
1015
+ "node/no-exports-assign": "error",
1016
+ "node/no-new-require": "error",
1017
+ "node/no-path-concat": "error",
1018
+ "node/prefer-global/buffer": ["error", "never"],
1019
+ "node/prefer-global/process": ["error", "never"],
1020
+ "node/process-exit-as-throw": "error"
972
1021
  }
973
- });
974
- }
975
- return configs;
1022
+ }
1023
+ ];
1024
+ }
1025
+
1026
+ // src/configs/perfectionist.ts
1027
+ async function perfectionist() {
1028
+ return [
1029
+ {
1030
+ name: "antfu/perfectionist/setup",
1031
+ plugins: {
1032
+ perfectionist: default7
1033
+ }
1034
+ }
1035
+ ];
976
1036
  }
977
1037
 
978
1038
  // src/configs/react.ts
@@ -980,6 +1040,15 @@ import { isPackageExists as isPackageExists3 } from "local-pkg";
980
1040
  var ReactRefreshAllowConstantExportPackages = [
981
1041
  "vite"
982
1042
  ];
1043
+ var RemixPackages = [
1044
+ "@remix-run/node",
1045
+ "@remix-run/react",
1046
+ "@remix-run/serve",
1047
+ "@remix-run/dev"
1048
+ ];
1049
+ var NextJsPackages = [
1050
+ "next"
1051
+ ];
983
1052
  async function react(options = {}) {
984
1053
  const {
985
1054
  files = [GLOB_TS, GLOB_TSX],
@@ -1003,9 +1072,9 @@ async function react(options = {}) {
1003
1072
  interopDefault(import("eslint-plugin-react-refresh")),
1004
1073
  interopDefault(import("@typescript-eslint/parser"))
1005
1074
  ]);
1006
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1007
- (i) => isPackageExists3(i)
1008
- );
1075
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists3(i));
1076
+ const isUsingRemix = RemixPackages.some((i) => isPackageExists3(i));
1077
+ const isUsingNext = NextJsPackages.some((i) => isPackageExists3(i));
1009
1078
  const plugins = pluginReact.configs.all.plugins;
1010
1079
  return [
1011
1080
  {
@@ -1051,7 +1120,26 @@ async function react(options = {}) {
1051
1120
  // react refresh
1052
1121
  "react-refresh/only-export-components": [
1053
1122
  "warn",
1054
- { allowConstantExport: isAllowConstantExport }
1123
+ {
1124
+ allowConstantExport: isAllowConstantExport,
1125
+ allowExportNames: [
1126
+ ...isUsingNext ? [
1127
+ "config",
1128
+ "generateStaticParams",
1129
+ "metadata",
1130
+ "generateMetadata",
1131
+ "viewport",
1132
+ "generateViewport"
1133
+ ] : [],
1134
+ ...isUsingRemix ? [
1135
+ "meta",
1136
+ "links",
1137
+ "headers",
1138
+ "loader",
1139
+ "action"
1140
+ ] : []
1141
+ ]
1142
+ }
1055
1143
  ],
1056
1144
  // recommended rules from @eslint-react
1057
1145
  "react/ensure-forward-ref-using-ref": "warn",
@@ -1100,6 +1188,82 @@ async function react(options = {}) {
1100
1188
  ];
1101
1189
  }
1102
1190
 
1191
+ // src/configs/solid.ts
1192
+ async function solid(options = {}) {
1193
+ const {
1194
+ files = [GLOB_JSX, GLOB_TSX],
1195
+ overrides = {},
1196
+ typescript: typescript2 = true
1197
+ } = options;
1198
+ await ensurePackages([
1199
+ "eslint-plugin-solid"
1200
+ ]);
1201
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1202
+ const isTypeAware = !!tsconfigPath;
1203
+ const [
1204
+ pluginSolid,
1205
+ parserTs
1206
+ ] = await Promise.all([
1207
+ interopDefault(import("eslint-plugin-solid")),
1208
+ interopDefault(import("@typescript-eslint/parser"))
1209
+ ]);
1210
+ return [
1211
+ {
1212
+ name: "antfu/solid/setup",
1213
+ plugins: {
1214
+ solid: pluginSolid
1215
+ }
1216
+ },
1217
+ {
1218
+ files,
1219
+ languageOptions: {
1220
+ parser: parserTs,
1221
+ parserOptions: {
1222
+ ecmaFeatures: {
1223
+ jsx: true
1224
+ },
1225
+ ...isTypeAware ? { project: tsconfigPath } : {}
1226
+ },
1227
+ sourceType: "module"
1228
+ },
1229
+ name: "antfu/solid/rules",
1230
+ rules: {
1231
+ // reactivity
1232
+ "solid/components-return-once": "warn",
1233
+ "solid/event-handlers": ["error", {
1234
+ // if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
1235
+ ignoreCase: false,
1236
+ // if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
1237
+ warnOnSpread: false
1238
+ }],
1239
+ // these rules are mostly style suggestions
1240
+ "solid/imports": "error",
1241
+ // identifier usage is important
1242
+ "solid/jsx-no-duplicate-props": "error",
1243
+ "solid/jsx-no-script-url": "error",
1244
+ "solid/jsx-no-undef": "error",
1245
+ "solid/jsx-uses-vars": "error",
1246
+ "solid/no-destructure": "error",
1247
+ // security problems
1248
+ "solid/no-innerhtml": ["error", { allowStatic: true }],
1249
+ "solid/no-react-deps": "error",
1250
+ "solid/no-react-specific-props": "error",
1251
+ "solid/no-unknown-namespaces": "error",
1252
+ "solid/prefer-for": "error",
1253
+ "solid/reactivity": "warn",
1254
+ "solid/self-closing-comp": "error",
1255
+ "solid/style-prop": ["error", { styleProps: ["style", "css"] }],
1256
+ ...typescript2 ? {
1257
+ "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
1258
+ "solid/no-unknown-namespaces": "off"
1259
+ } : {},
1260
+ // overrides
1261
+ ...overrides
1262
+ }
1263
+ }
1264
+ ];
1265
+ }
1266
+
1103
1267
  // src/configs/sort.ts
1104
1268
  async function sortPackageJson() {
1105
1269
  return [
@@ -1471,6 +1635,65 @@ async function test(options = {}) {
1471
1635
  ];
1472
1636
  }
1473
1637
 
1638
+ // src/configs/toml.ts
1639
+ async function toml(options = {}) {
1640
+ const {
1641
+ files = [GLOB_TOML],
1642
+ overrides = {},
1643
+ stylistic: stylistic2 = true
1644
+ } = options;
1645
+ const {
1646
+ indent = 2
1647
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1648
+ const [
1649
+ pluginToml,
1650
+ parserToml
1651
+ ] = await Promise.all([
1652
+ interopDefault(import("eslint-plugin-toml")),
1653
+ interopDefault(import("toml-eslint-parser"))
1654
+ ]);
1655
+ return [
1656
+ {
1657
+ name: "antfu/toml/setup",
1658
+ plugins: {
1659
+ toml: pluginToml
1660
+ }
1661
+ },
1662
+ {
1663
+ files,
1664
+ languageOptions: {
1665
+ parser: parserToml
1666
+ },
1667
+ name: "antfu/toml/rules",
1668
+ rules: {
1669
+ "style/spaced-comment": "off",
1670
+ "toml/comma-style": "error",
1671
+ "toml/keys-order": "error",
1672
+ "toml/no-space-dots": "error",
1673
+ "toml/no-unreadable-number-separator": "error",
1674
+ "toml/precision-of-fractional-seconds": "error",
1675
+ "toml/precision-of-integer": "error",
1676
+ "toml/tables-order": "error",
1677
+ "toml/vue-custom-block/no-parsing-error": "error",
1678
+ ...stylistic2 ? {
1679
+ "toml/array-bracket-newline": "error",
1680
+ "toml/array-bracket-spacing": "error",
1681
+ "toml/array-element-newline": "error",
1682
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1683
+ "toml/inline-table-curly-spacing": "error",
1684
+ "toml/key-spacing": "error",
1685
+ "toml/padding-line-between-pairs": "error",
1686
+ "toml/padding-line-between-tables": "error",
1687
+ "toml/quoted-keys": "error",
1688
+ "toml/spaced-comment": "error",
1689
+ "toml/table-bracket-spacing": "error"
1690
+ } : {},
1691
+ ...overrides
1692
+ }
1693
+ }
1694
+ ];
1695
+ }
1696
+
1474
1697
  // src/configs/typescript.ts
1475
1698
  import process2 from "node:process";
1476
1699
  async function typescript(options = {}) {
@@ -1924,190 +2147,6 @@ async function yaml(options = {}) {
1924
2147
  ];
1925
2148
  }
1926
2149
 
1927
- // src/configs/toml.ts
1928
- async function toml(options = {}) {
1929
- const {
1930
- files = [GLOB_TOML],
1931
- overrides = {},
1932
- stylistic: stylistic2 = true
1933
- } = options;
1934
- const {
1935
- indent = 2
1936
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1937
- const [
1938
- pluginToml,
1939
- parserToml
1940
- ] = await Promise.all([
1941
- interopDefault(import("eslint-plugin-toml")),
1942
- interopDefault(import("toml-eslint-parser"))
1943
- ]);
1944
- return [
1945
- {
1946
- name: "antfu/toml/setup",
1947
- plugins: {
1948
- toml: pluginToml
1949
- }
1950
- },
1951
- {
1952
- files,
1953
- languageOptions: {
1954
- parser: parserToml
1955
- },
1956
- name: "antfu/toml/rules",
1957
- rules: {
1958
- "style/spaced-comment": "off",
1959
- "toml/comma-style": "error",
1960
- "toml/keys-order": "error",
1961
- "toml/no-space-dots": "error",
1962
- "toml/no-unreadable-number-separator": "error",
1963
- "toml/precision-of-fractional-seconds": "error",
1964
- "toml/precision-of-integer": "error",
1965
- "toml/tables-order": "error",
1966
- "toml/vue-custom-block/no-parsing-error": "error",
1967
- ...stylistic2 ? {
1968
- "toml/array-bracket-newline": "error",
1969
- "toml/array-bracket-spacing": "error",
1970
- "toml/array-element-newline": "error",
1971
- "toml/indent": ["error", indent === "tab" ? 2 : indent],
1972
- "toml/inline-table-curly-spacing": "error",
1973
- "toml/key-spacing": "error",
1974
- "toml/padding-line-between-pairs": "error",
1975
- "toml/padding-line-between-tables": "error",
1976
- "toml/quoted-keys": "error",
1977
- "toml/spaced-comment": "error",
1978
- "toml/table-bracket-spacing": "error"
1979
- } : {},
1980
- ...overrides
1981
- }
1982
- }
1983
- ];
1984
- }
1985
-
1986
- // src/configs/astro.ts
1987
- async function astro(options = {}) {
1988
- const {
1989
- files = [GLOB_ASTRO],
1990
- overrides = {},
1991
- stylistic: stylistic2 = true
1992
- } = options;
1993
- const [
1994
- pluginAstro,
1995
- parserAstro,
1996
- parserTs
1997
- ] = await Promise.all([
1998
- interopDefault(import("eslint-plugin-astro")),
1999
- interopDefault(import("astro-eslint-parser")),
2000
- interopDefault(import("@typescript-eslint/parser"))
2001
- ]);
2002
- return [
2003
- {
2004
- name: "antfu/astro/setup",
2005
- plugins: {
2006
- astro: pluginAstro
2007
- }
2008
- },
2009
- {
2010
- files,
2011
- languageOptions: {
2012
- parser: parserAstro,
2013
- parserOptions: {
2014
- extraFileExtensions: [".astro"],
2015
- parser: parserTs
2016
- }
2017
- },
2018
- name: "antfu/astro/rules",
2019
- rules: {
2020
- "astro/no-set-html-directive": "off",
2021
- "astro/semi": "off",
2022
- ...stylistic2 ? {
2023
- "style/indent": "off",
2024
- "style/jsx-closing-tag-location": "off",
2025
- "style/jsx-indent": "off",
2026
- "style/jsx-one-expression-per-line": "off",
2027
- "style/no-multiple-empty-lines": "off"
2028
- } : {},
2029
- ...overrides
2030
- }
2031
- }
2032
- ];
2033
- }
2034
-
2035
- // src/configs/solid.ts
2036
- async function solid(options = {}) {
2037
- const {
2038
- files = [GLOB_JSX, GLOB_TSX],
2039
- overrides = {},
2040
- typescript: typescript2 = true
2041
- } = options;
2042
- await ensurePackages([
2043
- "eslint-plugin-solid"
2044
- ]);
2045
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
2046
- const isTypeAware = !!tsconfigPath;
2047
- const [
2048
- pluginSolid,
2049
- parserTs
2050
- ] = await Promise.all([
2051
- interopDefault(import("eslint-plugin-solid")),
2052
- interopDefault(import("@typescript-eslint/parser"))
2053
- ]);
2054
- return [
2055
- {
2056
- name: "antfu/solid/setup",
2057
- plugins: {
2058
- solid: pluginSolid
2059
- }
2060
- },
2061
- {
2062
- files,
2063
- languageOptions: {
2064
- parser: parserTs,
2065
- parserOptions: {
2066
- ecmaFeatures: {
2067
- jsx: true
2068
- },
2069
- ...isTypeAware ? { project: tsconfigPath } : {}
2070
- },
2071
- sourceType: "module"
2072
- },
2073
- name: "antfu/solid/rules",
2074
- rules: {
2075
- // reactivity
2076
- "solid/components-return-once": "warn",
2077
- "solid/event-handlers": ["error", {
2078
- // if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
2079
- ignoreCase: false,
2080
- // if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
2081
- warnOnSpread: false
2082
- }],
2083
- // these rules are mostly style suggestions
2084
- "solid/imports": "error",
2085
- // identifier usage is important
2086
- "solid/jsx-no-duplicate-props": "error",
2087
- "solid/jsx-no-script-url": "error",
2088
- "solid/jsx-no-undef": "error",
2089
- "solid/jsx-uses-vars": "error",
2090
- "solid/no-destructure": "error",
2091
- // security problems
2092
- "solid/no-innerhtml": ["error", { allowStatic: true }],
2093
- "solid/no-react-deps": "error",
2094
- "solid/no-react-specific-props": "error",
2095
- "solid/no-unknown-namespaces": "error",
2096
- "solid/prefer-for": "error",
2097
- "solid/reactivity": "warn",
2098
- "solid/self-closing-comp": "error",
2099
- "solid/style-prop": ["error", { styleProps: ["style", "css"] }],
2100
- ...typescript2 ? {
2101
- "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
2102
- "solid/no-unknown-namespaces": "off"
2103
- } : {},
2104
- // overrides
2105
- ...overrides
2106
- }
2107
- }
2108
- ];
2109
- }
2110
-
2111
2150
  // src/factory.ts
2112
2151
  var flatConfigProps = [
2113
2152
  "name",
@@ -2181,6 +2220,7 @@ function dhzh(options = {}, ...userConfigs) {
2181
2220
  stylistic: stylisticOptions
2182
2221
  }),
2183
2222
  unicorn(),
2223
+ command(),
2184
2224
  // Optional plugins (installed but not enabled by default)
2185
2225
  perfectionist()
2186
2226
  );
@@ -2348,6 +2388,7 @@ export {
2348
2388
  StylisticConfigDefaults,
2349
2389
  astro,
2350
2390
  combine,
2391
+ command,
2351
2392
  comments,
2352
2393
  src_default as default,
2353
2394
  defaultPluginRenaming,