-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(lint): modernize string and array checks with prefer-includes and prefer-string-starts-ends-with #11146
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?
fix(lint): modernize string and array checks with prefer-includes and prefer-string-starts-ends-with #11146
Changes from all commits
eb6595f
d6542d9
bab7cb5
4abdb0b
b1d4a91
3a8dec8
78c0369
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,6 @@ import * as readline from "readline"; | |
| import { FirebaseError } from "./error"; | ||
| import { logger } from "./logger"; | ||
|
|
||
| const DATA_LINE_REGEX = /^data: /; | ||
|
|
||
| const BANDWIDTH_NOTE = | ||
| "NOTE: The numbers reported here are only estimates of the data" + | ||
| " payloads from read operations. They are NOT a valid measure of your bandwidth bill."; | ||
|
|
@@ -25,11 +23,14 @@ const COLLAPSE_WILDCARD = ["$wildcard"]; | |
|
|
||
| // 'static' helper methods | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| export function extractJSON(line: string, input: any): string | null { | ||
| if (!input && !DATA_LINE_REGEX.test(line)) { | ||
| if (!input && !line.startsWith("data: ")) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the prefix check has been modernized to line.startsWith('data: ') (which is 6 characters long), the subsequent line.substring(5) on line 30 is now inconsistent as it leaves a leading space in the string before parsing. Consider updating it to line.substring(6) or line.slice(6) to cleanly remove the entire prefix.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please fix
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in commit d6542d9: Updated |
||
| return null; | ||
| } else if (!input) { | ||
| line = line.substring(5); | ||
| line = line.substring(6); | ||
| } | ||
| try { | ||
| return JSON.parse(line); | ||
|
|
@@ -38,10 +39,16 @@ export function extractJSON(line: string, input: any): string | null { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| export function pathString(path: string[]): string { | ||
| return `/${path ? path.join("/") : ""}`; | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| export function formatNumber(num: number) { | ||
| const parts = num.toFixed(2).split("."); | ||
| parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); | ||
|
|
@@ -51,6 +58,9 @@ export function formatNumber(num: number) { | |
| return parts.join("."); | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| export function formatBytes(bytes: number) { | ||
| const threshold = 1000; | ||
| if (Math.round(bytes) < threshold) { | ||
|
|
@@ -66,6 +76,9 @@ export function formatBytes(bytes: number) { | |
| return formatNumber(formattedBytes) + " " + units[u]; | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| export function extractReadableIndex(query: Record<string, any>): string { | ||
| if (query.orderBy) { | ||
| return query.orderBy; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.