Skip to content

Commit

Permalink
Use full import specifier path in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Nov 7, 2021
1 parent a6a5269 commit 105eb94
Show file tree
Hide file tree
Showing 93 changed files with 126 additions and 121 deletions.
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
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
2 changes: 1 addition & 1 deletion packages/babel-core/test/async.js
Expand Up @@ -6,7 +6,7 @@ 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,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
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
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
4 changes: 2 additions & 2 deletions packages/babel-parser/test/estree-throws.js
@@ -1,6 +1,6 @@
import path from "path";
import { runFixtureTestsWithoutExactASTMatch } from "./helpers/runFixtureTests";
import { parse } from "../lib";
import { runFixtureTestsWithoutExactASTMatch } from "./helpers/runFixtureTests.js";
import { parse } from "../lib/index.js";
import { fileURLToPath } from "url";

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

const fixtures = path.join(
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-parser/test/index.js
@@ -1,6 +1,6 @@
import path from "path";
import { runFixtureTests } from "./helpers/runFixtureTests";
import { parse } from "../lib";
import { runFixtureTests } from "./helpers/runFixtureTests.js";
import { parse } from "../lib/index.js";
import { fileURLToPath } from "url";

const fixtures = path.join(
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/test/options.js
@@ -1,4 +1,4 @@
import { parse } from "../lib";
import { parse } from "../lib/index.js";

describe("options", () => {
describe("strictMode", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/test/plugin-options.js
@@ -1,4 +1,4 @@
import { parse } from "../lib";
import { parse } from "../lib/index.js";

function getParser(code, plugins) {
return () => parse(code, { plugins, sourceType: "module" });
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/test/unit/tokenizer/types.js
@@ -1,4 +1,4 @@
import { tt, tokenOperatorPrecedence } from "../../../src/tokenizer/types";
import { tt, tokenOperatorPrecedence } from "../../../src/tokenizer/types.js";

describe("token types", () => {
it("should check if the binOp for relational === in", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/test/unit/util/identifier.js
@@ -1,7 +1,7 @@
import {
isKeyword,
keywordRelationalOperator,
} from "../../../src/util/identifier";
} from "../../../src/util/identifier.js";

describe("identifier", () => {
describe("isKeyword", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/test/unit/util/location.js
@@ -1,4 +1,4 @@
import { getLineInfo } from "../../../src/util/location";
import { getLineInfo } from "../../../src/util/location.js";

describe("getLineInfo", () => {
const input = "a\nb\nc\nd\ne\nf\ng\nh\ni";
Expand Down
@@ -1,5 +1,5 @@
import { parse } from "@babel/parser";
import shouldStoreRHSInTemporaryVariable from "../lib/shouldStoreRHSInTemporaryVariable";
import shouldStoreRHSInTemporaryVariable from "../lib/shouldStoreRHSInTemporaryVariable.js";

function getFistObjectPattern(program) {
return parse(program, { sourceType: "module" }).program.body[0]
Expand Down

0 comments on commit 105eb94

Please sign in to comment.