Skip to content

Enable more stylistic rules - #1792

Merged
scottanderson merged 3 commits into
mainfrom
eslint
Aug 12, 2025
Merged

scottanderson merged 3 commits into
mainfrom
eslint

Conversation

@scottanderson

Copy link
Copy Markdown
Contributor

Description:

Enable more stylistic rules.

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.

@scottanderson scottanderson added this to the v26 milestone Aug 12, 2025
@coderabbitai

coderabbitai Bot commented Aug 12, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Updates ESLint configuration to add and adjust stylistic and TypeScript rules, disable some core overlaps, and add TODO comments. In server code, adds an ESLint disable comment for a for-loop to silence a prefer-for-of rule. No functional code changes or exported API modifications.

Changes

Cohort / File(s) Summary
ESLint configuration
eslint.config.js
Reordered imports; added @stylistic/ts rules (indent, semi, space-infix-ops, type-annotation-spacing); disabled core space-infix-ops; turned off @typescript-eslint/no-unused-vars; added prefer-for-of, max-depth, max-lines, max-lines-per-function, no-loss-of-precision; inserted TODO comments; structure unchanged.
Server playlist code style suppression
src/server/MapPlaylist.ts
Added ESLint disable comment for @typescript-eslint/prefer-for-of on a single for-loop; no logic changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

Feature - Test

Poem

Lint winds whisper through the code at night,
Indents align, colons click just right.
A loop stands firm with a tiny shield,
Comments guard style on the compile field.
No logic stirred, just cleaner air—
The linter smiles: “Proceed with care.”


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 087afc7 into main Aug 12, 2025
@scottanderson
scottanderson deleted the eslint branch August 12, 2025 03:42
@github-project-automation github-project-automation Bot moved this from Triage to Complete in OpenFront Release Management Aug 12, 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 (1)
src/server/MapPlaylist.ts (1)

131-133: Drop the disable by using a for…of loop (no behavior change).

You don’t use the index or any element from maps. Switch to for…of and remove the lint-disable to keep the code clean.

-    // eslint-disable-next-line @typescript-eslint/prefer-for-of
-    for (let i = 0; i < maps.length; i++) {
+    for (const _ of maps) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9e5aa0 and 65e02d5.

📒 Files selected for processing (2)
  • eslint.config.js (4 hunks)
  • src/server/MapPlaylist.ts (1 hunks)
⏰ 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 (1)
eslint.config.js (1)

7-8: Confirm Node runtime supports import.meta.dirname; otherwise, use __dirname.

You already compute __dirname using fileURLToPath, but later the config uses import.meta.dirname for tsconfigRootDir. On older Node versions, import.meta.dirname is not available.

If needed, set tsconfigRootDir to __dirname:

// inside languageOptions.parserOptions
tsconfigRootDir: __dirname,

Please run ESLint locally to verify no runtime errors:

  • npx eslint . --max-warnings=0
  • npx eslint --print-config eslint.config.js > /tmp/eslint-effective-config.json

Comment thread eslint.config.js
Comment on lines +4 to +5
import pluginJs from "@eslint/js";
import stylisticTs from "@stylistic/eslint-plugin";

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.

⚠️ Potential issue

Fix @Stylistic plugin wiring; current rule names won’t resolve.

The rules are referenced under @stylistic/ts/* (e.g., @stylistic/ts/indent, @stylistic/ts/semi), but those live under the main plugin namespace (@stylistic/*). Only TS-specific rules (like type-annotation-spacing) use the ts/ sub-namespace. As written, ESLint will error with “Definition for rule '...not found'”.

Apply the following diff:

@@
-import pluginJs from "@eslint/js";
-import stylisticTs from "@stylistic/eslint-plugin";
+import pluginJs from "@eslint/js";
+import stylistic from "@stylistic/eslint-plugin";
@@
   {
     plugins: {
-      "@stylistic/ts": stylisticTs,
+      "@stylistic": stylistic,
     },
     rules: {
       // Enable rules
-      // '@stylistic/ts/quotes': ['error', 'single'], TODO: Enable this rule, https://github.com/openfrontio/OpenFrontIO/issues/1788
-      "@stylistic/ts/indent": ["error", 2],
-      "@stylistic/ts/semi": "error",
-      "@stylistic/ts/space-infix-ops": "error",
-      "@stylistic/ts/type-annotation-spacing": [
+      // '@stylistic/quotes': ['error', 'single'], TODO: Enable this rule, https://github.com/openfrontio/OpenFrontIO/issues/1788
+      "@stylistic/indent": ["error", 2],
+      "@stylistic/semi": "error",
+      "@stylistic/space-infix-ops": "error",
+      "@stylistic/ts/type-annotation-spacing": [
         "error",
         {
           after: true,
           before: true,
           overrides: {
             colon: {
               before: false,
             },
           },
         },
       ],

Also applies to: 49-52, 54-57, 58-69

🤖 Prompt for AI Agents
In eslint.config.js around lines 4-5 (and also adjust occurrences at 49-52,
54-57, 58-69), the @stylistic plugin is wired incorrectly so rule names like
@stylistic/ts/indent won't resolve; update the plugin reference and rule
namespace usage so rules reference @stylistic/* (e.g., @stylistic/indent,
@stylistic/semi) while leaving only actual TypeScript-specific rules under ts/*
(e.g., ts/type-annotation-spacing), and modify the plugin import/registration
and all rule keys accordingly to use the correct main plugin namespace to
prevent “Definition for rule '...not found'” errors.

@github-project-automation github-project-automation Bot moved this from Complete to Development in OpenFront Release Management Aug 12, 2025
TheGiraffe3 pushed a commit that referenced this pull request Sep 4, 2025
## Description:

Enable more stylistic rules.

## 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 more stylistic rules.

## 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 more stylistic rules.

## 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

This branch was previously deployed

1 inactive deployment
staging — 65e02d50 Deployed Aug 12, 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.

3 participants