Skip to content

Commit

Permalink
Use full file paths in imports
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Oct 17, 2024
1 parent c143261 commit a10c4da
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/data/currencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import { Currency } from '../types';
import { Currency } from '../types/index.js';

/**
* An object that maps a 2 char country code to its official 3 char currency code.
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export {
resolveCurrencyFormat,
isNumberFormatSupported,
isNumberFormatToPartsSupported,
} from './lib/number-format';
} from './lib/number-format/index.js';
export {
formatDate,
formatTime,
Expand All @@ -31,5 +31,5 @@ export {
resolveDateTimeFormat,
isDateTimeFormatSupported,
isDateTimeFormatToPartsSupported,
} from './lib/date-time-format';
export { CURRENCIES } from './data/currencies';
} from './lib/date-time-format/index.js';
export { CURRENCIES } from './data/currencies.js';
6 changes: 3 additions & 3 deletions src/lib/date-time-format/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import type {
FormattableDateTime,
FormattableTime,
Locale,
} from '../../types';
import { DATE_STYLES, TIME_STYLES } from '../../data/date-time-styles';
} from '../../types/index.js';
import { DATE_STYLES, TIME_STYLES } from '../../data/date-time-styles.js';

import {
getDateTimeFormat,
isDateTimeFormatSupported,
isDateTimeFormatToPartsSupported,
isDateTimeStyleSupported,
} from './intl';
} from './intl.js';

export { isDateTimeFormatSupported, isDateTimeFormatToPartsSupported };

Expand Down
3 changes: 2 additions & 1 deletion src/lib/date-time-format/intl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { Intl as IntlWithTemporal } from 'temporal-polyfill';
import memoizeFormatConstructor from 'intl-format-cache';

import { Locale } from '../../types';
import { Locale } from '../../types/index.js';

/**
* Whether the `Intl` and `Intl.DateTimeFormat` APIs
Expand Down Expand Up @@ -61,6 +61,7 @@ export const isDateTimeStyleSupported = (() => {
}
})();

// @ts-expect-error intl-format-cache is bundled in a non-standard way.
export const getDateTimeFormat = memoizeFormatConstructor(
IntlWithTemporal.DateTimeFormat,
) as (
Expand Down
4 changes: 2 additions & 2 deletions src/lib/date-time-format/tests/format-to-parts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import { describe, it, expect } from 'vitest';
import { Intl } from 'temporal-polyfill';

import { formatDateTimeToParts } from '..';
import { formatDateTimeToParts } from '../index.js';

import { datetimes, locales } from './shared';
import { datetimes, locales } from './shared.js';

describe('Dates & times', () => {
describe('formatDateTimeToParts', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/date-time-format/tests/format.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import { describe, it, expect } from 'vitest';
import { Intl } from 'temporal-polyfill';

import { formatDateTime, formatDate, formatTime } from '..';
import { formatDateTime, formatDate, formatTime } from '../index.js';

import { locales, dates, times, datetimes } from './shared';
import { locales, dates, times, datetimes } from './shared.js';

describe('Dates & times', () => {
describe('formatDateTime', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/date-time-format/tests/resolve-format.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import { describe, it, expect } from 'vitest';
import { Intl } from 'temporal-polyfill';

import { resolveDateTimeFormat } from '..';
import { resolveDateTimeFormat } from '../index.js';

import { locales } from './shared';
import { locales } from './shared.js';

describe('Dates & times', () => {
describe('resolveDateTimeFormat', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/date-time-format/tests/unsupported-intl-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import {
formatDateTime,
formatDateTimeToParts,
resolveDateTimeFormat,
} from '..';
} from '../index.js';

import { dates, datetimes, times } from './shared';
import { dates, datetimes, times } from './shared.js';

vi.mock('../intl', async () => {
const intl = await vi.importActual('../intl');
Expand Down
4 changes: 2 additions & 2 deletions src/lib/date-time-format/tests/unsupported-styles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import { vi, describe, it, expect } from 'vitest';
import { Intl } from 'temporal-polyfill';

import { formatDateTime } from '..';
import { formatDateTime } from '../index.js';

import { dates, datetimes, times } from './shared';
import { dates, datetimes, times } from './shared.js';

vi.mock('../intl', async () => {
const intl = await vi.importActual('../intl');
Expand Down
9 changes: 6 additions & 3 deletions src/lib/number-format/currencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@

/* eslint-disable no-continue */

