{"name":"@putout/plugin-package-json","version":"10.4.1","keywords":["putout","putout-plugin","plugin","package-json"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/plugin-package-json@10.4.1","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-package-json#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"57a49664af35e501064d462354bcdce3eb079dbd","tarball":"http://registry-npm.ywwl.com/@putout/plugin-package-json/download/@putout/plugin-package-json-10.4.1.tgz","fileCount":16,"integrity":"sha512-aI30g2g1ntaqGanA+ov58DLhkf4QLYwMprO9WIhJRZGJB1kHcFP9aBcyMHbJeeF6WdtUnTlMhTNF7ay7WK3qhw==","signatures":[{"sig":"MEYCIQCZ8iTGpaKQWHMhq+BkXKelvyUVQN5+VM5EQg1nfcPMpwIhANp7qHEQhnEAvYq2q9bWm45txDnWzZL2keHoVwQczvd+","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22021,"size":6369,"noattachment":false,"key":"/@putout/plugin-package-json/-/@putout/plugin-package-json-10.4.1.tgz"},"main":"lib/index.js","type":"module","engines":{"node":">=22"},"gitHead":"85bd98362d8224dd62b3bbf0881fde453be23a84","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"11.4.2","description":"🐊Putout plugin for package.json","directories":{},"_nodeVersion":"25.5.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","eslint":"^10.0.0-alpha.0","madrun":"^12.0.0","nodemon":"^3.0.1","@putout/test":"^15.0.0","eslint-plugin-n":"^17.0.0","@putout/eslint-flat":"^4.0.0","eslint-plugin-putout":"^30.0.0"},"peerDependencies":{"putout":">=41"},"_npmOperationalInternal":{"tmp":"tmp/plugin-package-json_10.4.1_1770408960038_0.5666142799247509","host":"s3://npm-registry-packages-npm-production"},"readme":"# @putout/plugin-package-json [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-package-json.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-package-json \"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin helps to automate fixing `package.json`.\n\n## Install\n\n```\nnpm i @putout/plugin-package-json -D\n```\n\n## Rules\n\n- ✅ [add-type](#add-type);\n- ✅ [apply-js-extension](#apply-js-extension);\n- ✅ [apply-https-to-repository-url](#apply-https-to-repository-url);\n- ✅ [remove-nyc](#remove-nyc);\n- ✅ [remove-commit-type](#remove-commit-type);\n- ✅ [remove-imports-nesting](#remove-imports-nesting);\n- ✅ [remove-exports-nesting](#remove-exports-nesting);\n- ✅ [remove-duplicate-keywords](#remove-duplicate-keywords);\n- ✅ [remove-dot-slash-from-bin](#remove-dot-slash-from-bin);\n- ✅ [remove-useless-exports](#remove-useless-exports);\n\n## Filesystem rules\n\n- ✅ [remove-exports-with-missing-files](#remove-exports-with-missing-files);\n- ✅ [find-file](#find-file);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"package-json/add-type\": \"on\",\n        \"package-json/apply-js-extension\": \"on\",\n        \"package-json/apply-https-to-repository-url\": \"on\",\n        \"package-json/remove-nyc\": \"on\",\n        \"package-json/remove-commit-type\": \"on\",\n        \"package-json/remove-imports-nesting\": \"on\",\n        \"package-json/remove-exports-nesting\": \"on\",\n        \"package-json/remove-dot-slash-from-bin\": \"bin\",\n        \"package-json/remove-exports-with-missing-files\": \"off\",\n        \"package-json/remove-useless-exports\": \"off\",\n        \"package-json/find-file\": \"off\"\n    }\n}\n```\n\n## add-type\n\nAdd [`type`](https://nodejs.org/dist/latest-v17.x/docs/api/packages.html#type) field to `package.json`:\n\n```diff\n{\n    \"name\": \"hello\",\n    \"version\": \"1.0.0\",\n+   \"type\": \"commonjs\"\n}\n```\n\n## apply-js-extension\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/31b208fae5f340b9d8a479c2d7475cd2/869370f138d0082cf67bb4372c62fb969bb98db5).\n\n```diff\n{\n  \"type\": \"module\",\n- \"main\": \"./lib/putout.mjs\",\n+ \"main\": \"./lib/putout.js\",\n  \"exports\": {\n    \".\": {\n      \"require\": \"./lib/index.cjs\",\n-     \"import\": \"./lib/index.mjs\"\n+     \"import\": \"./lib/index.js\"\n    },\n    \"./parse-error\": \"./lib/parse-error.cjs\",\n-   \"./ignores\": \"./lib/ignores.mjs\",\n+   \"./ignores\": \"./lib/ignores.js\",\n  },\n  \"bin\": {\n-   \"putout\": \"bin/tracer.mjs\"\n+   \"putout\": \"bin/tracer.js\"\n  }\n};\n```\n\n## apply-https-to-repository-url\n\nThe `git://` protocol for GitHub repos should not be used due [security concerns](https://github.blog/security/application-security/improving-git-protocol-security-github/).\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/63ab077723e3ff368fa4e3472f9a36f3/048984adbf078a7d153ea44100d3f03676aa02d5).\n\n```diff\n{\n  \"repository\": {\n    \"type\": \"git\",\n-   \"url\": \"git://github.com/coderaiser/putout.git\"\n+   \"url\": \"git+https://github.com/coderaiser/putout.git\"\n  }\n```\n\n## remove-nyc\n\n- additional fields in `package.json` produces more traffic then users of your package really need;\n- [c8](https://github.com/bcoe/c8) uses [same config name and format](https://github.com/bcoe/c8/blob/v7.3.5/lib/parse-args.js#L8) so transition between tools will be much easier;\n\n### ❌ Example of incorrect code\n\n`nyc` section in `package.json`:\n\n```json\n{\n    \"nyc\": {\n        \"check-coverage\": \"on\",\n        \"all\": \"on\",\n        \"exclude\": [\n            \"**/*.spec.js\",\n            \"**/fixture\",\n            \"test\",\n            \".*.js\"\n        ],\n        \"branches\": 100,\n        \"lines\": 100,\n        \"functions\": 100,\n        \"statements\": 100\n    }\n}\n```\n\n### ✅ Example of correct code\n\nFile `.nycrc.json`:\n\n```json\n{\n    \"check-coverage\": \"on\",\n    \"all\": \"on\",\n    \"exclude\": [\n        \"**/*.spec.js\",\n        \"**/fixture\",\n        \"test\",\n        \".*.js\"\n    ],\n    \"branches\": 100,\n    \"lines\": 100,\n    \"functions\": 100,\n    \"statements\": 100\n}\n```\n\n## remove-commit-type\n\nSince 🎁**Wisdom** [v14](https://github.com/coderaiser/wisdom/releases/tag/v14.0.0) `commitType` set to `colon` be default, so it can be dropped from `package.json` if it's value not `paren`:\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/eb12c902c8e99effc91ae44119d625d7/8e60d60b2c2e7bb28ca5b2eba61715a062ac5319).\n\n```diff\n{\n    \"name\": \"hello\",\n    \"version\": \"1.0.0\",\n    \"commitType\": \"colon\"\n}\n```\n\n## remove-duplicate-keywords\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/eb12c902c8e99effc91ae44119d625d7/8e60d60b2c2e7bb28ca5b2eba61715a062ac5319).\n\n```diff\n{\n    \"keywords\": [\n     \"putout\",\n     \"putout-plugin\",\n-    \"plugin\",\n-    \"putout\"\n+    \"plugin\"\n   ],\n}\n```\n\n## remove-useless-exports\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/111426a5251efe6702d705d388d4c63d/cc2f30061a4a7b169bb61afbb843592f2c664c82).\n\n```diff\n{\n-   \"exports\": {\n-       \".\": {}\n-     },\n}\n```\n\n## remove-dot-slash-from-bin\n\nFixes `npm` warnings:\n\n> \"npm warn publish bin[c8]\" script name was cleaned\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ef444a1679d00b8bb41a209e76499921/24a4a06d0db2d8b487b5ca5ff40290c8b3e24e3d).\n\n```diff\n{\n    \"bin\": {\n-       \"c8\": \"./bin/c8.js\"\n+       \"c8\": \"bin/c8.js\"\n    }\n}\n```\n\n## remove-imports-nesting\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3527617ece2bfd9c39875db50a8a6245/2f3c6248b7b0ab539212b747f3cd480dc77ce3f1).\n\n```diff\n{\n    \"imports\": {\n-       \"#get-imports\": {\n-         \"default\": \"./lib/shorten-imported-file/get-imports/index.js\"\n-       }\n+       \"#get-imports\": \"./lib/shorten-imported-file/get-imports/index.js\"\n    }\n}\n```\n\n## remove-exports-nesting\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/9939ae5f61016e4e6a17f1e92c0e2b5b/cfa3dea4221c6b783ed4f5b59259c8230a756337).\n\n```diff\n{\n    \"exports\": {\n-       \"./a.js\": {\n-         \"import\": \"./lib/a.js\"\n-       },\n+       \"./a.js\": \"./lib/a.js\"\n    }\n}\n```\n\n## find-file\n\nFind `package.json` inside of `.filesystem.json` and applies all other `package-json` rules.\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/325233d19fde0acacadbcf1f42dd3bb2/124a50fe0e92c6c3cab24f8b87c33b202dc3e540).\n\n```diff\n{\n    \"name\": \"hello\",\n    \"version\": \"1.0.0\",\n+   \"type\": \"commonjs\"\n}\n```\n\n## remove-exports-with-missing-files\n\nFind `package.json` inside of `.filesystem.json` and removes `exports` with missing files.\n\nCheckout in 🐊**Putout Editor**:\n\n- [`remove-exports-with-missing-files`](https://putout.cloudcmd.io/#/gist/c79a69b797ccd2d94499349150e65f7c/37a48a054b98299cb15e71c3eaeb23b0b919d62c);\n- [`find-keys`](https://putout.cloudcmd.io/#/gist/b138e991aa21ad0ffb562b4c6fe6290f/cca92b8b87ca9d91c0a280991a1558a5e3fc260b);\n- [`remove-keys`](https://putout.cloudcmd.io/#/gist/b2fa6fba917a22bfc676f01532b4794e/e5970eb901ef5b29f7c143f76df9a10148b69d9e);\n\n```diff\n__putout_processor_filesystem([\n    \"/\",\n    [\"/package.json\", `{\n        \"exports\": {\n            \"./parse-options\": \"./lib/parse-options/index.js\",\n-            \"./loader\": \"./lib/loader.mjs\"\n        }\n    }`],\n    \"/lib/\",\n    \"/lib/parse-options/\",\n    [\"/lib/parse-options/index.js\", \"export const a = 5\"],\n]);\n```\n\n## License\n\nMIT\n","publish_time":1770408960172,"_cnpm_publish_time":1770408960172,"dist-tags":{"latest":"11.3.0"}}