What version of Oxlint are you using?
1.59.0
What command did you run?
No response
What does your .oxlintrc.json (or oxlint.config.ts) config file look like?
What happened?
Given the code below:
someVar.replaceAll(/foo/gi, 'bar')
oxlint reports an error saying the regex should be replaced with a plain string 'foo' but that would result in different runtime behaviour as the replace would no longer be case-insensitive.
This works correctly in the original/JavaScript version of the unicorn/prefer-string-replace-all rule. Looking at the code the issues seems to be the difference between the following lines, the JavaScript version will only suggest replacing with a string if the only regex flags are g, u or v whereas the rust implementation in oxlint only checks if the g flag is set:
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/add2138bd8852592d3f75bb55cf0c1de8a63633a/rules/prefer-string-replace-all.js#L21
|
if !reg_exp_literal.regex.flags.contains(RegExpFlags::G) { |
What version of Oxlint are you using?
1.59.0
What command did you run?
No response
What does your
.oxlintrc.json(oroxlint.config.ts) config file look like?{ "$schema": "./node_modules/oxlint/configuration_schema.json", "plugins": [ "unicorn" ], "env": { "builtin": true }, "options": { "reportUnusedDisableDirectives": "off", "typeAware": false, "typeCheck": false }, "categories": { "correctness": "off", "nursery": "off", "pedantic": "off", "perf": "off", "restriction": "off", "style": "off", "suspicious": "off" }, "rules": { "unicorn/prefer-string-replace-all": "error" } }What happened?
Given the code below:
oxlint reports an error saying the regex should be replaced with a plain string
'foo'but that would result in different runtime behaviour as the replace would no longer be case-insensitive.This works correctly in the original/JavaScript version of the
unicorn/prefer-string-replace-allrule. Looking at the code the issues seems to be the difference between the following lines, the JavaScript version will only suggest replacing with a string if the only regex flags areg,uorvwhereas the rust implementation in oxlint only checks if thegflag is set:https://github.com/sindresorhus/eslint-plugin-unicorn/blob/add2138bd8852592d3f75bb55cf0c1de8a63633a/rules/prefer-string-replace-all.js#L21
oxc/crates/oxc_linter/src/rules/unicorn/prefer_string_replace_all.rs
Line 136 in ae45312