import type { Locale, Currency, NumericOptions } from '../../types';
import { CURRENCIES, CURRENCIES_WITHOUT_DECIMALS } from '../../data/currencies';
import type { Locale, Currency, NumericOptions } from '../../types/index.js';
import {
CURRENCIES,
CURRENCIES_WITHOUT_DECIMALS,
} from '../../data/currencies.js';

import { resolveLocale } from './intl';
import { resolveLocale } from './intl.js';

export function extractCountry(locale: string): string {
if (locale.length === 2) {
Expand Down
10 changes: 5 additions & 5 deletions src/lib/number-format/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ import type {
Locale,
NumberFormat,
NumericOptions,
} from '../../types';
import { findIndex } from '../find-index';
} from '../../types/index.js';
import { findIndex } from '../find-index.js';

import {
isNumberFormatSupported,
isNumberFormatToPartsSupported,
getNumberFormat,
} from './intl';
import { getNumberOptions } from './numbers';
import { getCurrencyOptions } from './currencies';
} from './intl.js';
import { getNumberOptions } from './numbers.js';
import { getCurrencyOptions } from './currencies.js';

export { isNumberFormatSupported, isNumberFormatToPartsSupported };

Expand Down
3 changes: 2 additions & 1 deletion src/lib/number-format/intl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import memoizeFormatConstructor from 'intl-format-cache';

import type { Locale } from '../../types';
import type { Locale } from '../../types/index.js';

/**
* Whether the `Intl` and `Intl.NumberFormat` APIs
Expand Down Expand Up @@ -44,6 +44,7 @@ export const isNumberFormatToPartsSupported = (() => {
}
})();

// @ts-expect-error intl-format-cache is bundled in a non-standard way.
export const getNumberFormat = memoizeFormatConstructor(Intl.NumberFormat) as (
locales?: Locale | Locale[],
options?: Intl.NumberFormatOptions,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/number-format/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import type { Locale } from '../../types';
import type { Locale } from '../../types/index.js';

export function getNumberOptions(
locales?: Locale | Locale[],
Expand Down
6 changes: 3 additions & 3 deletions src/lib/number-format/tests/format-to-parts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

import { describe, it, expect } from 'vitest';

import { formatNumberToParts, formatCurrencyToParts } from '..';
import { CURRENCIES_WITHOUT_DECIMALS } from '../../../data/currencies';
import { formatNumberToParts, formatCurrencyToParts } from '../index.js';
import { CURRENCIES_WITHOUT_DECIMALS } from '../../../data/currencies.js';

import { locales, number } from './shared';
import { locales, number } from './shared.js';

describe('Numbers', () => {
describe('formatNumberToParts', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/number-format/tests/format.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

import { describe, it, expect } from 'vitest';

import { formatNumber, formatCurrency } from '..';
import { CURRENCIES_WITHOUT_DECIMALS } from '../../../data/currencies';
import { formatNumber, formatCurrency } from '../index.js';
import { CURRENCIES_WITHOUT_DECIMALS } from '../../../data/currencies.js';

import { locales, number } from './shared';
import { locales, number } from './shared.js';

describe('Numbers', () => {
describe('formatNumber', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/number-format/tests/resolve-format.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

import { describe, it, expect } from 'vitest';

import { resolveNumberFormat, resolveCurrencyFormat } from '..';
import { CURRENCIES_WITHOUT_DECIMALS } from '../../../data/currencies';
import { resolveNumberFormat, resolveCurrencyFormat } from '../index.js';
import { CURRENCIES_WITHOUT_DECIMALS } from '../../../data/currencies.js';

import { locales } from './shared';
import { locales } from './shared.js';

describe('Numbers', () => {
describe('resolveNumberFormat', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/number-format/tests/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import { CURRENCIES } from '../../..';
import { CURRENCIES } from '../../../index.js';

export const locales: (string | string[])[] = [
...Object.keys(CURRENCIES),
Expand Down
4 changes: 2 additions & 2 deletions src/lib/number-format/tests/unsupported-intl-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import {
formatNumberToParts,
resolveCurrencyFormat,
resolveNumberFormat,
} from '..';
} from '../index.js';

import { number } from './shared';
import { number } from './shared.js';

vi.mock('../intl', async () => {
const intl = await vi.importActual('../intl');
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"compilerOptions": {
"target": "ES2017",
"module": "ES2020",
"module": "NodeNext",
"lib": ["es2020", "es2017", "es7", "es6", "dom"],
"declaration": true,
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"moduleResolution": "nodenext",
"resolveJsonModule": true,
"isolatedModules": true,
"outDir": "./dist"
Expand Down

0 comments on commit a10c4da

Please sign in to comment.