Skip to content

Commit

Permalink
Enable Babel and Prettier e2e tests for the esm build (#15672)
Browse files Browse the repository at this point in the history
* Try enabling more e2e tests for the esm build

* ssh

* babel, cra, prettier

* Dont load babel config in ESLint tests

* Add missing devdep used in tests

* Make sure to not load root babel.config.js in tests

* syntax old node
  • Loading branch information
nicolo-ribaudo committed Jun 26, 2023
1 parent 04f063e commit ef1cddb
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e-tests-esm.yml
Expand Up @@ -44,7 +44,9 @@ jobs:
fail-fast: false
matrix:
project:
- babel
- create-react-app
- prettier
steps:
- name: Get yarn1 cache directory path
id: yarn1-cache-dir-path
Expand Down Expand Up @@ -82,5 +84,3 @@ jobs:
path: /tmp/verdaccio-workspace
- name: Test
run: ./scripts/integration-tests/e2e-${{ matrix.project }}.sh
env:
USE_ESM: true
4 changes: 4 additions & 0 deletions babel.config.js
@@ -1,5 +1,9 @@
"use strict";

if (typeof it === "function") {
throw new Error("Monorepo root's babel.config.js loaded by a test.");
}

const pathUtils = require("path");
const fs = require("fs");
const { parseSync } = require("@babel/core");
Expand Down
13 changes: 12 additions & 1 deletion eslint/babel-eslint-parser/test/index.js
Expand Up @@ -3,9 +3,20 @@ import escope from "eslint-scope";
import unpad from "dedent";
import { fileURLToPath } from "url";
import { createRequire } from "module";
import { parseForESLint } from "../lib/index.cjs";
import { parseForESLint as parseForESLintOriginal } from "../lib/index.cjs";
import { ESLint } from "eslint";

function parseForESLint(code, options) {
return parseForESLintOriginal(code, {
requireConfigFile: false,
...options,
babelOptions: {
configFile: false,
...options.babelOptions,
},
});
}

const ESLINT_VERSION = ESLint.version;
const isESLint7 = ESLINT_VERSION.startsWith("7.");
const dirname = path.dirname(fileURLToPath(import.meta.url));
Expand Down
Expand Up @@ -25,13 +25,16 @@ export default function verifyAndAssertMessages(
parserOptions: {
sourceType,
requireConfigFile: false,
...(overrideConfig && overrideConfig.parserOptions),
babelOptions: {
configFile: path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
"../../../babel-eslint-shared-fixtures/config/babel.config.js",
),
...(overrideConfig &&
overrideConfig.parserOptions &&
overrideConfig.parserOptions.babelOptions),
},
...(overrideConfig && overrideConfig.parserOptions),
},
});

Expand Down
1 change: 1 addition & 0 deletions packages/babel-node/package.json
Expand Up @@ -36,6 +36,7 @@
"devDependencies": {
"@babel/core": "workspace:^",
"@babel/helper-fixtures": "workspace:^",
"@babel/preset-env": "workspace:^",
"@babel/runtime": "workspace:^",
"@types/v8flags": "^3.1.1",
"fs-readdir-recursive": "^1.0.0",
Expand Down
Expand Up @@ -3,13 +3,20 @@ import { parseSync, traverse } from "@babel/core";

function getPath(input, parserOpts) {
let targetPath;
traverse(parseSync(input, { parserOpts, filename: "example.js" }), {
OptionalMemberExpression(path) {
targetPath = path;
path.stop();
traverse(
parseSync(input, {
parserOpts,
filename: "example.js",
configFile: false,
}),
{
OptionalMemberExpression(path) {
targetPath = path;
path.stop();
},
noScope: true,
},
noScope: true,
});
);
return targetPath;
}

Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Expand Up @@ -1082,6 +1082,7 @@ __metadata:
dependencies:
"@babel/core": "workspace:^"
"@babel/helper-fixtures": "workspace:^"
"@babel/preset-env": "workspace:^"
"@babel/register": "workspace:^"
"@babel/runtime": "workspace:^"
"@types/v8flags": ^3.1.1
Expand Down

0 comments on commit ef1cddb

Please sign in to comment.