Skip to content

Commit

Permalink
Match ESM by using file extensions
Browse files Browse the repository at this point in the history
Refs #1750
  • Loading branch information
thewilkybarkid committed Jun 13, 2024
1 parent cfc7cda commit 294f1f7
Show file tree
Hide file tree
Showing 494 changed files with 2,462 additions and 2,420 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "no-comments"],
"plugins": ["@typescript-eslint", "no-comments", "require-extensions"],
"extends": [
"eslint:recommended",
"plugin:require-extensions/recommended",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:import/recommended",
Expand Down Expand Up @@ -79,7 +80,8 @@
"remixicon/**/*.svg",
"tinyld/heavy",
"integration/base",
"types/*"
"types/*",
"*/index.js"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion assets/error-summary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forceFocus, getTargetElement } from './dom'
import { forceFocus, getTargetElement } from './dom.js'

export class ErrorSummary extends HTMLElement {
static element = 'error-summary' as const
Expand Down
2 changes: 1 addition & 1 deletion assets/html-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import numberedListIcon from 'remixicon/icons/Editor/list-ordered.svg'
import bulletedListIcon from 'remixicon/icons/Editor/list-unordered.svg'
import subscriptIcon from 'remixicon/icons/Editor/subscript.svg'
import superscriptIcon from 'remixicon/icons/Editor/superscript.svg'
import { disableButton, enableButton, preventDefault } from './dom'
import { disableButton, enableButton, preventDefault } from './dom.js'

const deps = Promise.all([
import('@tiptap/core'),
Expand Down
2 changes: 1 addition & 1 deletion assets/notification-banner.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forceFocus } from './dom'
import { forceFocus } from './dom.js'

export class NotificationBanner extends HTMLElement {
static element = 'notification-banner' as const
Expand Down
2 changes: 1 addition & 1 deletion assets/single-use-form.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { disableButton } from './dom'
import { disableButton } from './dom.js'

export class SingleUseForm extends HTMLElement {
static element = 'single-use-form' as const
Expand Down
2 changes: 1 addition & 1 deletion assets/skip-link.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forceFocus, getTargetElement } from './dom'
import { forceFocus, getTargetElement } from './dom.js'

export class SkipLink extends HTMLElement {
static element = 'skip-link' as const
Expand Down
2 changes: 1 addition & 1 deletion integration/about-us.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can read about us', async ({ fetch, page }) => {
await page.goto('/')
Expand Down
2 changes: 1 addition & 1 deletion integration/author-invite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
invitedToBeAnAuthor,
test,
willUpdateAReview,
} from './base'
} from './base.js'

test.extend(canLogIn).extend(hasAVerifiedEmailAddress).extend(invitedToBeAnAuthor).extend(willUpdateAReview)(
'can accept an invite',
Expand Down
24 changes: 12 additions & 12 deletions integration/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ import {
UnsubmittedDepositionC,
type Record as ZenodoRecord,
} from 'zenodo-ts'
import { type ConfigEnv, app } from '../src/app'
import { AuthorInviteC } from '../src/author-invite'
import { ContactEmailAddressC } from '../src/contact-email-address'
import { createAuthorInviteEmail } from '../src/email'
import { type ConfigEnv, app } from '../src/app.js'
import { AuthorInviteC } from '../src/author-invite.js'
import { ContactEmailAddressC } from '../src/contact-email-address.js'
import { createAuthorInviteEmail } from '../src/email.js'
import type {
CanConnectOrcidProfileEnv,
CanRequestReviewsEnv,
CanUploadAvatarEnv,
CanUseSearchQueriesEnv,
} from '../src/feature-flags'
import { rawHtml } from '../src/html'
} from '../src/feature-flags.js'
import { rawHtml } from '../src/html.js'
import type {
AuthorInviteStoreEnv,
ContactEmailAddressStoreEnv,
Expand All @@ -48,12 +48,12 @@ import type {
ResearchInterestsStoreEnv,
ReviewRequestStoreEnv,
UserOnboardingStoreEnv,
} from '../src/keyv'
import type { LegacyPrereviewApiEnv } from '../src/legacy-prereview'
import type { IsUserBlockedEnv } from '../src/log-in'
import type { EmailAddress } from '../src/types/email-address'
import type { NonEmptyString } from '../src/types/string'
import type { WasPrereviewRemovedEnv } from '../src/zenodo'
} from '../src/keyv.js'
import type { LegacyPrereviewApiEnv } from '../src/legacy-prereview.js'
import type { IsUserBlockedEnv } from '../src/log-in/index.js'
import type { EmailAddress } from '../src/types/email-address.js'
import type { NonEmptyString } from '../src/types/string.js'
import type { WasPrereviewRemovedEnv } from '../src/zenodo.js'

import Logger = L.Logger
import LogEntry = L.LogEntry
Expand Down
2 changes: 1 addition & 1 deletion integration/clubs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can read about clubs', async ({ fetch, page }) => {
await page.goto('/')
Expand Down
2 changes: 1 addition & 1 deletion integration/code-of-conduct.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can read the Code of Conduct', async ({ fetch, page }) => {
await page.goto('/')
Expand Down
2 changes: 1 addition & 1 deletion integration/edia-statement.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can read the EDIA statement', async ({ fetch, page }) => {
await page.goto('/')
Expand Down
2 changes: 1 addition & 1 deletion integration/finding-a-club.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Doi } from 'doi-ts'
import type { Orcid } from 'orcid-id-ts'
import { URL } from 'url'
import { RecordC, RecordsC } from 'zenodo-ts'
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can find and view a club', async ({ fetch, page }) => {
fetch
Expand Down
2 changes: 1 addition & 1 deletion integration/finding-a-preprint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Doi } from 'doi-ts'
import type { Orcid } from 'orcid-id-ts'
import { URL } from 'url'
import { RecordsC } from 'zenodo-ts'
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can find and view a preprint', async ({ fetch, page }) => {
await page.goto('/preprints/doi-10.1101-2022.01.13.476201/write-a-prereview')
Expand Down
2 changes: 1 addition & 1 deletion integration/finding-a-profile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Doi } from 'doi-ts'
import type { Orcid } from 'orcid-id-ts'
import { URL } from 'url'
import { RecordC, RecordsC } from 'zenodo-ts'
import { areLoggedIn, canLogIn, expect, isASlackUser, test } from './base'
import { areLoggedIn, canLogIn, expect, isASlackUser, test } from './base.js'

