-
Notifications
You must be signed in to change notification settings - Fork 1
chore: Add ESLint and Prettier configuration files for code quality #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Added Vitest configuration for testing with coverage reporting. - Created initial test for the `run` function to ensure it returns true. - Updated `package.json` and `package-lock.json` to include necessary dependencies for testing. - Configured SonarQube to include JavaScript coverage reports and exclude test files from analysis. These changes enhance the testing framework for the temporal worker, ensuring better code quality and coverage tracking.
…index - Added a newline at the end of the vitest.config.ts file to adhere to best practices. - Added a newline at the end of the index.ts file to ensure proper file termination. These changes improve code quality and maintain consistency across files.
- Added resolved URLs and integrity hashes for various dependencies in package-lock.json to ensure consistent installations. - Removed unnecessary nested dependencies for improved clarity and maintenance. These changes enhance the reliability of package installations and maintain consistency across environments.
- Updated the `@types/node` dependency version in both `package.json` and `package-lock.json` to ensure compatibility and improved performance. - Updated the `undici-types` dependency version in `package-lock.json` for better stability. - Added documentation comments in `index.ts` to clarify the purpose and return type of the `run` function. These changes improve dependency management and enhance code clarity through better documentation.
- Introduced `.prettierrc` for consistent code formatting with specified rules. - Added `.prettierignore` to exclude certain directories from formatting. - Created `eslint.config.mjs` to configure ESLint with TypeScript support and various plugins for improved code quality. - Updated `package.json` and `package-lock.json` to include necessary ESLint and Prettier dependencies. - Added `tsconfig.json` for TypeScript compilation settings. - Modified `vitest.config.ts` to export the configuration properly. These changes enhance code quality and maintainability by integrating ESLint and Prettier into the project.
Warning Rate limit exceeded@anatolyshipitz has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 11 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 Walkthrough""" WalkthroughThis update introduces comprehensive code quality tooling to the Changes
Sequence Diagram(s)sequenceDiagram
participant CI Workflow
participant NPM
participant ESLint
participant Vitest
CI Workflow->>NPM: npm ci (install dependencies)
CI Workflow->>ESLint: npm run eslint (lint code)
CI Workflow->>Vitest: npm run coverage (run tests with coverage)
Possibly related PRs
Suggested reviewers
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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
🔍 Vulnerabilities of
|
digest | sha256:d320be4f2796ed8799d55ab0a3f4d089d38403713ecfc9f8e768184b69d23780 |
vulnerabilities | |
platform | linux/amd64 |
size | 243 MB |
packages | 1628 |
📦 Base Image node:20-alpine
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
|
- Added a newline at the end of `.prettierignore` to adhere to formatting standards. - Ensured proper file termination by adding a newline at the end of `.prettierrc`. - Updated `eslint.config.mjs` to include a newline at the end for consistency. These changes enhance the overall code quality and maintainability of the project by ensuring proper formatting and file structure.
- Updated TypeScript version from `^5.0.0` to `5.8.3` in both `package.json` and `package-lock.json` for better performance and compatibility. - Updated the version of `@vitest/pretty-format` from `3.1.3` to `3.1.4` in `package-lock.json` to ensure the latest features and fixes are included. - Modified the import statement in the test file `index.test.ts` for consistency and clarity. These changes enhance the development environment by ensuring up-to-date dependencies and improving code readability in tests.
- Removed the 'import/no-default-export' rule from `eslint.config.mjs` to streamline ESLint settings. - Updated the ESLint command in `package.json` to only include TypeScript files (.ts) for linting. - Changed the export statement in `vitest.config.ts` to use default export for consistency. These changes enhance the clarity and maintainability of the configuration files, ensuring a more straightforward setup for code quality tools.
…installation - Added a step to install dependencies in the code quality workflow. - Updated the linting step to run ESLint after installing dependencies. These changes improve the code quality workflow by ensuring that all necessary dependencies are installed before linting, enhancing the reliability of the linting process.
…-temporal-worker-eslint
- Removed the trailing comma in the `extensions` array of `eslint.config.mjs` to adhere to proper JavaScript syntax. This change improves the ESLint configuration file by ensuring it follows standard formatting rules, enhancing code quality and maintainability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anatolyshipitz please
- make this PR from main, not from feature branch
- extend prettier with stricter rules
- Added new Prettier options including `trailingComma`, `printWidth`, `tabWidth`, and `semi` for enhanced code formatting consistency. - Updated existing options to ensure better readability and maintainability of the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
♻️ Duplicate comments (1)
workers/main/.prettierrc (1)
1-11
: Prettier configuration matches the requested strict style
This.prettierrc
enforces trailing commas, an 80-character print width, 2-space tabs, semicolons, single quotes, bracket spacing, consistent props quoting, and proper end‐of‐line handling, as previously requested.
🧹 Nitpick comments (5)
workers/main/tsconfig.json (1)
1-12
: Good TypeScript configuration but consider adding source mapsThe TypeScript configuration looks well-structured with appropriate settings for a Node.js worker environment. The strict type checking and ES module interoperability are good choices for maintainability.
Consider adding source map generation for better debugging capabilities:
{ "compilerOptions": { "outDir": "./dist", "rootDir": ".", "module": "commonjs", "target": "es2019", "esModuleInterop": true, "strict": true, - "skipLibCheck": true + "skipLibCheck": true, + "sourceMap": true }, "include": ["./**/*.ts"] }workers/main/src/index.ts (1)
1-7
: Unnecessary await on Promise.resolveThe function is well-documented with proper JSDoc comments, but contains an unnecessary
await
.The
await
beforePromise.resolve()
is redundant sincePromise.resolve()
already returns a resolved Promise. Consider simplifying:export async function run() { - return await Promise.resolve(true); + return Promise.resolve(true);Or even more concisely:
export async function run() { - return await Promise.resolve(true); + return true;Since the function is already declared
async
, returning a non-Promise value will automatically wrap it in a Promise..github/workflows/code-quality.yml (1)
17-20
: Add a Prettier check to the CI pipeline
Currently, we run ESLint (which integrates Prettier viaeslint-plugin-prettier
), but it's beneficial to surface formatting issues directly via Prettier. Consider adding a dedicatedprettier --check
step after ESLint:- name: Run ESLint run: cd workers/main && npm run eslint + - name: Run Prettier check + run: cd workers/main && npx prettier --check .Also applies to: 31-34
workers/main/eslint.config.mjs (2)
32-39
: Simplify coverage directory exclusion pattern.There's unnecessary redundancy in excluding coverage directories. The pattern with
**/*
is sufficient to exclude the directory and all of its contents.ignores: [ 'node_modules', 'dist', 'eslint.config.mjs', - 'coverage', - 'coverage/*', 'coverage/**/*' ],
52-58
: Missing internal path groups configuration for import order.The
import/order
rule defines an 'internal' group but doesn't specify what should be considered as internal modules. This might lead to inconsistent import ordering.import/order: [ 'error', { groups: ['builtin', 'external', 'internal'], 'newlines-between': 'always', alphabetize: { order: 'asc', caseInsensitive: true, }, + pathGroups: [ + // Define what's considered "internal" + // e.g., { pattern: '@/**', group: 'internal' } + ], }, ],
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
workers/main/package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (10)
.github/workflows/code-quality.yml
(2 hunks)sonar-project.properties
(1 hunks)workers/main/.prettierignore
(1 hunks)workers/main/.prettierrc
(1 hunks)workers/main/eslint.config.mjs
(1 hunks)workers/main/package.json
(1 hunks)workers/main/src/__tests__/index.test.ts
(1 hunks)workers/main/src/index.ts
(1 hunks)workers/main/tsconfig.json
(1 hunks)workers/main/vitest.config.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
workers/main/src/__tests__/index.test.ts (1)
workers/main/src/index.ts (1)
run
(5-7)
🔇 Additional comments (5)
workers/main/src/__tests__/index.test.ts (1)
1-9
: Simple and effective test setupThe test correctly verifies the expected behavior of the
run
function using Vitest's async testing capabilities.workers/main/.prettierignore (1)
1-4
: Appropriate Prettier ignore configurationThe
.prettierignore
file correctly excludes build outputs, test coverage reports, and cache files from Prettier formatting.sonar-project.properties (1)
3-4
: SonarQube coverage and exclusion paths configured correctly
The LCOV report path (workers/main/coverage/lcov.info
) and exclusion patterns (**/src/__tests__/**
,**/src/dist/**
) properly target the newworkers/main
tests and distribution outputs.workers/main/vitest.config.ts (1)
1-22
: Vitest configuration set up correctly
The test inclusion patterns, V8 coverage provider, reporters, and 80% thresholds for statements, branches, functions, and lines align with the project's quality requirements.workers/main/eslint.config.mjs (1)
1-80
: LGTM! This is a comprehensive ESLint configuration for TypeScript.This ESLint configuration provides a solid foundation for maintaining code quality in a TypeScript project. It includes essential plugins for TypeScript, Prettier integration, import management, and defines a comprehensive set of rules that enforce good practices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
workers/main/package.json
(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
workers/main/package.json
[error] 21-21: expected ,
but instead found "prettier"
Remove "prettier"
(parse)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
🔇 Additional comments (3)
workers/main/package.json (3)
7-8
: Approve addition of coverage and ESLint scripts.
The new"coverage": "vitest run --coverage"
and"eslint": "eslint . --ext .ts"
scripts integrate testing, coverage reporting, and linting into the npm workflow as intended.
11-21
: Approve devDependencies additions.
The added devDependencies—ESLint core, TypeScript resolver, import sorting, Prettier plugin, and related utilities—provide comprehensive linting and formatting support. Versions appear reasonable, but confirm they align with your Node/TypeScript environment.🧰 Tools
🪛 Biome (1.9.4)
[error] 21-21: expected
,
but instead found"prettier"
Remove "prettier"
(parse)
24-24
: Verify correctness oftypescript-eslint
dependency.
The package name"typescript-eslint"
is uncommon—did you mean@typescript-eslint/eslint-plugin
or@typescript-eslint/parser
? Please confirm you’ve installed the intended package.
- Removed the nested "node" object from the "import/resolver" settings in `eslint.config.mjs`, streamlining the configuration. - Deleted the "import/order" rule to simplify the ESLint settings, focusing on essential linting requirements. These changes enhance the clarity and maintainability of the ESLint configuration, ensuring a more straightforward setup for code quality tools.
- Added a trailing comma to the "eslint-config-prettier" entry in `package.json` for consistency in formatting. This change maintains the standard formatting style within the configuration file, ensuring better readability and adherence to coding conventions.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
.prettierrc
for consistent code formatting with specified rules..prettierignore
to exclude certain directories from formatting.eslint.config.mjs
to configure ESLint with TypeScript support and various plugins for improved code quality.package.json
andpackage-lock.json
to include necessary ESLint and Prettier dependencies.tsconfig.json
for TypeScript compilation settings.vitest.config.ts
to export the configuration properly.These changes enhance code quality and maintainability by integrating ESLint and Prettier into the project.