'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var process$1 = require('node:process'); var tseslint = require('typescript-eslint'); var pluginVue = require('eslint-plugin-vue'); var fs = require('node:fs'); var fg = require('fast-glob'); var path = require('node:path'); var vueParser = require('vue-eslint-parser'); const CONFIG_NAMES = [ "all", "base", "disableTypeChecked", "eslintRecommended", "recommended", "recommendedTypeChecked", "recommendedTypeCheckedOnly", "strict", "strictTypeChecked", "strictTypeCheckedOnly", "stylistic", "stylisticTypeChecked", "stylisticTypeCheckedOnly" ]; function toArray(value) { return Array.isArray(value) ? value : [value]; } class TsEslintConfigForVue { /** * The name of the config object as defined in `typescript-eslint`. */ configName; /** * the name property is here to provide better error messages when ESLint throws an error */ name; constructor(configName) { this.configName = configName; this.name = `vueTsConfigs.${configName}`; } extendsOptions; /** * Create a new instance of `TsEslintConfigForVue` with the `restOfConfig` merged into it. * Should be used when the config is used in the `extends` field of another config. */ asExtendedWith(restOfConfig) { const extendedConfig = new TsEslintConfigForVue(this.configName); extendedConfig.extendsOptions = { name: [restOfConfig.name, this.name].filter(Boolean).join("__"), ...restOfConfig.files && { files: restOfConfig.files }, ...restOfConfig.ignores && { ignores: restOfConfig.ignores } }; return extendedConfig; } needsTypeChecking() { if (this.configName === "disableTypeChecked") { return false; } if (this.configName === "all") { return true; } return this.configName.includes("TypeChecked"); } toConfigArray() { return toArray(tseslint.configs[this.configName]).flat().map((config) => ({ ...config, ...config.files && config.files.includes("**/*.ts") ? { files: [...config.files, "**/*.vue"] } : {}, ...this.extendsOptions })); } } const vueTsConfigs = Object.fromEntries( CONFIG_NAMES.map((name) => [ name, new Proxy(new TsEslintConfigForVue(name), { // `ownKeys` is called by ESLint when validating the config object. // The only possible scenario where this is called is when the placeholder object // isn't replaced, which means it's passed to ESLint without being wrapped by // `defineConfigWithVueTs()` // We throw an error here to provide a better error message to the user. ownKeys() { throw new Error( "Please wrap the config object with `defineConfigWithVueTs()`" ); } }) ]) ); function groupVueFiles(rootDir) { const { vueFilesWithScriptTs, otherVueFiles } = fg.sync(["**/*.vue"], { cwd: rootDir, ignore: ["**/node_modules/**"] }).reduce( (acc, file) => { const absolutePath = path.resolve(rootDir, file); const contents = fs.readFileSync(absolutePath, "utf8"); if (/]*\blang\s*=\s*"ts"[^>]*>/i.test(contents)) { acc.vueFilesWithScriptTs.push(file); } else { acc.otherVueFiles.push(file); } return acc; }, { vueFilesWithScriptTs: [], otherVueFiles: [] } ); return { // Only `.vue` files with `