1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.normalizeESLintConfig = normalizeESLintConfig;
|
7 | exports.normalizeBabelParseConfig = normalizeBabelParseConfig;
|
8 |
|
9 | var _core = require("@babel/core");
|
10 |
|
11 | function normalizeESLintConfig(options) {
|
12 | const defaultOptions = {
|
13 | babelOptions: {},
|
14 | ecmaVersion: 2020,
|
15 | sourceType: "module",
|
16 | allowImportExportEverywhere: false,
|
17 | requireConfigFile: true
|
18 | };
|
19 | return Object.assign(defaultOptions, options);
|
20 | }
|
21 |
|
22 | function normalizeBabelParseConfig(options) {
|
23 | var _options$babelOptions, _options$babelOptions2;
|
24 |
|
25 | const parseOptions = Object.assign({
|
26 | sourceType: options.sourceType,
|
27 | filename: options.filePath
|
28 | }, options.babelOptions, {
|
29 | parserOpts: Object.assign({
|
30 | allowImportExportEverywhere: options.allowImportExportEverywhere,
|
31 | allowReturnOutsideFunction: true,
|
32 | allowSuperOutsideMethod: true
|
33 | }, options.babelOptions.parserOpts, {
|
34 | plugins: ["estree", ...((_options$babelOptions = (_options$babelOptions2 = options.babelOptions.parserOpts) == null ? void 0 : _options$babelOptions2.plugins) != null ? _options$babelOptions : [])],
|
35 | ranges: true,
|
36 | tokens: true
|
37 | }),
|
38 | caller: Object.assign({
|
39 | name: "@babel/eslint-parser"
|
40 | }, options.babelOptions.caller)
|
41 | });
|
42 |
|
43 | if (options.requireConfigFile !== false) {
|
44 | const config = (0, _core.loadPartialConfig)(parseOptions);
|
45 |
|
46 | if (config !== null) {
|
47 | if (!config.hasFilesystemConfig()) {
|
48 | throw new 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.`);
|
49 | }
|
50 |
|
51 | return config.options;
|
52 | }
|
53 | }
|
54 |
|
55 | return parseOptions;
|
56 | } |
\ | No newline at end of file |