1.0.3 • Published 3 years ago

eslint-plugin-lookbehind-assertions v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

eslint-plugin-lookbehind-assertions

An ESLint plugin that disallows the use of regular expression lookbehind assertions.

npm version License: MIT Twitter

Installation

npm install --save-dev eslint-plugin-lookbehind-assertions

Or

yarn add --dev eslint-plugin-lookbehind-assertions

Usage

Modify your .eslintrc

// .eslintrc.json
module.exports = {
  "plugins": [
    ...,
    "lookbehind-assertions"
  ],
  "rules": [
    ...,
    "lookbehind-assertions/no-lookbehind-assertions-regexp": "error"
  ]
  ...,
}

Rules

Rule IDDescription
no-lookbehind-assertions-regexpDisallows the use of regular expression lookbehind assertions

Examples

Examples of incorrect code:

let re = /(?<=ripe )orange/;
re = new RegExp('(?<=ripe )orange');

Examples of correct code:

let re = /\d+(?=%)/;
re = new RegExp('d+(?=%)');

License

MIT