From 3fe2139a17959e8036231aa7991aab2f6c3fc889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C3=BCller?= Date: Thu, 20 Jun 2024 15:24:14 +0200 Subject: [PATCH] NodeNext Compat (#1224) * Add file extension to imports/exports This fixes compat with TypeScript's NodeNext module resolution. * Remove ESLint import plugins * 1.0.5-0 * Remove eslint-plugin-import package * Fixup prettier scripts and issues It seems like the prettier API has changed and it is no longer possible to combine --list-different and --write. --- package.json | 6 +++--- src/index.ts | 12 ++++++------ src/struct.ts | 4 ++-- src/structs/coercions.ts | 6 +++--- src/structs/refinements.ts | 4 ++-- src/structs/types.ts | 6 +++--- src/structs/utilities.ts | 11 ++++++++--- src/utils.ts | 4 ++-- 8 files changed, 29 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 45c9fa3f..9772ccbf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "superstruct", "description": "A simple and composable way to validate data in JavaScript (and TypeScript).", - "version": "1.0.4", + "version": "1.0.5-0", "license": "MIT", "repository": "git://github.com/ianstormtaylor/superstruct.git", "type": "module", @@ -49,10 +49,10 @@ "clean": "rm -rf ./{dist,node_modules}", "fix": "npm run fix:eslint && npm run fix:prettier", "fix:eslint": "npm run lint:eslint --fix", - "fix:prettier": "npm run lint:prettier --write", + "fix:prettier": "prettier '**/*.{js,json,ts}' --write", "lint": "npm run lint:eslint && npm run lint:prettier", "lint:eslint": "eslint '{src,test}/*.{js,ts}'", - "lint:prettier": "prettier --list-different '**/*.{js,json,ts}'", + "lint:prettier": "prettier '**/*.{js,json,ts}' --check", "release": "npm run build && npm run lint && np", "test": "npm run build && npm run test:types && npm run test:vitest", "test:types": "tsc --noEmit && tsc --project ./test/tsconfig.json --noEmit", diff --git a/src/index.ts b/src/index.ts index de84ece0..53baf221 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ -export * from './error' -export * from './struct' -export * from './structs/coercions' -export * from './structs/refinements' -export * from './structs/types' -export * from './structs/utilities' +export * from './error.js' +export * from './struct.js' +export * from './structs/coercions.js' +export * from './structs/refinements.js' +export * from './structs/types.js' +export * from './structs/utilities.js' diff --git a/src/struct.ts b/src/struct.ts index b482fd3b..9a5c37ec 100644 --- a/src/struct.ts +++ b/src/struct.ts @@ -1,5 +1,5 @@ -import { toFailures, shiftIterator, StructSchema, run } from './utils' -import { StructError, Failure } from './error' +import { toFailures, shiftIterator, StructSchema, run } from './utils.js' +import { StructError, Failure } from './error.js' /** * `Struct` objects encapsulate the validation logic for a specific type of diff --git a/src/structs/coercions.ts b/src/structs/coercions.ts index 6dca4ece..62566c50 100644 --- a/src/structs/coercions.ts +++ b/src/structs/coercions.ts @@ -1,6 +1,6 @@ -import { Struct, is, Coercer } from '../struct' -import { isPlainObject } from '../utils' -import { string, unknown } from './types' +import { Struct, is, Coercer } from '../struct.js' +import { isPlainObject } from '../utils.js' +import { string, unknown } from './types.js' /** * Augment a `Struct` to add an additional coercion step to its input. diff --git a/src/structs/refinements.ts b/src/structs/refinements.ts index a99621ee..f21001ee 100644 --- a/src/structs/refinements.ts +++ b/src/structs/refinements.ts @@ -1,5 +1,5 @@ -import { Struct, Refiner } from '../struct' -import { toFailures } from '../utils' +import { Struct, Refiner } from '../struct.js' +import { toFailures } from '../utils.js' /** * Ensure that a string, array, map, or set is empty. diff --git a/src/structs/types.ts b/src/structs/types.ts index 8bcc0ef3..19493104 100644 --- a/src/structs/types.ts +++ b/src/structs/types.ts @@ -1,5 +1,5 @@ -import { Infer, Struct } from '../struct' -import { define } from './utilities' +import { Infer, Struct } from '../struct.js' +import { define } from './utilities.js' import { ObjectSchema, ObjectType, @@ -9,7 +9,7 @@ import { AnyStruct, InferStructTuple, UnionToIntersection, -} from '../utils' +} from '../utils.js' /** * Ensure that any value passes validation. diff --git a/src/structs/utilities.ts b/src/structs/utilities.ts index 7b27da49..3720572d 100644 --- a/src/structs/utilities.ts +++ b/src/structs/utilities.ts @@ -1,6 +1,11 @@ -import { Context, Struct, Validator } from '../struct' -import { Assign, ObjectSchema, ObjectType, PartialObjectSchema } from '../utils' -import { object, optional, type } from './types' +import { Context, Struct, Validator } from '../struct.js' +import { + Assign, + ObjectSchema, + ObjectType, + PartialObjectSchema, +} from '../utils.js' +import { object, optional, type } from './types.js' /** * Create a new struct that combines the properties properties from multiple diff --git a/src/utils.ts b/src/utils.ts index c6a022e0..db69aea1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,5 @@ -import { Struct, Infer, Result, Context, Describe } from './struct' -import { Failure } from './error' +import { Struct, Infer, Result, Context, Describe } from './struct.js' +import { Failure } from './error.js' /** * Check if a value is an iterator.