Skip to content

Commit

Permalink
Merge branch 'main' into fix-enum-schema-options
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller authored Jan 4, 2025
2 parents d169c78 + e72f2e4 commit bec7bdc
Show file tree
Hide file tree
Showing 473 changed files with 11,038 additions and 3,970 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.

2 changes: 2 additions & 0 deletions library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ 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)
- 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)
Expand Down
99 changes: 99 additions & 0 deletions library/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
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',

// 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.7",
"exports": "./src/index.ts"
"version": "1.0.0-beta.9",
"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.7",
"version": "1.0.0-beta.9",
"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
1 change: 1 addition & 0 deletions library/src/actions/await/awaitAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions library/src/actions/base64/base64.ts
Original file line number Diff line number Diff line change
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
1 change: 1 addition & 0 deletions library/src/actions/bic/bic.ts
Original file line number Diff line number Diff line change
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
1 change: 1 addition & 0 deletions library/src/actions/brand/brand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface BrandAction<TInput, TName extends BrandName>
*
* @returns A brand action.
*/
// @__NO_SIDE_EFFECTS__
export function brand<TInput, TName extends BrandName>(
name: TName
): BrandAction<TInput, TName> {
Expand Down
1 change: 1 addition & 0 deletions library/src/actions/bytes/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function bytes<
message: TMessage
): BytesAction<TInput, TRequirement, TMessage>;

// @__NO_SIDE_EFFECTS__
export function bytes(
requirement: number,
message?: ErrorMessage<BytesIssue<string, number>>
Expand Down
1 change: 1 addition & 0 deletions library/src/actions/check/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function check<
message: TMessage
): CheckAction<TInput, TMessage>;

// @__NO_SIDE_EFFECTS__
export function check(
requirement: (input: unknown) => boolean,
message?: ErrorMessage<CheckIssue<unknown>>
Expand Down
1 change: 1 addition & 0 deletions library/src/actions/check/checkAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function checkAsync<
message: TMessage
): CheckActionAsync<TInput, TMessage>;

// @__NO_SIDE_EFFECTS__
export function checkAsync(
requirement: (input: unknown) => MaybePromise<boolean>,
message?: ErrorMessage<CheckIssue<unknown>>
Expand Down
1 change: 1 addition & 0 deletions library/src/actions/checkItems/checkItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function checkItems<
message: TMessage
): CheckItemsAction<TInput, TMessage>;

// @__NO_SIDE_EFFECTS__
export function checkItems(
requirement: ArrayRequirement<unknown[]>,
message?: ErrorMessage<CheckItemsIssue<unknown[]>>
Expand Down
1 change: 1 addition & 0 deletions library/src/actions/checkItems/checkItemsAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function checkItemsAsync<
message: TMessage
): CheckItemsActionAsync<TInput, TMessage>;

// @__NO_SIDE_EFFECTS__
export function checkItemsAsync(
requirement: ArrayRequirementAsync<unknown[]>,
message?: ErrorMessage<CheckItemsIssue<unknown[]>>
Expand Down
2 changes: 2 additions & 0 deletions library/src/actions/creditCard/creditCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const PROVIDER_REGEX_LIST = [
// JCB
/^(?:2131|1800|35\d{3})\d{11}$/u,
// Mastercard
// eslint-disable-next-line redos-detector/no-unsafe-regex
/^5[1-5]\d{2}|(?:222\d|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}$/u,
// UnionPay
/^(?:6[27]\d{14,17}|81\d{14,17})$/u,
Expand Down Expand Up @@ -114,6 +115,7 @@ export function creditCard<
const TMessage extends ErrorMessage<CreditCardIssue<TInput>> | undefined,
>(message: TMessage): CreditCardAction<TInput, TMessage>;

// @__NO_SIDE_EFFECTS__
export function creditCard(
message?: ErrorMessage<CreditCardIssue<string>>
): CreditCardAction<string, ErrorMessage<CreditCardIssue<string>> | undefined> {
Expand Down
1 change: 1 addition & 0 deletions library/src/actions/cuid2/cuid2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export function cuid2<
const TMessage extends ErrorMessage<Cuid2Issue<TInput>> | undefined,
>(message: TMessage): Cuid2Action<TInput, TMessage>;

// @__NO_SIDE_EFFECTS__
export function cuid2(
message?: ErrorMessage<Cuid2Issue<string>>
): Cuid2Action<string, ErrorMessage<Cuid2Issue<string>> | undefined> {
Expand Down
Loading

0 comments on commit bec7bdc

Please sign in to comment.