sindresorhus/eslint-plugin-unicorn

Rule proposal: `prefer-regexp-dot-all`

Open

#982 opened on Jan 1, 2021

View on GitHub
 (2 comments) (2 reactions) (0 assignees)JavaScript (5,022 stars) (468 forks)user submission
help wantednew rule

Description

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll

https://github.com/tc39/proposal-regexp-dotall-flag

This could be auto-fixed as long as the regex doesn't contain a . pattern. If it does, we can do a suggestion instead.

Fail

/foo[^]bar/.test('foo\nbar');
/foo[\s\S]bar/.test('foo\nbar');
/foo[\S\s]bar/.test('foo\nbar');
/foo[\w\W]bar/.test('foo\nbar');
/foo[\W\w]bar/.test('foo\nbar');
/foo[\d\D]bar/.test('foo\nbar');
/foo[\D\d]bar/.test('foo\nbar');

Pass

/foo.bar/s.test('foo\nbar');

Contributor guide

Rule proposal: `prefer-regexp-dot-all` · sindresorhus/eslint-plugin-unicorn#982 | Good First Issue