eslint-plugin-unicorn
eslint-plugin-unicorn copied to clipboard
`prefer-string-slice` bad autofix from `.substr()`
let string = "::";
// Prefer `String#slice()` over `String#substr()`.
// eslint(unicorn/prefer-string-slice)
let eslintError = string.substr(-2, 2);
^^^^^^^^^^^^^^^^^^^^
// After applying fix:
let fixed = string.slice(-2, -2 + 2);
eslintError // "::"
fixed // ""
// Uncaught AssertionError [ERR_ASSERTION]: '::' == ''
assert.equal(eslintError, fixed)