Skip to content

Commit

Permalink
Update tsconfig (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
sz-piotr authored Apr 21, 2024
1 parent 0353b98 commit ae95d7e
Show file tree
Hide file tree
Showing 47 changed files with 85 additions and 78 deletions.
File renamed without changes.
3 changes: 1 addition & 2 deletions packages/earl/.mocharc.js → packages/earl/.mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ process.env.NODE_ENV = 'test'
module.exports = {
spec: 'src/**/*.test.ts',
file: 'src/test/setup.ts',
// require: 'ts-node/register/transpile-only',
'node-option': [
'experimental-specifier-resolution=node',
'loader=ts-node/esm/transpile-only',
'loader=ts-node/esm',
],
watchExtensions: ['js', 'ts'],
extension: ['js', 'ts'],
Expand Down
1 change: 1 addition & 0 deletions packages/earl/cjs-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "type": "commonjs" }
11 changes: 5 additions & 6 deletions packages/earl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
"bugs": {
"url": "https://github.com/l2beat/earl/issues"
},
"author": "Kris Kaczor <chris@kaczor.io>",
"author": "Piotr Szlachciak <szlachciak.piotr@gmail.com>",
"license": "MIT",
"version": "1.2.0",
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"exports": {
Expand All @@ -48,11 +49,9 @@
"lint:fix": "pnpm lint --fix",
"typecheck": "tsc --noEmit",
"clean": "rimraf dist",
"build": "pnpm clean && pnpm build:cjs && pnpm build:esm",
"build:cjs": "tsc -p ./tsconfig.cjs.json && cp static/package-cjs.json dist/cjs/package.json",
"build:esm": "tsc -p ./tsconfig.esm.json && cp static/package-esm.json dist/esm/package.json",
"build:watch": "pnpm clean && tsc -p ./tsconfig.prod.json --watch",
"build:watch:test": "pnpm clean && tsc -p ./tsconfig.json --watch",
"build": "pnpm run clean && pnpm run build:esm && pnpm run build:cjs",
"build:esm": "tsc -p tsconfig.esm.json",
"build:cjs": "tsc -p tsconfig.cjs.json && cp cjs-package.json dist/cjs/package.json",
"test": "mocha",
"test:fix": "pnpm lint:fix && pnpm format:fix && pnpm typecheck && pnpm test",
"release": "pnpm lint && pnpm format && pnpm typecheck && pnpm test && pnpm build"
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/FormatOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
DEFAULT_EQUALITY_OPTIONS,
EqualityOptions,
type EqualityOptions,
LOOSE_EQUALITY_OPTIONS,
} from '../isEqual/EqualityOptions.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect } from 'chai'

import { expect as earl } from '../index.js'
import { format } from './format.js'
import { FormatOptions } from './FormatOptions.js'
import type { FormatOptions } from './FormatOptions.js'

describe('format', () => {
const DEFAULTS: FormatOptions = {
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/formatArrayEntries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormatOptions } from './FormatOptions.js'
import type { FormatOptions } from './FormatOptions.js'
import { formatUnknown } from './formatUnknown.js'
import { getOptionsWith } from './getOptionsWith.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/formatCompact.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { format } from './format.js'
import { FormatOptions } from './FormatOptions.js'
import type { FormatOptions } from './FormatOptions.js'

const FORMAT_OPTIONS: FormatOptions = {
compareErrorStack: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/formatMapEntries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormatOptions } from './FormatOptions.js'
import type { FormatOptions } from './FormatOptions.js'
import { formatUnknown } from './formatUnknown.js'
import { getOptionsWith } from './getOptionsWith.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/formatNumber.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormatOptions } from './FormatOptions.js'
import type { FormatOptions } from './FormatOptions.js'
import { toLine } from './toLine.js'

export function formatNumber(
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/formatObjectEntries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormatOptions } from './FormatOptions.js'
import type { FormatOptions } from './FormatOptions.js'
import { formatUnknown } from './formatUnknown.js'
import { getOptionsWith } from './getOptionsWith.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/formatSetEntries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormatOptions } from './FormatOptions.js'
import type { FormatOptions } from './FormatOptions.js'
import { formatUnknown } from './formatUnknown.js'
import { getOptionsWith } from './getOptionsWith.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/formatString.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormatOptions } from './FormatOptions.js'
import type { FormatOptions } from './FormatOptions.js'

export function formatString(value: string, options: FormatOptions) {
if (options.inline && value.length > options.maxLineLength - 2) {
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/formatUnknown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { formatArrayEntries } from './formatArrayEntries.js'
import { formatMapEntries } from './formatMapEntries.js'
import { formatNumber } from './formatNumber.js'
import { formatObjectEntries } from './formatObjectEntries.js'
import { FormatOptions } from './FormatOptions.js'
import type { FormatOptions } from './FormatOptions.js'
import { formatSetEntries } from './formatSetEntries.js'
import { formatString } from './formatString.js'
import { formatSymbol } from './formatSymbol.js'
Expand Down
5 changes: 4 additions & 1 deletion packages/earl/src/format/getComparedTypeName.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { CanonicalType, getCanonicalType } from '../isEqual/getCanonicalType.js'
import {
type CanonicalType,
getCanonicalType,
} from '../isEqual/getCanonicalType.js'

export function getComparedTypeName(
value: unknown,
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/format/getOptionsWith.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormatOptions } from './FormatOptions.js'
import type { FormatOptions } from './FormatOptions.js'

export function getOptionsWith(
options: FormatOptions,
Expand Down
4 changes: 2 additions & 2 deletions packages/earl/src/format/getRepresentation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CanonicalType } from '../isEqual/getCanonicalType.js'
import { FormatOptions } from './FormatOptions.js'
import type { CanonicalType } from '../isEqual/getCanonicalType.js'
import type { FormatOptions } from './FormatOptions.js'
import { formatString } from './formatString.js'

export function getRepresentation(
Expand Down
4 changes: 2 additions & 2 deletions packages/earl/src/isEqual/getKeys.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EqualityOptions } from './EqualityOptions.js'
import { CanonicalType } from './getCanonicalType.js'
import type { EqualityOptions } from './EqualityOptions.js'
import type { CanonicalType } from './getCanonicalType.js'

export function getKeys(
value: object,
Expand Down
4 changes: 2 additions & 2 deletions packages/earl/src/isEqual/isEqual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/* eslint-disable no-new-wrappers */
import { expect } from 'chai'

import { format, FormatOptions } from '../format/index.js'
import { format, type FormatOptions } from '../format/index.js'
import { expect as earl } from '../index.js'
import { EqualityOptions } from './EqualityOptions.js'
import type { EqualityOptions } from './EqualityOptions.js'
import { isEqual } from './isEqual.js'

describe('isEqual', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/isEqual/isEqualMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EqualityOptions } from './EqualityOptions.js'
import type { EqualityOptions } from './EqualityOptions.js'
import { isEqualUnknown } from './isEqualUnknown.js'

export function isEqualMap(
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/isEqual/isEqualNumber.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EqualityOptions } from './EqualityOptions.js'
import type { EqualityOptions } from './EqualityOptions.js'

export function isEqualNumber(
value: number,
Expand Down
4 changes: 2 additions & 2 deletions packages/earl/src/isEqual/isEqualObject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EqualityOptions } from './EqualityOptions.js'
import { CanonicalType } from './getCanonicalType.js'
import type { EqualityOptions } from './EqualityOptions.js'
import type { CanonicalType } from './getCanonicalType.js'
import { getKeys } from './getKeys.js'
import { isEqualUnknown } from './isEqualUnknown.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/isEqual/isEqualUnknown.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Matcher } from '../expect.js'
import { EqualityOptions } from './EqualityOptions.js'
import type { EqualityOptions } from './EqualityOptions.js'
import { getCanonicalType } from './getCanonicalType.js'
import { isEqualMap } from './isEqualMap.js'
import { isEqualNumber } from './isEqualNumber.js'
Expand Down
4 changes: 2 additions & 2 deletions packages/earl/src/mocks/mockFn.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from 'chai'
import { AssertTrue, IsExact } from 'conditional-type-checks'
import type { AssertTrue, IsExact } from 'conditional-type-checks'

import { expect as earl } from '../expect.js'
import { mockFn } from './mockFn.js'
import { MockFunction, MockFunctionOf } from './types/index.js'
import type { MockFunction, MockFunctionOf } from './types/index.js'

const sum = (a: number, b: number) => a + b

Expand Down
7 changes: 6 additions & 1 deletion packages/earl/src/mocks/mockFn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { isEqual } from '../isEqual/index.js'
import { MockCall, MockFunction, MockFunctionOf, Spec } from './types/index.js'
import type {
MockCall,
MockFunction,
MockFunctionOf,
Spec,
} from './types/index.js'

interface Override {
args: any[]
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/mocks/mockObject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isMockFn, mockFn } from './mockFn.js'
import { MockFunctionOf } from './types/index.js'
import type { MockFunctionOf } from './types/index.js'

export type MockObject<T> = T & {
[P in keyof T]: T[P] extends (...args: any[]) => any
Expand Down
4 changes: 2 additions & 2 deletions packages/earl/src/mocks/types/MockFunction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MockGiven } from './MockGiven.js'
import { Awaited } from './util.js'
import type { MockGiven } from './MockGiven.js'
import type { Awaited } from './util.js'

export interface MockCall<TArgs, TReturn> {
args: TArgs
Expand Down
4 changes: 2 additions & 2 deletions packages/earl/src/mocks/types/MockGiven.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MockFunction } from './MockFunction.js'
import { Awaited } from './util.js'
import type { MockFunction } from './MockFunction.js'
import type { Awaited } from './util.js'

export interface MockGiven<
TArgs extends any[],
Expand Down
3 changes: 0 additions & 3 deletions packages/earl/src/package.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/earl/src/validators/basic/toBeA.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Control } from '../../Control.js'
import { registerValidator } from '../../expect.js'
import { formatCompact } from '../../format/index.js'
import { a, NewableOrPrimitive } from '../../matchers/basic/a.js'
import { a, type NewableOrPrimitive } from '../../matchers/basic/a.js'

declare module '../../expect.js' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/validators/custom/toMatchSchema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Control } from '../../Control.js'
import { registerValidator } from '../../expect.js'
import { formatCompact } from '../../format/index.js'
import { schema, ZodSchema } from '../../matchers/custom/schema.js'
import { schema, type ZodSchema } from '../../matchers/custom/schema.js'

declare module '../../expect.js' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/validators/mocks/toHaveBeenCalled.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Control } from '../../Control.js'
import { registerValidator } from '../../expect.js'
import { MockFunction } from '../../mocks/index.js'
import type { MockFunction } from '../../mocks/index.js'
import { assertIsMock, formatCalledTimes } from './utils.js'

declare module '../../expect.js' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Control } from '../../Control.js'
import { registerValidator } from '../../expect.js'
import { formatCompact } from '../../format/index.js'
import { MockFunction } from '../../mocks/index.js'
import type { MockFunction } from '../../mocks/index.js'
import { assertIsMock, formatCalledTimes, formatTimes } from './utils.js'

declare module '../../expect.js' {
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/validators/mocks/toHaveBeenCalledWith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Control } from '../../Control.js'
import { registerValidator } from '../../expect.js'
import { formatCompact } from '../../format/index.js'
import { isEqual } from '../../isEqual/index.js'
import { MockFunction, MockParameters } from '../../mocks/index.js'
import type { MockFunction, MockParameters } from '../../mocks/index.js'
import { assertIsMock } from './utils.js'

declare module '../../expect.js' {
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/validators/mocks/toHaveBeenExhausted.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Control } from '../../Control.js'
import { registerValidator } from '../../expect.js'
import { MockFunction } from '../../mocks/index.js'
import type { MockFunction } from '../../mocks/index.js'
import { assertIsMock } from './utils.js'

declare module '../../expect.js' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Control } from '../../Control.js'
import { registerValidator } from '../../expect.js'
import { MockFunction, MockParameters } from '../../mocks/index.js'
import type { MockFunction, MockParameters } from '../../mocks/index.js'
import { assertIsMock, compareArgs } from './utils.js'

declare module '../../expect.js' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Control } from '../../Control.js'
import { registerValidator } from '../../expect.js'
import { formatCompact } from '../../format/index.js'
import { MockFunction, MockParameters } from '../../mocks/index.js'
import type { MockFunction, MockParameters } from '../../mocks/index.js'
import {
assertIsMock,
compareArgs,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Control } from '../../Control.js'
import { registerValidator } from '../../expect.js'
import { MockFunction, MockParameters } from '../../mocks/index.js'
import type { MockFunction, MockParameters } from '../../mocks/index.js'
import { assertIsMock, compareArgs, formatCalledTimes } from './utils.js'

