"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { defineConfig: () => defineConfig }); module.exports = __toCommonJS(src_exports); // src/configs/javascript.ts var import_globals = __toESM(require("globals"), 1); var import_js = __toESM(require("@eslint/js"), 1); // src/constants/glob.ts var GLOB_SRC_EXT = "?([cm])[jt]s?(x)"; var GLOB_SRC = "**/*.?([cm])[jt]s?(x)"; var GLOB_JSX = "**/*.?([cm])jsx"; var GLOB_TSX = "**/*.?([cm])tsx"; var GLOB_VUE = "**/*.vue"; var GLOB_ASTRO = "**/*.astro"; var GLOB_SVELTE = "**/*.svelte"; var GLOB_HTML = "**/*.htm?(l)"; var GLOB_CSS = "**/*.css"; var GLOB_POSTCSS = "**/*.{p,post}css"; var GLOB_LESS = "**/*.less"; var GLOB_SCSS = "**/*.scss"; var GLOB_JSON = "**/*.json"; var GLOB_JSON5 = "**/*.json5"; var GLOB_JSONC = "**/*.jsonc"; var GLOB_MARKDOWN = "**/*.md"; var GLOB_YAML = "**/*.y?(a)ml"; var GLOB_TOML = "**/*.toml"; var GLOB_PRETTIER_LINT = [GLOB_SRC, GLOB_VUE]; var GLOB_TESTS = [ `**/__tests__/**/*.${GLOB_SRC_EXT}`, `**/*.spec.${GLOB_SRC_EXT}`, `**/*.test.${GLOB_SRC_EXT}`, `**/*.bench.${GLOB_SRC_EXT}`, `**/*.benchmark.${GLOB_SRC_EXT}` ]; var GLOB_EXCLUDE = [ "**/node_modules", "**/dist", "**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml", "**/bun.lockb", "**/output", "**/coverage", "**/temp", "**/.temp", "**/tmp", "**/.tmp", "**/.history", "**/.vitepress/cache", "**/.nuxt", "**/.next", "**/.vercel", "**/.changeset", "**/.idea", "**/.cache", "**/.output", "**/.vite-inspect", "**/CHANGELOG*.md", "**/*.min.*", "**/LICENSE*", "**/__snapshots__", "**/auto-import?(s).d.ts", "**/components.d.ts", "**/.github/workflows/*.yml" ]; // src/configs/javascript.ts function createJsConfig() { const js = [ { languageOptions: { ecmaVersion: 2022, globals: { ...import_globals.default.browser, ...import_globals.default.es2021, ...import_globals.default.node, document: "readonly", navigator: "readonly", window: "readonly" }, parserOptions: { ecmaFeatures: { jsx: true }, ecmaVersion: 2022, sourceType: "module" }, sourceType: "module" }, rules: { ...import_js.default.configs.all.rules, "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }], camelcase: "off", "capitalized-comments": "off", "dot-notation": ["error", { allowKeywords: true }], "func-style": "off", "id-length": "off", "init-declarations": "off", "line-comment-position": "off", "max-classes-per-file": "off", "max-lines": "off", "max-lines-per-function": "off", "max-statements": "off", "max-statements-per-line": "off", "multiline-comment-style": "off", "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }], "no-console": "warn", "no-duplicate-imports": "off", "no-empty": ["error", { allowEmptyCatch: true }], "no-empty-function": "off", "no-inline-comments": "off", "no-labels": ["error", { allowLoop: false, allowSwitch: false }], "no-magic-numbers": "off", "no-mixed-operators": [ "error", { groups: [ ["+", "-", "*", "/", "%", "**"], ["&", "|", "^", "~", "<<", ">>", ">>>"], ["==", "!=", "===", "!==", ">", ">=", "<", "<="], ["&&", "||"], ["in", "instanceof"] ], allowSamePrecedence: true } ], "no-negated-condition": "off", "no-redeclare": ["error", { builtinGlobals: false }], "no-restricted-globals": [ "error", { message: "Use `globalThis` instead.", name: "global" }, { message: "Use `globalThis` instead.", name: "self" } ], "no-restricted-properties": [ "error", { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" }, { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" }, { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" }, { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" }, { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" } ], "no-restricted-syntax": [ "error", "DebuggerStatement", "LabeledStatement", "WithStatement", "TSEnumDeclaration[const=true]", "TSExportAssignment" ], "no-self-assign": ["error", { props: true }], "no-ternary": "off", "no-undefined": "off", "no-unneeded-ternary": ["error", { defaultAssignment: false }], "no-unused-expressions": [ "error", { allowShortCircuit: true, allowTaggedTemplates: true, allowTernary: true } ], "no-unused-vars": [ "error", { vars: "all", args: "all", ignoreRestSiblings: false, varsIgnorePattern: "^_", argsIgnorePattern: "^_" } ], "no-use-before-define": ["error", { functions: false, classes: false, variables: true }], "object-shorthand": [ "error", "always", { ignoreConstructors: false, avoidQuotes: true } ], "one-var": ["error", "never"], "prefer-arrow-callback": [ "error", { allowNamedFunctions: false, allowUnboundThis: true } ], "prefer-const": [ "error", { destructuring: "all", ignoreReadBeforeAssign: true } ], "prefer-destructuring": "off", "prefer-named-capture-group": "off", "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }], "require-await": "off", "require-unicode-regexp": "off", "sort-imports": [ "error", { allowSeparatedGroups: false, ignoreCase: false, ignoreDeclarationSort: true, ignoreMemberSort: false, memberSyntaxSortOrder: ["none", "all", "multiple", "single"] } ], "sort-keys": "off", "spaced-comment": [ "error", "always", { line: { markers: ["*package", "!", "/", ",", "="] }, block: { balanced: true, markers: ["*package", "!", ",", ":", "::", "flow-include"], exceptions: ["*"] } } ], "unicode-bom": ["error", "never"] } }, { files: [`**/scripts/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`], rules: { "no-console": "off" } }, { files: GLOB_TESTS, rules: { "no-unused-expressions": "off" } } ]; return js; } // src/shared/index.ts var import_node_process = __toESM(require("process"), 1); var import_promises = require("fs/promises"); var import_node_path = __toESM(require("path"), 1); var import_local_pkg = require("local-pkg"); async function interopDefault(m) { const resolved = await m; return resolved.default || resolved; } async function ensurePackages(packages) { if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false) return; const nonExistingPackages = packages.filter((i) => !(0, import_local_pkg.isPackageExists)(i)); if (nonExistingPackages.length === 0) return; const { default: prompts } = await import("prompts"); const message = `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`; const { result } = await prompts([ { message, name: "result", type: "confirm" } ]); if (result) { const { installPackage } = await import("@antfu/install-pkg"); await installPackage(nonExistingPackages, { dev: true }); } } async function loadPrettierConfig(cwd) { let prettierConfig = {}; try { const prettierrc = await (0, import_promises.readFile)(import_node_path.default.join(cwd, ".prettierrc"), "utf-8"); prettierConfig = JSON.parse(prettierrc); } catch { } return prettierConfig; } // src/configs/node.ts async function createNodeConfig() { const pluginNode = await interopDefault(import("eslint-plugin-n")); const configs = [ { plugins: { n: pluginNode }, rules: { "n/handle-callback-err": ["error", "^(err|error)$"], "n/no-deprecated-api": "error", "n/no-exports-assign": "error", "n/no-new-require": "error", "n/no-path-concat": "error", "n/prefer-global/buffer": ["error", "never"], "n/prefer-global/process": ["error", "never"], "n/process-exit-as-throw": "error" } } ]; return configs; } // src/configs/import.ts async function createImportConfig() { const pluginImport = await interopDefault(import("eslint-plugin-i")); const configs = [ { plugins: { import: pluginImport }, rules: { "import/first": "error", "import/no-duplicates": "error", "import/no-mutable-exports": "error", "import/no-named-default": "error", "import/no-self-import": "error", "import/no-webpack-loader-syntax": "error", "import/order": [ "error", { groups: ["builtin", "external", "internal", "parent", "sibling", "index", "object"], pathGroups: [{ group: "internal", pattern: "{{@,~}/,#}**" }] } ] } } ]; return configs; } // src/configs/unicorn.ts async function createUnicornConfig() { const pluginUnicorn = await interopDefault(import("eslint-plugin-unicorn")); const configs = [ { plugins: { unicorn: pluginUnicorn }, rules: { "unicorn/error-message": "error", "unicorn/escape-case": "error", "unicorn/no-instanceof-array": "error", "unicorn/no-new-array": "error", "unicorn/no-new-buffer": "error", "unicorn/number-literal-case": "error", "unicorn/prefer-dom-node-text-content": "error", "unicorn/prefer-includes": "error", "unicorn/prefer-node-protocol": "error", "unicorn/prefer-number-properties": "error", "unicorn/prefer-string-starts-ends-with": "error", "unicorn/prefer-type-error": "error", "unicorn/throw-new-error": "error" } } ]; return configs; } // src/configs/typescript.ts async function createTsRules() { const pluginTs = await interopDefault(import("@typescript-eslint/eslint-plugin")); const { rules: recommendedRules } = pluginTs.configs["eslint-recommended"].overrides[0]; const tsRules = { ...pluginTs.configs.base.rules, ...recommendedRules, ...pluginTs.configs.strict.rules, "@typescript-eslint/consistent-type-imports": ["error", { prefer: "type-imports", disallowTypeAnnotations: false }], "@typescript-eslint/no-empty-interface": [ "error", { allowSingleExtends: true } ], // Override JS "no-redeclare": "off", "@typescript-eslint/no-redeclare": "error", "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": [ "error", { vars: "all", args: "all", ignoreRestSiblings: false, varsIgnorePattern: "^_", argsIgnorePattern: "^_" } ], "no-use-before-define": "off", "@typescript-eslint/no-use-before-define": ["error", { functions: false, classes: false, variables: true }], "no-shadow": "off", "@typescript-eslint/no-shadow": "error", // off "@typescript-eslint/consistent-type-definitions": "off", "@typescript-eslint/no-empty-function": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/unified-signatures": "off" }; return tsRules; } async function createTsConfig() { const [pluginTs, parserTs] = await Promise.all([ interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser")) ]); const tsRules = await createTsRules(); const ts = [ { files: [GLOB_SRC], languageOptions: { parser: parserTs, parserOptions: { sourceType: "module" } }, plugins: { "@typescript-eslint": pluginTs }, rules: { ...tsRules } }, { files: ["**/*.js", "**/*.cjs"], rules: { "@typescript-eslint/no-require-imports": "off", "@typescript-eslint/no-var-requires": "off" } } ]; return ts; } // src/configs/vue.ts async function createVueConfig(options) { if (!options) return []; const { version, files, overrides } = options; await ensurePackages(["eslint-plugin-vue", "vue-eslint-parser"]); const [pluginVue, parserVue, pluginTs] = await Promise.all([ interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser")), interopDefault(import("@typescript-eslint/eslint-plugin")) ]); const tsRules = await createTsRules(); const configKeys = version === 3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"]; const vueRules = configKeys.reduce((preRules, key) => { const config = pluginVue.configs[key]; return { ...preRules, ...config.rules }; }, {}); const configs = [ { plugins: { vue: pluginVue } }, { files, languageOptions: { parser: parserVue, parserOptions: { ecmaFeatures: { jsx: true }, extraFileExtensions: [".vue"], parser: "@typescript-eslint/parser", sourceType: "module" } }, processor: pluginVue.processors[".vue"], plugins: { "@typescript-eslint": pluginTs }, rules: { ...tsRules, ...pluginVue.configs.base.rules, ...vueRules, "vue/block-order": ["warn", { order: ["script", "template", "style"] }], "vue/component-api-style": ["warn", ["script-setup", "composition"]], "vue/component-name-in-template-casing": [ "warn", "PascalCase", { registeredComponentsOnly: false, ignores: [] } ], "vue/component-options-name-casing": ["warn", "PascalCase"], "vue/custom-event-name-casing": ["warn", "camelCase"], "vue/define-emits-declaration": ["warn", "type-based"], "vue/define-macros-order": "off", // 'vue/define-macros-order': [ // 'warn', // { // order: ['defineOptions', 'defineProps', 'defineEmits', 'defineSlots'] // } // ], "vue/define-props-declaration": ["warn", "type-based"], "vue/html-comment-content-newline": "warn", "vue/multi-word-component-names": "warn", "vue/next-tick-style": ["warn", "promise"], "vue/no-duplicate-attr-inheritance": "warn", "vue/no-required-prop-with-default": "warn", "vue/no-static-inline-styles": "warn", "vue/no-template-target-blank": "error", "vue/no-this-in-before-route-enter": "error", "vue/no-undef-properties": "warn", "vue/no-unsupported-features": "warn", "vue/no-unused-emit-declarations": "warn", "vue/no-unused-properties": "warn", "vue/no-unused-refs": "warn", "vue/no-use-v-else-with-v-for": "error", "vue/no-useless-mustaches": "warn", "vue/no-useless-v-bind": "error", "vue/no-v-text": "warn", "vue/padding-line-between-blocks": "warn", "vue/prefer-define-options": "warn", "vue/prefer-separate-static-class": "warn", "vue/prefer-true-attribute-shorthand": "warn", "vue/prop-name-casing": ["warn", "camelCase"], "vue/require-macro-variable-name": [ "warn", { defineProps: "props", defineEmits: "emit", defineSlots: "slots", useSlots: "slots", useAttrs: "attrs" } ], "vue/valid-define-options": "warn", ...overrides } } ]; return configs; } // src/configs/react.ts var import_local_pkg2 = require("local-pkg"); async function createReactConfig(options) { if (!options) return []; const { files, overrides } = options; await ensurePackages(["eslint-plugin-react", "eslint-plugin-react-hooks", "eslint-plugin-react-refresh"]); const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([ interopDefault(import("eslint-plugin-react")), interopDefault(import("eslint-plugin-react-hooks")), interopDefault(import("eslint-plugin-react-refresh")) ]); const ReactRefreshAllowConstantExportPackages = ["vite"]; const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)); const configs = [ { plugins: { react: pluginReact, "react-hooks": pluginReactHooks, "react-refresh": pluginReactRefresh }, settings: { react: { version: "detect" } } }, { files, languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } }, rules: { // recommended rules react-hooks "react-hooks/exhaustive-deps": "warn", "react-hooks/rules-of-hooks": "error", // react refresh "react-refresh/only-export-components": ["warn", { allowConstantExport: isAllowConstantExport }], ...pluginReact.configs.recommended.rules, // react runtime "react/react-in-jsx-scope": "off", "react/jsx-uses-react": "off", ...overrides } } ]; return configs; } async function createReactNativeConfig(options) { if (!options) return []; const { files, overrides } = options; await ensurePackages(["eslint-plugin-react-native"]); const pluginReactNative = await interopDefault(import("eslint-plugin-react-native")); const config = [ { plugins: { "react-native": pluginReactNative } }, { files, languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } }, globals: { ...pluginReactNative.environments["react-native"].globals } }, rules: { ...pluginReactNative.configs.all.rules, ...overrides } } ]; return config; } // src/configs/solid.ts async function createSolidConfig(options) { if (!options) return []; const { files, overrides } = options; await ensurePackages(["eslint-plugin-solid"]); const pluginSolid = await interopDefault(import("eslint-plugin-solid")); const configs = [ { plugins: { solid: pluginSolid } }, { files, languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } }, rules: { ...pluginSolid.configs.typescript.rules, ...overrides } } ]; return configs; } // src/configs/svelte.ts async function createSvelteConfig(options, prettierRules2 = {}) { if (!options) return []; const { files, overrides } = options; await ensurePackages(["eslint-plugin-svelte", "svelte-eslint-parser", "prettier-plugin-svelte"]); const [pluginSvelte, parserSvelte, pluginTs, pluginPrettier] = await Promise.all([ interopDefault(import("eslint-plugin-svelte")), interopDefault(import("svelte-eslint-parser")), interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("eslint-plugin-prettier")) ]); const tsRules = await createTsRules(); const { plugins = [] } = prettierRules2; const pRules = { ...prettierRules2, plugins: plugins.concat("prettier-plugin-svelte") }; const configs = [ { files, languageOptions: { parser: parserSvelte, parserOptions: { extraFileExtensions: [".svelte"], parser: "@typescript-eslint/parser", sourceType: "module" } }, plugins: { "@typescript-eslint": pluginTs, svelte: pluginSvelte, prettier: pluginPrettier }, processor: pluginSvelte.processors.svelte, rules: { ...tsRules, ...pluginSvelte.configs.recommended.rules, ...overrides, "prettier/prettier": [ "warn", { ...pRules, parser: "svelte" } ] } } ]; return configs; } // src/configs/astro.ts async function createAstroConfig(options, prettierRules2 = {}) { if (!options) return []; const { files, overrides } = options; await ensurePackages(["eslint-plugin-astro", "astro-eslint-parser", "prettier-plugin-astro"]); const [pluginAstro, parserAstro, pluginTs, parserTs, pluginPrettier] = await Promise.all([ interopDefault(import("eslint-plugin-astro")), interopDefault(import("astro-eslint-parser")), interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser")), interopDefault(import("eslint-plugin-prettier")) ]); const tsRules = await createTsRules(); const { plugins = [] } = prettierRules2; const pRules = { ...prettierRules2, plugins: plugins.concat("prettier-plugin-astro") }; const configs = [ { files, languageOptions: { parser: parserAstro, parserOptions: { extraFileExtensions: [".astro"], parser: "@typescript-eslint/parser", sourceType: "module" } }, plugins: { "@typescript-eslint": pluginTs, astro: pluginAstro, prettier: pluginPrettier }, processor: pluginAstro.processors.astro, rules: { ...tsRules, ...pluginAstro.configs.recommended.rules, ...overrides, "prettier/prettier": [ "warn", { ...pRules, parser: "astro" } ] } }, { files: ["**/*.astro/*.js", "*.astro/*.js"], languageOptions: { parser: parserTs } } ]; return configs; } // src/configs/prettier.ts var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1); var { rules: eslintRules } = import_eslint_config_prettier.default; async function createPrettierConfig(rules) { const pluginPrettier = await interopDefault(import("eslint-plugin-prettier")); const { plugins = [] } = rules; const pRules = { ...rules, plugins: plugins.concat("prettier-plugin-jsdoc") }; const configs = [ { files: GLOB_PRETTIER_LINT, plugins: { prettier: pluginPrettier }, rules: { ...eslintRules, "prettier/prettier": ["warn", pRules], "arrow-body-style": "off", "prefer-arrow-callback": "off" } } ]; return configs; } // src/configs/formatter.ts async function createFormatterConfig(options, prettierRules2 = {}) { const { html = true, css = true, json = true, markdown, yaml, toml } = options || {}; const [pluginPrettier, parserPlain] = await Promise.all([ interopDefault(import("eslint-plugin-prettier")), interopDefault(import("eslint-parser-plain")) ]); function createPrettierFormatter(files, parser, plugins) { const rules = { ...prettierRules2, parser }; if (plugins == null ? void 0 : plugins.length) { rules.plugins = [...rules.plugins || [], ...plugins]; } const config = { files, languageOptions: { parser: parserPlain }, plugins: { prettier: pluginPrettier }, rules: { "prettier/prettier": ["warn", rules] } }; return config; } const configs = []; if (css) { const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css"); const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss"); const lessConfig = createPrettierFormatter([GLOB_LESS], "less"); configs.push(cssConfig, scssConfig, lessConfig); } if (html) { const htmlConfig = createPrettierFormatter([GLOB_HTML], "html"); configs.push(htmlConfig); } if (json) { const jsonConfig = createPrettierFormatter([GLOB_JSON, GLOB_JSONC], "json", ["prettier-plugin-json-sort"]); const json5Config = createPrettierFormatter([GLOB_JSON5], "json5"); configs.push(jsonConfig, json5Config); } if (markdown) { const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown"); configs.push(markdownConfig); } if (yaml) { const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml"); configs.push(yamlConfig); } if (toml) { await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]); const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", ["prettier-plugin-toml"]); configs.push(tomlConfig); } return configs; } // src/options.ts var import_node_process2 = __toESM(require("process"), 1); // src/constants/prettier.ts var DEFAULT_PRETTIER_RULES = { printWidth: 120, singleQuote: true, trailingComma: "none", arrowParens: "avoid", htmlWhitespaceSensitivity: "ignore", jsdocCapitalizeDescription: false }; // src/options.ts async function createOptions(options = {}) { const opts = { cwd: import_node_process2.default.cwd(), ignores: GLOB_EXCLUDE, prettierRules: { ...DEFAULT_PRETTIER_RULES }, usePrettierrc: true, formatter: { html: true, css: true, json: true } }; const { cwd, ignores, prettierRules: prettierRules2, usePrettierrc, formatter, ...rest } = options; if (cwd) { opts.cwd = cwd; } if (ignores == null ? void 0 : ignores.length) { opts.ignores = [...opts.ignores, ...ignores]; } if (prettierRules2) { opts.prettierRules = { ...opts.prettierRules, ...prettierRules2 }; } if (usePrettierrc !== void 0) { opts.usePrettierrc = usePrettierrc; } if (opts.usePrettierrc) { const prettierConfig = await loadPrettierConfig(opts.cwd); Object.assign(opts.prettierRules, prettierConfig); } if (formatter) { Object.assign(opts.formatter, formatter); } const onDemandKeys = ["vue", "react", "react-native", "solid", "svelte", "astro"]; const onDemandFiles = { vue: [GLOB_VUE], react: [GLOB_JSX, GLOB_TSX], "react-native": [GLOB_JSX, GLOB_TSX], solid: [GLOB_JSX, GLOB_TSX], svelte: [GLOB_SVELTE], astro: [GLOB_ASTRO] }; onDemandKeys.forEach((key) => { if (key === "vue") { opts[key] = createItemDemandOptions(key, rest[key], onDemandFiles[key]); } else { opts[key] = createItemDemandOptions(key, rest[key], onDemandFiles[key]); } }); if (rest["react-native"] && !rest.react) { opts.react = createItemDemandOptions("react", true, onDemandFiles.react); } return opts; } function createItemDemandOptions(key, options, files) { if (!options) return void 0; if (key === "vue") { const vueOptions = { version: 3, files, overrides: {} }; if (typeof options === "object") { Object.assign(vueOptions, options); } return vueOptions; } const itemOptions = { files, overrides: {} }; if (typeof options === "object") { Object.assign(itemOptions, options); } return itemOptions; } // src/index.ts async function defineConfig(options = {}, ...userConfigs) { const opts = await createOptions(options); const ignore = { ignores: opts.ignores }; const js = createJsConfig(); const node = await createNodeConfig(); const imp = await createImportConfig(); const unicorn = await createUnicornConfig(); const ts = await createTsConfig(); const vue = await createVueConfig(opts.vue); const solid = await createSolidConfig(opts.solid); const react = await createReactConfig(opts.react); const reactNative = await createReactNativeConfig(opts["react-native"]); const svelte = await createSvelteConfig(opts.svelte, opts.prettierRules); const astro = await createAstroConfig(opts.astro); const prettier = await createPrettierConfig(opts.prettierRules); const formatter = await createFormatterConfig(opts.formatter, opts.prettierRules); const userResolved = await Promise.all(userConfigs); const configs = [ ignore, ...js, ...node, ...imp, ...unicorn, ...ts, ...vue, ...react, ...reactNative, ...solid, ...astro, ...svelte, ...userResolved, ...prettier, ...formatter ]; return configs; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { defineConfig });