Skip to content

Commit 8661538

Browse files
Merge branch 'main' into actions-everywhere
2 parents 274c950 + c28feda commit 8661538

File tree

219 files changed

+8590
-4035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+8590
-4035
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ backups
1515
# Services
1616
.vscode
1717
.netlify
18+
.vercel
1819

1920
# Others
2021
logs

CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ representative at an online or offline event.
6060

6161
Instances of abusive, harassing, or otherwise unacceptable behavior may be
6262
reported to the community leaders responsible for enforcement at
63-
63+
6464
All complaints will be reviewed and investigated promptly and fairly.
6565

6666
All community leaders are obligated to respect the privacy and security of the

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Reporting Security Issues
22

3-
To report a vulnerability, please contact us via [email protected].
3+
To report a vulnerability, please contact us via [email protected].
44

55
We recommend that you use the latest versions of the library to ensure that your application remains as secure as possible.

library/.eslintrc.cjs

-85
This file was deleted.

library/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ All notable changes to the library will be documented in this file.
99
- Add `graphemes`, `maxGraphemes`, `minGraphemes` and `notGraphemes` action (pull request #853)
1010
- Add `words`, `maxWords`, `minWords` and `notWords` action
1111
- Add `args` and `returns` action to transform functions (issue #243)
12+
- Add `rfcEmail` action to validate RFC 5322 email addresses (pull request #912)
1213
- Add new overload signature to `pipe` and `pipeAync` method to support unlimited pipe items of same input and output type (issue #852)
1314
- Add `@__NO_SIDE_EFFECTS__` notation to improve tree shaking (pull request #995)
1415
- Change types and implementation to support Standard Schema
@@ -19,6 +20,8 @@ All notable changes to the library will be documented in this file.
1920
- Refactor `bytes`, `maxBytes`, `minBytes` and `notBytes` action
2021
- Fix implementation of `nonOptional`, `nonOptionalAsync`, `nonNullable`, `nonNullableAsync`, `nonNullish` and `nonNullishAsync` schema in edge cases (issue #909)
2122
- Fix instantiation error for `any` in `PathKeys` type (issue #929)
23+
- Fix TypeScript error of `keyof` method for objects with many keys (pull request #988)
24+
- Fix options filtering in `enum_` schema (pull request #941)
2225

2326
## v0.42.1 (September 20, 2024)
2427

library/eslint.config.js

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import eslint from '@eslint/js';
2+
import importPlugin from 'eslint-plugin-import';
3+
import jsdoc from 'eslint-plugin-jsdoc';
4+
import redosDetector from 'eslint-plugin-redos-detector';
5+
import regexpPlugin from 'eslint-plugin-regexp';
6+
import pluginSecurity from 'eslint-plugin-security';
7+
import tseslint from 'typescript-eslint';
8+
9+
export default tseslint.config(
10+
eslint.configs.recommended,
11+
tseslint.configs.strict,
12+
tseslint.configs.stylistic,
13+
jsdoc.configs['flat/recommended'],
14+
pluginSecurity.configs.recommended,
15+
regexpPlugin.configs['flat/recommended'],
16+
{
17+
files: ['src/**/*.ts'],
18+
extends: [importPlugin.flatConfigs.recommended],
19+
plugins: { jsdoc, 'redos-detector': redosDetector },
20+
rules: {
21+
// Enable rules -----------------------------------------------------------
22+
23+
// TypeScript
24+
'@typescript-eslint/consistent-type-definitions': 'error', // Enforce declaring types using `interface` keyword for better TS performance.
25+
'@typescript-eslint/consistent-type-imports': 'warn',
26+
27+
// Import
28+
'import/extensions': ['error', 'always'], // Require file extensions
29+
30+
// JSDoc
31+
'jsdoc/tag-lines': ['error', 'any', { startLines: 1 }],
32+
'jsdoc/sort-tags': [
33+
'error',
34+
{
35+
linesBetween: 1,
36+
tagSequence: [
37+
{ tags: ['deprecated'] },
38+
{ tags: ['param'] },
39+
{ tags: ['returns'] },
40+
],
41+
},
42+
],
43+
// NOTE: For overloads functions, we only require a JSDoc at the top
44+
// SEE: https://github.com/gajus/eslint-plugin-jsdoc/issues/666
45+
'jsdoc/require-jsdoc': [
46+
'error',
47+
{
48+
contexts: [
49+
'ExportNamedDeclaration[declaration.type="TSDeclareFunction"]:not(ExportNamedDeclaration[declaration.type="TSDeclareFunction"] + ExportNamedDeclaration[declaration.type="TSDeclareFunction"])',
50+
'ExportNamedDeclaration[declaration.type="FunctionDeclaration"]:not(ExportNamedDeclaration[declaration.type="TSDeclareFunction"] + ExportNamedDeclaration[declaration.type="FunctionDeclaration"])',
51+
],
52+
require: {
53+
FunctionDeclaration: false,
54+
},
55+
},
56+
],
57+
'jsdoc/check-tag-names': [
58+
'error',
59+
{
60+
definedTags: ['alpha', 'beta', '__NO_SIDE_EFFECTS__'],
61+
},
62+
],
63+
64+
// Regexp
65+
'regexp/no-super-linear-move': 'error', // Prevent DoS regexps
66+
'regexp/no-control-character': 'error', // Avoid unneeded regexps characters
67+
'regexp/no-octal': 'error', // Avoid unneeded regexps characters
68+
'regexp/no-standalone-backslash': 'error', // Avoid unneeded regexps characters
69+
'regexp/prefer-escape-replacement-dollar-char': 'error', // Avoid unneeded regexps characters
70+
'regexp/prefer-quantifier': 'error', // Avoid unneeded regexps characters
71+
'regexp/hexadecimal-escape': ['error', 'always'], // Avoid unneeded regexps characters
72+
'regexp/sort-alternatives': 'error', // Avoid unneeded regexps characters
73+
'regexp/require-unicode-regexp': 'error', // /u flag is faster and enables regexp strict mode
74+
'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
75+
76+
// Redos detector
77+
'redos-detector/no-unsafe-regex': ['error', { ignoreError: true }], // Prevent DoS regexps
78+
79+
// Disable rules ----------------------------------------------------------
80+
81+
// TypeScript
82+
'@typescript-eslint/ban-ts-comment': 'off',
83+
'@typescript-eslint/no-non-null-assertion': 'off',
84+
'@typescript-eslint/consistent-indexed-object-style': 'off',
85+
'@typescript-eslint/no-inferrable-types': 'off',
86+
87+
// Imports
88+
'no-duplicate-imports': 'off',
89+
90+
// JSDoc
91+
'jsdoc/require-param-type': 'off',
92+
'jsdoc/require-returns-type': 'off',
93+
94+
// Security
95+
'security/detect-object-injection': 'off', // Too many false positives
96+
'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
97+
},
98+
}
99+
);

library/jsr.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@valibot/valibot",
3-
"version": "1.0.0-beta.9",
3+
"version": "1.0.0-beta.11",
44
"exports": "./src/index.ts",
55
"publish": {
66
"include": ["src/**/*.ts", "README.md"],

library/package.json

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "valibot",
33
"description": "The modular and type safe schema library for validating structural data",
4-
"version": "1.0.0-beta.9",
4+
"version": "1.0.0-beta.11",
55
"license": "MIT",
66
"author": "Fabian Hiller",
77
"homepage": "https://valibot.dev",
@@ -52,22 +52,21 @@
5252
"build": "tsup"
5353
},
5454
"devDependencies": {
55-
"@types/eslint": "^8.56.10",
56-
"@typescript-eslint/eslint-plugin": "^7.15.0",
57-
"@typescript-eslint/parser": "^7.15.0",
58-
"@vitest/coverage-v8": "^1.6.0",
59-
"eslint": "^8.57.0",
60-
"eslint-plugin-import": "^2.29.1",
61-
"eslint-plugin-jsdoc": "^48.5.2",
62-
"eslint-plugin-redos-detector": "^2.4.0",
63-
"eslint-plugin-regexp": "^2.6.0",
64-
"eslint-plugin-security": "^2.1.1",
65-
"jsdom": "^24.1.0",
55+
"@eslint/js": "^9.17.0",
56+
"@vitest/coverage-v8": "^2.1.8",
57+
"eslint": "^9.17.0",
58+
"eslint-plugin-import": "^2.31.0",
59+
"eslint-plugin-jsdoc": "^50.6.1",
60+
"eslint-plugin-redos-detector": "^3.1.0",
61+
"eslint-plugin-regexp": "^2.7.0",
62+
"eslint-plugin-security": "^3.0.1",
63+
"jsdom": "^25.0.1",
6664
"tsm": "^2.3.0",
67-
"tsup": "^8.1.0",
68-
"typescript": "^5.5.3",
69-
"vite": "^5.3.3",
70-
"vitest": "1.6.0"
65+
"tsup": "^8.3.5",
66+
"typescript": "^5.7.2",
67+
"typescript-eslint": "^8.18.2",
68+
"vite": "^6.0.6",
69+
"vitest": "2.1.8"
7170
},
7271
"peerDependencies": {
7372
"typescript": ">=5"

library/src/actions/bic/bic.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { BIC_REGEX } from '../../regex.ts';
33
import type { StringIssue } from '../../schemas/index.ts';
44
import { expectActionIssue } from '../../vitest/expectActionIssue.ts';
55
import { expectNoActionIssue } from '../../vitest/expectNoActionIssue.ts';
6-
import type { BicIssue } from './bic.ts';
7-
import { bic, type BicAction } from './bic.ts';
6+
import { bic, type BicAction, type BicIssue } from './bic.ts';
87

98
describe('bic', () => {
109
describe('should return action object', () => {

library/src/actions/creditCard/creditCard.ts

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const PROVIDER_REGEX_LIST = [
8585
// JCB
8686
/^(?:2131|1800|35\d{3})\d{11}$/u,
8787
// Mastercard
88+
// eslint-disable-next-line redos-detector/no-unsafe-regex
8889
/^5[1-5]\d{2}|(?:222\d|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}$/u,
8990
// UnionPay
9091
/^(?:6[27]\d{14,17}|81\d{14,17})$/u,

library/src/actions/email/email.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe('email', () => {
152152
expectNoActionIssue(action, ['[email protected]']);
153153
});
154154

155-
test('for subdomain and country code TDL', () => {
155+
test('for subdomain and country code TLD', () => {
156156
expectNoActionIssue(action, ['[email protected]']);
157157
});
158158

library/src/actions/email/email.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export interface EmailAction<
6767
*
6868
* Hint: This validation action intentionally only validates common email
6969
* addresses. If you are interested in an action that covers the entire
70-
* specification, please see issue [#204](https://github.com/fabian-hiller/valibot/issues/204).
70+
* specification, please use the `rfcEmail` action instead.
7171
*
7272
* @returns An email action.
7373
*/
@@ -79,7 +79,7 @@ export function email<TInput extends string>(): EmailAction<TInput, undefined>;
7979
*
8080
* Hint: This validation action intentionally only validates common email
8181
* addresses. If you are interested in an action that covers the entire
82-
* specification, please see issue [#204](https://github.com/fabian-hiller/valibot/issues/204).
82+
* specification, please use the `rfcEmail` action instead.
8383
*
8484
* @param message The error message.
8585
*

library/src/actions/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export * from './readonly/index.ts';
7373
export * from './reduceItems/index.ts';
7474
export * from './regex/index.ts';
7575
export * from './returns/index.ts';
76+
export * from './rfcEmail/index.ts';
7677
export * from './safeInteger/index.ts';
7778
export * from './size/index.ts';
7879
export * from './someItem/index.ts';

library/src/actions/partialCheck/partialCheck.test.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@ describe('partialCheck', () => {
9393
tuple: [number, { key: string }, number];
9494
other: string;
9595
};
96-
const pathList = [
97-
['nested', 'key'],
98-
['tuple', 1, 'key'],
99-
] as const;
100-
type PathList = typeof pathList;
96+
type PathList = [['nested', 'key'], ['tuple', 1, 'key']];
10197
type Selection = DeepPickN<Input, PathList>;
10298
const requirement = (input: Selection) =>
10399
input.nested.key === input.tuple[1].key;

library/src/actions/partialCheck/partialCheckAsync.test.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ describe('partialCheckAsync', () => {
106106
tuple: [number, { key: string }, number];
107107
other: string;
108108
};
109-
const pathList = [
110-
['nested', 'key'],
111-
['tuple', 1, 'key'],
112-
] as const;
113-
type PathList = typeof pathList;
109+
type PathList = [['nested', 'key'], ['tuple', 1, 'key']];
114110
type Selection = DeepPickN<Input, PathList>;
115111
const requirement = async (input: Selection) =>
116112
input.nested.key === input.tuple[1].key;

library/src/actions/rawCheck/rawCheck.test-d.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ import type { RawCheckIssue } from './types.ts';
55

66
describe('rawCheck', () => {
77
test('should return action object', () => {
8-
expectTypeOf(rawCheck<string>(() => {})).toEqualTypeOf<
9-
RawCheckAction<string>
10-
>();
8+
expectTypeOf(
9+
rawCheck<string>(
10+
// eslint-disable-next-line @typescript-eslint/no-empty-function
11+
() => {}
12+
)
13+
).toEqualTypeOf<RawCheckAction<string>>();
1114
});
1215

1316
describe('should infer correct types', () => {

library/src/actions/rawCheck/rawCheckAsync.test-d.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ import type { RawCheckIssue } from './types.ts';
55

66
describe('rawCheckAsync', () => {
77
test('should return action object', () => {
8-
expectTypeOf(rawCheckAsync<string>(async () => {})).toEqualTypeOf<
9-
RawCheckActionAsync<string>
10-
>();
8+
expectTypeOf(
9+
rawCheckAsync<string>(
10+
// eslint-disable-next-line @typescript-eslint/no-empty-function
11+
async () => {}
12+
)
13+
).toEqualTypeOf<RawCheckActionAsync<string>>();
1114
});
1215

1316
describe('should infer correct types', () => {

library/src/actions/rfcEmail/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './rfcEmail.ts';

0 commit comments

Comments
 (0)