Debian Codegraph @

eslint/babel-eslint-tests/test/integration/parser-override.js

raw symbols SCIP
1 import path from "path";
2 import { fileURLToPath } from "url";
3 import { createRequire } from "module";
4 import * as babelESLint from "@babel/eslint-parser";
5
6 describe("parserOverride", () => {
7 const expectedAST = {
8 type: "Program",
9 body: [
10 {
11 type: "ExpressionStatement",
12 expression: {
13 type: "Identifier",
14 name: "foo",
15 },
16 },
17 ],
18 };
19
20 it("works when parsing in the main thread", () => {
21 const { ast } = babelESLint.parseForESLint(`27`, {
22 filename: "input.js",
23 babelOptions: {
24 configFile: path.resolve(
25 path.dirname(fileURLToPath(import.meta.url)),
26 "../fixtures/parser-override/babel.config.json",
27 ),
28 },
29 });
30
31 expect(ast).toMatchObject(expectedAST);
32 });
33
34 const babel7node12 = parseInt(process.versions.node) < 12 ? it.skip : it;
35 babel7node12("works when parsing in a worker", async () => {
36 const require = createRequire(import.meta.url);
37 // eslint-disable-next-line import/extensions
38 const babelESLintWorker = require("@babel/eslint-parser/experimental-worker");
39
40 const { ast } = babelESLintWorker.parseForESLint(`27`, {
41 filename: "input.js",
42 babelOptions: {
43 configFile: path.resolve(
44 path.dirname(fileURLToPath(import.meta.url)),
45 "../fixtures/parser-override/babel.config.json",
46 ),
47 },
48 });
49
50 expect(ast).toMatchObject(expectedAST);
51 });
52 });