Skip to content

Commit 4313916

Browse files
committed
style: format
1 parent 7407e60 commit 4313916

File tree

3 files changed

+55
-58
lines changed

3 files changed

+55
-58
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ A Vite plugin that validates your environment variables at **build** or **dev ti
1010

1111
## ✅ Features
1212

13-
* Validate environment variables **at build time only**, zero runtime overhead
14-
* Fully **type-safe**
15-
* Supports [standard-schema](https://github.com/standard-schema/standard-schema) — works with Zod, Valibot, ArkType, and more
16-
* Built-in parsing, validation, and transformation
17-
* Custom rules and error messages
13+
- Validate environment variables **at build time only**, zero runtime overhead
14+
- Fully **type-safe**
15+
- Supports [standard-schema](https://github.com/standard-schema/standard-schema) — works with Zod, Valibot, ArkType, and more
16+
- Built-in parsing, validation, and transformation
17+
- Custom rules and error messages
1818

1919
---
2020

@@ -43,8 +43,8 @@ export default defineConfig({
4343
ValidateEnv({
4444
validator: 'builtin',
4545
schema: {
46-
VITE_MY_VAR: Schema.string()
47-
}
46+
VITE_MY_VAR: Schema.string(),
47+
},
4848
}),
4949
],
5050
})
@@ -64,8 +64,8 @@ export default defineConfig({
6464
ValidateEnv({
6565
validator: 'standard', // 👈
6666
schema: {
67-
VITE_MY_VAR: z.string()
68-
}
67+
VITE_MY_VAR: z.string(),
68+
},
6969
}),
7070
],
7171
})
@@ -93,9 +93,7 @@ ValidateEnv({
9393
VITE_URL_SUFFIXED_WITH_SLASH: (key, value) => {
9494
if (!value) throw new Error(`Missing ${key}`)
9595

96-
return value.endsWith('/')
97-
? value
98-
: `${value}/`
96+
return value.endsWith('/') ? value : `${value}/`
9997
},
10098
})
10199
```
@@ -132,10 +130,12 @@ import { defineConfig } from 'vite'
132130
import { ValidateEnv } from '@julr/vite-plugin-validate-env'
133131

134132
export default defineConfig({
135-
plugins: [ValidateEnv({
136-
// Optional: you can specify a custom path for the config file
137-
configFile: 'config/env'
138-
})],
133+
plugins: [
134+
ValidateEnv({
135+
// Optional: you can specify a custom path for the config file
136+
configFile: 'config/env',
137+
}),
138+
],
139139
})
140140
```
141141

@@ -144,7 +144,7 @@ export default defineConfig({
144144
import { defineConfig, Schema } from '@julr/vite-plugin-validate-env'
145145

146146
export default defineConfig({
147-
validator: "builtin",
147+
validator: 'builtin',
148148
schema: {
149149
VITE_MY_VAR: Schema.enum(['foo', 'bar'] as const),
150150
},
@@ -184,22 +184,22 @@ In some cases, you might want to validate environment variables outside of Vite
184184
> `process.env` only accept string values, so don't be surprised if a `number` or `boolean` variable comes back as a string when accessing it after validation.
185185
186186
```ts
187-
import { loadAndValidateEnv } from '@julr/vite-plugin-validate-env';
187+
import { loadAndValidateEnv } from '@julr/vite-plugin-validate-env'
188188

189189
const env = await loadAndValidateEnv(
190190
{
191191
mode: 'development', // required
192192
root: import.meta.dirname, // optional
193193
},
194-
{
195-
// Plugin options. Also optional if you
194+
{
195+
// Plugin options. Also optional if you
196196
// are using a dedicated `env.ts` file
197197
validator: 'builtin',
198198
schema: { VITE_MY_VAR: Schema.string() },
199199
},
200-
);
200+
)
201201

202-
console.log(env.VITE_MY_VAR);
202+
console.log(env.VITE_MY_VAR)
203203
console.log(process.env.VITE_MY_VAR)
204204
```
205205

package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
11
{
22
"name": "@julr/vite-plugin-validate-env",
3-
"type": "module",
43
"version": "2.2.0",
5-
"packageManager": "pnpm@10.32.1",
64
"description": "✅ Vite plugin for validating your environment variables",
7-
"author": "Julien Ripouteau <julien@ripouteau.com>",
8-
"license": "MIT",
9-
"funding": "https://github.com/sponsors/Julien-R44",
10-
"homepage": "https://github.com/Julien-R44/vite-plugin-validate-env#readme",
11-
"repository": {
12-
"type": "git",
13-
"url": "git+https://github.com/Julien-R44/vite-plugin-validate-env.git"
14-
},
15-
"bugs": {
16-
"url": "https://github.com/Julien-R44/vite-plugin-validate-env/issues"
17-
},
185
"keywords": [
19-
"vite",
20-
"vite-plugin",
6+
"env",
217
"env-var",
228
"validation",
23-
"zod",
24-
"env"
9+
"vite",
10+
"vite-plugin",
11+
"zod"
2512
],
26-
"publishConfig": {
27-
"access": "public"
13+
"homepage": "https://github.com/Julien-R44/vite-plugin-validate-env#readme",
14+
"bugs": {
15+
"url": "https://github.com/Julien-R44/vite-plugin-validate-env/issues"
2816
},
29-
"main": "./dist/index.js",
17+
"license": "MIT",
18+
"author": "Julien Ripouteau <julien@ripouteau.com>",
19+
"repository": {
20+
"type": "git",
21+
"url": "git+https://github.com/Julien-R44/vite-plugin-validate-env.git"
22+
},
23+
"funding": "https://github.com/sponsors/Julien-R44",
3024
"files": [
3125
"dist"
3226
],
33-
"engines": {
34-
"node": ">=22"
27+
"type": "module",
28+
"main": "./dist/index.js",
29+
"publishConfig": {
30+
"access": "public"
3531
},
3632
"scripts": {
3733
"build": "tsdown",
@@ -48,9 +44,6 @@
4844
"typecheck": "tsc --noEmit",
4945
"checks": "pnpm lint:check && pnpm format:check && pnpm typecheck"
5046
},
51-
"peerDependencies": {
52-
"vite": "^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
53-
},
5447
"dependencies": {
5548
"@poppinss/cliui": "^6.7.0",
5649
"@poppinss/validator-lite": "^2.1.2",
@@ -75,5 +68,12 @@
7568
"valibot": "^1.2.0",
7669
"vite": "^8.0.0",
7770
"zod": "^3.25.76"
78-
}
71+
},
72+
"peerDependencies": {
73+
"vite": "^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
74+
},
75+
"engines": {
76+
"node": ">=22"
77+
},
78+
"packageManager": "pnpm@10.32.1"
7979
}

playground/index.html

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
3-
4-
<head>
5-
<meta charset="UTF-8" />
6-
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<title>Vite App</title>
9-
</head>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite App</title>
8+
</head>
109
<script type="module" src="/src/main.ts"></script>
11-
</body>
12-
1310
</html>

0 commit comments

Comments
 (0)