@sanity/plugin-kit 8.0.1 → 9.0.1
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/README.md +8 -63
- package/dist/constants-BIVJp2Jy.js +7 -0
- package/dist/constants-BIVJp2Jy.js.map +1 -0
- package/dist/index.js +9 -16
- package/dist/index.js.map +1 -1
- package/dist/{init-Du_rQVkw.js → init-7tPgEM_5.js} +6 -8
- package/dist/init-7tPgEM_5.js.map +1 -0
- package/dist/{inject-_X7Is81B.js → inject-DCHoqs0d.js} +5 -6
- package/dist/inject-DCHoqs0d.js.map +1 -0
- package/dist/{link-watch-L1kA3AR0.js → link-watch-bvv8kQCJ.js} +4 -4
- package/dist/{link-watch-L1kA3AR0.js.map → link-watch-bvv8kQCJ.js.map} +1 -1
- package/dist/oxlint.js +8 -0
- package/dist/oxlint.js.map +1 -1
- package/dist/{package-B_o7MhuL.js → package-Cx3OyOx-.js} +20 -380
- package/dist/package-Cx3OyOx-.js.map +1 -0
- package/dist/package-DcGaUtE-.js +4 -0
- package/dist/package-DcGaUtE-.js.map +1 -0
- package/dist/{init-pYTOs-Fv.js → studio-detect-CuoRHDQA.js} +24 -7
- package/dist/studio-detect-CuoRHDQA.js.map +1 -0
- package/dist/{verify-package-Dala-0lE.js → verify-package-fNlJK-qr.js} +41 -14
- package/dist/verify-package-fNlJK-qr.js.map +1 -0
- package/dist/{version-COtAw8Ls.js → version-B37Jvdal.js} +2 -2
- package/dist/{version-COtAw8Ls.js.map → version-B37Jvdal.js.map} +1 -1
- package/package.json +7 -9
- package/dist/constants-BLTUL_Wd.js +0 -11
- package/dist/constants-BLTUL_Wd.js.map +0 -1
- package/dist/init-Du_rQVkw.js.map +0 -1
- package/dist/init-pYTOs-Fv.js.map +0 -1
- package/dist/inject-_X7Is81B.js.map +0 -1
- package/dist/package-B_o7MhuL.js.map +0 -1
- package/dist/package-CXmMmZoh.js +0 -4
- package/dist/package-CXmMmZoh.js.map +0 -1
- package/dist/verify-common-CzG3zw3J.js +0 -39
- package/dist/verify-common-CzG3zw3J.js.map +0 -1
- package/dist/verify-package-Dala-0lE.js.map +0 -1
- package/dist/verify-studio-Cg8aSAky.js +0 -61
- package/dist/verify-studio-Cg8aSAky.js.map +0 -1
package/README.md
CHANGED
|
@@ -12,16 +12,10 @@ npx @sanity/plugin-kit@latest init my-sanity-plugin
|
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
|
-
# Verify your plugin package
|
|
16
|
-
# This command can also be used when upgrading plugins from Sanity Studio v2 → v3.
|
|
15
|
+
# Verify your plugin package
|
|
17
16
|
npx @sanity/plugin-kit@latest verify-package
|
|
18
17
|
```
|
|
19
18
|
|
|
20
|
-
```sh
|
|
21
|
-
# Get help upgrading from Sanity Studio v2 → v3.
|
|
22
|
-
npx @sanity/plugin-kit@latest verify-studio
|
|
23
|
-
```
|
|
24
|
-
|
|
25
19
|
`@sanity/plugin-kit` assumes and recommends [`@sanity/pkg-utils`](https://github.com/sanity-io/pkg-utils#sanitypkg-utils) for building,
|
|
26
20
|
and [Yalc](https://github.com/wclr/yalc) with watch for testing the plugin in Sanity Studio.
|
|
27
21
|
Check the [FAQ](#faq) fro more on these.
|
|
@@ -33,11 +27,8 @@ Check the [FAQ](#faq) fro more on these.
|
|
|
33
27
|
- [Formatting with oxfmt](#formatting-with-oxfmt)
|
|
34
28
|
- [Linting with oxlint](#linting-with-oxlint)
|
|
35
29
|
- [Verify plugin package](#verify-plugin-package)
|
|
36
|
-
|
|
37
|
-
- [Upgrade help in v2 Studio](#upgrade-help-in-v2-studio)
|
|
38
|
-
- [Inject config into existing v3 plugin](#inject-config-into-existing-package)
|
|
30
|
+
- [Inject config into existing package](#inject-config-into-existing-package)
|
|
39
31
|
- [Testing a plugin in Sanity Studio](#testing-a-plugin-in-sanity-studio)
|
|
40
|
-
- [Upgrading from plugin-kit 1.x](#upgrade-from-v1x-to-v2)
|
|
41
32
|
- [FAQ](#faq) aka "Do I _have_ to use this plugin-kit?" aka No
|
|
42
33
|
- [Configuration reference](#configuration-reference)
|
|
43
34
|
- [Developing plugin-kit](#develop-plugin-kit)
|
|
@@ -204,16 +195,13 @@ Verify that the plugin package is configured correctly by running:
|
|
|
204
195
|
- Check package.json for:
|
|
205
196
|
- recommended script commands
|
|
206
197
|
- ESM-only configuration (bans CJS `main`/`module` fields and `require` export conditions)
|
|
207
|
-
- sanity
|
|
208
|
-
-
|
|
209
|
-
-
|
|
210
|
-
- Check for redundant
|
|
211
|
-
- babel
|
|
212
|
-
- the deprecated `@sanity/incompatible-plugin` v2 compatibility shim (`sanity.json` + `v2-incompatible.js`)
|
|
198
|
+
- @sanity/pkg-utils devDependency (and required major version)
|
|
199
|
+
- recommended `engines.node`
|
|
200
|
+
- no publishing of `src` via the `files` array
|
|
201
|
+
- Check for redundant legacy tooling config (for example Babel) and deprecated build tools
|
|
213
202
|
- Check that the plugin is formatted with oxfmt using the shared `@sanity/plugin-kit/oxfmt` preset (and that no legacy prettier config remains)
|
|
214
203
|
- Check that the plugin lints with oxlint using the shared `@sanity/plugin-kit/oxlint` config (and that no legacy eslint config remains)
|
|
215
204
|
- Check tsconfig.json settings
|
|
216
|
-
- Check for [SPDX](https://spdx.org/licenses/) compatible license definition
|
|
217
205
|
|
|
218
206
|
Each check will explain why it is needed, steps to fix it and how it can be individually disabled.
|
|
219
207
|
|
|
@@ -221,40 +209,13 @@ Each check will explain why it is needed, steps to fix it and how it can be indi
|
|
|
221
209
|
|
|
222
210
|
`verify-package` is _not_ a codemod tool. It will only check files and recommended settings: it will not change any files.
|
|
223
211
|
|
|
224
|
-
Consider using `npx @sanity/plugin-kit@latest inject` if you want to add recommended
|
|
212
|
+
Consider using `npx @sanity/plugin-kit@latest inject` if you want to add recommended plugin configuration automatically.
|
|
225
213
|
See the [Inject docs](#inject-config-into-existing-package) for more on this.
|
|
226
214
|
|
|
227
|
-
### Upgrading a v2 plugin
|
|
228
|
-
|
|
229
|
-
Simply use the `verify-package` command in a v2 plugin package, and it will notify you about steps you need to take to upgrade the
|
|
230
|
-
plugin to v3.
|
|
231
|
-
|
|
232
|
-
```sh
|
|
233
|
-
npx @sanity/plugin-kit@latest verify-package
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
## Upgrade help in V2 Studio
|
|
237
|
-
|
|
238
|
-
You can use the `verify-studio` command in a v2 Sanity Studio to get some of the same validation there, to help in the upgrade from v2
|
|
239
|
-
to v3.
|
|
240
|
-
|
|
241
|
-
```sh
|
|
242
|
-
npx @sanity/plugin-kit@latest verify-studio
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
This will:
|
|
246
|
-
|
|
247
|
-
- Check for `sanity.json,` `sanity.config.(ts|js)` and `sanity.cli.(ts|js)` and advice on how to convert the former to the latter two.
|
|
248
|
-
- Check for sanity dependencies that has changed in v3
|
|
249
|
-
|
|
250
215
|
### Fail fast mode
|
|
251
216
|
|
|
252
217
|
```sh
|
|
253
|
-
## for plugins
|
|
254
218
|
npx @sanity/plugin-kit@latest verify-package --single
|
|
255
|
-
|
|
256
|
-
## for studio
|
|
257
|
-
npx @sanity/plugin-kit@latest verify-package --studio --single
|
|
258
219
|
```
|
|
259
220
|
|
|
260
221
|
This will only output the first validation that fails. Useful when working through the list of issues by fixing and rerunning the command.
|
|
@@ -265,7 +226,7 @@ This will only output the first validation that fails. Useful when working throu
|
|
|
265
226
|
npx @sanity/plugin-kit@latest inject
|
|
266
227
|
```
|
|
267
228
|
|
|
268
|
-
will inject recommended
|
|
229
|
+
will inject recommended plugin package boilerplate into an existing plugin.
|
|
269
230
|
Be sure to commit any local changes before running this command, so you can easily revert anything
|
|
270
231
|
you dont want.
|
|
271
232
|
|
|
@@ -371,19 +332,6 @@ If you have not published any modules to npm before, you will be asked to create
|
|
|
371
332
|
|
|
372
333
|
For an opinionated template for publication based on semantic-release, see [semver-workflow preset](docs/semver-workflow.md)
|
|
373
334
|
|
|
374
|
-
### Upgrade from v1.x to v2
|
|
375
|
-
|
|
376
|
-
To upgrade a plugin that already uses `@sanity/plugin-kit` 1.x:
|
|
377
|
-
|
|
378
|
-
- Update `@sanity/plugin-kit` to version to 2.x in `package.json`
|
|
379
|
-
- Run: `npx @sanity/plugin-kit@latest inject`
|
|
380
|
-
- This will update package.json with new defaults
|
|
381
|
-
- Feel free to answer no to any file-overwrite prompts
|
|
382
|
-
- Inspect git diff to see what was changed
|
|
383
|
-
- Run: `npm install`
|
|
384
|
-
- Run: `npm run build`
|
|
385
|
-
- Fix any outstanding issues, if any
|
|
386
|
-
|
|
387
335
|
## FAQ
|
|
388
336
|
|
|
389
337
|
#### Q: Do I _have_ to use this for developing Sanity plugins?
|
|
@@ -504,14 +452,11 @@ Provide a sanityPlugin config in package.json (defaults shown):
|
|
|
504
452
|
"packageName": true,
|
|
505
453
|
"esmOnly": true,
|
|
506
454
|
"tsconfig": true,
|
|
507
|
-
"dependencies": true,
|
|
508
455
|
"deprecatedDependencies": true,
|
|
509
456
|
"babelConfig": true,
|
|
510
|
-
"incompatiblePlugin": true,
|
|
511
457
|
"scripts": true,
|
|
512
458
|
"pkg-utils": true,
|
|
513
459
|
"nodeEngine": true,
|
|
514
|
-
"studioConfig": true,
|
|
515
460
|
"srcIndex": true,
|
|
516
461
|
"bannedFiles": true,
|
|
517
462
|
"oxfmt": true,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const cliName = "@sanity/plugin-kit", urls = {
|
|
2
|
+
refDocs: "https://www.sanity.io/docs/reference",
|
|
3
|
+
pluginReadme: "https://github.com/sanity-io/plugins/tree/main/packages/@sanity/plugin-kit#readme"
|
|
4
|
+
}, defaultOutDir = "dist", requiredNodeEngine = ">=20.19 <22 || >=22.12";
|
|
5
|
+
export { urls as i, defaultOutDir as n, requiredNodeEngine as r, cliName as t };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=constants-BIVJp2Jy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-BIVJp2Jy.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const cliName = '@sanity/plugin-kit'\n\nexport const urls = {\n refDocs: 'https://www.sanity.io/docs/reference',\n pluginReadme: 'https://github.com/sanity-io/plugins/tree/main/packages/@sanity/plugin-kit#readme',\n}\n\nexport const defaultOutDir = 'dist'\n\n/**\n * Minimum major version of `@sanity/pkg-utils` required in userland.\n *\n * plugin-kit loads `package.config.ts` via the plugin's own `@sanity/pkg-utils` (a peer\n * dependency) using the `loadConfig({cwd, pkgPath})` signature introduced in v10. Older majors\n * expose an incompatible `loadConfig({cwd})` and cannot reliably load ESM TypeScript configs.\n */\nexport const minPkgUtilsMajor = 10\n\n/**\n * Required `engines.node` range for plugins, matching `@sanity/pkg-utils` so plugins declare the\n * same Node.js support as the build tool they use.\n */\nexport const requiredNodeEngine = '>=20.19 <22 || >=22.12'\n"],"mappings":"AAAA,MAAa,UAAU,sBAEV,OAAO;CAClB,SAAS;CACT,cAAc;AAChB,GAEa,gBAAgB,QAehB,qBAAqB"}
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import { t as cliName } from "./constants-
|
|
1
|
+
import { t as cliName } from "./constants-BIVJp2Jy.js";
|
|
2
2
|
import { n as sharedFlags_default, t as log_default } from "./log-DgQL-Rv9.js";
|
|
3
3
|
import meow from "meow";
|
|
4
4
|
var cmds_default = {
|
|
5
5
|
init: async (options) => {
|
|
6
|
-
await (await import("./init-
|
|
6
|
+
await (await import("./init-7tPgEM_5.js")).default(options);
|
|
7
7
|
},
|
|
8
8
|
inject: async (options) => {
|
|
9
|
-
await (await import("./inject-
|
|
9
|
+
await (await import("./inject-DCHoqs0d.js")).default(options);
|
|
10
10
|
},
|
|
11
11
|
"link-watch": async (options) => {
|
|
12
|
-
await (await import("./link-watch-
|
|
12
|
+
await (await import("./link-watch-bvv8kQCJ.js")).default(options);
|
|
13
13
|
},
|
|
14
14
|
"verify-package": async (options) => {
|
|
15
|
-
await (await import("./verify-package-
|
|
16
|
-
},
|
|
17
|
-
"verify-studio": async (options) => {
|
|
18
|
-
await (await import("./verify-studio-Cg8aSAky.js")).default(options);
|
|
15
|
+
await (await import("./verify-package-fNlJK-qr.js")).default(options);
|
|
19
16
|
},
|
|
20
17
|
version: async (options) => {
|
|
21
|
-
(await import("./version-
|
|
18
|
+
(await import("./version-B37Jvdal.js")).default(options);
|
|
22
19
|
}
|
|
23
20
|
};
|
|
24
21
|
/** @public */
|
|
@@ -30,9 +27,8 @@ async function cliEntry(argv = process.argv) {
|
|
|
30
27
|
These are common commands used in various situations:
|
|
31
28
|
|
|
32
29
|
init Create a new Sanity plugin
|
|
33
|
-
inject Inject config into an existing Sanity
|
|
34
|
-
verify-package Check that a Sanity plugin package follows
|
|
35
|
-
verify-studio Check that a Sanity Studio follows V3 conventions. Prints upgrade steps.
|
|
30
|
+
inject Inject config into an existing Sanity plugin
|
|
31
|
+
verify-package Check that a Sanity plugin package follows plugin-kit conventions
|
|
36
32
|
link-watch Recompiles plugin automatically on changes and runs yalc push --publish
|
|
37
33
|
version Show the version of ${cliName} currently installed
|
|
38
34
|
|
|
@@ -50,11 +46,8 @@ async function cliEntry(argv = process.argv) {
|
|
|
50
46
|
# Init a new plugin in my-sanity-plugin directory
|
|
51
47
|
$ ${cliName} init my-sanity-plugin
|
|
52
48
|
|
|
53
|
-
# Check that a Sanity plugin package in current directory follows
|
|
49
|
+
# Check that a Sanity plugin package in current directory follows plugin-kit conventions
|
|
54
50
|
$ ${cliName} verify-package
|
|
55
|
-
|
|
56
|
-
# Check that a Sanity Studio in current directory follows V3 conventions
|
|
57
|
-
$ ${cliName} verify-studio
|
|
58
51
|
`, {
|
|
59
52
|
autoHelp: !1,
|
|
60
53
|
flags: sharedFlags_default,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["sharedFlags","commands"],"sources":["../src/cmds/index.ts","../src/cli.ts"],"sourcesContent":["export default {\n 'init': async (options: {argv: string[]}) => {\n await (await import('./init')).default(options)\n },\n 'inject': async (options: {argv: string[]}) => {\n await (await import('./inject')).default(options)\n },\n 'link-watch': async (options: {argv: string[]}) => {\n await (await import('./link-watch')).default(options)\n },\n 'verify-package': async (options: {argv: string[]}) => {\n await (await import('./verify-package')).default(options)\n },\n '
|
|
1
|
+
{"version":3,"file":"index.js","names":["sharedFlags","commands"],"sources":["../src/cmds/index.ts","../src/cli.ts"],"sourcesContent":["export default {\n 'init': async (options: {argv: string[]}) => {\n await (await import('./init')).default(options)\n },\n 'inject': async (options: {argv: string[]}) => {\n await (await import('./inject')).default(options)\n },\n 'link-watch': async (options: {argv: string[]}) => {\n await (await import('./link-watch')).default(options)\n },\n 'verify-package': async (options: {argv: string[]}) => {\n await (await import('./verify-package')).default(options)\n },\n 'version': async (options: {argv: string[]}) => {\n ;(await import('./version')).default(options)\n },\n}\n","import meow from 'meow'\n\nimport commands from './cmds'\nimport {cliName} from './constants'\nimport sharedFlags from './sharedFlags'\nimport log from './util/log'\n\n/** @public */\nexport async function cliEntry(argv = process.argv) {\n const cli = meow(\n `\n\tUsage\n\t $ ${cliName} [--help] [--debug] <command> [<args>]\n\n These are common commands used in various situations:\n\n init Create a new Sanity plugin\n inject Inject config into an existing Sanity plugin\n verify-package Check that a Sanity plugin package follows plugin-kit conventions\n link-watch Recompiles plugin automatically on changes and runs yalc push --publish\n version Show the version of ${cliName} currently installed\n\n Options\n --silent Do not print info and warning messages\n --verbose Log everything. This option conflicts with --silent\n --debug Print stack trace on errors\n --version Output the version number\n --help Output usage information\n\n Examples\n # Init a new plugin in current directory\n $ ${cliName} init\n\n # Init a new plugin in my-sanity-plugin directory\n $ ${cliName} init my-sanity-plugin\n\n # Check that a Sanity plugin package in current directory follows plugin-kit conventions\n $ ${cliName} verify-package\n`,\n {\n autoHelp: false,\n flags: sharedFlags,\n argv: argv.slice(2),\n },\n )\n\n const commandName = cli.input[0]\n if (!commandName) {\n cli.showHelp() // Exits\n }\n\n if (!(commandName in commands)) {\n console.error(`Unknown command \"${commandName}\"`)\n cli.showHelp() // Exits\n }\n\n if (cli.flags.silent && cli.flags.verbose) {\n log.error(`--silent and --verbose are mutually exclusive`)\n cli.showHelp() // Exits\n }\n\n // Lazy-load command\n const cmd = commands[commandName as keyof typeof commands]\n\n try {\n log.setVerbosity(cli.flags)\n await cmd({argv: argv.slice(3)})\n } catch (err: any) {\n log.error(err instanceof TypeError || cli.flags.debug ? err.stack : err.message)\n\n process.exit(1)\n }\n}\n"],"mappings":";;;AAAA,IAAA,eAAe;CACb,MAAQ,OAAO,YAA8B;EAC3C,OAAO,MAAM,OAAO,sBAAA,CAAW,QAAQ,OAAO;CAChD;CACA,QAAU,OAAO,YAA8B;EAC7C,OAAO,MAAM,OAAO,wBAAA,CAAa,QAAQ,OAAO;CAClD;CACA,cAAc,OAAO,YAA8B;EACjD,OAAO,MAAM,OAAO,4BAAA,CAAiB,QAAQ,OAAO;CACtD;CACA,kBAAkB,OAAO,YAA8B;EACrD,OAAO,MAAM,OAAO,gCAAA,CAAqB,QAAQ,OAAO;CAC1D;CACA,SAAW,OAAO,YAA8B;EAC7C,CAAC,MAAM,OAAO,yBAAA,CAAc,QAAQ,OAAO;CAC9C;AACF;;ACRA,eAAsB,SAAS,OAAO,QAAQ,MAAM;CAClD,IAAM,MAAM,KACV;;OAEG,QAAQ;;;;;;;;0CAQ2B,QAAQ;;;;;;;;;;;QAW1C,QAAQ;;;QAGR,QAAQ;;;QAGR,QAAQ;GAEZ;EACE,UAAU;EACV,OAAOA;EACP,MAAM,KAAK,MAAM,CAAC;CACpB,CACF,GAEM,cAAc,IAAI,MAAM;CAU9B,AATK,eACH,IAAI,SAAS,GAGT,eAAeC,iBACnB,QAAQ,MAAM,oBAAoB,YAAY,EAAE,GAChD,IAAI,SAAS,IAGX,IAAI,MAAM,UAAU,IAAI,MAAM,YAChC,YAAI,MAAM,+CAA+C,GACzD,IAAI,SAAS;CAIf,IAAM,MAAMA,aAAS;CAErB,IAAI;EAEF,AADA,YAAI,aAAa,IAAI,KAAK,GAC1B,MAAM,IAAI,EAAC,MAAM,KAAK,MAAM,CAAC,EAAC,CAAC;CACjC,SAAS,KAAU;EAGjB,AAFA,YAAI,MAAM,eAAe,aAAa,IAAI,MAAM,QAAQ,IAAI,QAAQ,IAAI,OAAO,GAE/E,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as cliName } from "./constants-
|
|
1
|
+
import { t as cliName } from "./constants-BIVJp2Jy.js";
|
|
2
2
|
import { t as log_default } from "./log-DgQL-Rv9.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { a as presetHelpList, n as init, r as initFlags, t as findStudioConfig } from "./studio-detect-CuoRHDQA.js";
|
|
4
|
+
import { D as ensureDir, F as prompt, k as isEmptyish } from "./package-Cx3OyOx-.js";
|
|
5
5
|
import meow from "meow";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import execa from "execa";
|
|
@@ -78,10 +78,8 @@ async function run({ argv }) {
|
|
|
78
78
|
flags: initFlags,
|
|
79
79
|
argv,
|
|
80
80
|
description: "Initialize a new Sanity plugin"
|
|
81
|
-
}), basePath = path.resolve(cli.input[0] || process.cwd()), {
|
|
82
|
-
if (
|
|
83
|
-
let { v3ConfigFile } = await findStudioV3Config(basePath);
|
|
84
|
-
if (v3ConfigFile) throw Error(`${v3ConfigFile} exists - are you trying to init into a studio instead of a plugin?`);
|
|
81
|
+
}), basePath = path.resolve(cli.input[0] || process.cwd()), { configFile } = await findStudioConfig(basePath);
|
|
82
|
+
if (configFile) throw Error(`${configFile} exists - are you trying to init into a studio instead of a plugin?`);
|
|
85
83
|
if (log_default.info("Initializing new plugin in \"%s\"", basePath), !cli.flags.force && !await isEmptyish(basePath) && !await prompt("Directory is not empty, proceed?", {
|
|
86
84
|
type: "confirm",
|
|
87
85
|
default: !1
|
|
@@ -96,4 +94,4 @@ async function run({ argv }) {
|
|
|
96
94
|
}
|
|
97
95
|
export { run as default };
|
|
98
96
|
|
|
99
|
-
//# sourceMappingURL=init-
|
|
97
|
+
//# sourceMappingURL=init-7tPgEM_5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-7tPgEM_5.js","names":[],"sources":["../src/npm/manager.ts","../src/cmds/init.ts"],"sourcesContent":["import execa from 'execa'\n\nimport {prompt} from '../util/prompt'\n\nfunction npmIsAvailable() {\n return execa('npm', ['-v'])\n .then(() => true)\n .catch(() => false)\n}\n\nfunction yarnIsAvailable() {\n return execa('yarn', ['-v'])\n .then(() => true)\n .catch(() => false)\n}\n\nfunction pnpmAvailable() {\n return execa('pnpm', ['-v'])\n .then(() => true)\n .catch(() => false)\n}\n\nexport async function promptForPackageManager() {\n const [npm, yarn, pnpm] = await Promise.all([\n npmIsAvailable(),\n yarnIsAvailable(),\n pnpmAvailable(),\n ])\n\n const choices = [npm && 'npm', yarn && 'yarn', pnpm && 'pnpm'].filter(Boolean)\n if (choices.length < 2) {\n return choices[0] || 'npm'\n }\n\n return prompt('Which package manager do you prefer?', {\n choices: choices.map((value) => ({value, name: value})),\n default: choices[0],\n })\n}\n\nexport async function installDependencies(pm: string, {cwd}: {cwd?: string}) {\n const proc = execa(pm, ['install'], {cwd, stdio: 'inherit'})\n const {exitCode} = await proc\n return exitCode <= 0\n}\n","import path from 'path'\n\nimport meow from 'meow'\n\nimport {init, initFlags} from '../actions/init'\nimport {cliName} from '../constants'\nimport {installDependencies, promptForPackageManager} from '../npm/manager'\nimport {presetHelpList} from '../presets/presets'\nimport {findStudioConfig} from '../sanity/studio-detect'\nimport {isEmptyish, ensureDir} from '../util/files'\nimport log from '../util/log'\nimport {prompt} from '../util/prompt'\n\nconst description = `Initialize a new Sanity plugin`\n\nconst help = `\nUsage\n $ ${cliName} init [dir] [<args>]\n\nOptions\n --no-oxlint Disables oxlint config and dependencies from being added\n --no-oxfmt Disables oxfmt config and dependencies from being added\n --no-typescript Disables typescript config and dependencies from being added\n --no-license Disables LICENSE + package.json license field from being added\n --no-editorconfig Disables .editorconfig from being added\n --no-gitignore Disables .gitignore from being added\n --no-scripts Disables scripts from being added to package.json\n --no-install Disables automatically running package manager install\n\n --name [package-name] Use the provided package-name\n --author [name] Use the provided author\n --repo [url] Use the provided repo url\n --license [spdx] Use the license with the given SPDX identifier\n --force No prompt when overwriting files\n\n --preset [preset-name] Adds config and files from a named preset. --preset can be supplied multiple times.\n The following presets are available:\n${presetHelpList(30)}\n\nExamples\n # Initialize a new plugin in the current directory\n $ ${cliName} init\n\n # Initialize a plugin in the directory ~/my-plugin\n $ ${cliName} init ~/my-plugin\n\n # Don't add oxlint or oxfmt\n $ ${cliName} init --no-oxlint --no-oxfmt\n`\n\nasync function run({argv}: {argv: string[]}) {\n const cli = meow(help, {flags: initFlags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n\n const {configFile} = await findStudioConfig(basePath)\n if (configFile) {\n throw new Error(\n `${configFile} exists - are you trying to init into a studio instead of a plugin?`,\n )\n }\n\n log.info('Initializing new plugin in \"%s\"', basePath)\n if (\n !cli.flags.force &&\n !(await isEmptyish(basePath)) &&\n !(await prompt('Directory is not empty, proceed?', {type: 'confirm', default: false}))\n ) {\n log.error('Directory is not empty. Cancelled.')\n return\n }\n\n await ensureDir(basePath)\n await init({basePath, flags: cli.flags})\n if (cli.flags.install) {\n if (await installDependencies(await promptForPackageManager(), {cwd: basePath})) {\n log.info('Done!')\n } else {\n log.error('Failed to install dependencies, try manually running `npm install`')\n }\n } else {\n log.info('Dependency installation skipped.')\n }\n}\n\nexport default run\n"],"mappings":";;;;;;;AAIA,SAAS,iBAAiB;CACxB,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CACxB,WAAW,EAAI,CAAC,CAChB,YAAY,EAAK;AACtB;AAEA,SAAS,kBAAkB;CACzB,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC,CACzB,WAAW,EAAI,CAAC,CAChB,YAAY,EAAK;AACtB;AAEA,SAAS,gBAAgB;CACvB,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC,CACzB,WAAW,EAAI,CAAC,CAChB,YAAY,EAAK;AACtB;AAEA,eAAsB,0BAA0B;CAC9C,IAAM,CAAC,KAAK,MAAM,QAAQ,MAAM,QAAQ,IAAI;EAC1C,eAAe;EACf,gBAAgB;EAChB,cAAc;CAChB,CAAC,GAEK,UAAU;EAAC,OAAO;EAAO,QAAQ;EAAQ,QAAQ;CAAM,CAAC,CAAC,OAAO,OAAO;CAK7E,OAJI,QAAQ,SAAS,IACZ,QAAQ,MAAM,QAGhB,OAAO,wCAAwC;EACpD,SAAS,QAAQ,KAAK,WAAW;GAAC;GAAO,MAAM;EAAK,EAAE;EACtD,SAAS,QAAQ;CACnB,CAAC;AACH;AAEA,eAAsB,oBAAoB,IAAY,EAAC,OAAsB;CAE3E,IAAM,EAAC,aAAY,MADN,MAAM,IAAI,CAAC,SAAS,GAAG;EAAC;EAAK,OAAO;CAAS,CAC9B;CAC5B,OAAO,YAAY;AACrB;AC/BA,MAEM,OAAO;;MAEP,QAAQ;;;;;;;;;;;;;;;;;;;;EAoBZ,eAAe,EAAE,EAAE;;;;MAIf,QAAQ;;;MAGR,QAAQ;;;MAGR,QAAQ;;AAGd,eAAe,IAAI,EAAC,QAAyB;CAC3C,IAAM,MAAM,KAAK,MAAM;EAAC,OAAO;EAAW;EAAM;CAAW,CAAC,GACtD,WAAW,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CAAC,GAErD,EAAC,eAAc,MAAM,iBAAiB,QAAQ;CACpD,IAAI,YACF,MAAU,MACR,GAAG,WAAW,oEAChB;CAIF,IADA,YAAI,KAAK,qCAAmC,QAAQ,GAElD,CAAC,IAAI,MAAM,SACX,CAAE,MAAM,WAAW,QAAQ,KAC3B,CAAE,MAAM,OAAO,oCAAoC;EAAC,MAAM;EAAW,SAAS;CAAK,CAAC,GACpF;EACA,YAAI,MAAM,oCAAoC;EAC9C;CACF;CAIA,AAFA,MAAM,UAAU,QAAQ,GACxB,MAAM,KAAK;EAAC;EAAU,OAAO,IAAI;CAAK,CAAC,GACnC,IAAI,MAAM,UACR,MAAM,oBAAoB,MAAM,wBAAwB,GAAG,EAAC,KAAK,SAAQ,CAAC,IAC5E,YAAI,KAAK,OAAO,IAEhB,YAAI,MAAM,oEAAoE,IAGhF,YAAI,KAAK,kCAAkC;AAE/C"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as cliName } from "./constants-
|
|
1
|
+
import { t as cliName } from "./constants-BIVJp2Jy.js";
|
|
2
2
|
import { t as log_default } from "./log-DgQL-Rv9.js";
|
|
3
|
-
import {
|
|
4
|
-
import { u as findStudioV3Config } from "./package-B_o7MhuL.js";
|
|
3
|
+
import { a as presetHelpList, i as inject, r as initFlags, t as findStudioConfig } from "./studio-detect-CuoRHDQA.js";
|
|
5
4
|
import { t as loadPackageConfig } from "./load-package-config-CNQRvdGW.js";
|
|
6
5
|
import meow from "meow";
|
|
7
6
|
import path from "path";
|
|
@@ -48,8 +47,8 @@ async function run({ argv }) {
|
|
|
48
47
|
flags: initFlags,
|
|
49
48
|
argv,
|
|
50
49
|
description: "Inject configuration into a Sanity plugin"
|
|
51
|
-
}), basePath = path.resolve(cli.input[0] || process.cwd()), outDir = (await loadPackageConfig({ basePath }))?.dist ?? "dist", {
|
|
52
|
-
if (
|
|
50
|
+
}), basePath = path.resolve(cli.input[0] || process.cwd()), outDir = (await loadPackageConfig({ basePath }))?.dist ?? "dist", { configFile } = await findStudioConfig(basePath);
|
|
51
|
+
if (configFile) throw Error(`${configFile} exists - are you trying to INJECT into a studio instead of a plugin?`);
|
|
53
52
|
log_default.info("Inject config into plugin in \"%s\"", basePath), await inject({
|
|
54
53
|
basePath,
|
|
55
54
|
outDir,
|
|
@@ -59,4 +58,4 @@ async function run({ argv }) {
|
|
|
59
58
|
}
|
|
60
59
|
export { run as default };
|
|
61
60
|
|
|
62
|
-
//# sourceMappingURL=inject-
|
|
61
|
+
//# sourceMappingURL=inject-DCHoqs0d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-DCHoqs0d.js","names":[],"sources":["../src/cmds/inject.ts"],"sourcesContent":["import path from 'path'\n\nimport meow from 'meow'\n\nimport {initFlags} from '../actions/init'\nimport {inject} from '../actions/inject'\nimport {cliName, defaultOutDir} from '../constants'\nimport {presetHelpList} from '../presets/presets'\nimport {findStudioConfig} from '../sanity/studio-detect'\nimport {loadPackageConfig} from '../util/load-package-config'\nimport log from '../util/log'\n\nconst description = `Inject configuration into a Sanity plugin`\n\nconst help = `\nUsage\n $ ${cliName} inject [dir] [<args>]\n\nOptions\n --no-oxlint Disables oxlint config and dependencies from being added\n --no-oxfmt Disables oxfmt config and dependencies from being added\n --no-typescript Disables typescript config and dependencies from being added\n --no-license Disables LICENSE + package.json license field from being added\n --no-editorconfig Disables .editorconfig from being added\n --no-gitignore Disables .gitignore from being added\n --no-scripts Disables scripts from being added to package.json\n\n --license [spdx] Use the license with the given SPDX identifier\n --force No prompt when overwriting files\n\n --preset [preset-name] Adds config and files from a named preset. --preset can be supplied multiple times.\n The following presets are available:\n${presetHelpList(30)}\n --preset-only Skips the default inject steps. Use this to apply a preset to an otherwise complete plugin.\n\nExamples\n # Inject configuration into the plugin in the current directory\n $ ${cliName} inject\n\n # Inject configuration into the plugin in ~/my-plugin\n $ ${cliName} inject ~/my-plugin\n\n # Don't inject oxlint or oxfmt\n $ ${cliName} inject --no-oxlint --no-oxfmt\n\n # Inject plugin configuration and semver-workflow into the plugin in the current directory\n $ @sanity/plugin-kit inject --preset semver-workflow\n\n # Only inject semver-workflow and renovatebot config from presets\n $ ${cliName} inject --preset-only --preset semver-workflow --preset renovatebot\n\n`\n\nasync function run({argv}: {argv: string[]}) {\n const cli = meow(help, {flags: initFlags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n const packageConfig = await loadPackageConfig({basePath})\n const outDir = packageConfig?.dist ?? defaultOutDir\n\n const {configFile} = await findStudioConfig(basePath)\n if (configFile) {\n throw new Error(\n `${configFile} exists - are you trying to INJECT into a studio instead of a plugin?`,\n )\n }\n log.info('Inject config into plugin in \"%s\"', basePath)\n\n await inject({basePath, outDir, flags: cli.flags, validate: false})\n log.info('Done!')\n}\n\nexport default run\n"],"mappings":";;;;;;AAYA,MAEM,OAAO;;MAEP,QAAQ;;;;;;;;;;;;;;;;EAgBZ,eAAe,EAAE,EAAE;;;;;MAKf,QAAQ;;;MAGR,QAAQ;;;MAGR,QAAQ;;;;;;MAMR,QAAQ;;;AAId,eAAe,IAAI,EAAC,QAAyB;CAC3C,IAAM,MAAM,KAAK,MAAM;EAAC,OAAO;EAAW;EAAM;CAAW,CAAC,GACtD,WAAW,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CAAC,GAErD,UAAS,MADa,kBAAkB,EAAC,SAAQ,CAAC,EAAA,EAC1B,QAAA,QAExB,EAAC,eAAc,MAAM,iBAAiB,QAAQ;CACpD,IAAI,YACF,MAAU,MACR,GAAG,WAAW,sEAChB;CAKF,AAHA,YAAI,KAAK,uCAAqC,QAAQ,GAEtD,MAAM,OAAO;EAAC;EAAU;EAAQ,OAAO,IAAI;EAAO,UAAU;CAAK,CAAC,GAClE,YAAI,KAAK,OAAO;AAClB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./constants-
|
|
1
|
+
import "./constants-BIVJp2Jy.js";
|
|
2
2
|
import { n as sharedFlags_default, t as log_default } from "./log-DgQL-Rv9.js";
|
|
3
|
-
import {
|
|
4
|
-
import { t as binname } from "./package-
|
|
3
|
+
import { A as mkdir, O as fileExists, a as getPackage } from "./package-Cx3OyOx-.js";
|
|
4
|
+
import { t as binname } from "./package-DcGaUtE-.js";
|
|
5
5
|
import { t as loadPackageConfig } from "./load-package-config-CNQRvdGW.js";
|
|
6
6
|
import meow from "meow";
|
|
7
7
|
import chalk from "chalk";
|
|
@@ -90,4 +90,4 @@ function run({ argv }) {
|
|
|
90
90
|
}
|
|
91
91
|
export { run as default };
|
|
92
92
|
|
|
93
|
-
//# sourceMappingURL=link-watch-
|
|
93
|
+
//# sourceMappingURL=link-watch-bvv8kQCJ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-watch-
|
|
1
|
+
{"version":3,"file":"link-watch-bvv8kQCJ.js","names":["pkg.binname","sharedFlags"],"sources":["../src/actions/link-watch.ts","../src/cmds/link-watch.ts"],"sourcesContent":["/*\nISC License (ISC)\nCopyright 2019 Johan Otterud\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,\nprovided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH\nTHE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\n\n/*\nThis code is a modified version of https://github.com/johot/yalc-watch,\nand the ISC License has been added for this file only, in accordance with the package.json license field in that package\n*/\n\nimport fs from 'fs'\nimport path from 'path'\n\nimport chalk from 'chalk'\nimport concurrently from 'concurrently'\nimport nodemon from 'nodemon'\nimport outdent from 'outdent'\n\nimport {defaultOutDir} from '../constants'\nimport {getPackage} from '../npm/package'\nimport {fileExists, mkdir} from '../util/files'\nimport {loadPackageConfig} from '../util/load-package-config'\nimport log from '../util/log'\n\ninterface YalcWatchConfig {\n command?: string\n extensions?: string\n}\n\ninterface PackageJson {\n sanityPlugin?: {linkWatch?: YalcWatchConfig}\n}\n\nexport async function linkWatch({basePath}: {basePath: string}) {\n const packageJson: PackageJson = JSON.parse(\n fs.readFileSync(path.join(basePath, 'package.json'), 'utf8'),\n )\n\n const packageConfig = await loadPackageConfig({basePath})\n const outDir = packageConfig?.dist ?? defaultOutDir\n\n const watch: Required<YalcWatchConfig> = {\n command: 'npm run watch',\n extensions: 'ts,js,png,svg,gif,jpeg,css',\n ...packageJson.sanityPlugin?.linkWatch,\n }\n\n nodemon({\n watch: [outDir],\n ext: watch.extensions,\n exec: 'yalc push --changed',\n //delay: 1000\n })\n\n // ensure the folder exits so it can be watched\n const folder = path.join(basePath, outDir)\n if (!(await fileExists(folder))) {\n await mkdir(folder)\n }\n\n const pkg = await getPackage({basePath, validate: false})\n\n concurrently([watch.command])\n\n nodemon\n .on('start', function () {\n log.info(\n outdent`\n Watching ${outDir} for changes to files with extensions: ${watch.extensions}\n\n To test this package in Sanity Studio or another package, in a separate shell run:\n cd /path/to/sanity/studio-or-package\n\n Then, run one of the below commands, based on the package manager used in studio-or-package:\n\n ## yarn\n ${chalk.greenBright(`yalc add --link ${pkg.name} && yarn install`)}\n\n ## npm\n ${chalk.greenBright(`npx yalc add ${pkg.name} && npx yalc link ${pkg.name} && npm install`)}\n `.trimStart(),\n )\n })\n .on('quit', function () {\n process.exit()\n })\n .on('restart', function (files: any) {\n log.info('Found changes in files:', chalk.magentaBright(files))\n log.info('Pushing new yalc package...')\n })\n}\n","import path from 'path'\n\nimport meow from 'meow'\n\nimport pkg from '../../package.json'\nimport {linkWatch} from '../actions/link-watch'\nimport sharedFlags from '../sharedFlags'\n\nconst description = `Run the watch command and pushes any changes to yalc`\n\nconst help = `\nUsage\n $ ${pkg.binname} link-watch [<args>]\n\nOptions\n --silent Do not print info and warning messages\n --verbose Log everything. This option conflicts with --silent\n --version Output the version number\n --help Output usage information\n\nConfiguration\nTo override the default watch command configuration, provide an override in package.json under sanityPlugin:\n{\n \"sanityPlugin\": {\n \"watchCommand\": \"microbundle watch --format modern,esm,cjs --jsx React.createElement --jsxImportSource react --css inline\",\n \"linkWatch\": {\n \"command\": \"npm run watch\",\n \"extensions\": \"js,png,svg,gif,jpeg,css\"\n }\n }\n}\n\nExamples\n # Run the watch command and pushes any changes to yalc\n $ ${pkg.binname} link-watch\n`\n\nconst flags = {\n ...sharedFlags,\n watch: {\n type: 'boolean',\n default: false,\n },\n} as const\n\nfunction run({argv}: {argv: string[]}) {\n const cli = meow(help, {flags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n return linkWatch({basePath})\n}\n\nexport default run\n"],"mappings":";;;;;;;;;;;;AA0CA,eAAsB,UAAU,EAAC,YAA+B;CAC9D,IAAM,cAA2B,KAAK,MACpC,GAAG,aAAa,KAAK,KAAK,UAAU,cAAc,GAAG,MAAM,CAC7D,GAGM,UAAS,MADa,kBAAkB,EAAC,SAAQ,CAAC,EAAA,EAC1B,QAAA,QAExB,QAAmC;EACvC,SAAS;EACT,YAAY;EACZ,GAAG,YAAY,cAAc;CAC/B;CAEA,QAAQ;EACN,OAAO,CAAC,MAAM;EACd,KAAK,MAAM;EACX,MAAM;CAER,CAAC;CAGD,IAAM,SAAS,KAAK,KAAK,UAAU,MAAM;CACzC,AAAM,MAAM,WAAW,MAAM,KAC3B,MAAM,MAAM,MAAM;CAGpB,IAAM,MAAM,MAAM,WAAW;EAAC;EAAU,UAAU;CAAK,CAAC;CAIxD,AAFA,aAAa,CAAC,MAAM,OAAO,CAAC,GAE5B,QACG,GAAG,SAAS,WAAY;EACvB,YAAI,KACF,OAAO;mBACI,OAAO,yCAAyC,MAAM,WAAW;;;;;;;;UAQ1E,MAAM,YAAY,mBAAmB,IAAI,KAAK,iBAAiB,EAAE;;;UAGjE,MAAM,YAAY,gBAAgB,IAAI,KAAK,oBAAoB,IAAI,KAAK,gBAAgB,EAAE;QAC5F,UAAU,CACZ;CACF,CAAC,CAAC,CACD,GAAG,QAAQ,WAAY;EACtB,QAAQ,KAAK;CACf,CAAC,CAAC,CACD,GAAG,WAAW,SAAU,OAAY;EAEnC,AADA,YAAI,KAAK,2BAA2B,MAAM,cAAc,KAAK,CAAC,GAC9D,YAAI,KAAK,6BAA6B;CACxC,CAAC;AACL;AC3FA,MAEM,OAAO;;MAEPA,QAAY;;;;;;;;;;;;;;;;;;;;;;MAsBZA,QAAY;GAGZ,QAAQ;CACZ,GAAGC;CACH,OAAO;EACL,MAAM;EACN,SAAS;CACX;AACF;AAEA,SAAS,IAAI,EAAC,QAAyB;CACrC,IAAM,MAAM,KAAK,MAAM;EAAC;EAAO;EAAM;CAAW,CAAC;CAEjD,OAAO,UAAU,EAAC,UADD,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CACjC,EAAC,CAAC;AAC7B"}
|
package/dist/oxlint.js
CHANGED
|
@@ -65,6 +65,14 @@ const config = {
|
|
|
65
65
|
name: "lodash-es",
|
|
66
66
|
message: "Import from individual modules instead, e.g. `import debounce from 'lodash-es/debounce.js'`. Barrel imports are ~55% slower."
|
|
67
67
|
},
|
|
68
|
+
{
|
|
69
|
+
name: "date-fns",
|
|
70
|
+
message: "Import from individual modules instead, e.g. `import {startOfDay} from 'date-fns/startOfDay'`. Barrel imports are ~50% slower."
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "date-fns-tz",
|
|
74
|
+
message: "Use the official `@date-fns/tz` package (TZDate, tz, tzOffset) with date-fns v4 instead, matching sanity core."
|
|
75
|
+
},
|
|
68
76
|
{
|
|
69
77
|
name: "react",
|
|
70
78
|
importNames: ["createElement"],
|
package/dist/oxlint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint.js","names":[],"sources":["../src/oxlint.ts"],"sourcesContent":["import type {OxlintConfig} from 'oxlint'\n\n/**\n * Shared [oxlint](https://oxc.rs/docs/guide/usage/linter.html) config for Sanity plugins - the\n * same settings the [sanity-io/plugins](https://github.com/sanity-io/plugins) monorepo uses:\n * type-aware rules and TypeScript type checking enabled (via `oxlint-tsgolint`), warnings denied,\n * and the React, React Compiler, import, promise, a11y and unicorn rule sets turned on.\n *\n * Re-export it from an `oxlint.config.ts` next to the `package.json` that runs oxlint (the\n * repository root in a monorepo, otherwise the plugin directory):\n *\n * ```ts\n * export {default} from '@sanity/plugin-kit/oxlint'\n * ```\n *\n * To customize, extend it and add your own options ([`ignorePatterns` do not propagate through\n * `extends`](https://oxc.rs/docs/guide/usage/linter/config.html#extend-shared-configs), so spread\n * them explicitly when adding your own):\n *\n * ```ts\n * import sanityPluginKitOxlint from '@sanity/plugin-kit/oxlint'\n * import {defineConfig} from 'oxlint'\n *\n * export default defineConfig({\n * extends: [sanityPluginKitOxlint],\n * ignorePatterns: [...(sanityPluginKitOxlint.ignorePatterns ?? []), 'examples/**'],\n * })\n * ```\n *\n * Note: TypeScript config files require the Node-based `oxlint` package and Node `>=22.18`.\n *\n * @public\n */\nconst config: OxlintConfig = {\n plugins: ['typescript', 'unicorn', 'react', 'react-perf', 'oxc', 'import', 'jsx-a11y', 'promise'],\n ignorePatterns: ['**/.sanity/*', '**/dist/*', '**/sanity.types.ts'],\n options: {\n denyWarnings: true,\n reportUnusedDisableDirectives: 'error',\n typeAware: true,\n typeCheck: true,\n },\n categories: {\n correctness: 'error',\n suspicious: 'error',\n perf: 'error',\n },\n rules: {\n 'no-underscore-dangle': 'off',\n 'consistent-function-scoping': 'off',\n 'eslint/no-restricted-imports': [\n 'error',\n {\n paths: [\n {\n name: 'lodash-es',\n message:\n \"Import from individual modules instead, e.g. `import debounce from 'lodash-es/debounce.js'`. Barrel imports are ~55% slower.\",\n },\n {\n name: 'react',\n importNames: ['createElement'],\n message:\n 'Please use JSX instead of createElement, for example `createElement(Icon)` should be `<Icon />`',\n },\n {\n name: 'react',\n importNames: ['forwardRef'],\n message:\n 'forwardRef is unnecessary in React 19 — `ref` is a regular prop. Accept `ref` in your component props instead, e.g. `function Foo({ref, ...props}: Props & {ref?: Ref<T>}) {}`. See the sanity-plugin-best-practices skill.',\n },\n ],\n patterns: [\n {\n group: ['lodash.*', 'lodash/*', 'lodash'],\n message:\n \"Please use individual imports from 'lodash-es' instead, e.g. `import debounce from 'lodash-es/debounce.js'`.\",\n },\n ],\n },\n ],\n\n // React Compiler checks\n 'react/react-compiler': 'error',\n\n 'typescript/ban-ts-comment': 'error',\n 'typescript/no-deprecated': 'error',\n 'typescript/no-unnecessary-type-assertion': 'error',\n 'typescript/no-unnecessary-type-arguments': 'error',\n 'typescript/prefer-ts-expect-error': 'error',\n 'import/no-commonjs': 'error',\n 'import/no-unassigned-import': ['error', {allow: ['**/*.css']}],\n 'no-restricted-globals': [\n 'error',\n {name: '__dirname', message: 'Use path.dirname(fileURLToPath(import.meta.url)) instead'},\n {name: '__filename', message: 'Use fileURLToPath(import.meta.url) instead'},\n ],\n 'react/jsx-key': 'error',\n 'unicorn/no-abusive-eslint-disable': 'error',\n // Not relevant as we use the modern jsx-runtime transform\n 'react-in-jsx-scope': 'off',\n // Not relevant due to React Compiler\n 'react_perf/jsx-no-new-array-as-prop': 'off',\n 'react_perf/jsx-no-new-object-as-prop': 'off',\n 'react_perf/jsx-no-new-function-as-prop': 'off',\n 'react_perf/jsx-no-jsx-as-prop': 'off',\n // False negatives\n 'jsx_a11y/anchor-is-valid': 'off',\n 'jsx_a11y/no-autofocus': 'off',\n // Handy rules that are disabled by default\n 'react/exhaustive-deps': 'error',\n 'react/rules-of-hooks': 'error',\n 'eslint/no-console': ['error', {allow: ['warn', 'error']}],\n // Requires polyfills for older browsers\n 'no-array-reverse': 'off',\n 'no-array-sort': 'off',\n // Too noisy, common in callbacks/closures\n 'no-shadow': 'off',\n },\n}\n\nexport default config\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,SAAuB;CAC3B,SAAS;EAAC;EAAc;EAAW;EAAS;EAAc;EAAO;EAAU;EAAY;CAAS;CAChG,gBAAgB;EAAC;EAAgB;EAAa;CAAoB;CAClE,SAAS;EACP,cAAc;EACd,+BAA+B;EAC/B,WAAW;EACX,WAAW;CACb;CACA,YAAY;EACV,aAAa;EACb,YAAY;EACZ,MAAM;CACR;CACA,OAAO;EACL,wBAAwB;EACxB,+BAA+B;EAC/B,gCAAgC,CAC9B,SACA;GACE,OAAO;IACL;KACE,MAAM;KACN,SACE;IACJ;IACA;KACE,MAAM;KACN,aAAa,CAAC,eAAe;KAC7B,SACE;IACJ;IACA;KACE,MAAM;KACN,aAAa,CAAC,YAAY;KAC1B,SACE;IACJ;GACF;GACA,UAAU,CACR;IACE,OAAO;KAAC;KAAY;KAAY;IAAQ;IACxC,SACE;GACJ,CACF;EACF,CACF;EAGA,wBAAwB;EAExB,6BAA6B;EAC7B,4BAA4B;EAC5B,4CAA4C;EAC5C,4CAA4C;EAC5C,qCAAqC;EACrC,sBAAsB;EACtB,+BAA+B,CAAC,SAAS,EAAC,OAAO,CAAC,UAAU,EAAC,CAAC;EAC9D,yBAAyB;GACvB;GACA;IAAC,MAAM;IAAa,SAAS;GAA0D;GACvF;IAAC,MAAM;IAAc,SAAS;GAA4C;EAC5E;EACA,iBAAiB;EACjB,qCAAqC;EAErC,sBAAsB;EAEtB,uCAAuC;EACvC,wCAAwC;EACxC,0CAA0C;EAC1C,iCAAiC;EAEjC,4BAA4B;EAC5B,yBAAyB;EAEzB,yBAAyB;EACzB,wBAAwB;EACxB,qBAAqB,CAAC,SAAS,EAAC,OAAO,CAAC,QAAQ,OAAO,EAAC,CAAC;EAEzD,oBAAoB;EACpB,iBAAiB;EAEjB,aAAa;CACf;AACF"}
|
|
1
|
+
{"version":3,"file":"oxlint.js","names":[],"sources":["../src/oxlint.ts"],"sourcesContent":["import type {OxlintConfig} from 'oxlint'\n\n/**\n * Shared [oxlint](https://oxc.rs/docs/guide/usage/linter.html) config for Sanity plugins - the\n * same settings the [sanity-io/plugins](https://github.com/sanity-io/plugins) monorepo uses:\n * type-aware rules and TypeScript type checking enabled (via `oxlint-tsgolint`), warnings denied,\n * and the React, React Compiler, import, promise, a11y and unicorn rule sets turned on.\n *\n * Re-export it from an `oxlint.config.ts` next to the `package.json` that runs oxlint (the\n * repository root in a monorepo, otherwise the plugin directory):\n *\n * ```ts\n * export {default} from '@sanity/plugin-kit/oxlint'\n * ```\n *\n * To customize, extend it and add your own options ([`ignorePatterns` do not propagate through\n * `extends`](https://oxc.rs/docs/guide/usage/linter/config.html#extend-shared-configs), so spread\n * them explicitly when adding your own):\n *\n * ```ts\n * import sanityPluginKitOxlint from '@sanity/plugin-kit/oxlint'\n * import {defineConfig} from 'oxlint'\n *\n * export default defineConfig({\n * extends: [sanityPluginKitOxlint],\n * ignorePatterns: [...(sanityPluginKitOxlint.ignorePatterns ?? []), 'examples/**'],\n * })\n * ```\n *\n * Note: TypeScript config files require the Node-based `oxlint` package and Node `>=22.18`.\n *\n * @public\n */\nconst config: OxlintConfig = {\n plugins: ['typescript', 'unicorn', 'react', 'react-perf', 'oxc', 'import', 'jsx-a11y', 'promise'],\n ignorePatterns: ['**/.sanity/*', '**/dist/*', '**/sanity.types.ts'],\n options: {\n denyWarnings: true,\n reportUnusedDisableDirectives: 'error',\n typeAware: true,\n typeCheck: true,\n },\n categories: {\n correctness: 'error',\n suspicious: 'error',\n perf: 'error',\n },\n rules: {\n 'no-underscore-dangle': 'off',\n 'consistent-function-scoping': 'off',\n 'eslint/no-restricted-imports': [\n 'error',\n {\n paths: [\n {\n name: 'lodash-es',\n message:\n \"Import from individual modules instead, e.g. `import debounce from 'lodash-es/debounce.js'`. Barrel imports are ~55% slower.\",\n },\n {\n name: 'date-fns',\n message:\n \"Import from individual modules instead, e.g. `import {startOfDay} from 'date-fns/startOfDay'`. Barrel imports are ~50% slower.\",\n },\n {\n name: 'date-fns-tz',\n message:\n 'Use the official `@date-fns/tz` package (TZDate, tz, tzOffset) with date-fns v4 instead, matching sanity core.',\n },\n {\n name: 'react',\n importNames: ['createElement'],\n message:\n 'Please use JSX instead of createElement, for example `createElement(Icon)` should be `<Icon />`',\n },\n {\n name: 'react',\n importNames: ['forwardRef'],\n message:\n 'forwardRef is unnecessary in React 19 — `ref` is a regular prop. Accept `ref` in your component props instead, e.g. `function Foo({ref, ...props}: Props & {ref?: Ref<T>}) {}`. See the sanity-plugin-best-practices skill.',\n },\n ],\n patterns: [\n {\n group: ['lodash.*', 'lodash/*', 'lodash'],\n message:\n \"Please use individual imports from 'lodash-es' instead, e.g. `import debounce from 'lodash-es/debounce.js'`.\",\n },\n ],\n },\n ],\n\n // React Compiler checks\n 'react/react-compiler': 'error',\n\n 'typescript/ban-ts-comment': 'error',\n 'typescript/no-deprecated': 'error',\n 'typescript/no-unnecessary-type-assertion': 'error',\n 'typescript/no-unnecessary-type-arguments': 'error',\n 'typescript/prefer-ts-expect-error': 'error',\n 'import/no-commonjs': 'error',\n 'import/no-unassigned-import': ['error', {allow: ['**/*.css']}],\n 'no-restricted-globals': [\n 'error',\n {name: '__dirname', message: 'Use path.dirname(fileURLToPath(import.meta.url)) instead'},\n {name: '__filename', message: 'Use fileURLToPath(import.meta.url) instead'},\n ],\n 'react/jsx-key': 'error',\n 'unicorn/no-abusive-eslint-disable': 'error',\n // Not relevant as we use the modern jsx-runtime transform\n 'react-in-jsx-scope': 'off',\n // Not relevant due to React Compiler\n 'react_perf/jsx-no-new-array-as-prop': 'off',\n 'react_perf/jsx-no-new-object-as-prop': 'off',\n 'react_perf/jsx-no-new-function-as-prop': 'off',\n 'react_perf/jsx-no-jsx-as-prop': 'off',\n // False negatives\n 'jsx_a11y/anchor-is-valid': 'off',\n 'jsx_a11y/no-autofocus': 'off',\n // Handy rules that are disabled by default\n 'react/exhaustive-deps': 'error',\n 'react/rules-of-hooks': 'error',\n 'eslint/no-console': ['error', {allow: ['warn', 'error']}],\n // Requires polyfills for older browsers\n 'no-array-reverse': 'off',\n 'no-array-sort': 'off',\n // Too noisy, common in callbacks/closures\n 'no-shadow': 'off',\n },\n}\n\nexport default config\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,SAAuB;CAC3B,SAAS;EAAC;EAAc;EAAW;EAAS;EAAc;EAAO;EAAU;EAAY;CAAS;CAChG,gBAAgB;EAAC;EAAgB;EAAa;CAAoB;CAClE,SAAS;EACP,cAAc;EACd,+BAA+B;EAC/B,WAAW;EACX,WAAW;CACb;CACA,YAAY;EACV,aAAa;EACb,YAAY;EACZ,MAAM;CACR;CACA,OAAO;EACL,wBAAwB;EACxB,+BAA+B;EAC/B,gCAAgC,CAC9B,SACA;GACE,OAAO;IACL;KACE,MAAM;KACN,SACE;IACJ;IACA;KACE,MAAM;KACN,SACE;IACJ;IACA;KACE,MAAM;KACN,SACE;IACJ;IACA;KACE,MAAM;KACN,aAAa,CAAC,eAAe;KAC7B,SACE;IACJ;IACA;KACE,MAAM;KACN,aAAa,CAAC,YAAY;KAC1B,SACE;IACJ;GACF;GACA,UAAU,CACR;IACE,OAAO;KAAC;KAAY;KAAY;IAAQ;IACxC,SACE;GACJ,CACF;EACF,CACF;EAGA,wBAAwB;EAExB,6BAA6B;EAC7B,4BAA4B;EAC5B,4CAA4C;EAC5C,4CAA4C;EAC5C,qCAAqC;EACrC,sBAAsB;EACtB,+BAA+B,CAAC,SAAS,EAAC,OAAO,CAAC,UAAU,EAAC,CAAC;EAC9D,yBAAyB;GACvB;GACA;IAAC,MAAM;IAAa,SAAS;GAA0D;GACvF;IAAC,MAAM;IAAc,SAAS;GAA4C;EAC5E;EACA,iBAAiB;EACjB,qCAAqC;EAErC,sBAAsB;EAEtB,uCAAuC;EACvC,wCAAwC;EACxC,0CAA0C;EAC1C,iCAAiC;EAEjC,4BAA4B;EAC5B,yBAAyB;EAEzB,yBAAyB;EACzB,wBAAwB;EACxB,qBAAqB,CAAC,SAAS,EAAC,OAAO,CAAC,QAAQ,OAAO,EAAC,CAAC;EAEzD,oBAAoB;EACpB,iBAAiB;EAEjB,aAAa;CACf;AACF"}
|