{"name":"@putout/plugin-types","version":"5.1.0","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to transform code related to types assertions","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-types#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git://github.com/coderaiser/putout.git"},"scripts":{"test":"madrun test","watch:test":"madrun watch:test","lint":"madrun lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","fix:lint":"madrun fix:lint","coverage":"madrun coverage","report":"madrun report"},"dependencies":{},"keywords":["putout","putout-plugin","plugin","types"],"devDependencies":{"@putout/plugin-putout":"*","@putout/test":"^11.0.0","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^23.0.0","lerna":"^6.0.1","madrun":"^10.0.0","montag":"^1.2.1","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=36"},"license":"MIT","engines":{"node":">=18"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-types@5.1.0","gitHead":"d79864e3020b63800295c2462efc6188c35cff56","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"22.8.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Oy4e2/P2w56TedzIk5rh/u2Yd3EovMhjxnrAjMFI6R/h7MM8kQSwI4RQFCWTgxQcDvLfw0FS7uOw09eNSJNOkQ==","shasum":"1452dd1eb0e8bfcd4188f191a56232a433575593","tarball":"http://registry-npm.ywwl.com/@putout/plugin-types/download/@putout/plugin-types-5.1.0.tgz","fileCount":11,"unpackedSize":13606,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD6H4QxzxBbST0Olg/OvhMyGpC1m6RWjARoJufcAQm65gIhAJ0KwRxvwZ/zr4DiZCKt40Je8PnyrB5s1ec5Arg4XtPl"}],"size":4525,"noattachment":false,"key":"/@putout/plugin-types/-/@putout/plugin-types-5.1.0.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/plugin-types_5.1.0_1727101000544_0.6678569130168299"},"_hasShrinkwrap":false,"readme":"# @putout/plugin-types [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-types.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-types \"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to help with transforming code related to types.\n\n## Install\n\n```\nnpm i putout @putout/plugin-types -D\n```\n\n## Rules\n\n- ✅ [apply-is-array](#apply-is-array);\n- ✅ [convert-typeof-to-is-type](#convert-typeof-to-is-type);\n- ✅ [declare](#declare);\n- ✅ [remove-double-negations](#remove-double-negations);\n- ✅ [remove-useless-conversion](#remove-useless-conversion);\n- ✅ [remove-useless-constructor](#remove-useless-constructor);\n- ✅ [remove-useless-typeof](#remove-useless-typeof);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"types/declare\": \"on\",\n        \"types/convert-typeof-to-istype\": \"on\",\n        \"types/remove-useless-conversion\": \"on\",\n        \"types/remove-useless-constructor\": \"on\",\n        \"types/remove-double-negations\": \"on\",\n        \"types/remove-useless-typeof\": \"on\",\n        \"types/apply-is-array\": \"on\"\n    }\n}\n```\n\n## declare\n\nBased on [`@putout/operator-declare`](https://github.com/coderaiser/putout/tree/master/packages/operator-declare#putoutoperator-declare-).\nSupported assertions:\n\n- `isString`;\n- `isEmptyString`;\n- `isNumber`;\n- `isFn`;\n- `isBool`;\n- `isObject`;\n- `isUndefined`;\n- `isSymbol`;\n- `isNull`;\n- `isBigInt`;\n- `isArray`;\n- `isEmptyArray`;\n\n### ❌ Example of incorrect code\n\n```js\nisString('hello');\n```\n\n### ✅ Example of correct code\n\n```js\nconst isString = (a) => typeof a === 'string';\nisString('hello');\n```\n\nWhen you want to skip some declaration use `dismiss`:\n\n```json\n{\n    \"rules\": {\n        \"types/declare\": [\"on\", {\n            \"dismiss\": [\"isString\"]\n        }]\n    }\n}\n```\n\n## convert-typeof-to-is-type\n\n> The `typeof` operator returns a string indicating the type of the unevaluated operand.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof)\n\n### ❌ Example of incorrect code\n\n```js\nif (typeof a === 'boolean')\n    return x;\n```\n\n### ✅ Example of correct code\n\n```js\nconst isBool = (a) => typeof a === 'boolean';\n\nif (isBool(a))\n    return x;\n```\n\n## remove-useless-conversion\n\n### ❌ Example of incorrect code\n\n```js\nconst a = !![1].includes(1);\nconst b = Boolean([1].includes(1));\n```\n\n### ✅ Example of correct code\n\n```js\nconst a = [1].includes(1);\n```\n\n## remove-useless-constructor\n\n> Wrapper classes have surprising behaviour, such as `new Boolean(false)` evaluating to `true`.\n>\n> (c) [Google TypeScript Style Guide](https://google.github.io/styleguide/tsguide.html#primitive-types-wrapper-classes)\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to remove useless `constructor`. Use with [`new/remove-useless`](https://github.com/coderaiser/putout/tree/master/packages/plugin-new#readme).\n\n### ❌ Example of incorrect code\n\n```js\nconst s = String('hello');\nconst b = Boolean(false);\nconst n = Number(5);\n```\n\n### ✅ Example of correct code\n\n```js\nconst s = 'hello';\nconst b = false;\nconst n = 5;\n```\n\n## remove-double-negations\n\n> It is possible to use a couple of **NOT** operators (`!!`) in series to explicitly force the conversion of any value to the corresponding boolean primitive. The conversion is based on the \"truthyness\" or \"falsyness\" of the value.\n>\n> The same conversion can be done through the `Boolean` function.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_NOT)\n\n### ❌ Example of incorrect code\n\n```js\nif (!!a)\n    console.log('hi');\n```\n\n### ✅ Example of correct code\n\n```js\nif (a)\n    console.log('hi');\n```\n\n## remove-useless-typeof\n\n> The `typeof` operator returns a string indicating the type of the unevaluated operand.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof)\n\n### ❌ Example of incorrect code\n\n```js\ntypeof typeof 'hello';\n```\n\n### ✅ Example of correct code\n\n```js\ntypeof 'hello';\n```\n\n## apply-is-array\n\n> The `Array.isArray()` method determines whether the passed value is an `Array`.\n> When checking for `Array` instance, `Array.isArray()` is preferred over `instanceof` because it works through `iframes`.\n\n### ❌ Example of incorrect code\n\n```js\nx instanceof Array;\n```\n\n### ✅ Example of correct code\n\n```js\nconst {isArray} = Array;\nisArray(x);\n```\n\nIn case of using `inline` option:\n\n```json\n{\n    \"rules\": {\n        \"types/apply-is-array\": [\"on\", {\n            \"inline\": true\n        }]\n    }\n}\n```\n\n`Array.isArray` will be inlined:\n\n```js\nArray.isArray(x);\n```\n\n## License\n\nMIT\n\n## Comparison\n\nLinter | Rule | Fix\n--------|-------|------------|\n🐊 **Putout** | [`types`](https://github.com/coderaiser/putout/tree/master/packages/plugin-types#readme)| ✅\n⏣ **ESLint** | [`no-implicit-coercion`](https://eslint.org/docs/rules/no-implicit-coercion) | ✅\n\n## License\n\nMIT\n","publish_time":1727101000757,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1727101000757,"dist-tags":{"latest":"10.6.2"}}