declare module '../../expect.js' {
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/validators/mocks/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Control } from '../../Control.js'
import { formatCompact } from '../../format/index.js'
import { isEqual } from '../../isEqual/index.js'
import { isMockFn, MockFunction } from '../../mocks/index.js'
import { isMockFn, type MockFunction } from '../../mocks/index.js'

export function assertIsMock(
control: Control,
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/validators/objects/toHaveSubset.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Control } from '../../Control.js'
import { registerValidator } from '../../expect.js'
import { formatCompact } from '../../format/index.js'
import { Subset, subset } from '../../matchers/objects/subset.js'
import { type Subset, subset } from '../../matchers/objects/subset.js'

declare module '../../expect.js' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
4 changes: 2 additions & 2 deletions packages/earl/src/validators/snapshots/getSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { readFileSync } from 'fs'
import path from 'path'

import { parseSnapshot } from './format.js'
import { SnapshotUpdateMode } from './getSnapshotUpdateMode.js'
import { TestContext } from './TestContext.js'
import type { SnapshotUpdateMode } from './getSnapshotUpdateMode.js'
import type { TestContext } from './TestContext.js'

const counters = new Map<string, Map<string, number>>()
const snapshots = new Map<string, Record<string, string>>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { format, formatCompact } from '../../format/index.js'
import { expect as earl } from '../../index.js'
import { formatSnapshot, parseSnapshot } from './format.js'
import { resetSnapshotCache } from './getSnapshot.js'
import { MochaTestContext } from './TestContext.js'
import type { MochaTestContext } from './TestContext.js'
import { toMatchSnapshot } from './toMatchSnapshot.js'

describe(toMatchSnapshot.name, () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/earl/src/validators/snapshots/toMatchSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { format, formatCompact } from '../../format/index.js'
import { formatSnapshot } from './format.js'
import { getSnapshot } from './getSnapshot.js'
import { getSnapshotUpdateMode } from './getSnapshotUpdateMode.js'
import { TestContext } from './TestContext.js'
import type { TestContext } from './TestContext.js'

declare module '../../expect.js' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
9 changes: 4 additions & 5 deletions packages/earl/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/cjs",
"rootDir": "./src",
"module": "CommonJS",
"moduleResolution": "node"
"moduleResolution": "Node",
"verbatimModuleSyntax": false,
"outDir": "dist/cjs"
},
"include": ["src"],
"exclude": ["src/test", "src/**/*.test.ts"]
"exclude": ["dist", "src/test", "src/**/*.test.ts"]
}
9 changes: 1 addition & 8 deletions packages/earl/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/esm",
"rootDir": "./src",
"lib": ["ES2020"],
"module": "ES2020"
},
"include": ["src"],
"exclude": ["src/test", "src/**/*.test.ts"]
"exclude": ["dist", "src/test", "src/**/*.test.ts"]
}
Loading

0 comments on commit ae95d7e

Please sign in to comment.