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 .js(x) for all imports instead of .ts(x) #5573

Merged
merged 1 commit into from
Jan 6, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,6 @@ module.exports = {
'no-restricted-syntax': ['error', {
selector: 'ImportDeclaration[source.value=/^@uppy\\x2F[a-z-0-9]+\\x2F/]:not([source.value=/^@uppy\\x2Futils\\x2F/]):not([source.value=/\\.(js|css)$/])',
message: 'Use ".js" file extension for import type declarations from a different package',
}, {
selector: 'ImportDeclaration[importKind="type"][source.value=/^\\.\\.?\\x2F.+\\.js$/]',
message: 'Do not use ".js" file extension for relative import type declarations',
}, {
selector: 'ImportDeclaration[source.value=/^@uppy\\x2Futils\\x2Flib\\x2F.+\\.[mc]?[jt]sx?$/]',
message: 'Do not use file extension when importing from @uppy/utils',
Expand Down
8 changes: 4 additions & 4 deletions packages/@uppy/audio/src/Audio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import type {
import type { Uppy } from '@uppy/core/lib/Uppy.js'

import getFileTypeExtension from '@uppy/utils/lib/getFileTypeExtension'
import supportsMediaRecorder from './supportsMediaRecorder.ts'
import RecordingScreen from './RecordingScreen.tsx'
import PermissionsScreen from './PermissionsScreen.tsx'
import locale from './locale.ts'
import supportsMediaRecorder from './supportsMediaRecorder.js'
import RecordingScreen from './RecordingScreen.jsx'
import PermissionsScreen from './PermissionsScreen.jsx'
import locale from './locale.js'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
import packageJson from '../package.json'
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/audio/src/RecordingLength.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h } from 'preact'
import type { I18n } from '@uppy/utils/lib/Translator'
import formatSeconds from './formatSeconds.ts'
import formatSeconds from './formatSeconds.js'

interface RecordingLengthProps {
recordingLengthSeconds: number
Expand Down
12 changes: 6 additions & 6 deletions packages/@uppy/audio/src/RecordingScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import { h } from 'preact'
import { useEffect, useRef } from 'preact/hooks'
import type { I18n } from '@uppy/utils/lib/Translator'
import RecordButton from './RecordButton.tsx'
import RecordingLength from './RecordingLength.tsx'
import RecordButton from './RecordButton.jsx'
import RecordingLength from './RecordingLength.jsx'
import AudioSourceSelect, {
type AudioSourceSelectProps,
} from './AudioSourceSelect.tsx'
import AudioOscilloscope from './audio-oscilloscope/index.ts'
import SubmitButton from './SubmitButton.tsx'
import DiscardButton from './DiscardButton.tsx'
} from './AudioSourceSelect.jsx'
import AudioOscilloscope from './audio-oscilloscope/index.js'
import SubmitButton from './SubmitButton.jsx'
import DiscardButton from './DiscardButton.jsx'

interface RecordingScreenProps extends AudioSourceSelectProps {
stream: MediaStream | null | undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/audio/src/formatSeconds.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import formatSeconds from './formatSeconds.ts'
import formatSeconds from './formatSeconds.js'

describe('formatSeconds', () => {
it("should return a value of '0:43' when an argument of 43 seconds is supplied", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/audio/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default } from './Audio.tsx'
export type { AudioOptions } from './Audio.tsx'
export { default } from './Audio.jsx'
export type { AudioOptions } from './Audio.jsx'
2 changes: 1 addition & 1 deletion packages/@uppy/audio/src/supportsMediaRecorder.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-classes-per-file, compat/compat */
import { describe, expect, it } from 'vitest'
import supportsMediaRecorder from './supportsMediaRecorder.ts'
import supportsMediaRecorder from './supportsMediaRecorder.js'

describe('supportsMediaRecorder', () => {
it('should return true if MediaRecorder is supported', () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/@uppy/aws-s3/src/HTTPCommunicationQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type {
RateLimitedQueue,
WrapPromiseFunctionType,
} from '@uppy/utils/lib/RateLimitedQueue'
import { pausingUploadReason, type Chunk } from './MultipartUploader.ts'
import type AwsS3Multipart from './index.ts'
import { throwIfAborted } from './utils.ts'
import type { UploadPartBytesResult, UploadResult } from './utils.ts'
import type { AwsS3MultipartOptions, uploadPartBytes } from './index.ts'
import { pausingUploadReason, type Chunk } from './MultipartUploader.js'
import type AwsS3Multipart from './index.js'
import { throwIfAborted } from './utils.js'
import type { UploadPartBytesResult, UploadResult } from './utils.js'
import type { AwsS3MultipartOptions, uploadPartBytes } from './index.js'

function removeMetadataFromURL(urlString: string) {
const urlObject = new URL(urlString)
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3/src/MultipartUploader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Uppy } from '@uppy/core'
import { AbortController } from '@uppy/utils/lib/AbortController'
import type { Meta, Body, UppyFile } from '@uppy/utils/lib/UppyFile'
import type { HTTPCommunicationQueue } from './HTTPCommunicationQueue.ts'
import type { HTTPCommunicationQueue } from './HTTPCommunicationQueue.js'

const MB = 1024 * 1024

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3/src/createSignedURL.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
PutObjectCommand,
} from '@aws-sdk/client-s3'
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
import createSignedURL from './createSignedURL.ts'
import createSignedURL from './createSignedURL.js'

const bucketName = 'some-bucket.with.dots'
const s3ClientOptions = {
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import 'whatwg-fetch'
import nock from 'nock'
import Core from '@uppy/core'
import AwsS3Multipart, { type AwsBody } from './index.ts'
import AwsS3Multipart, { type AwsBody } from './index.js'

const KB = 1024
const MB = KB * KB
Expand Down
12 changes: 6 additions & 6 deletions packages/@uppy/aws-s3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import {
} from '@uppy/utils/lib/fileFilters'
import { createAbortError } from '@uppy/utils/lib/AbortController'
import getAllowedMetaFields from '@uppy/utils/lib/getAllowedMetaFields'
import MultipartUploader from './MultipartUploader.ts'
import { throwIfAborted } from './utils.ts'
import MultipartUploader from './MultipartUploader.js'
import { throwIfAborted } from './utils.js'
import type {
UploadResult,
UploadResultWithSignal,
MultipartUploadResultWithSignal,
UploadPartBytesResult,
} from './utils.ts'
import createSignedURL from './createSignedURL.ts'
import { HTTPCommunicationQueue } from './HTTPCommunicationQueue.ts'
} from './utils.js'
import createSignedURL from './createSignedURL.js'
import { HTTPCommunicationQueue } from './HTTPCommunicationQueue.js'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
import packageJson from '../package.json'
Expand Down Expand Up @@ -290,7 +290,7 @@ const defaultOptions = {
retryDelays: [0, 1000, 3000, 5000],
} satisfies Partial<AwsS3MultipartOptions<any, any>>

export type { AwsBody } from './utils.ts'
export type { AwsBody } from './utils.js'

export default class AwsS3Multipart<
M extends Meta,
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createAbortError } from '@uppy/utils/lib/AbortController'
import type { Body } from '@uppy/utils/lib/UppyFile'

import type { AwsS3Part } from './index.ts'
import type { AwsS3Part } from './index.js'

export function throwIfAborted(signal?: AbortSignal | null): void {
if (signal?.aborted) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/box/src/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
UnknownProviderPlugin,
UnknownProviderPluginState,
} from '@uppy/core/lib/Uppy.js'
import locale from './locale.ts'
import locale from './locale.js'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
import packageJson from '../package.json'
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/box/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default } from './Box.tsx'
export type { BoxOptions } from './Box.tsx'
export { default } from './Box.jsx'
export type { BoxOptions } from './Box.jsx'
6 changes: 3 additions & 3 deletions packages/@uppy/companion-client/src/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type {
CompanionClientProvider,
} from '@uppy/utils/lib/CompanionClientProvider'
import type { UnknownProviderPlugin } from '@uppy/core/lib/Uppy.js'
import RequestClient, { authErrorStatusCode } from './RequestClient.ts'
import type { CompanionPluginOptions } from './index.ts'
import { isOriginAllowed } from './getAllowedHosts.ts'
import RequestClient, { authErrorStatusCode } from './RequestClient.js'
import type { CompanionPluginOptions } from './index.js'
import { isOriginAllowed } from './getAllowedHosts.js'

export interface Opts extends PluginOpts, CompanionPluginOptions {
pluginId: string
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion-client/src/RequestClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import RequestClient from './RequestClient.ts'
import RequestClient from './RequestClient.js'

describe('RequestClient', () => {
it('has a hostname without trailing slash', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion-client/src/RequestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import getSocketHost from '@uppy/utils/lib/getSocketHost'
import type Uppy from '@uppy/core'
import type { UppyFile, Meta, Body } from '@uppy/utils/lib/UppyFile'
import type { RequestOptions } from '@uppy/utils/lib/CompanionClientProvider'
import AuthError from './AuthError.ts'
import AuthError from './AuthError.js'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
import packageJson from '../package.json'
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion-client/src/SearchProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { Uppy } from '@uppy/core'
import type { CompanionClientSearchProvider } from '@uppy/utils/lib/CompanionClientProvider'
import RequestClient, { type Opts } from './RequestClient.ts'
import RequestClient, { type Opts } from './RequestClient.js'

const getName = (id: string): string => {
return id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import getAllowedHosts, { isOriginAllowed } from './getAllowedHosts.ts'
import getAllowedHosts, { isOriginAllowed } from './getAllowedHosts.js'

describe('getAllowedHosts', () => {
it('can convert companionAllowedHosts', () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/@uppy/companion-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* Manages communications with Companion
*/

export { default as RequestClient } from './RequestClient.ts'
export { default as Provider } from './Provider.ts'
export { default as SearchProvider } from './SearchProvider.ts'
export { default as RequestClient } from './RequestClient.js'
export { default as Provider } from './Provider.js'
export { default as SearchProvider } from './SearchProvider.js'

export { default as getAllowedHosts } from './getAllowedHosts.ts'
export { default as getAllowedHosts } from './getAllowedHosts.js'

export * as tokenStorage from './tokenStorage.ts'
export * as tokenStorage from './tokenStorage.js'

export type { CompanionPluginOptions } from './CompanionPluginOptions.ts'
export type { CompanionPluginOptions } from './CompanionPluginOptions.js'
2 changes: 1 addition & 1 deletion packages/@uppy/compressor/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Core from '@uppy/core'
import getFileNameAndExtension from '@uppy/utils/lib/getFileNameAndExtension'
import fs from 'node:fs'
import path from 'node:path'
import CompressorPlugin from './index.ts'
import CompressorPlugin from './index.js'

// Compressor uses browser canvas API, so need to mock compress()
// @ts-expect-error mocked
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/compressor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CompressorJS from 'compressorjs'
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
import type { DefinePluginOpts, PluginOpts } from '@uppy/core/lib/BasePlugin.js'

import locale from './locale.ts'
import locale from './locale.js'

declare module '@uppy/core' {
export interface UppyEventMap<M extends Meta, B extends Body> {
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/core/src/BasePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
OptionalPluralizeLocale,
} from '@uppy/utils/lib/Translator'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { State, UnknownPlugin, Uppy } from './Uppy.ts'
import type { State, UnknownPlugin, Uppy } from './Uppy.js'

export type PluginOpts = {
locale?: Locale
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/core/src/EventManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, Body, UppyFile } from '@uppy/utils/lib/UppyFile'
import type { Uppy, UppyEventMap, _UppyEventMap } from './Uppy.ts'
import type { Uppy, UppyEventMap, _UppyEventMap } from './Uppy.js'

/**
* Create a wrapper around an event emitter with a `remove` method to remove
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/core/src/Restricter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import prettierBytes from '@transloadit/prettier-bytes'
import match from 'mime-match'
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
import type { I18n } from '@uppy/utils/lib/Translator'
import type { State, NonNullableUppyOptions } from './Uppy.ts'
import type { State, NonNullableUppyOptions } from './Uppy.js'

export type Restrictions = {
maxFileSize: number | null
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/core/src/UIPlugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import UIPlugin from './UIPlugin.ts'
import Core from './index.ts'
import UIPlugin from './UIPlugin.js'
import Core from './index.js'

describe('UIPlugin', () => {
describe('getPluginState', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/@uppy/core/src/UIPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import findDOMElement from '@uppy/utils/lib/findDOMElement'
import getTextDirection from '@uppy/utils/lib/getTextDirection'

import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import BasePlugin from './BasePlugin.ts'
import type { PluginOpts } from './BasePlugin.ts'
import type { State } from './Uppy.ts'
import BasePlugin from './BasePlugin.js'
import type { PluginOpts } from './BasePlugin.js'
import type { State } from './Uppy.js'

/**
* Defer a frequent call to the microtask queue.
Expand Down
20 changes: 10 additions & 10 deletions packages/@uppy/core/src/Uppy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import path from 'node:path'
import prettierBytes from '@transloadit/prettier-bytes'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { Locale } from '@uppy/utils/lib/Translator'
import Core from './index.ts'
import UIPlugin from './UIPlugin.ts'
import Core from './index.js'
import UIPlugin from './UIPlugin.js'
import BasePlugin, {
type DefinePluginOpts,
type PluginOpts,
} from './BasePlugin.ts'
import { debugLogger } from './loggers.ts'
import AcquirerPlugin1 from './mocks/acquirerPlugin1.ts'
import AcquirerPlugin2 from './mocks/acquirerPlugin2.ts'
import InvalidPlugin from './mocks/invalidPlugin.ts'
import InvalidPluginWithoutId from './mocks/invalidPluginWithoutId.ts'
import InvalidPluginWithoutType from './mocks/invalidPluginWithoutType.ts'
} from './BasePlugin.js'
import { debugLogger } from './loggers.js'
import AcquirerPlugin1 from './mocks/acquirerPlugin1.js'
import AcquirerPlugin2 from './mocks/acquirerPlugin2.js'
import InvalidPlugin from './mocks/invalidPlugin.js'
import InvalidPluginWithoutId from './mocks/invalidPluginWithoutId.js'
import InvalidPluginWithoutType from './mocks/invalidPluginWithoutType.js'
// @ts-expect-error trying to import a file from outside the package
import DeepFrozenStore from '../../../../e2e/cypress/fixtures/DeepFrozenStore.mjs'
import type { State } from './Uppy.ts'
import type { State } from './Uppy.js'

const sampleImage = fs.readFileSync(
// eslint-disable-next-line no-restricted-globals
Expand Down
14 changes: 7 additions & 7 deletions packages/@uppy/core/src/Uppy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ import type {
I18n,
OptionalPluralizeLocale,
} from '@uppy/utils/lib/Translator'
import supportsUploadProgress from './supportsUploadProgress.ts'
import getFileName from './getFileName.ts'
import { justErrorsLogger, debugLogger } from './loggers.ts'
import supportsUploadProgress from './supportsUploadProgress.js'
import getFileName from './getFileName.js'
import { justErrorsLogger, debugLogger } from './loggers.js'
import {
Restricter,
defaultOptions as defaultRestrictionOptions,
RestrictionError,
} from './Restricter.ts'
} from './Restricter.js'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
import packageJson from '../package.json'
import locale from './locale.ts'
import locale from './locale.js'

import type BasePlugin from './BasePlugin.ts'
import type { Restrictions, ValidateableFile } from './Restricter.ts'
import type BasePlugin from './BasePlugin.js'
import type { Restrictions, ValidateableFile } from './Restricter.js'

type Processor = (
fileIDs: string[],
Expand Down
12 changes: 6 additions & 6 deletions packages/@uppy/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { default } from './Uppy.ts'
export { default } from './Uppy.js'
export {
default as Uppy,
type State,
Expand All @@ -8,13 +8,13 @@ export {
type UploadResult,
type UppyEventMap,
type UppyOptions,
} from './Uppy.ts'
export { default as UIPlugin } from './UIPlugin.ts'
export { default as BasePlugin } from './BasePlugin.ts'
export { debugLogger } from './loggers.ts'
} from './Uppy.js'
export { default as UIPlugin } from './UIPlugin.js'
export { default as BasePlugin } from './BasePlugin.js'
export { debugLogger } from './loggers.js'

export type { Store } from '@uppy/store-default'

export type { UIPluginOptions } from './UIPlugin.ts'
export type { UIPluginOptions } from './UIPlugin.js'

export type { UppyFile, Meta, Body } from '@uppy/utils/lib/UppyFile'
4 changes: 2 additions & 2 deletions packages/@uppy/core/src/mocks/acquirerPlugin1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi } from 'vitest' // eslint-disable-line import/no-extraneous-dependencies
import UIPlugin from '../UIPlugin.ts'
import type Uppy from '../Uppy.ts'
import UIPlugin from '../UIPlugin.js'
import type Uppy from '../Uppy.js'

type mock = ReturnType<typeof vi.fn>

Expand Down
Loading
Loading