Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use full import specifier path in tests #13938

Merged
merged 2 commits into from Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc.cjs
Expand Up @@ -67,7 +67,10 @@ module.exports = {
"jest/no-standalone-expect": "off",
"jest/no-test-callback": "off",
"jest/valid-describe": "off",
"import/extensions": ["error", { json: "always", cjs: "always" }],
"import/extensions": [
"error",
{ json: "always", js: "always", cjs: "always", mjs: "always" },
],
},
},
{
Expand Down
@@ -1,6 +1,6 @@
import path from "path";
import rule from "../../src/rules/dry-error-messages";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester";
import rule from "../../lib/rules/dry-error-messages.js";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";
import { fileURLToPath } from "url";

const dirname = path.dirname(fileURLToPath(import.meta.url));
Expand Down
@@ -1,5 +1,5 @@
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester";
import rule from "../../src/rules/report-error-message-format";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";
import rule from "../../lib/rules/report-error-message-format.js";

const ruleTester = new RuleTester();

Expand Down
@@ -1,5 +1,5 @@
import rule from "../../src/rules/no-deprecated-clone";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester";
import rule from "../../lib/rules/no-deprecated-clone.js";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";

const cloneError = "t.clone() is deprecated. Use t.cloneNode() instead.";
const cloneDeepError =
Expand Down
@@ -1,5 +1,5 @@
import rule from "../../src/rules/no-undefined-identifier";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester";
import rule from "../../lib/rules/no-undefined-identifier.js";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";

const error =
"Use path.scope.buildUndefinedNode() to create an undefined identifier directly.";
Expand Down
@@ -1,5 +1,5 @@
import rule from "../../src/rules/plugin-name";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester";
import rule from "../../lib/rules/plugin-name.js";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";

const missingPluginError = "This file does not export a Babel plugin.";
const missingNameError = "This Babel plugin doesn't have a 'name' property.";
Expand Down
4 changes: 2 additions & 2 deletions eslint/babel-eslint-plugin/test/rules/new-cap.js
@@ -1,5 +1,5 @@
import rule from "../../src/rules/new-cap";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester";
import rule from "../../lib/rules/new-cap.js";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";

const ruleTester = new RuleTester();
ruleTester.run("@babel/new-cap", rule, {
Expand Down
4 changes: 2 additions & 2 deletions eslint/babel-eslint-plugin/test/rules/no-invalid-this.js
@@ -1,6 +1,6 @@
import cloneDeep from "clone-deep";
import rule from "../../src/rules/no-invalid-this";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester";
import rule from "../../lib/rules/no-invalid-this.js";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";

/**
* A constant value for non strict mode environment.
Expand Down
@@ -1,5 +1,5 @@
import rule from "../../src/rules/no-unused-expressions";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester";
import rule from "../../lib/rules/no-unused-expressions.js";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";

const ruleTester = new RuleTester();
ruleTester.run("@babel/no-unused-expressions", rule, {
Expand Down
4 changes: 2 additions & 2 deletions eslint/babel-eslint-plugin/test/rules/object-curly-spacing.js
@@ -1,5 +1,5 @@
import rule from "../../src/rules/object-curly-spacing";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester";
import rule from "../../lib/rules/object-curly-spacing.js";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";

const ruleTester = new RuleTester();
ruleTester.run("@babel/object-curly-spacing", rule, {
Expand Down
4 changes: 2 additions & 2 deletions eslint/babel-eslint-plugin/test/rules/semi.js
@@ -1,5 +1,5 @@
import rule from "../../src/rules/semi";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester";
import rule from "../../lib/rules/semi.js";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";

const ruleTester = new RuleTester();

Expand Down
@@ -1,4 +1,4 @@
import verifyAndAssertMessages from "../../helpers/verifyAndAssertMessages";
import verifyAndAssertMessages from "../../helpers/verifyAndAssertMessages.js";
import path from "path";
import { fileURLToPath } from "url";

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-cli/test/index.js
Expand Up @@ -7,7 +7,7 @@ import fs from "fs";
import { fileURLToPath } from "url";
import { createRequire } from "module";

import { chmod } from "../lib/babel/util";
import { chmod } from "../lib/babel/util.js";

const require = createRequire(import.meta.url);

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-code-frame/test/index.js
@@ -1,6 +1,6 @@
import chalk from "chalk";
import stripAnsi from "strip-ansi";
import codeFrame, { codeFrameColumns } from "..";
import codeFrame, { codeFrameColumns } from "../lib/index.js";

describe("@babel/code-frame", function () {
test("basic usage", function () {
Expand Down
10 changes: 5 additions & 5 deletions packages/babel-core/test/api.js
@@ -1,13 +1,13 @@
import * as babel from "../lib/index";
import * as babel from "../lib/index.js";
import sourceMap from "source-map";
import path from "path";
import Plugin from "../lib/config/plugin";
import Plugin from "../lib/config/plugin.js";
import generator from "@babel/generator";
import { fileURLToPath } from "url";

import presetEnv from "../../babel-preset-env";
import pluginSyntaxFlow from "../../babel-plugin-syntax-flow";
import pluginFlowStripTypes from "../../babel-plugin-transform-flow-strip-types";
import presetEnv from "../../babel-preset-env/lib/index.js";
import pluginSyntaxFlow from "../../babel-plugin-syntax-flow/lib/index.js";
import pluginFlowStripTypes from "../../babel-plugin-transform-flow-strip-types/lib/index.js";

const cwd = path.dirname(fileURLToPath(import.meta.url));

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/test/assumptions.js
@@ -1,6 +1,6 @@
import path from "path";
import { fileURLToPath } from "url";
import { loadOptions as loadOptionsOrig, transformSync } from "../lib";
import { loadOptions as loadOptionsOrig, transformSync } from "../lib/index.js";
import pluginCommonJS from "@babel/plugin-transform-modules-commonjs";

const cwd = path.dirname(fileURLToPath(import.meta.url));
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-core/test/async.js
@@ -1,12 +1,12 @@
import path from "path";
import { fileURLToPath } from "url";
import * as babel from "..";
import * as babel from "../lib/index.js";

import {
spawnTransformAsync,
spawnTransformSync,
supportsESM,
} from "./helpers/esm";
} from "./helpers/esm.js";

const nodeGte8 = (...args) => {
// "minNodeVersion": "8.0.0" <-- For Ctrl+F when dropping node 6
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-core/test/caching-api.js
@@ -1,6 +1,6 @@
import gensync from "gensync";
import { makeStrongCacheSync, makeStrongCache } from "../lib/config/caching";
import { waitFor } from "../lib/gensync-utils/async";
import { makeStrongCacheSync, makeStrongCache } from "../lib/config/caching.js";
import { waitFor } from "../lib/gensync-utils/async.js";

describe("caching API", () => {
it("should allow permacaching with .forever()", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-core/test/config-chain.js
Expand Up @@ -2,12 +2,12 @@ import fs from "fs";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import * as babel from "../lib";
import * as babel from "../lib/index.js";
import getTargets from "@babel/helper-compilation-targets";

const dirname = path.dirname(fileURLToPath(import.meta.url));

import { isMJS, loadOptionsAsync, skipUnsupportedESM } from "./helpers/esm";
import { isMJS, loadOptionsAsync, skipUnsupportedESM } from "./helpers/esm.js";

// TODO: In Babel 8, we can directly uses fs.promises which is supported by
// node 8+
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-core/test/config-loading.js
@@ -1,7 +1,7 @@
import loadConfigRunner, {
loadPartialConfig,
createConfigItem,
} from "../lib/config";
} from "../lib/config/index.js";
import path from "path";
import { fileURLToPath } from "url";
import { createRequire } from "module";
Expand Down Expand Up @@ -38,10 +38,10 @@ describe("@babel/core config loading", () => {
filename: FILEPATH,
presets: skipProgrammatic
? null
: [[require("./fixtures/config-loading/preset3"), {}]],
: [[require("./fixtures/config-loading/preset3.js"), {}]],
plugins: skipProgrammatic
? null
: [[require("./fixtures/config-loading/plugin6"), {}]],
: [[require("./fixtures/config-loading/plugin6.js"), {}]],
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/test/helpers/esm.js
Expand Up @@ -4,7 +4,7 @@ import path from "path";
import { fileURLToPath } from "url";
import { createRequire } from "module";

import * as babel from "../../lib";
import * as babel from "../../lib/index.js";

const require = createRequire(import.meta.url);
const dirname = path.dirname(fileURLToPath(import.meta.url));
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/test/option-manager.js
@@ -1,4 +1,4 @@
import { loadOptions as loadOptionsOrig } from "../lib";
import { loadOptions as loadOptionsOrig } from "../lib/index.js";
import path from "path";
import { fileURLToPath } from "url";

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/test/parse.js
@@ -1,6 +1,6 @@
import fs from "fs";
import path from "path";
import { parse } from "../lib";
import { parse } from "../lib/index.js";
import { fileURLToPath } from "url";
import { createRequire } from "module";

Expand Down
4 changes: 2 additions & 2 deletions packages/babel-core/test/path.js
@@ -1,5 +1,5 @@
import { transform } from "../lib/index";
import Plugin from "../lib/config/plugin";
import { transform } from "../lib/index.js";
import Plugin from "../lib/config/plugin.js";
import { fileURLToPath } from "url";
import path from "path";

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/test/resolution.js
@@ -1,4 +1,4 @@
import * as babel from "../lib/index";
import * as babel from "../lib/index.js";
import path from "path";
import { fileURLToPath } from "url";

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/test/targets.js
@@ -1,4 +1,4 @@
import { loadOptions as loadOptionsOrig } from "../lib";
import { loadOptions as loadOptionsOrig } from "../lib/index.js";
import { join, dirname } from "path";
import { fileURLToPath } from "url";

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-generator/test/arrow-functions.js
@@ -1,4 +1,4 @@
import generate from "../lib";
import generate from "../lib/index.js";
import { parse } from "@babel/parser";

describe("parameter parentheses", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-generator/test/index.js
@@ -1,5 +1,5 @@
import Printer from "../lib/printer";
import generate, { CodeGenerator } from "../lib";
import Printer from "../lib/printer.js";
import generate, { CodeGenerator } from "../lib/index.js";
import { parse } from "@babel/parser";
import * as t from "@babel/types";
import fs from "fs";
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-helper-annotate-as-pure/test/index.js
@@ -1,4 +1,4 @@
import annotateAsPure from "../";
import annotateAsPure from "../lib/index.js";

describe("@babel/helper-annotate-as-pure", () => {
it("will add leading comment", () => {
Expand Down
@@ -1,6 +1,6 @@
import { dirname, resolve } from "path";
import { fileURLToPath } from "url";
import getTargets from "../../lib";
import getTargets from "../../lib/index.js";

const currentDir = dirname(fileURLToPath(import.meta.url));

Expand Down
@@ -1,4 +1,4 @@
import getTargets from "../..";
import getTargets from "../../lib/index.js";
import { fileURLToPath } from "url";
import path from "path";

Expand Down
@@ -1,4 +1,4 @@
import getTargets from "../..";
import getTargets from "../../lib/index.js";
import { fileURLToPath } from "url";
import path from "path";

Expand Down
@@ -1,4 +1,4 @@
import getTargets from "../..";
import getTargets from "../../lib/index.js";
import { fileURLToPath } from "url";
import path from "path";

Expand Down
@@ -1,4 +1,4 @@
import { prettifyTargets, prettifyVersion } from "../lib/pretty";
import { prettifyTargets, prettifyVersion } from "../lib/pretty.js";

describe("pretty", () => {
describe("prettifyVersion", () => {
Expand Down
@@ -1,7 +1,7 @@
import browserslist from "browserslist";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
import getTargets from "..";
import getTargets from "../lib/index.js";

describe("getTargets", () => {
it("parses", () => {
Expand Down
@@ -1,4 +1,4 @@
import { targetsSupported } from "../lib/filter-items";
import { targetsSupported } from "../lib/filter-items.js";

describe("targetsSupported", () => {
const MAX_VERSION = `${Number.MAX_SAFE_INTEGER}.0.0`;
Expand Down
@@ -1,4 +1,4 @@
import { semverify } from "../lib/utils";
import { semverify } from "../lib/utils.js";

describe("utils", () => {
describe("semverify", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-helper-module-imports/test/index.js
Expand Up @@ -2,7 +2,7 @@ import * as babel from "@babel/core";
import { fileURLToPath } from "url";
import path from "path";

import { ImportInjector } from "../";
import { ImportInjector } from "../lib/index.js";

const cwd = path.dirname(fileURLToPath(import.meta.url));

Expand Down
@@ -1,7 +1,7 @@
import { parse } from "@babel/parser";
import generator from "@babel/generator";
import * as t from "@babel/types";
import optimizeCallExpression from "..";
import optimizeCallExpression from "../lib/index.js";

function transformInput(input, thisIdentifier) {
const ast = parse(input);
Expand Down
@@ -1,4 +1,4 @@
import { runCodeInTestContext } from "..";
import { runCodeInTestContext } from "../lib/index.js";
import { fileURLToPath } from "url";

const filename = fileURLToPath(import.meta.url);
Expand Down
@@ -1,4 +1,4 @@
import { isIdentifierName } from "..";
import { isIdentifierName } from "../lib/index.js";

describe("isIdentifierName", function () {
it("returns false if provided string is empty", function () {
Expand Down
@@ -1,4 +1,4 @@
import { findSuggestion } from "..";
import { findSuggestion } from "../lib/index.js";

describe("findSuggestion", function () {
test.each([
Expand Down
@@ -1,4 +1,4 @@
import { OptionValidator } from "..";
import { OptionValidator } from "../lib/index.js";

describe("OptionValidator", () => {
describe("validateTopLevelOptions", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-helpers/test/helpers/define-helper.js
@@ -1,6 +1,6 @@
import path from "path";
import template from "@babel/template";
import helpers from "../../lib/helpers";
import helpers from "../../lib/helpers.js";

function getHelperId(dir, name) {
const testName = path.basename(dir);
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-highlight/test/index.js
@@ -1,6 +1,6 @@
import chalk from "chalk";
import stripAnsi from "strip-ansi";
import highlight, { shouldHighlight, getChalk } from "..";
import highlight, { shouldHighlight, getChalk } from "../lib/index.js";

describe("@babel/highlight", function () {
function stubColorSupport(supported) {
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-parser/test/attachComment-false.js
@@ -1,6 +1,6 @@
import path from "path";
import { runFixtureTestsWithoutExactASTMatch } from "./helpers/runFixtureTests";
import { parseExpression } from "../lib";
import { runFixtureTestsWithoutExactASTMatch } from "./helpers/runFixtureTests.js";
import { parseExpression } from "../lib/index.js";
import { fileURLToPath } from "url";

runFixtureTestsWithoutExactASTMatch(
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/test/error-codes.js
@@ -1,4 +1,4 @@
import { parse } from "../lib";
import { parse } from "../lib/index.js";

describe("error codes", function () {
it("raises an error with BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED and reasonCode", function () {
Expand Down