JSPM

  • Created
  • Published
  • Downloads 11459
  • Score
    100M100P100Q139048F
  • License MIT

putout plugin helps whith regexp

Package Exports

  • @putout/plugin-regexp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@putout/plugin-regexp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@putout/plugin-regexp NPM version Dependency Status

putout plugin helps with Regular Expressions.

Install

npm i @putout/plugin-regexp -D

Rules

{
    "rules": {
        "regexp/simplify": "on",
        "regexp/optimize": "on",
        "regexp/convert-to-string": "on",
        "regexp/convert-replace-to-replace-all": "on"
    }
}

regexp/optimize

❌ Incorrect code example

const a = /(ab|ab)/;

✅ Correct code Example

const a = /(ab)/;

regexp/simplify

❌ Incorrect code example

const a = new RegExp('hello', 'i');

✅ Correct code Example

const a = /hello/i;

regexp/convert-to-string

❌ Incorrect code example

'hello'.replace(/hello/, 'world');

✅ Correct code Example

'hello'.replace('hello', 'world');

regexp/convert-replace-to-replace-all

❌ Incorrect code example

'hello'.replace(/hello/g, 'world');

✅ Correct code Example

'hello'.replaceAll('hello', 'world');

License

MIT