Open
Description
Environment
Node version: 16.16.0
pnpm version: 7.15.0
Local ESLint version: 8.23.0
Operating System: macOS 13.0.1, M1 Pro
What parser are you using?
@typescript-eslint/parser
What did you do?
Forward slashes are not escaped in no-restricted-syntax.
Regex as below:
const extMatchingRex = /^(?:[\S\t]*[-.& ,+!@#$%\^*\(\);\/\|\<\>"\'?=:_\[\]\{\}~`\t])?(jpg|jpeg|png|gif|svg|webp|apng|pdf|doc|docx|ppt|pptx|xls|xlsx|txt|rtf|md|html|xml|zip|rar|7z|iso|exe|rmvb|avi|mpeg|mp4|m4v|mov|asf|flv|f4v|3gp|mp3|wma|wav|ape|flac|ogg|aac|m4a)(?:[-.& ,+!@#$%\^*\(\);\/\|\<\>"\'?=:_\[\]\{\}~`\t][\S\t]*)?$/
Usage as below:
{
selector: `Literal[value=${extMatchingRex}]`,
message: 'Use it uppercased.',
},
No luck putting my regex in a string or RegExp either.
What did you expect to happen?
It should match the following strings:
const jpg = 'jpg';
const jpeg = '.jpeg';
const mixed_png = 'This is a hh .png. hh file';
What actually happened?
Participation
- I am willing to submit a pull request for this issue.
Additional comments
As you can see, my forward slashed is well escaped, but it came up with the error above.
After I removed \/
, it went well... How to fix this?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Blocked