Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-gtValue
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller authored Feb 16, 2025
2 parents 8525b05 + 85f5f35 commit bf6f69f
Show file tree
Hide file tree
Showing 1,012 changed files with 23,942 additions and 6,675 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ backups
# Services
.vscode
.netlify
.vercel

# Others
logs
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
[email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reporting Security Issues

To report a vulnerability, please contact us via [email protected].
To report a vulnerability, please contact us via [email protected].

We recommend that you use the latest versions of the library to ensure that your application remains as secure as possible.
85 changes: 0 additions & 85 deletions library/.eslintrc.cjs

This file was deleted.

10 changes: 10 additions & 0 deletions library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,25 @@ All notable changes to the library will be documented in this file.
- Add `graphemes`, `maxGraphemes`, `minGraphemes` and `notGraphemes` action (pull request #853)
- Add `words`, `maxWords`, `minWords` and `notWords` action
- Add `args` and `returns` action to transform functions (issue #243)
- Add `rfcEmail` action to validate RFC 5322 email addresses (pull request #912)
- Add new overload signature to `pipe` and `pipeAync` method to support unlimited pipe items of same input and output type (issue #852)
- Add `@__NO_SIDE_EFFECTS__` notation to improve tree shaking (pull request #995)
- Add `exactOptional` and `exactOptionalAsync` schema (PR #1013)
- Change types and implementation to support Standard Schema
- Change behaviour of `minValue` and `maxValue` for `NaN` (pull request #843)
- Change type and behaviour of `nullable`, `nullableAsync`, `nullish`, `nullishAsync`, `optional`, `optionalAsync`, `undefinedable` and `undefinedableAsync` for undefined default value (issue #878)
- Change type signature of `partialCheck` and `partialCheckAsync` action to add `.pathList` property in a type-safe way
- Change type signature of `findItem` action to support type predicates (issue #867)
- Change validation of missing object entries in `looseObject`, `looseObjectAsync`, `object`, `objectAsync`, `objectWithRest`, `objectWithRestAsync`, `strictObject` and `strictObject` (PR #1013)
- Change type signature of `optional` and `optionalAsync` when used within an object schema (PR #1013)
- Change `MarkOptional` type to fix order of entries and TS error when using generic schemas (issue #1021)
- Change `VariantOption` and `VariantOptionAsync` type to fix TS error when using generic schemas (issue #842)
- Change implementation of `variant` and `variantAsync` to support optional discriminators using `exactOptional`, `exactOptionalAsync`, `optional`, `optionalAsync`, `nullish` or `nullishAsync`
- Refactor `bytes`, `maxBytes`, `minBytes` and `notBytes` action
- Fix implementation of `nonOptional`, `nonOptionalAsync`, `nonNullable`, `nonNullableAsync`, `nonNullish` and `nonNullishAsync` schema in edge cases (issue #909)
- Fix instantiation error for `any` in `PathKeys` type (issue #929)
- Fix TypeScript error of `keyof` method for objects with many keys (pull request #988)
- Fix options filtering in `enum_` schema (pull request #941)

## v0.42.1 (September 20, 2024)

Expand Down
102 changes: 102 additions & 0 deletions library/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import eslint from '@eslint/js';
import importPlugin from 'eslint-plugin-import';
import jsdoc from 'eslint-plugin-jsdoc';
import redosDetector from 'eslint-plugin-redos-detector';
import regexpPlugin from 'eslint-plugin-regexp';
import pluginSecurity from 'eslint-plugin-security';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.strict,
tseslint.configs.stylistic,
jsdoc.configs['flat/recommended'],
pluginSecurity.configs.recommended,
regexpPlugin.configs['flat/recommended'],
{
files: ['src/**/*.ts'],
extends: [importPlugin.flatConfigs.recommended],
plugins: { jsdoc, 'redos-detector': redosDetector },
rules: {
// Enable rules -----------------------------------------------------------

// TypeScript
'@typescript-eslint/consistent-type-definitions': 'error', // Enforce declaring types using `interface` keyword for better TS performance.
'@typescript-eslint/consistent-type-imports': 'warn',

// Import
'import/extensions': ['error', 'always'], // Require file extensions

// JSDoc
'jsdoc/tag-lines': ['error', 'any', { startLines: 1 }],
'jsdoc/sort-tags': [
'error',
{
linesBetween: 1,
tagSequence: [
{ tags: ['deprecated'] },
{ tags: ['param'] },
{ tags: ['returns'] },
],
},
],
// NOTE: For overloads functions, we only require a JSDoc at the top
// SEE: https://github.com/gajus/eslint-plugin-jsdoc/issues/666
'jsdoc/require-jsdoc': [
'error',
{
contexts: [
'ExportNamedDeclaration[declaration.type="TSDeclareFunction"]:not(ExportNamedDeclaration[declaration.type="TSDeclareFunction"] + ExportNamedDeclaration[declaration.type="TSDeclareFunction"])',
'ExportNamedDeclaration[declaration.type="FunctionDeclaration"]:not(ExportNamedDeclaration[declaration.type="TSDeclareFunction"] + ExportNamedDeclaration[declaration.type="FunctionDeclaration"])',
],
require: {
FunctionDeclaration: false,
},
},
],
'jsdoc/check-tag-names': [
'error',
{
definedTags: ['alpha', 'beta', '__NO_SIDE_EFFECTS__'],
},
],

// RegExp
'regexp/no-super-linear-move': 'error', // Prevent DoS regexps
'regexp/no-control-character': 'error', // Avoid unneeded regexps characters
'regexp/no-octal': 'error', // Avoid unneeded regexps characters
'regexp/no-standalone-backslash': 'error', // Avoid unneeded regexps characters
'regexp/prefer-escape-replacement-dollar-char': 'error', // Avoid unneeded regexps characters
'regexp/prefer-quantifier': 'error', // Avoid unneeded regexps characters
'regexp/hexadecimal-escape': ['error', 'always'], // Avoid unneeded regexps characters
'regexp/sort-alternatives': 'error', // Avoid unneeded regexps characters
'regexp/require-unicode-regexp': 'error', // /u flag is faster and enables regexp strict mode
'regexp/prefer-regexp-exec': 'error', // Enforce that RegExp#exec is used instead of String#match if no global flag is provided, as exec is faster

// Redos detector
'redos-detector/no-unsafe-regex': ['error', { ignoreError: true }], // Prevent DoS regexps

// Disable rules ----------------------------------------------------------

// TypeScript
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/no-inferrable-types': 'off',

// Imports
'no-duplicate-imports': 'off',

// JSDoc
'jsdoc/require-param-type': 'off',
'jsdoc/require-returns-type': 'off',

// RegExp
'regexp/use-ignore-case': 'off', // We sometimes don't use the i flag for a better JSON Schema compatibility

// Security
'security/detect-object-injection': 'off', // Too many false positives
'security/detect-unsafe-regex': 'off', // Too many false positives, see https://github.com/eslint-community/eslint-plugin-security/issues/28 - we use the redos-detector plugin instead
},
}
);
8 changes: 6 additions & 2 deletions library/jsr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"name": "@valibot/valibot",
"version": "1.0.0-beta.9",
"exports": "./src/index.ts"
"version": "1.0.0-rc.0",
"exports": "./src/index.ts",
"publish": {
"include": ["src/**/*.ts", "README.md"],
"exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts", "src/vitest/**/*.ts"]
}
}
31 changes: 15 additions & 16 deletions library/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "valibot",
"description": "The modular and type safe schema library for validating structural data",
"version": "1.0.0-beta.9",
"version": "1.0.0-rc.0",
"license": "MIT",
"author": "Fabian Hiller",
"homepage": "https://valibot.dev",
Expand Down Expand Up @@ -52,22 +52,21 @@
"build": "tsup"
},
"devDependencies": {
"@types/eslint": "^8.56.10",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"@vitest/coverage-v8": "^1.6.0",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.5.2",
"eslint-plugin-redos-detector": "^2.4.0",
"eslint-plugin-regexp": "^2.6.0",
"eslint-plugin-security": "^2.1.1",
"jsdom": "^24.1.0",
"@eslint/js": "^9.17.0",
"@vitest/coverage-v8": "^2.1.8",
"eslint": "^9.17.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsdoc": "^50.6.1",
"eslint-plugin-redos-detector": "^3.1.0",
"eslint-plugin-regexp": "^2.7.0",
"eslint-plugin-security": "^3.0.1",
"jsdom": "^25.0.1",
"tsm": "^2.3.0",
"tsup": "^8.1.0",
"typescript": "^5.5.3",
"vite": "^5.3.3",
"vitest": "1.6.0"
"tsup": "^8.3.5",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.2",
"vite": "^6.0.6",
"vitest": "2.1.8"
},
"peerDependencies": {
"typescript": ">=5"
Expand Down
1 change: 1 addition & 0 deletions library/src/actions/args/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function args<
TSchema extends Schema,
>(schema: TSchema): ArgsAction<TInput, TSchema>;

// @__NO_SIDE_EFFECTS__
export function args(
schema: Schema
): ArgsAction<(...args: unknown[]) => unknown, Schema> {
Expand Down
1 change: 1 addition & 0 deletions library/src/actions/args/argsAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export function argsAsync<
TSchema extends Schema,
>(schema: TSchema): ArgsActionAsync<TInput, TSchema>;

// @__NO_SIDE_EFFECTS__
export function argsAsync(
schema: Schema
): ArgsActionAsync<(...args: unknown[]) => unknown, Schema> {
Expand Down
3 changes: 2 additions & 1 deletion library/src/actions/await/awaitAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
} from '../../types/index.ts';

/**
* Await action async type.
* Await action async interface.
*/
export interface AwaitActionAsync<TInput extends Promise<unknown>>
extends BaseTransformationAsync<TInput, Awaited<TInput>, never> {
Expand All @@ -23,6 +23,7 @@ export interface AwaitActionAsync<TInput extends Promise<unknown>>
*
* @returns An await action.
*/
// @__NO_SIDE_EFFECTS__
export function awaitAsync<
TInput extends Promise<unknown>,
>(): AwaitActionAsync<TInput> {
Expand Down
5 changes: 3 additions & 2 deletions library/src/actions/base64/base64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
import { _addIssue } from '../../utils/index.ts';

/**
* Base64 issue type.
* Base64 issue interface.
*/
export interface Base64Issue<TInput extends string> extends BaseIssue<TInput> {
/**
Expand All @@ -33,7 +33,7 @@ export interface Base64Issue<TInput extends string> extends BaseIssue<TInput> {
}

/**
* Base64 action type.
* Base64 action interface.
*/
export interface Base64Action<
TInput extends string,
Expand Down Expand Up @@ -83,6 +83,7 @@ export function base64<
const TMessage extends ErrorMessage<Base64Issue<TInput>> | undefined,
>(message: TMessage): Base64Action<TInput, TMessage>;

// @__NO_SIDE_EFFECTS__
export function base64(
message?: ErrorMessage<Base64Issue<string>>
): Base64Action<string, ErrorMessage<Base64Issue<string>> | undefined> {
Expand Down
3 changes: 1 addition & 2 deletions library/src/actions/bic/bic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { BIC_REGEX } from '../../regex.ts';
import type { StringIssue } from '../../schemas/index.ts';
import { expectActionIssue } from '../../vitest/expectActionIssue.ts';
import { expectNoActionIssue } from '../../vitest/expectNoActionIssue.ts';
import type { BicIssue } from './bic.ts';
import { bic, type BicAction } from './bic.ts';
import { bic, type BicAction, type BicIssue } from './bic.ts';

describe('bic', () => {
describe('should return action object', () => {
Expand Down
5 changes: 3 additions & 2 deletions library/src/actions/bic/bic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
import { _addIssue } from '../../utils/index.ts';

/**
* BIC issue type.
* BIC issue interface.
*/
export interface BicIssue<TInput extends string> extends BaseIssue<TInput> {
/**
Expand All @@ -33,7 +33,7 @@ export interface BicIssue<TInput extends string> extends BaseIssue<TInput> {
}

/**
* BIC action type.
* BIC action interface.
*/
export interface BicAction<
TInput extends string,
Expand Down Expand Up @@ -80,6 +80,7 @@ export function bic<
const TMessage extends ErrorMessage<BicIssue<TInput>> | undefined,
>(message: TMessage): BicAction<TInput, TMessage>;

// @__NO_SIDE_EFFECTS__
export function bic(
message?: ErrorMessage<BicIssue<string>>
): BicAction<string, ErrorMessage<BicIssue<string>> | undefined> {
Expand Down
Loading

0 comments on commit bf6f69f

Please sign in to comment.