npm.io
1.0.3 • Published 5 years ago

eslint-plugin-lookbehind-assertions

Licence
MIT
Version
1.0.3
Deps
0
Size
12 kB
Vulns
0
Weekly
0
Stars
4

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 ID Description
no-lookbehind-assertions-regexp Disallows 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

Keywords