{"name":"@putout/plugin-regexp","version":"10.0.0","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin helps with regexp","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-regexp#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://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":{"regexp-tree":"^0.1.21","try-catch":"^3.0.0"},"keywords":["putout","putout-plugin","plugin","regexp"],"devDependencies":{"@putout/eslint-flat":"^2.0.0","@putout/plugin-remove-useless-escape":"*","@putout/test":"^12.0.0","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^25.0.1","madrun":"^10.0.0","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=38"},"license":"MIT","engines":{"node":">=18"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-regexp@10.0.0","gitHead":"b5bebbfcbadc986a9e586c7694039960b33a4702","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"22.14.0","_npmVersion":"11.1.0","dist":{"integrity":"sha512-oISppaFndgoDeO4YrEAeRdb4UfCkjYAr0gN1WjmfefrGI8EIsgYGiJZqaBXnTW3psLhg4RF9+ltKn0EKGisSug==","shasum":"17964cfb5c41ac411573ca20414f9b06955e4c23","tarball":"http://registry-npm.ywwl.com/@putout/plugin-regexp/download/@putout/plugin-regexp-10.0.0.tgz","fileCount":13,"unpackedSize":18347,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFNEWXl+i0r7+qmSJlgK+aSgwRq8aPL6Tb9eQLRERGHxAiEAol9mp9Jqu4PxoNAgnf562E5qirgctjntuQfV+K9raNg="}],"size":5356,"noattachment":false,"key":"/@putout/plugin-regexp/-/@putout/plugin-regexp-10.0.0.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-regexp_10.0.0_1741021170823_0.24960928570839314"},"_hasShrinkwrap":false,"readme":"# @putout/plugin-regexp [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-regexp.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-regexp\"npm\"\n\n> Regular expressions are patterns used to match character combinations in strings.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin helps with **Regular Expressions**.\n\n## Install\n\n```\nnpm i @putout/plugin-regexp -D\n```\n\n## Rules\n\n- ✅ [apply-ends-with](#apply-ends-with);\n- ✅ [apply-literal-notation](#apply-literal-notation);\n- ✅ [apply-starts-with](#apply-starts-with);\n- ✅ [convert-replace-to-replace-all](#convert-replace-to-replace-all);\n- ✅ [convert-to-string](#convert-to-string);\n- ✅ [optimize](#optimize);\n- ✅ [remove-useless-group](#remove-useless-group);\n- ✅ [remove-useless-regexp](#remove-useless-regexp);\n- ✅ [types.js](#types.js);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"regexp/apply-literal-notation\": \"on\",\n        \"regexp/apply-starts-with\": \"on\",\n        \"regexp/apply-ends-with\": \"on\",\n        \"regexp/optimize\": \"on\",\n        \"regexp/convert-to-string\": \"on\",\n        \"regexp/convert-replace-to-replace-all\": \"on\",\n        \"regexp/remove-useless-group\": \"on\",\n        \"regexp/remove-useless-regexp\": \"on\"\n    }\n}\n```\n\n## optimize\n\n### ❌ Example of incorrect code\n\n```js\nconst a = /(ab|ab)/;\n```\n\n### ✅ Example of correct code\n\n```js\nconst a = /(ab)/;\n```\n\n## apply-literal-notation\n\n### ❌ Example of incorrect code\n\n```js\nconst a = new RegExp('hello', 'i');\n```\n\n### ✅ Example of correct code\n\n```js\nconst a = /hello/i;\n```\n\n## apply-starts-with\n\n> The `startsWith()` method determines whether a string begins with the characters of a specified string, returning `true` or `false` as appropriate.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)\n\n**RegExp** is overkill for such a simple task as determining that string located at the beginning. Check it out in 🐊 [**Putout Editor**](https://putout.cloudcmd.io/#/gist/79e3e41c3491fb8c45fb03580e42ef20/89971d2d6528ee78df4c2a0d6271179560f76cc1).\n\n### ❌ Example of incorrect code\n\n```js\n/^hello/.test(a);\n```\n\n### ✅ Example of correct code\n\n```js\na.startsWith('hello');\n```\n\n### Comparison\n\nLinter | Rule | Fix\n--------|-------|------------|\n🐊 **Putout**| [`regexp/apply-starts-with`](https://github.com/coderaiser/putout/tree/master/packages/plugin-regexp#apply-starts-with)| ✅\n🦕 **TypeScript ESLint** | [`prefer-string-starts-ends-with`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md#prefer-string-starts-ends-with) | ✅\n\n## apply-ends-with\n\n> The `startsWith()` method determines whether a string ends with the characters of a specified string, returning `true` or `false` as appropriate.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)\n\n**RegExp** is overkill for such a simple task as determining that string located at the end.\n\n### ❌ Example of incorrect code\n\n```js\n/hello$/.test(a);\n```\n\n### ✅ Example of correct code\n\n```js\na.endsWith('hello');\n```\n\n### Comparison\n\nLinter | Rule | Fix\n--------|-------|------------|\n🐊 **Putout**| [`regexp/apply-ends-with`](https://github.com/coderaiser/putout/tree/master/packages/plugin-regexp#apply-ends-with)| ✅\n🦕 **TypeScript ESLint** | [`prefer-string-starts-ends-with`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md#prefer-string-starts-ends-with) | ✅\n\n## convert-to-string\n\n### ❌ Example of incorrect code\n\n```js\n'hello'.replace(/hello/, 'world');\n```\n\n### ✅ Example of correct code\n\n```js\n'hello'.replace('hello', 'world');\n```\n\n## convert-replace-to-replace-all\n\nSimplify code according to [string-replace-all](https://github.com/tc39/proposal-string-replaceall).\n\n### ❌ Example of incorrect code\n\n```js\n'hello'.replace(/hello/g, 'world');\n```\n\n### ✅ Example of correct code\n\n```js\n'hello'.replaceAll('hello', 'world');\n```\n\n## remove-useless-group\n\n### ❌ Example of incorrect code\n\n```js\n/(hello)/.test(str);\n```\n\n### ✅ Example of correct code\n\n```js\n/hello/.test(str);\n```\n\n## remove-useless-regexp\n\n### ❌ Example of incorrect code\n\n```js\nconst a = /^\\.hello$/.test(str);\n```\n\n### ✅ Example of correct code\n\n```js\nconst a = str === '.hello';\n```\n\n## License\n\nMIT\n","publish_time":1741021170986,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1741021170986,"dist-tags":{"latest":"14.0.0"}}