Skip to content

feat: add linter flow (#61) - #62

Merged
adminvns merged 3 commits into
mainfrom
feature/61-linting
Jan 12, 2026
Merged

adminvns merged 3 commits into
mainfrom
feature/61-linting

Conversation

@adminvns

@adminvns adminvns commented Jan 12, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added automated code linting via a GitHub Actions workflow to maintain code quality.
  • Documentation

    • Added lint status badge to README.
  • Chores

    • Introduced ESLint configuration for consistent code formatting and linting.
    • Added lint and lint:fix npm scripts.
    • Added ESLint as a development dependency.

✏️ Tip: You can customize this high-level summary in your review settings.

@adminvns

adminvns commented Jan 12, 2026 •

Copy link
Copy Markdown
Owner Author

✅ Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Jan 12, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

Adds ESLint configuration, npm scripts, and a GitHub Actions workflow for linting; standardizes formatting across files and removes unused next parameters from route handlers and the error middleware signature.

Changes

Cohort / File(s) Summary
ESLint config & CI
.github/workflows/lint.yml, eslint.config.js, package.json
Add GitHub Actions workflow .github/workflows/lint.yml (runs Node 22, npm ci, npm run lint), new eslint.config.js exporting ESLint config and ignores, add lint / lint:fix scripts and eslint devDependency in package.json.
Route handler signatures & formatting
api/routes/orders.js, api/routes/products.js
Remove unused next parameter from all route callbacks, normalize indentation/quotes/JSON responses, collapse redundant response blocks (POST). No functional behavior changes.
Visitor routes formatting
api/routes/visitors.js
Whitespace and indentation normalization only; no behavioral changes.
App error middleware & export style
app.js
Adjust formatting and change error-handler signature to omit next (from (err, req, res, next) to (err, req, res)), and normalize module.exports = app;.
Documentation
README.md
Insert lint status badge line near existing badges.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add linter flow' directly and clearly describes the main change: introducing ESLint linting infrastructure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/61-linting

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to Reviews > Disable Cache setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 11561d7 and f80e514.

📒 Files selected for processing (1)
  • .github/workflows/lint.yml

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@adminvns adminvns self-assigned this Jan 12, 2026
@adminvns
adminvns temporarily deployed to feature/61-linting - testapi PR #62 January 12, 2026 19:00 — with Render Destroyed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In @.github/workflows/lint.yml:
- Line 19: Update the GitHub Actions workflow matrix entry that sets
node-version (the node-version: '18' value in the lint workflow) to a supported
LTS like '22' or '24' (e.g., change node-version: '18' → node-version: '22') so
the CI runs on a current LTS; ensure any job matrices or tooling that depend on
Node.js version are adjusted accordingly.

In @api/routes/products.js:
- Around line 44-48: The response JSON in the router.patch('/:productID' route
contains a message string with an unintended leading space; update the message
value in the route handler (router.patch('/:productID', ...)) from ' Product
updated successfully!' to 'Product updated successfully!' so the API returns the
correct string without the extra space.
- Around line 52-56: The response message in the DELETE route handler for
router.delete('/:productID', (req, res) => { ... }) contains a leading space ("
Product deleted successfully."); remove the extra leading space from the message
string so it reads "Product deleted successfully." to ensure consistent
formatting in JSON responses.

In @app.js:
- Around line 25-33: The error-handling middleware passed to app.use is declared
with only three parameters so Express won't recognize it; update the handler
signature to include the fourth parameter `next` (e.g., change the callback for
app.use to (err, req, res, next) => { ... }) and, to avoid ESLint
no-unused-vars, either prefix `next` with an underscore or add an eslint disable
comment for that line so the required but unused parameter is not flagged.
🧹 Nitpick comments (3)
package.json (1)

22-26: Consider moving test libraries to devDependencies.

chai and mocha are testing libraries and should be in devDependencies rather than dependencies to avoid shipping them in production builds.

Suggested change
  "dependencies": {
    "body-parser": "^2.2.2",
-   "chai": "^6.2.2",
    "express": "^5.2.1",
-   "mocha": "^11.7.5",
    "mongoose": "^9.1.2",
    "morgan": "^1.10.1"
  },
  "devDependencies": {
+   "chai": "^6.2.2",
    "eslint": "^9.39.2"
+   "mocha": "^11.7.5",
  }
eslint.config.js (1)

9-22: Consider using the globals package for cleaner Node.js globals definition.

Instead of manually listing Node.js globals, you could use the globals package which provides predefined sets.

Optional improvement
npm install --save-dev globals
 const js = require('@eslint/js');
+const globals = require('globals');

 module.exports = [
   js.configs.recommended,
   {
     languageOptions: {
       ecmaVersion: 'latest',
       sourceType: 'commonjs',
-      globals: {
-        console: 'readonly',
-        process: 'readonly',
-        require: 'readonly',
-        module: 'readonly',
-        __dirname: 'readonly',
-        __filename: 'readonly',
-        exports: 'readonly',
-        Buffer: 'readonly',
-        setTimeout: 'readonly',
-        setInterval: 'readonly',
-        clearTimeout: 'readonly',
-        clearInterval: 'readonly'
-      }
+      globals: {
+        ...globals.node
+      }
     },
api/routes/products.js (1)

26-26: Use strict equality (===) instead of loose equality (==).

req.params.productID is always a string, so comparing with == 123 relies on type coercion. Using === '123' (or === 123 after parsing) is safer and more explicit.

Suggested fix
-  if (id == 123) {
+  if (id === '123') {
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to Reviews > Disable Cache setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 5724be8 and 11561d7.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • .github/workflows/lint.yml
  • README.md
  • api/routes/orders.js
  • api/routes/products.js
  • api/routes/visitors.js
  • app.js
  • eslint.config.js
  • package.json
🧰 Additional context used
🧬 Code graph analysis (2)
api/routes/products.js (2)
api/routes/orders.js (1)
  • router (2-2)
api/routes/visitors.js (1)
  • router (2-2)
api/routes/orders.js (2)
api/routes/products.js (1)
  • router (2-2)
api/routes/visitors.js (1)
  • router (2-2)
🪛 GitHub Check: Codacy Static Code Analysis
eslint.config.js

[warning] 1-1: eslint.config.js#L1
Require statement not part of import statement.

⏰ 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: Codacy Static Code Analysis
🔇 Additional comments (15)
api/routes/visitors.js (2)

7-25: LGTM!

The formatting changes are consistent with the new ESLint configuration. The route logic remains unchanged.


28-37: LGTM!

The /stats endpoint formatting is now consistent with the project's linting rules.

package.json (2)

9-10: LGTM!

The lint scripts are correctly configured for running ESLint checks and auto-fixing issues.


28-30: No action needed — ESLint 9.39.2 is the current latest version.

The version ^9.39.2 is valid and up-to-date.

Likely an incorrect or invalid review comment.

app.js (2)

1-14: LGTM!

The imports and route mounting are correctly formatted.


17-24: LGTM!

The 404 handler correctly creates an error and passes it to the next middleware via next(err).

eslint.config.js (1)

1-35: LGTM!

The ESLint flat config is well-structured with sensible defaults for a Node.js CommonJS project. The rules align with the formatting changes across the codebase.

api/routes/orders.js (4)

4-11: LGTM!

Removing the unused next parameter is correct for this simple route handler that always responds directly.


13-20: LGTM!

The POST handler is correctly simplified.


23-30: LGTM!

The GET by ID handler is correctly formatted.


32-39: LGTM!

The DELETE handler is correctly formatted.

api/routes/products.js (2)

4-11: LGTM!

The route handler signature change removing the unused next parameter is appropriate since it's not used in the handler logic.


13-19: LGTM!

Clean POST handler with proper 201 status code for resource creation.

README.md (1)

3-3: LGTM!

The lint badge is correctly formatted and consistent with the existing Dependabot and Version badges. It properly links to the new lint workflow.

.github/workflows/lint.yml (1)

1-26: Well-structured lint workflow.

The workflow configuration follows best practices: using npm ci for deterministic installs, enabling npm caching, and using current action versions.

Comment thread .github/workflows/lint.yml Outdated
Comment thread api/routes/products.js
Comment thread api/routes/products.js
Comment on lines +52 to +56
router.delete('/:productID', (req, res) => {
res.status(200).json({

message: " Product deleted successfully."
})
message: ' Product deleted successfully.'
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove leading space in message string.

Same issue here — ' Product deleted successfully.' has a leading space.

Suggested fix
-    message: ' Product deleted successfully.'
+    message: 'Product deleted successfully.'
🤖 Prompt for AI Agents
In @api/routes/products.js around lines 52 - 56, The response message in the
DELETE route handler for router.delete('/:productID', (req, res) => { ... })
contains a leading space (" Product deleted successfully."); remove the extra
leading space from the message string so it reads "Product deleted
successfully." to ensure consistent formatting in JSON responses.

Comment thread app.js
@adminvns
adminvns merged commit 970720f into main Jan 12, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant