Skip to content

Conversation

@btea
Copy link
Contributor

@btea btea commented Aug 8, 2025

When determining the value of the first letter of a string, using strict equality is more efficient than startsWith. refer to link

@changeset-bot
Copy link

changeset-bot bot commented Aug 8, 2025

🦋 Changeset detected

Latest commit: 2bd1290

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-regexp Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@btea btea changed the title refctor: replace startsWith with strict equality refctor: replace indexOf with strict equality Aug 8, 2025
@ota-meshi ota-meshi merged commit 15ff713 into ota-meshi:master Aug 8, 2025
11 checks passed
Copy link
Owner

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@btea btea deleted the refactor/replace-startsWith branch August 8, 2025 03:24
@btea
Copy link
Contributor Author

btea commented Aug 8, 2025

https://typescript-eslint.io/rules/prefer-string-starts-ends-with#options Can we enable rule options configuration in the project?

@ota-meshi
Copy link
Owner

Is there a rule that reports str.startsWith('c') instead?
If there isn't a rule, I'm hesitant to change the option because it would require a human to manually review them 🤔

@btea
Copy link
Contributor Author

btea commented Aug 8, 2025

typescript-eslint doesn't seem to have a relevant rule at the moment. 😦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants