configuration.cjs.map 6.27 KB
{"version":3,"names":["babel","require","ESLINT_VERSION","getParserPlugins","babelOptions","babelParserPlugins","parserOpts","plugins","estreeOptions","classFeatures","plugin","Array","isArray","Object","assign","normalizeParserOptions","options","sourceType","filename","filePath","allowImportExportEverywhere","allowSuperOutsideMethod","allowReturnOutsideFunction","ecmaFeatures","globalReturn","attachComment","ranges","tokens","caller","name","validateResolvedConfig","config","parseOptions","requireConfigFile","hasFilesystemConfig","error","includes","Error","getDefaultParserOptions","babelrc","configFile","browserslistConfigFile","ignore","only","exports","normalizeBabelParseConfig","loadPartialConfigAsync","normalizeBabelParseConfigSync","loadPartialConfigSync"],"sources":["../../src/worker/configuration.cjs"],"sourcesContent":["const babel = require(\"./babel-core.cjs\");\nconst ESLINT_VERSION = require(\"../utils/eslint-version.cjs\");\n\n/**\n * Merge user supplied estree plugin options to default estree plugin options\n *\n * @param {*} babelOptions\n * @returns {Array} Merged parser plugin descriptors\n */\nfunction getParserPlugins(babelOptions) {\n  const babelParserPlugins = babelOptions.parserOpts?.plugins ?? [];\n  const estreeOptions = { classFeatures: ESLINT_VERSION >= 8 };\n  for (const plugin of babelParserPlugins) {\n    if (Array.isArray(plugin) && plugin[0] === \"estree\") {\n      Object.assign(estreeOptions, plugin[1]);\n      break;\n    }\n  }\n  // estree must be the first parser plugin to work with other parser plugins\n  return [[\"estree\", estreeOptions], ...babelParserPlugins];\n}\n\nfunction normalizeParserOptions(options) {\n  return {\n    sourceType: options.sourceType,\n    filename: options.filePath,\n    ...options.babelOptions,\n    parserOpts: {\n      ...(process.env.BABEL_8_BREAKING\n        ? {}\n        : {\n            allowImportExportEverywhere:\n              options.allowImportExportEverywhere ?? false,\n            allowSuperOutsideMethod: true,\n          }),\n      allowReturnOutsideFunction:\n        options.ecmaFeatures?.globalReturn ??\n        (process.env.BABEL_8_BREAKING ? false : true),\n      ...options.babelOptions.parserOpts,\n      plugins: getParserPlugins(options.babelOptions),\n      // skip comment attaching for parsing performance\n      attachComment: false,\n      ranges: true,\n      tokens: true,\n    },\n    caller: {\n      name: \"@babel/eslint-parser\",\n      ...options.babelOptions.caller,\n    },\n  };\n}\n\nfunction validateResolvedConfig(config, options, parseOptions) {\n  if (config !== null) {\n    if (options.requireConfigFile !== false) {\n      if (!config.hasFilesystemConfig()) {\n        let error = `No Babel config file detected for ${config.options.filename}. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.`;\n\n        if (config.options.filename.includes(\"node_modules\")) {\n          error += `\\nIf you have a .babelrc.js file or use package.json#babel, keep in mind that it's not used when parsing dependencies. If you want your config to be applied to your whole app, consider using babel.config.js or babel.config.json instead.`;\n        }\n\n        throw new Error(error);\n      }\n    }\n    if (config.options) return config.options;\n  }\n\n  return getDefaultParserOptions(parseOptions);\n}\n\nfunction getDefaultParserOptions(options) {\n  return {\n    plugins: [],\n    ...options,\n    babelrc: false,\n    configFile: false,\n    browserslistConfigFile: false,\n    ignore: null,\n    only: null,\n  };\n}\n\nexports.normalizeBabelParseConfig = async function (options) {\n  const parseOptions = normalizeParserOptions(options);\n  const config = await babel.loadPartialConfigAsync(parseOptions);\n  return validateResolvedConfig(config, options, parseOptions);\n};\n\nexports.normalizeBabelParseConfigSync = function (options) {\n  const parseOptions = normalizeParserOptions(options);\n  const config = babel.loadPartialConfigSync(parseOptions);\n  return validateResolvedConfig(config, options, parseOptions);\n};\n"],"mappings":";;;;AAAA,MAAMA,KAAK,GAAGC,OAAO,CAAC,kBAAD,CAArB;;AACA,MAAMC,cAAc,GAAGD,OAAO,CAAC,6BAAD,CAA9B;;AAQA,SAASE,gBAAT,CAA0BC,YAA1B,EAAwC;EAAA;;EACtC,MAAMC,kBAAkB,sDAAGD,YAAY,CAACE,UAAhB,qBAAG,uBAAyBC,OAA5B,oCAAuC,EAA/D;EACA,MAAMC,aAAa,GAAG;IAAEC,aAAa,EAAEP,cAAc,IAAI;EAAnC,CAAtB;;EACA,KAAK,MAAMQ,MAAX,IAAqBL,kBAArB,EAAyC;IACvC,I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