test('can find and view a profile', async ({ fetch, page }) => {
fetch
Expand Down
2 changes: 1 addition & 1 deletion integration/finding-a-review.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Doi } from 'doi-ts'
import type { Orcid } from 'orcid-id-ts'
import { URL } from 'url'
import { type Record, RecordC, RecordsC } from 'zenodo-ts'
import { areLoggedIn, canLogIn, canUseSearchQueries, expect, prereviewWasRemoved, test } from './base'
import { areLoggedIn, canLogIn, canUseSearchQueries, expect, prereviewWasRemoved, test } from './base.js'

test.extend(canLogIn).extend(areLoggedIn)('can see my own PREreviews', async ({ fetch, page }) => {
await page.goto('/')
Expand Down
2 changes: 1 addition & 1 deletion integration/finding-rapid-prereviews.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RecordsC } from 'zenodo-ts'
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can find and view Rapid PREreviews', async ({ fetch, page }) => {
fetch
Expand Down
2 changes: 1 addition & 1 deletion integration/funding.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test("can read about how we're funded", async ({ fetch, page }) => {
await page.goto('/')
Expand Down
2 changes: 1 addition & 1 deletion integration/legacy-routes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test('when the page has been temporarily removed', async ({ page }) => {
await page.goto('/prereviewers')
Expand Down
2 changes: 1 addition & 1 deletion integration/live-reviews.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can read about Live Reviews', async ({ fetch, page }) => {
await page.goto('/')
Expand Down
2 changes: 1 addition & 1 deletion integration/log-in.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
isASlackUser,
test,
userIsBlocked,
} from './base'
} from './base.js'

test.extend(canLogIn).extend(areLoggedIn)('can view my details', async ({ page }) => {
await page.getByRole('link', { name: 'My details' }).click()
Expand Down
2 changes: 1 addition & 1 deletion integration/log-out.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { areLoggedIn, canLogIn, expect, test } from './base'
import { areLoggedIn, canLogIn, expect, test } from './base.js'

test.extend(canLogIn).extend(areLoggedIn)('can log out', async ({ javaScriptEnabled, page }) => {
const logOut = page.getByRole('link', { name: 'Log out' })
Expand Down
2 changes: 1 addition & 1 deletion integration/page-not-found.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test('when the page does not exist', async ({ page }) => {
await page.goto('/this-should-not-find-anything')
Expand Down
2 changes: 1 addition & 1 deletion integration/people.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can read about people', async ({ fetch, page }) => {
await page.goto('/')
Expand Down
2 changes: 1 addition & 1 deletion integration/privacy-policy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can read the privacy policy', async ({ fetch, page }) => {
await page.goto('/')
Expand Down
2 changes: 1 addition & 1 deletion integration/publishing-a-prereview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
test,
updatesLegacyPrereview,
willPublishAReview,
} from './base'
} from './base.js'

test.extend(canLogIn).extend(hasAVerifiedEmailAddress).extend(willPublishAReview)(
'can publish a PREreview',
Expand Down
2 changes: 1 addition & 1 deletion integration/requesting-a-prereview.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Status } from 'hyper-ts'
import { areLoggedIn, canLogIn, canRequestReviews, expect, test } from './base'
import { areLoggedIn, canLogIn, canRequestReviews, expect, test } from './base.js'

test.extend(canLogIn).extend(canRequestReviews)('can request a PREreview', async ({ fetch, page }) => {
await page.goto('/')
Expand Down
2 changes: 1 addition & 1 deletion integration/trainings.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from './base'
import { expect, test } from './base.js'

test('can read about trainings', async ({ fetch, page }) => {
await page.goto('/')
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
roots: ['./src/', './test/'],
testPathIgnorePatterns: ['./test/assets/'],
moduleFileExtensions: ['js', 'ts'],
moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1' },
transform: {
'^.+\\.ts$': [
'ts-jest',
Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"eslint-plugin-fp-ts": "^0.3.2",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-no-comments": "^1.1.10",
"eslint-plugin-require-extensions": "^0.1.3",
"eslint-plugin-wc": "^2.1.0",
"fetch-mock": "^9.11.0",
"fp-ts-contrib": "^0.1.29",
Expand Down
10 changes: 5 additions & 5 deletions src/about-us.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { format } from 'fp-ts-routing'
import * as RTE from 'fp-ts/ReaderTaskEither'
import { pipe } from 'fp-ts/function'
import { getPage } from './ghost'
import { type Html, fixHeadingLevels, html, plainText } from './html'
import { havingProblemsPage } from './http-error'
import { PageResponse } from './response'
import { aboutUsMatch } from './routes'
import { getPage } from './ghost.js'
import { type Html, fixHeadingLevels, html, plainText } from './html.js'
import { havingProblemsPage } from './http-error.js'
import { PageResponse } from './response.js'
import { aboutUsMatch } from './routes.js'

export const aboutUs = pipe(
getPage('6154aa157741400e8722bb14'),
Expand Down
34 changes: 17 additions & 17 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ import { getSession } from 'hyper-ts-session'
import * as RM from 'hyper-ts/ReaderMiddleware'
import { toRequestHandler } from 'hyper-ts/express'
import * as L from 'logger-fp-ts'
import * as l from 'logging-ts/lib/IO'
import * as l from 'logging-ts/lib/IO.js'
import { match, P as p } from 'ts-pattern'
import * as uuid from 'uuid-ts'
import { getPreprintFromCrossref, isCrossrefPreprintDoi } from './crossref'
import { getPreprintFromDatacite, isDatacitePreprintDoi } from './datacite'
import type { Email } from './email'
import { type SleepEnv, collapseRequests, logFetch, useStaleCache } from './fetch'
import { pageNotFound } from './http-error'
import { getUserOnboarding } from './keyv'
import { getPreprintIdFromLegacyPreviewUuid, getProfileIdFromLegacyPreviewUuid } from './legacy-prereview'
import { type LegacyEnv, legacyRoutes } from './legacy-routes'
import { type MailjetApiEnv, sendEmailWithMailjet } from './mailjet'
import { type NodemailerEnv, sendEmailWithNodemailer } from './nodemailer'
import { page } from './page'
import { getPreprintFromPhilsci } from './philsci'
import { handleResponse } from './response'
import { type RouterEnv, routes } from './router'
import type { IndeterminatePreprintId } from './types/preprint-id'
import { getUserFromSession, maybeGetUser } from './user'
import { getPreprintFromCrossref, isCrossrefPreprintDoi } from './crossref.js'
import { getPreprintFromDatacite, isDatacitePreprintDoi } from './datacite.js'
import type { Email } from './email.js'
import { type SleepEnv, collapseRequests, logFetch, useStaleCache } from './fetch.js'
import { pageNotFound } from './http-error.js'
import { getUserOnboarding } from './keyv.js'
import { getPreprintIdFromLegacyPreviewUuid, getProfileIdFromLegacyPreviewUuid } from './legacy-prereview.js'
import { type LegacyEnv, legacyRoutes } from './legacy-routes/index.js'
import { type MailjetApiEnv, sendEmailWithMailjet } from './mailjet.js'
import { type NodemailerEnv, sendEmailWithNodemailer } from './nodemailer.js'
import { page } from './page.js'
import { getPreprintFromPhilsci } from './philsci.js'
import { handleResponse } from './response.js'
import { type RouterEnv, routes } from './router.js'
import type { IndeterminatePreprintId } from './types/preprint-id.js'
import { getUserFromSession, maybeGetUser } from './user.js'

export type ConfigEnv = Omit<
RouterEnv & LegacyEnv,
Expand Down
12 changes: 6 additions & 6 deletions src/author-invite-flow/author-invite-published.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import { pipe } from 'fp-ts/function'
import type { LanguageCode } from 'iso-639-1'
import { P, match } from 'ts-pattern'
import type { Uuid } from 'uuid-ts'
import { type GetAuthorInviteEnv, getAuthorInvite } from '../author-invite'
import { type Html, html, plainText } from '../html'
import { havingProblemsPage, noPermissionPage, pageNotFound } from '../http-error'
import { LogInResponse, type PageResponse, RedirectResponse, StreamlinePageResponse } from '../response'
import { type GetAuthorInviteEnv, getAuthorInvite } from '../author-invite.js'
import { type Html, html, plainText } from '../html.js'
import { havingProblemsPage, noPermissionPage, pageNotFound } from '../http-error.js'
import { LogInResponse, type PageResponse, RedirectResponse, StreamlinePageResponse } from '../response.js'
import {
authorInviteCheckMatch,
authorInviteDeclineMatch,
authorInviteMatch,
authorInvitePublishedMatch,
reviewMatch,
} from '../routes'
import type { User } from '../user'
} from '../routes.js'
import type { User } from '../user.js'

export interface Prereview {
doi: Doi
Expand Down
Loading

0 comments on commit 294f1f7

Please sign in to comment.