Skip to content

Enable eslint rule quote-props - #1795

Merged
scottanderson merged 1 commit into
mainfrom
eslint
Aug 13, 2025
Merged

scottanderson merged 1 commit into
mainfrom
eslint

Conversation

@scottanderson

Copy link
Copy Markdown
Contributor

Description:

Enable eslint rule quote-props

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Aug 13, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This 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

Cohort / File(s) Summary
Lint config updates
eslint.config.js
Adds/adjusts stylistic ESLint rules (array/object newline policies, arrow-parens, comma-dangle, function-call-argument-newline, property/curly newlines, no-multi-spaces, quote-props). Quotes some rule keys (e.g., "eqeqeq", "indent"). No runtime impact.
Header key quoting cleanup
src/client/Cosmetics.ts, src/server/Cloudflare.ts
Converts header/object keys to quoted strings (e.g., "authorization", "Authorization", "ingress", "tunnel"). Values and behavior unchanged.
CustomFlag mapping normalization
src/core/CustomFlag.ts
Rewrites ANIMATION_DURATIONS keys as quoted strings and removes sort-keys comments. Keeps existing durations and usage; no functional changes.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

DevOps - CICD

Suggested reviewers

  • drillskibo
  • evanpelle

Poem

Keys now quoted, neat and tight,
Lint rules nudge our code to right.
Flags still dance with timed delight,
Headers shine with proper might.
No new paths, no altered flight—
Just clean lines, crisp and bright. ✨


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@scottanderson
scottanderson merged commit af8bb9a into main Aug 13, 2025
@scottanderson
scottanderson deleted the eslint branch August 13, 2025 03:51
@github-project-automation github-project-automation Bot moved this from Triage to Complete in OpenFront Release Management Aug 13, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 time

Switch 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 consistency

You’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

📥 Commits

Reviewing files that changed from the base of the PR and between 087afc7 and 8ae8155.

📒 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 semantics

Good move to a quoted string key; conventional "Authorization" casing is retained and consistent across server code.


187-199: LGTM: quoted object keys for Cloudflared config

Quoting "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-props

Quoting "eqeqeq" and "indent" aligns with the new stylistic rule and with other dashed rule keys in this object.

Comment thread src/client/Cosmetics.ts
Comment on lines 42 to 45
headers: {
"Content-Type": "application/json",
authorization: getAuthHeader(),
"authorization": getAuthHeader(),
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 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 3

Length 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.

Suggested change
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.

@github-project-automation github-project-automation Bot moved this from Complete to Development in OpenFront Release Management Aug 13, 2025
@scottanderson scottanderson linked an issue Aug 13, 2025 that may be closed by this pull request
@scottanderson scottanderson self-assigned this Aug 13, 2025
TheGiraffe3 pushed a commit that referenced this pull request Sep 4, 2025
## 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
mokizzz pushed a commit to mokizzz/OpenFrontIO that referenced this pull request Sep 4, 2025
## 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
DiesselOne pushed a commit to DiesselOne/OpenFrontIO that referenced this pull request Sep 6, 2025
## 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
@coderabbitai coderabbitai Bot mentioned this pull request Sep 29, 2025
4 tasks done

This branch was previously deployed

1 inactive deployment
staging — 8ae81550 Deployed Aug 13, 2025 by openfrontio[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

Enable various typescript and eslint rules

2 participants