Repository navigation
Enable more stylistic rules - #1792
Conversation
|
|
WalkthroughUpdates 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
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 (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 tofor…ofand 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
📒 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
__dirnameusingfileURLToPath, but later the config usesimport.meta.dirnamefortsconfigRootDir. On older Node versions,import.meta.dirnameis not available.If needed, set
tsconfigRootDirto__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
| import pluginJs from "@eslint/js"; | ||
| import stylisticTs from "@stylistic/eslint-plugin"; |
There was a problem hiding this comment.
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.
## 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
## 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
## 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
Description:
Enable more stylistic rules.
Please complete the following: