-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read the FAQ and my problem is not listed.
Repro
{
"rules": {
"@typescript-eslint/prefer-string-starts-ends-with": ["error"]
}
}export function isThreeCharPrefixMatch(str: string, candidate: string): boolean {
return str.substring(0, 3) === candidate;
}tsconfig: the default as generated by tsc --init
Expected Result
No error, since a substring call other than substring(0) can not be replaced with startsWith alone.
Actual Result
The following error was printed:
2:10 error Use 'String#startsWith' method instead @typescript-eslint/prefer-string-starts-ends-with
Additional Info
Consider the code with the change suggested by the linter:
export function isThreeCharPrefixMatchB(str: string, candidate: string): boolean {
return str.startsWith(candidate);
}Now
> isThreeCharPrefixMatch("int32", "in");
false
> isThreeCharPrefixMatchB("int32", "in");
true
Versions
| package | version |
|---|---|
@typescript-eslint/eslint-plugin |
5.4.0 |
@typescript-eslint/parser |
5.4.0 |
TypeScript |
4.5.2 |
ESLint |
8.2.0 |
node |
12.22.5 |
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin