Skip to content

Commit 7b0f7f9

Browse files
FEI-4957.1: Remove file extensions from imports/requires (#522)
## Summary: TypeScript doesn't work with file extensions in imports. This PR removes all .js file imports and requires. I use find'n'replace with `.js";` and `.js");`. This was imprecise and require a bunch of manual fixes. In the future I will try using eslint's auto-fixing and if that doesn't work I'll use regex find and replaces to be more precise. Issue: FEI-4957 ## Test plan: - yarn lint - yarn test Author: kevinbarabash Reviewers: jeresig, kevinbarabash, somewhatabstract Required Reviewers: Approved By: jeresig, somewhatabstract Checks: ✅ codecov/project, ✅ Test (macos-latest, 16.x), ✅ Lint, flow, and coverage check (ubuntu-latest, 16.x), ⏭ gerald, ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 16.x), ✅ Test (macos-latest, 16.x), ✅ CodeQL, ✅ Lint, flow, and coverage check (ubuntu-latest, 16.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 16.x), ✅ gerald, ✅ Analyze (javascript), ⏭ dependabot Pull Request URL: #522
1 parent 16d5fbc commit 7b0f7f9

File tree

118 files changed

+278
-277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+278
-277
lines changed

.changeset/olive-humans-remain.md

+2

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = {
7474
"import/no-named-default": "error",
7575
"import/extensions": [
7676
"error",
77-
"always",
77+
"never",
7878
{
7979
ignorePackages: true,
8080
},

.flowconfig

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module.use_strict=true
1313

1414
[lints]
1515
deprecated-type=error
16-
deprecated-utility=error
1716
sketchy-null=error
1817
sketchy-number=error
1918
unclear-type=error

.prettierrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require("./packages/eslint-config-khan/.prettierrc.js");
1+
module.exports = require("./packages/eslint-config-khan/.prettierrc");

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
* Jest looks for the babel config in the cwd of the project and as such we
55
* need a file to tell it where the config really lies or it would use it.
66
*/
7-
module.exports = require("./build-settings/babel.config.js");
7+
module.exports = require("./build-settings/babel.config");

build-settings/babel.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable import/no-commonjs */
2-
const createBabelPresets = require("./create-babel-presets.js");
3-
const createBabelPlugins = require("./create-babel-plugins.js");
2+
const createBabelPresets = require("./create-babel-presets");
3+
const createBabelPlugins = require("./create-babel-plugins");
44

55
// This config is used for Jest testing here in this repository, only.
66
module.exports = {

build-settings/rollup.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import filesize from "rollup-plugin-filesize";
1111
import {preserveShebangs} from "rollup-plugin-preserve-shebangs";
1212
import rollupExecutable from "rollup-plugin-executable-output";
1313

14-
const createBabelPresets = require("./create-babel-presets.js");
15-
const createBabelPlugins = require("./create-babel-plugins.js");
14+
const createBabelPresets = require("./create-babel-presets");
15+
const createBabelPlugins = require("./create-babel-plugins");
1616

1717
/**
1818
* We support the following config args with this rollup configuration:

config/jest/test.transform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable import/no-commonjs */
22
const babelJest = require("babel-jest").default;
33

4-
const babelConfig = require("../../build-settings/babel.config.js");
4+
const babelConfig = require("../../build-settings/babel.config");
55

66
module.exports = babelJest.createTransformer(babelConfig);

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/* eslint-disable import/no-commonjs */
2-
module.exports = require("./config/jest/test.config.js");
2+
module.exports = require("./config/jest/test.config");

packages/eslint-config-khan/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ module.exports = {
107107
/**
108108
* prettier rules
109109
*/
110-
"prettier/prettier": ["error", require("./.prettierrc.js")],
110+
"prettier/prettier": ["error", require("./.prettierrc")],
111111

112112
/**
113113
* react rules

packages/wonder-stuff-core/src/__tests__/build-caused-by-message.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {buildCausedByMessage} from "../build-caused-by-message.js";
2+
import {buildCausedByMessage} from "../build-caused-by-message";
33

44
describe("#buildCausedByMessage", () => {
55
it("should combine the strings into a 'caused by' message", () => {

packages/wonder-stuff-core/src/__tests__/clone-metadata.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {cloneMetadata} from "../clone-metadata.js";
2+
import {cloneMetadata} from "../clone-metadata";
33

44
describe("#cloneMetadata", () => {
55
it.each([undefined, null])(

packages/wonder-stuff-core/src/__tests__/clone.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {clone} from "../clone.js";
2+
import {clone} from "../clone";
33

44
describe("#clone", () => {
55
it.each([undefined, null])(

packages/wonder-stuff-core/src/__tests__/entries.flowtest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {entries} from "../entries.js";
2+
import {entries} from "../entries";
33

44
{
55
// should type returned array element as tuples of keys as string subtype

packages/wonder-stuff-core/src/__tests__/entries.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {entries} from "../entries.js";
2+
import {entries} from "../entries";
33

44
describe("#entries", () => {
55
it("should call Object.entries with the given object", () => {

packages/wonder-stuff-core/src/__tests__/error-info.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @flow
2-
import * as BuildCausedByMessage from "../build-caused-by-message.js";
3-
import {ErrorInfo} from "../error-info.js";
2+
import * as BuildCausedByMessage from "../build-caused-by-message";
3+
import {ErrorInfo} from "../error-info";
44

5-
jest.mock("../build-caused-by-message.js");
5+
jest.mock("../build-caused-by-message");
66

77
describe("ErrorInfo", () => {
88
const NODE_ENV = process.env.NODE_ENV;

packages/wonder-stuff-core/src/__tests__/errors-from-error.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @flow
2-
import {KindError} from "../kind-error.js";
3-
import {errorsFromError, Order} from "../errors-from-error.js";
2+
import {KindError} from "../kind-error";
3+
import {errorsFromError, Order} from "../errors-from-error";
44

5-
import type {Options as KindErrorOptions} from "../kind-error.js";
5+
import type {Options as KindErrorOptions} from "../kind-error";
66

77
describe("#errorsFromError", () => {
88
it.each([null, undefined, "NOT_A_GOOD_VALUE", 42])(

packages/wonder-stuff-core/src/__tests__/errors.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {Errors} from "../errors.js";
2+
import {Errors} from "../errors";
33

44
describe("Errors", () => {
55
it("should be frozen", () => {

packages/wonder-stuff-core/src/__tests__/get-kind-from-error.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
2-
import {Errors} from "../errors.js";
3-
import {getKindFromError} from "../get-kind-from-error.js";
4-
import {KindError} from "../kind-error.js";
2+
import {Errors} from "../errors";
3+
import {getKindFromError} from "../get-kind-from-error";
4+
import {KindError} from "../kind-error";
55

66
describe("#getKindFromError", () => {
77
it.each([null, undefined, new Error("test")])(

packages/wonder-stuff-core/src/__tests__/get-original-stack-from-error.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
2-
import {getOriginalStackFromError} from "../get-original-stack-from-error.js";
3-
import {KindError} from "../kind-error.js";
2+
import {getOriginalStackFromError} from "../get-original-stack-from-error";
3+
import {KindError} from "../kind-error";
44

55
describe("#getOriginalStackFromError", () => {
66
it("should return the stack of the error for a non-KindError value", () => {

packages/wonder-stuff-core/src/__tests__/keys.flowtest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {keys} from "../keys.js";
2+
import {keys} from "../keys";
33

44
{
55
// should type returned array element as subtype of string

packages/wonder-stuff-core/src/__tests__/keys.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {keys} from "../keys.js";
2+
import {keys} from "../keys";
33

44
describe("#keys", () => {
55
it("should call Object.keys with the given object", () => {

packages/wonder-stuff-core/src/__tests__/kind-error.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @flow
2-
import * as CloneMetadata from "../clone-metadata.js";
3-
import {ErrorInfo} from "../error-info.js";
4-
import {Errors} from "../errors.js";
5-
import {KindError} from "../kind-error.js";
2+
import * as CloneMetadata from "../clone-metadata";
3+
import {ErrorInfo} from "../error-info";
4+
import {Errors} from "../errors";
5+
import {KindError} from "../kind-error";
66

77
describe("KindError", () => {
88
const NODE_ENV = process.env.NODE_ENV;

packages/wonder-stuff-core/src/__tests__/safe-stringify.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {safeStringify} from "../safe-stringify.js";
2+
import {safeStringify} from "../safe-stringify";
33

44
describe("#safeStringify", () => {
55
describe("without options or default value argument", () => {

packages/wonder-stuff-core/src/__tests__/truncate-middle.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {truncateMiddle} from "../truncate-middle.js";
2+
import {truncateMiddle} from "../truncate-middle";
33

44
describe("#truncateMiddle", () => {
55
it.each(["", "ABCDE", "ABCDEFGH"])(

packages/wonder-stuff-core/src/__tests__/values.flowtest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {values} from "../values.js";
2+
import {values} from "../values";
33

44
{
55
// should type returned array element with union of value types of passed object

packages/wonder-stuff-core/src/__tests__/values.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {values} from "../values.js";
2+
import {values} from "../values";
33

44
describe("#values", () => {
55
it("should call Object.values with the given object", () => {

packages/wonder-stuff-core/src/clone-metadata.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
2-
import {clone} from "./clone.js";
3-
import type {Metadata} from "./types.js";
2+
import {clone} from "./clone";
3+
import type {Metadata} from "./types";
44

55
/**
66
* Clone the given metadata.

packages/wonder-stuff-core/src/error-info.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {buildCausedByMessage} from "./build-caused-by-message.js";
2+
import {buildCausedByMessage} from "./build-caused-by-message";
33

44
/**
55
* Information about an error.

packages/wonder-stuff-core/src/errors-from-error.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
2-
import {KindError} from "./kind-error.js";
3-
import {Errors} from "./errors.js";
2+
import {KindError} from "./kind-error";
3+
import {Errors} from "./errors";
44

55
export const Order = Object.freeze({
66
ConsequenceFirst: "consequence-first",

packages/wonder-stuff-core/src/get-kind-from-error.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
2-
import {KindError} from "./kind-error.js";
3-
import {Errors} from "./errors.js";
2+
import {KindError} from "./kind-error";
3+
import {Errors} from "./errors";
44

55
/**
66
* Get the kind for the given error.

packages/wonder-stuff-core/src/get-original-stack-from-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {KindError} from "./kind-error.js";
2+
import {KindError} from "./kind-error";
33

44
/**
55
* Get the original stack trace for the given error.
+12-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// @flow
2-
export {clone} from "./clone.js";
3-
export {entries} from "./entries.js";
4-
export {keys} from "./keys.js";
5-
export {values} from "./values.js";
6-
export {Errors} from "./errors.js";
7-
export {errorsFromError, Order} from "./errors-from-error.js";
8-
export {getKindFromError} from "./get-kind-from-error.js";
9-
export {getOriginalStackFromError} from "./get-original-stack-from-error.js";
10-
export {KindError} from "./kind-error.js";
11-
export {safeStringify} from "./safe-stringify.js";
12-
export {truncateMiddle} from "./truncate-middle.js";
2+
export {clone} from "./clone";
3+
export {entries} from "./entries";
4+
export {keys} from "./keys";
5+
export {values} from "./values";
6+
export {Errors} from "./errors";
7+
export {errorsFromError, Order} from "./errors-from-error";
8+
export {getKindFromError} from "./get-kind-from-error";
9+
export {getOriginalStackFromError} from "./get-original-stack-from-error";
10+
export {KindError} from "./kind-error";
11+
export {safeStringify} from "./safe-stringify";
12+
export {truncateMiddle} from "./truncate-middle";
1313

14-
export type {Metadata} from "./types.js";
14+
export type {Metadata} from "./types";

packages/wonder-stuff-core/src/kind-error.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// @flow
2-
import {Errors} from "./errors.js";
3-
import {ErrorInfo} from "./error-info.js";
4-
import {cloneMetadata} from "./clone-metadata.js";
2+
import {Errors} from "./errors";
3+
import {ErrorInfo} from "./error-info";
4+
import {cloneMetadata} from "./clone-metadata";
55

6-
import type {Metadata} from "./types.js";
6+
import type {Metadata} from "./types";
77

88
/**
99
* Options for constructing a `KindError`.

packages/wonder-stuff-i18n/src/bin/all-i18n-strings.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* yarn all-i18n-strings file.js
1111
* yarn all-i18n-strings "src/*.js"
1212
*/
13-
import {getFilesToExtractFrom, getPoItemMap} from "../utils/pofile-utils.js";
13+
import {getFilesToExtractFrom, getPoItemMap} from "../utils/pofile-utils";
1414

1515
// Get the files that we want to process.
1616
const files = getFilesToExtractFrom(process.argv.slice(2));

packages/wonder-stuff-i18n/src/bin/gen-potfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import {
2020
getFilesToExtractFrom,
2121
getPOTFileStringFromFiles,
22-
} from "../utils/pofile-utils.js";
22+
} from "../utils/pofile-utils";
2323

2424
// Get the files that we want to process.
2525
const files = getFilesToExtractFrom(process.argv.slice(2));
+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// @flow
22
/* istanbul ignore file */
3-
export {default as I18nPlugin} from "./plugins/i18n-plugin.js";
4-
export {extractStrings} from "./utils/extract-i18n.js";
3+
export {default as I18nPlugin} from "./plugins/i18n-plugin";
4+
export {extractStrings} from "./utils/extract-i18n";
55
export {
66
getFilesToExtractFrom,
77
getPOTFileStringFromFiles,
8-
} from "./utils/pofile-utils.js";
8+
} from "./utils/pofile-utils";
99
export {
1010
getIgnoreGlobs,
1111
getI18nStringsFromString,
1212
translateString,
13-
} from "./utils/i18n-utils.js";
14-
export {getEmojiForLocale} from "./utils/emoji-for-locale.js";
13+
} from "./utils/i18n-utils";
14+
export {getEmojiForLocale} from "./utils/emoji-for-locale";
1515

16-
export type {ExtractedString} from "./utils/extract-i18n.js";
17-
export type {TranslatedLocaleStrings} from "./utils/i18n-utils.js";
16+
export type {ExtractedString} from "./utils/extract-i18n";
17+
export type {TranslatedLocaleStrings} from "./utils/i18n-utils";

packages/wonder-stuff-i18n/src/plugins/__tests__/i18n-plugin.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @flow
2-
import I18nPlugin from "../i18n-plugin.js";
2+
import I18nPlugin from "../i18n-plugin";
33

4-
import type {TranslatedLocaleStrings} from "../../utils/i18n-utils.js";
5-
import type {TranslatedStrings, Assets} from "../i18n-plugin.js";
4+
import type {TranslatedLocaleStrings} from "../../utils/i18n-utils";
5+
import type {TranslatedStrings, Assets} from "../i18n-plugin";
66

77
type ResolvedAssets = {|
88
[string]: ResolvedAsset,

packages/wonder-stuff-i18n/src/plugins/i18n-plugin.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
import path from "path";
2121
import {eachLimit} from "async";
2222

23-
import * as I18nUtils from "../utils/i18n-utils.js";
23+
import * as I18nUtils from "../utils/i18n-utils";
2424
import {
2525
hashFileContents,
2626
extractHashFromFileName,
2727
localizeFile,
28-
} from "../utils/localize-file.js";
29-
import {getEmojiForLocale} from "../utils/emoji-for-locale.js";
28+
} from "../utils/localize-file";
29+
import {getEmojiForLocale} from "../utils/emoji-for-locale";
3030

31-
import type {TranslatedLocaleStrings} from "../utils/i18n-utils.js";
31+
import type {TranslatedLocaleStrings} from "../utils/i18n-utils";
3232

3333
/**
3434
* Add a new asset to the Webpack compilation assets.

packages/wonder-stuff-i18n/src/utils/__tests__/emoji-for-locale.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {getEmojiForLocale} from "../emoji-for-locale.js";
2+
import {getEmojiForLocale} from "../emoji-for-locale";
33

44
describe("getEmojiForLocale", () => {
55
it("returns an emoji for boxes", () => {

packages/wonder-stuff-i18n/src/utils/__tests__/extract-i18n.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import {extractStrings} from "../extract-i18n.js";
2+
import {extractStrings} from "../extract-i18n";
33

44
const TEST_FILE = `
55
const explanation = "I am a happy javascript file!";

packages/wonder-stuff-i18n/src/utils/__tests__/i18n-utils.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
getIgnoreGlobs,
66
getI18nStringsFromString,
77
translateString,
8-
} from "../i18n-utils.js";
8+
} from "../i18n-utils";
99

1010
jest.mock("ancesdir");
1111

packages/wonder-stuff-i18n/src/utils/__tests__/localize-file.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
localizeString,
55
localizeFile,
66
hashFileContents,
7-
} from "../localize-file.js";
7+
} from "../localize-file";
88

99
describe("hashFileContents", () => {
1010
it("produces a 20-char hash of a string", () => {

0 commit comments

Comments
 (0)