Skip to content

linter: unicorn/prefer-string-slice .substr->.slice causes a bug #17933

@elnygren

Description

@elnygren

What version of Oxlint are you using?

latest

What command did you run?

oxlint --fix

What does your .oxlintrc.json config file look like?

// your config here

What happened?

str.substr(start, LENGTH) <-- note the difference!
str.substring(start, end)
str.slice(start, end)

oxlint replaces .substr with .slice without recalculating the second argument, which causes a bug.

.substr(11, 8) should NOT be fixed to .slice(11, 8) but it is currently

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions