sindresorhus/eslint-plugin-unicorn

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

Chiusa

#982 aperta il 1 gen 2021

 (2 commenti) (2 reazioni) (0 assegnatari)JavaScript (468 fork)user submission
help wantednew rule

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 1g 16h) (399 PR mergiate in 30 g)

Descrizione

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');

Guida contributor