Repository navigation
Enable eslint rule quote-props - #1795
Conversation
|
|
WalkthroughThis PR updates ESLint stylistic rules and converts several object keys to quoted string form across client, core, and server files. It also normalizes key syntax in a flag animation duration map. No runtime logic or control flow changes. Changes
Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/core/CustomFlag.ts (1)
3-12: Use a typed union for special animation names; enforce completeness at compile timeSwitch from Record<string, number> to a typed union so missing/extra keys are caught during development. Keep the keys quoted for ESLint.
Apply this diff to the map declaration to assert coverage:
-const ANIMATION_DURATIONS: Record<string, number> = { +const ANIMATION_DURATIONS = { "bright-rainbow": 4000, "copper-glow": 3000, "gold-glow": 3000, "lava": 6000, "neon": 3000, "rainbow": 4000, "silver-glow": 3000, "water": 6200, -}; +} as const satisfies Record<FlagAnimation, number>;Add this type outside the block:
type FlagAnimation = | "bright-rainbow" | "copper-glow" | "gold-glow" | "lava" | "neon" | "rainbow" | "silver-glow" | "water";eslint.config.js (1)
93-109: Consider using the stylistic plugin variant of quote-props for consistencyYou’re already using @stylistic/ts for other stylistic rules. Using its quote-props keeps the rule source consistent and avoids future confusion over which variant is active.
Apply this diff:
- "quote-props": ["error", "consistent-as-needed"], + "@stylistic/ts/quote-props": ["error", "consistent-as-needed"],
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
eslint.config.js(1 hunks)src/client/Cosmetics.ts(1 hunks)src/core/CustomFlag.ts(1 hunks)src/server/Cloudflare.ts(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/client/Cosmetics.ts (1)
src/client/jwt.ts (1)
getAuthHeader(74-78)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Deploy to openfront.dev
🔇 Additional comments (3)
src/server/Cloudflare.ts (2)
72-74: LGTM: quoted "Authorization" header aligns with quote-props and keeps semanticsGood move to a quoted string key; conventional "Authorization" casing is retained and consistent across server code.
187-199: LGTM: quoted object keys for Cloudflared configQuoting "ingress" and "tunnel" makes the object consistent with "credentials-file" under quote-props: consistent-as-needed. No runtime impact on yaml output.
eslint.config.js (1)
84-86: LGTM: quoted rule keys are consistent with quote-propsQuoting "eqeqeq" and "indent" aligns with the new stylistic rule and with other dashed rule keys in this object.
| headers: { | ||
| "Content-Type": "application/json", | ||
| authorization: getAuthHeader(), | ||
| "authorization": getAuthHeader(), | ||
| }, |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Only set Authorization when present and standardize header case
getAuthHeader() returns an empty string when no token (see src/client/jwt.ts). Sending an empty Authorization header can trigger unnecessary CORS preflights and confuse the server. Also, use the conventional "Authorization" casing for consistency with src/server/Cloudflare.ts.
Apply this diff to build the headers without an empty Authorization, and align casing:
headers: {
- "Content-Type": "application/json",
- "authorization": getAuthHeader(),
+ "Content-Type": "application/json",
+ ...(auth ? { "Authorization": auth } : {}),
},Add this just above the fetch call:
const auth = getAuthHeader();Optional: verify other places where getAuthHeader() is used to avoid sending empty headers.
🏁 Script executed:
#!/bin/bash
rg -n --hidden --glob '!node_modules' 'getAuthHeader\(' -A 3 -B 3Length of output: 816
Guard against empty Authorization header and unify casing
getAuthHeader() returns an empty string when there’s no token. Sending "authorization": "" can trigger unnecessary CORS preflights and confuse the server. Also, use the conventional "Authorization" casing to match src/server/Cloudflare.ts.
Locations to update:
- src/client/Cosmetics.ts (around lines 41–47)
Apply this diff:
// just above the fetch call
+ const auth = getAuthHeader();
return fetch(`${getApiBase()}/cosmetics/${itemId}/purchase`, {
method: "POST",
- headers: {
- "Content-Type": "application/json",
- "authorization": getAuthHeader(),
- },
+ headers: {
+ "Content-Type": "application/json",
+ ...(auth ? { "Authorization": auth } : {}),
+ },
body: JSON.stringify({ priceId }),
});No other uses of getAuthHeader() were found in the codebase.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| headers: { | |
| "Content-Type": "application/json", | |
| authorization: getAuthHeader(), | |
| "authorization": getAuthHeader(), | |
| }, | |
| // just above the fetch call | |
| const auth = getAuthHeader(); | |
| return fetch(`${getApiBase()}/cosmetics/${itemId}/purchase`, { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json", | |
| ...(auth ? { "Authorization": auth } : {}), | |
| }, | |
| body: JSON.stringify({ priceId }), | |
| }); |
🤖 Prompt for AI Agents
In src/client/Cosmetics.ts around lines 42 to 45, the request headers currently
always include "authorization": getAuthHeader(), which sends an empty string
when no token and uses nonstandard casing; change this to use the conventional
"Authorization" key and only add that header when getAuthHeader() returns a
non-empty value (e.g., compute const auth = getAuthHeader(); if (auth) set
headers["Authorization"] = auth), leaving other headers unchanged so no empty
Authorization header is sent.
## Description: Enable eslint rule `quote-props` ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced
## Description: Enable eslint rule `quote-props` ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced
## Description: Enable eslint rule `quote-props` ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced
Description:
Enable eslint rule
quote-propsPlease complete the following: