-
Notifications
You must be signed in to change notification settings - Fork 109
Algolia improvements #2350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Algolia improvements #2350
Conversation
✅ Don't forget to add
|
| Name | Link |
|---|---|
| 🔨 Latest commit | 3df8255 |
| 🔍 Latest deploy log | https://app.netlify.com/projects/semgrep-docs-prod/deploys/68ed868fa0f9200008aa9ec1 |
| 😎 Deploy Preview | https://deploy-preview-2350--semgrep-docs-prod.netlify.app |
| 📱 Preview on mobile |
To edit notification comments on pull requests, go to your Netlify project configuration.
|
|
||
| // Update the count | ||
| const count = searchResults.length; | ||
| const plural = count === 1 ? 'result' : 'results'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semgrep identified an issue in your code:
Just so you know, we have a JS library that handles pluralization of words. You can call pluralize('word', number) and it'll output either "word" or "words". It understands irregular words, including stuff like "have"/"has".
To resolve this comment:
✨ Commit Assistant Fix Suggestion
- Import the
pluralizelibrary at the top of your file if it's not already imported:import pluralize from 'pluralize'; - Replace the line
const plural = count === 1 ? 'result' : 'results';withconst plural = pluralize('result', count);
This will handle all pluralization logic, including irregular forms, more reliably.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by we_have_a_pluralize_library.
You can view more details about this finding in the Semgrep AppSec Platform.
Can we improve Algolia instead of implementing a new search engine?