@sanity/pkg-utils 6.4.1 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/consoleSpy.cjs +47 -12
- package/dist/_chunks-cjs/consoleSpy.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +108 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.js +47 -11
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/node/__snapshots__/strict.test.ts.snap +154 -0
- package/src/node/core/config/types.ts +7 -1
- package/src/node/core/pkg/parseExports.ts +36 -33
- package/src/node/index.ts +1 -0
- package/src/node/resolveBuildContext.ts +28 -8
- package/src/node/strict.test-d.ts +7 -0
- package/src/node/strict.ts +84 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"parse-git-config": "^3.0.0",
|
|
89
89
|
"pkg-up": "^3.1.0",
|
|
90
90
|
"prettier": "^3.2.5",
|
|
91
|
-
"prettier-plugin-packagejson": "^2.
|
|
91
|
+
"prettier-plugin-packagejson": "^2.5.0",
|
|
92
92
|
"pretty-bytes": "^5.6.0",
|
|
93
93
|
"prompts": "^2.4.2",
|
|
94
94
|
"rimraf": "^4.4.1",
|
|
@@ -97,7 +97,8 @@
|
|
|
97
97
|
"rxjs": "^7.8.1",
|
|
98
98
|
"treeify": "^1.1.0",
|
|
99
99
|
"uuid": "^9.0.1",
|
|
100
|
-
"zod": "
|
|
100
|
+
"zod": "3.22.4",
|
|
101
|
+
"zod-validation-error": "3.1.0"
|
|
101
102
|
},
|
|
102
103
|
"devDependencies": {
|
|
103
104
|
"@commitlint/cli": "^19.2.1",
|
|
@@ -133,9 +134,9 @@
|
|
|
133
134
|
"semver": "^7.6.0",
|
|
134
135
|
"ts-node": "^10.9.2",
|
|
135
136
|
"typescript": "5.4.5",
|
|
136
|
-
"vitest": "^1.
|
|
137
|
+
"vitest": "^1.5.0",
|
|
137
138
|
"vitest-github-actions-reporter": "^0.11.1",
|
|
138
|
-
"@sanity/pkg-utils": "6.
|
|
139
|
+
"@sanity/pkg-utils": "6.6.0"
|
|
139
140
|
},
|
|
140
141
|
"peerDependencies": {
|
|
141
142
|
"typescript": "5.4.x"
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`{'noPackageJsonTypings': 'error'}} 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"alwaysPackageJsonFiles": "error",
|
|
6
|
+
"alwaysPackageJsonMain": "error",
|
|
7
|
+
"alwaysPackageJsonTypes": "error",
|
|
8
|
+
"noImplicitBrowsersList": "warn",
|
|
9
|
+
"noImplicitSideEffects": "warn",
|
|
10
|
+
"noPackageJsonTypings": "error",
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
exports[`{'noPackageJsonTypings': 'off'}} 1`] = `
|
|
15
|
+
{
|
|
16
|
+
"alwaysPackageJsonFiles": "error",
|
|
17
|
+
"alwaysPackageJsonMain": "error",
|
|
18
|
+
"alwaysPackageJsonTypes": "error",
|
|
19
|
+
"noImplicitBrowsersList": "warn",
|
|
20
|
+
"noImplicitSideEffects": "warn",
|
|
21
|
+
"noPackageJsonTypings": "off",
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
exports[`{'noPackageJsonTypings': 'warn'}} 1`] = `
|
|
26
|
+
{
|
|
27
|
+
"alwaysPackageJsonFiles": "error",
|
|
28
|
+
"alwaysPackageJsonMain": "error",
|
|
29
|
+
"alwaysPackageJsonTypes": "error",
|
|
30
|
+
"noImplicitBrowsersList": "warn",
|
|
31
|
+
"noImplicitSideEffects": "warn",
|
|
32
|
+
"noPackageJsonTypings": "warn",
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
exports[`{'noPackageJsonTypings': false}} 1`] = `
|
|
37
|
+
[ZodError: [
|
|
38
|
+
{
|
|
39
|
+
"code": "invalid_union",
|
|
40
|
+
"unionErrors": [
|
|
41
|
+
{
|
|
42
|
+
"issues": [
|
|
43
|
+
{
|
|
44
|
+
"received": false,
|
|
45
|
+
"code": "invalid_literal",
|
|
46
|
+
"expected": "error",
|
|
47
|
+
"path": [
|
|
48
|
+
"strictOptions",
|
|
49
|
+
"noPackageJsonTypings"
|
|
50
|
+
],
|
|
51
|
+
"message": "Validation error: Invalid literal value, expected \\"error\\" at \\"strictOptions.noPackageJsonTypings\\""
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"name": "ZodError"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"issues": [
|
|
58
|
+
{
|
|
59
|
+
"received": false,
|
|
60
|
+
"code": "invalid_literal",
|
|
61
|
+
"expected": "warn",
|
|
62
|
+
"path": [
|
|
63
|
+
"strictOptions",
|
|
64
|
+
"noPackageJsonTypings"
|
|
65
|
+
],
|
|
66
|
+
"message": "Validation error: Invalid literal value, expected \\"warn\\" at \\"strictOptions.noPackageJsonTypings\\""
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"name": "ZodError"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"issues": [
|
|
73
|
+
{
|
|
74
|
+
"received": false,
|
|
75
|
+
"code": "invalid_literal",
|
|
76
|
+
"expected": "off",
|
|
77
|
+
"path": [
|
|
78
|
+
"strictOptions",
|
|
79
|
+
"noPackageJsonTypings"
|
|
80
|
+
],
|
|
81
|
+
"message": "Validation error: Invalid literal value, expected \\"off\\" at \\"strictOptions.noPackageJsonTypings\\""
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"name": "ZodError"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"path": [
|
|
88
|
+
"strictOptions",
|
|
89
|
+
"noPackageJsonTypings"
|
|
90
|
+
],
|
|
91
|
+
"message": "Validation error: Validation error: Invalid literal value, expected \\"error\\" at \\"strictOptions.noPackageJsonTypings\\" at \\"strictOptions.noPackageJsonTypings\\", or Validation error: Invalid literal value, expected \\"warn\\" at \\"strictOptions.noPackageJsonTypings\\" at \\"strictOptions.noPackageJsonTypings\\", or Validation error: Invalid literal value, expected \\"off\\" at \\"strictOptions.noPackageJsonTypings\\" at \\"strictOptions.noPackageJsonTypings\\""
|
|
92
|
+
}
|
|
93
|
+
]]
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
exports[`{'noPackageJsonTypings': true}} 1`] = `
|
|
97
|
+
[ZodError: [
|
|
98
|
+
{
|
|
99
|
+
"code": "invalid_union",
|
|
100
|
+
"unionErrors": [
|
|
101
|
+
{
|
|
102
|
+
"issues": [
|
|
103
|
+
{
|
|
104
|
+
"received": true,
|
|
105
|
+
"code": "invalid_literal",
|
|
106
|
+
"expected": "error",
|
|
107
|
+
"path": [
|
|
108
|
+
"strictOptions",
|
|
109
|
+
"noPackageJsonTypings"
|
|
110
|
+
],
|
|
111
|
+
"message": "Validation error: Invalid literal value, expected \\"error\\" at \\"strictOptions.noPackageJsonTypings\\""
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"name": "ZodError"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"issues": [
|
|
118
|
+
{
|
|
119
|
+
"received": true,
|
|
120
|
+
"code": "invalid_literal",
|
|
121
|
+
"expected": "warn",
|
|
122
|
+
"path": [
|
|
123
|
+
"strictOptions",
|
|
124
|
+
"noPackageJsonTypings"
|
|
125
|
+
],
|
|
126
|
+
"message": "Validation error: Invalid literal value, expected \\"warn\\" at \\"strictOptions.noPackageJsonTypings\\""
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"name": "ZodError"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"issues": [
|
|
133
|
+
{
|
|
134
|
+
"received": true,
|
|
135
|
+
"code": "invalid_literal",
|
|
136
|
+
"expected": "off",
|
|
137
|
+
"path": [
|
|
138
|
+
"strictOptions",
|
|
139
|
+
"noPackageJsonTypings"
|
|
140
|
+
],
|
|
141
|
+
"message": "Validation error: Invalid literal value, expected \\"off\\" at \\"strictOptions.noPackageJsonTypings\\""
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"name": "ZodError"
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
"path": [
|
|
148
|
+
"strictOptions",
|
|
149
|
+
"noPackageJsonTypings"
|
|
150
|
+
],
|
|
151
|
+
"message": "Validation error: Validation error: Invalid literal value, expected \\"error\\" at \\"strictOptions.noPackageJsonTypings\\" at \\"strictOptions.noPackageJsonTypings\\", or Validation error: Invalid literal value, expected \\"warn\\" at \\"strictOptions.noPackageJsonTypings\\" at \\"strictOptions.noPackageJsonTypings\\", or Validation error: Invalid literal value, expected \\"off\\" at \\"strictOptions.noPackageJsonTypings\\" at \\"strictOptions.noPackageJsonTypings\\""
|
|
152
|
+
}
|
|
153
|
+
]]
|
|
154
|
+
`;
|
|
@@ -2,8 +2,10 @@ import type {PluginItem as BabelPluginItem} from '@babel/core'
|
|
|
2
2
|
import type {OptimizeLodashOptions} from '@optimize-lodash/rollup-plugin'
|
|
3
3
|
import type {NormalizedOutputOptions, Plugin as RollupPlugin, TreeshakingOptions} from 'rollup'
|
|
4
4
|
|
|
5
|
+
import type {StrictOptions} from '../../strict'
|
|
6
|
+
|
|
5
7
|
// re-export
|
|
6
|
-
export type {RollupPlugin}
|
|
8
|
+
export type {RollupPlugin, StrictOptions}
|
|
7
9
|
|
|
8
10
|
/** @public */
|
|
9
11
|
export type PkgFormat = 'commonjs' | 'esm'
|
|
@@ -157,4 +159,8 @@ export interface PkgConfigOptions {
|
|
|
157
159
|
*/
|
|
158
160
|
src?: string
|
|
159
161
|
tsconfig?: string
|
|
162
|
+
/**
|
|
163
|
+
* Configure what checks are made when running `--strict` builds and checks
|
|
164
|
+
*/
|
|
165
|
+
strictOptions?: StrictOptions
|
|
160
166
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type {Logger} from '../../logger'
|
|
2
|
+
import type {InferredStrictOptions} from '../../strict'
|
|
1
3
|
import {defaultEnding, fileEnding, legacyEnding} from '../../tasks/dts/getTargetPaths'
|
|
2
4
|
import type {PkgExport} from '../config'
|
|
3
5
|
import {isRecord} from '../isRecord'
|
|
@@ -9,12 +11,33 @@ import {validateExports} from './validateExports'
|
|
|
9
11
|
export function parseExports(options: {
|
|
10
12
|
pkg: PackageJSON
|
|
11
13
|
strict: boolean
|
|
14
|
+
strictOptions: InferredStrictOptions
|
|
12
15
|
legacyExports: boolean
|
|
16
|
+
logger: Logger
|
|
13
17
|
}): (PkgExport & {_path: string})[] {
|
|
14
|
-
const {pkg, strict, legacyExports} = options
|
|
18
|
+
const {pkg, strict, strictOptions, legacyExports, logger} = options
|
|
15
19
|
const type = pkg.type || 'commonjs'
|
|
16
20
|
const errors: string[] = []
|
|
17
21
|
|
|
22
|
+
const report = (kind: 'warn' | 'error', message: string) => {
|
|
23
|
+
if (kind === 'warn') {
|
|
24
|
+
logger.warn(message)
|
|
25
|
+
} else {
|
|
26
|
+
errors.push(message)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!pkg.main && strict && strictOptions.alwaysPackageJsonMain !== 'off') {
|
|
31
|
+
report(strictOptions.alwaysPackageJsonMain, 'package.json: `main` must be declared')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!Array.isArray(pkg.files) && strict && strictOptions.alwaysPackageJsonFiles !== 'off') {
|
|
35
|
+
report(
|
|
36
|
+
strictOptions.alwaysPackageJsonFiles,
|
|
37
|
+
'package.json: `files` should be used over `.npmignore`',
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
18
41
|
if (pkg.source) {
|
|
19
42
|
if (
|
|
20
43
|
strict &&
|
|
@@ -113,44 +136,24 @@ export function parseExports(options: {
|
|
|
113
136
|
)
|
|
114
137
|
}
|
|
115
138
|
|
|
116
|
-
/*
|
|
117
|
-
const rootExports: PkgExport & {_path: string} = {
|
|
118
|
-
_exported: true,
|
|
119
|
-
_path: '.',
|
|
120
|
-
source: pkg.source || '',
|
|
121
|
-
browser: pkg.browser && {
|
|
122
|
-
source: pkg.source || '',
|
|
123
|
-
require: pkg.main && pkg.browser[pkg.main],
|
|
124
|
-
import: pkg.module && pkg.browser[pkg.module],
|
|
125
|
-
},
|
|
126
|
-
require: legacyExports
|
|
127
|
-
? pkg.main
|
|
128
|
-
: typeof pkg.exports?.['.'] === 'object' && 'require' in pkg.exports['.']
|
|
129
|
-
? pkg.exports['.'].require
|
|
130
|
-
: '',
|
|
131
|
-
import: legacyExports
|
|
132
|
-
? pkg.module
|
|
133
|
-
: typeof pkg.exports?.['.'] === 'object' && 'import' in pkg.exports['.']
|
|
134
|
-
? pkg.exports['.'].import
|
|
135
|
-
: '',
|
|
136
|
-
default: legacyExports
|
|
137
|
-
? pkg.module || pkg.main || ''
|
|
138
|
-
: typeof pkg.exports?.['.'] === 'object' && 'default' in pkg.exports['.']
|
|
139
|
-
? pkg.exports['.'].default || ''
|
|
140
|
-
: pkg.module || pkg.main || '',
|
|
141
|
-
}
|
|
142
|
-
// */
|
|
143
|
-
|
|
144
139
|
const _exports: (PkgExport & {_path: string})[] = []
|
|
145
140
|
|
|
146
141
|
// @TODO validate typesVersions when legacyExports is true
|
|
147
142
|
|
|
148
|
-
if (strict && 'typings' in pkg) {
|
|
149
|
-
|
|
143
|
+
if (strict && strictOptions.noPackageJsonTypings !== 'off' && 'typings' in pkg) {
|
|
144
|
+
report(strictOptions.noPackageJsonTypings, 'package.json: `typings` should be `types`')
|
|
150
145
|
}
|
|
151
146
|
|
|
152
|
-
if (
|
|
153
|
-
|
|
147
|
+
if (
|
|
148
|
+
strict &&
|
|
149
|
+
strictOptions.alwaysPackageJsonTypes !== 'off' &&
|
|
150
|
+
!pkg.types &&
|
|
151
|
+
typeof pkg.exports?.['.'] === 'object' &&
|
|
152
|
+
'source' in pkg.exports['.'] &&
|
|
153
|
+
pkg.exports['.'].source?.endsWith('.ts')
|
|
154
|
+
) {
|
|
155
|
+
report(
|
|
156
|
+
strictOptions.alwaysPackageJsonTypes,
|
|
154
157
|
'package.json: `types` must be declared for the npm listing to show as a TypeScript module.',
|
|
155
158
|
)
|
|
156
159
|
}
|
package/src/node/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {findCommonDirPath, pathContains} from './core/findCommonPath'
|
|
|
17
17
|
import type {Logger} from './logger'
|
|
18
18
|
import {resolveBrowserTarget} from './resolveBrowserTarget'
|
|
19
19
|
import {resolveNodeTarget} from './resolveNodeTarget'
|
|
20
|
+
import {parseStrictOptions} from './strict'
|
|
20
21
|
|
|
21
22
|
export async function resolveBuildContext(options: {
|
|
22
23
|
config?: PkgConfigOptions
|
|
@@ -37,24 +38,41 @@ export async function resolveBuildContext(options: {
|
|
|
37
38
|
tsconfig: tsconfigPath,
|
|
38
39
|
} = options
|
|
39
40
|
const tsconfig = await loadTSConfig({cwd, tsconfigPath})
|
|
41
|
+
const strictOptions = parseStrictOptions(config?.strictOptions ?? {})
|
|
40
42
|
|
|
41
43
|
/* eslint-disable padding-line-between-statements */
|
|
42
44
|
let browserslist = pkg.browserslist
|
|
43
45
|
if (!browserslist) {
|
|
44
|
-
if (strict) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if (strict && strictOptions.noImplicitBrowsersList !== 'off') {
|
|
47
|
+
if (strictOptions.noImplicitBrowsersList === 'error') {
|
|
48
|
+
throw new Error(
|
|
49
|
+
'\n- ' +
|
|
50
|
+
`package.json: "browserslist" is missing, set it to \`"browserslist": "extends @sanity/browserslist-config"\``,
|
|
51
|
+
)
|
|
52
|
+
} else {
|
|
53
|
+
logger.warn(
|
|
54
|
+
'Could not detect a `browserslist` property in `package.json`, using default configuration. Add `"browserslist": "extends @sanity/browserslist-config"` to silence this warning.',
|
|
55
|
+
)
|
|
56
|
+
}
|
|
48
57
|
}
|
|
49
58
|
browserslist = DEFAULT_BROWSERSLIST_QUERY
|
|
50
59
|
}
|
|
51
60
|
const targetVersions = browserslistToEsbuild(browserslist)
|
|
52
61
|
/* eslint-enable padding-line-between-statements */
|
|
53
62
|
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
if (
|
|
64
|
+
strict &&
|
|
65
|
+
strictOptions.noImplicitSideEffects !== 'off' &&
|
|
66
|
+
typeof pkg.sideEffects === 'undefined'
|
|
67
|
+
) {
|
|
68
|
+
const msg =
|
|
69
|
+
'package.json: `sideEffects` is missing, see https://webpack.js.org/guides/tree-shaking/#clarifying-tree-shaking-and-sideeffects for how to define `sideEffects`'
|
|
70
|
+
|
|
71
|
+
if (strictOptions.noImplicitSideEffects === 'error') {
|
|
72
|
+
throw new Error(msg)
|
|
73
|
+
} else {
|
|
74
|
+
logger.warn(msg)
|
|
75
|
+
}
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
const nodeTarget = resolveNodeTarget(targetVersions)
|
|
@@ -78,6 +96,8 @@ export async function resolveBuildContext(options: {
|
|
|
78
96
|
pkg,
|
|
79
97
|
strict,
|
|
80
98
|
legacyExports: config?.legacyExports ?? false,
|
|
99
|
+
strictOptions,
|
|
100
|
+
logger,
|
|
81
101
|
}).reduce<PkgExports>((acc, x) => {
|
|
82
102
|
const {_path: exportPath, ...exportEntry} = x
|
|
83
103
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {z} from 'zod'
|
|
2
|
+
import {errorMap} from 'zod-validation-error'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export const toggle = z.union([z.literal('error'), z.literal('warn'), z.literal('off')])
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export type ToggleType = z.infer<typeof toggle>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export const strictOptions = z
|
|
18
|
+
.object({
|
|
19
|
+
noPackageJsonTypings: toggle.default('error'),
|
|
20
|
+
noImplicitSideEffects: toggle.default('warn'),
|
|
21
|
+
noImplicitBrowsersList: toggle.default('warn'),
|
|
22
|
+
alwaysPackageJsonTypes: toggle.default('error'),
|
|
23
|
+
alwaysPackageJsonMain: toggle.default('error'),
|
|
24
|
+
alwaysPackageJsonFiles: toggle.default('error'),
|
|
25
|
+
})
|
|
26
|
+
.strict()
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* To make error message paths line up with the paths in package.config.ts the schema is hoisted into a root schema
|
|
30
|
+
* This way errors will say `Expected boolean, received string at "strict.noPackageJsonTypings"` instead of `Expected boolean, received string at "noPackageJsonTypings"`.
|
|
31
|
+
*/
|
|
32
|
+
const validationSchema = z.object({
|
|
33
|
+
strictOptions: strictOptions.default({}),
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export type InferredStrictOptions = z.infer<typeof strictOptions>
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export interface StrictOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Disallows a top level `typings` field in `package.json` if it is equal to `exports['.'].source`.
|
|
47
|
+
* @defaultValue 'error'
|
|
48
|
+
*/
|
|
49
|
+
noPackageJsonTypings?: ToggleType
|
|
50
|
+
/**
|
|
51
|
+
* Requires specifying `sideEffects` in `package.json`.
|
|
52
|
+
* @defaultValue 'warn'
|
|
53
|
+
*/
|
|
54
|
+
noImplicitSideEffects?: ToggleType
|
|
55
|
+
/**
|
|
56
|
+
* Requires specifying `browserslist` in `package.json`, instead of relying on it implicitly being:
|
|
57
|
+
* @example
|
|
58
|
+
* ```
|
|
59
|
+
* "browserslist": "extends @sanity/browserslist-config"
|
|
60
|
+
* ```
|
|
61
|
+
* @defaultValue 'warn'
|
|
62
|
+
*/
|
|
63
|
+
noImplicitBrowsersList?: ToggleType
|
|
64
|
+
/**
|
|
65
|
+
* If typescript is used then `types` in `package.json` should be specified for npm listings to show the TS icon.
|
|
66
|
+
* @defaultValue 'error'
|
|
67
|
+
*/
|
|
68
|
+
alwaysPackageJsonTypes?: ToggleType
|
|
69
|
+
/**
|
|
70
|
+
* A lot of analysis tooling requiers the `main` field to work (like bundlephobia) and so it's best practice to always include it
|
|
71
|
+
* @defaultValue 'error'
|
|
72
|
+
*/
|
|
73
|
+
alwaysPackageJsonMain?: ToggleType
|
|
74
|
+
/**
|
|
75
|
+
* Using `.npmignore` is error prone, it's best practice to always declare `files` instead
|
|
76
|
+
* @defaultValue 'error'
|
|
77
|
+
*/
|
|
78
|
+
alwaysPackageJsonFiles?: ToggleType
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** @internal */
|
|
82
|
+
export function parseStrictOptions(input: unknown): InferredStrictOptions {
|
|
83
|
+
return validationSchema.parse({strictOptions: input}, {errorMap}).strictOptions
|
|
84
|
+
}
|