Skip to content
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

fix: eslint broken in vscode #2920

Merged
merged 2 commits into from
Dec 31, 2024
Merged

fix: eslint broken in vscode #2920

merged 2 commits into from
Dec 31, 2024

Conversation

r4zendev
Copy link
Collaborator

@r4zendev r4zendev commented Dec 30, 2024

This PR fixes an issue related to VSCode ESLint extension that prevents it from detecting tsconfig in appropriate directory unless base directory is specified and makes it unable to detect eslintignore files outside root directory of the workspace.

Summary by CodeRabbit

  • Chores
    • Updated ESLint configuration across multiple projects to standardize TypeScript parsing settings
    • Modified .eslintignore to exclude specific directories and configuration files from linting
    • Refined ESLint configuration to use consistent project and root directory settings

@r4zendev r4zendev self-assigned this Dec 30, 2024
Copy link

changeset-bot bot commented Dec 30, 2024

⚠️ No Changeset found

Latest commit: 4821f71

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Dec 30, 2024

Walkthrough

This pull request focuses on standardizing ESLint configuration across multiple projects and packages. The changes primarily involve updating the parserOptions in various .eslintrc.cjs files, specifically modifying the project path to reference tsconfig.eslint.json directly and adding a new tsconfigRootDir property set to __dirname. Additionally, an .eslintignore file was updated to exclude certain directories and configuration files from linting.

Changes

File Change Summary
.eslintignore Added exclusions for node_modules, dist, .eslintrc.cjs, rollup.config.js, babel.config.js, and packages/config
apps/backoffice-v2/.eslintrc.cjs Updated parserOptions with tsconfigRootDir: __dirname and project: tsconfig.eslint.json
apps/kyb-app/.eslintrc.cjs Updated parserOptions with tsconfigRootDir: __dirname and project: tsconfig.eslint.json
apps/workflows-dashboard/.eslintrc.cjs Updated parserOptions with tsconfigRootDir: __dirname and project: tsconfig.eslint.json
packages/blocks/.eslintrc.cjs Updated parserOptions with tsconfigRootDir: __dirname and project: tsconfig.eslint.json
packages/common/.eslintrc.cjs Updated parserOptions with tsconfigRootDir: __dirname and project: tsconfig.eslint.json
packages/ui/.eslintrc.cjs Updated parserOptions with tsconfigRootDir: __dirname and project: tsconfig.eslint.json
packages/workflow-core/.eslintrc.cjs Updated parserOptions with tsconfigRootDir: __dirname and project: tsconfig.eslint.json
sdks/web-ui-sdk/.eslintrc.cjs Updated parserOptions with tsconfigRootDir: __dirname and project: tsconfig.eslint.json
sdks/workflow-browser-sdk/.eslintrc.cjs Added extends: ['@ballerine/eslint-config'] and updated parserOptions

Poem

🐰 Linting Rabbit's Delight

Configs aligned, paths set just right,
ESLint dancing with pure might,
__dirname whispers, configs bright,
No more relative paths in sight,
A rabbit's code, now clean and tight! 🔍


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ebd8447 and 82ac379.

📒 Files selected for processing (10)
  • .eslintignore (1 hunks)
  • apps/backoffice-v2/.eslintrc.cjs (1 hunks)
  • apps/kyb-app/.eslintrc.cjs (1 hunks)
  • apps/workflows-dashboard/.eslintrc.cjs (1 hunks)
  • packages/blocks/.eslintrc.cjs (1 hunks)
  • packages/common/.eslintrc.cjs (1 hunks)
  • packages/ui/.eslintrc.cjs (1 hunks)
  • packages/workflow-core/.eslintrc.cjs (1 hunks)
  • sdks/web-ui-sdk/.eslintrc.cjs (1 hunks)
  • sdks/workflow-browser-sdk/.eslintrc.cjs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .eslintignore
🔇 Additional comments (10)
packages/common/.eslintrc.cjs (1)

5-6: Looks good. Confirm ESLint picks up the correct tsconfig.

Updating the project property and adding tsconfigRootDir: __dirname is standard for resolving the correct tsconfig.eslint.json. Please confirm that ESLint correctly recognizes this new configuration in any IDE or workspace environment.

✅ Verification successful

ESLint configuration appears to be correctly set up

The verification shows that:

  • tsconfig.eslint.json exists in the correct location and extends the base tsconfig.json
  • The base tsconfig.json is properly configured with correct compiler options
  • The include paths in tsconfig.eslint.json (src and rollup.config.ts) match the actual TypeScript files in the project
  • The .eslintrc.cjs configuration is properly set up with tsconfigRootDir and project properties

The TypeScript project references are correctly configured, and ESLint should be able to properly resolve and use the TypeScript configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that ESLint is able to load the 'tsconfig.eslint.json' from the current directory
eslint --print-config . | grep 'tsconfig'

Length of output: 138


Script:

#!/bin/bash
# Check if tsconfig.eslint.json exists in the expected location
fd -t f "tsconfig.eslint.json" packages/common/

# Check the content of tsconfig.eslint.json if it exists
fd -t f "tsconfig.eslint.json" packages/common/ -x cat {}

# Check the content of .eslintrc.cjs to verify the complete configuration
cat packages/common/.eslintrc.cjs

Length of output: 459


Script:

#!/bin/bash
# Check if the base tsconfig.json exists and its content
fd -t f "tsconfig.json" packages/common/ -x cat {}

# Check if there are any TypeScript files in the specified include paths
fd -e ts "." packages/common/src/
fd -t f "rollup.config.ts" packages/common/

Length of output: 7839

apps/kyb-app/.eslintrc.cjs (1)

5-6: Ensuring consistent TypeScript linting root.

The addition of tsconfigRootDir: __dirname and referencing 'tsconfig.eslint.json' is consistent with best practices for multi-package projects. No further changes are needed here.

apps/workflows-dashboard/.eslintrc.cjs (1)

5-6: Maintain consistency in multi-project setups.

Adopting tsconfigRootDir: __dirname and pointing to 'tsconfig.eslint.json' helps ESLint accurately locate TypeScript configs. The changes appear correct.

packages/blocks/.eslintrc.cjs (1)

8-9: Alignment with ESLint’s recommended approach.

Setting tsconfigRootDir to __dirname and using 'tsconfig.eslint.json' ensures reliable resolution of configs, especially in monorepos. This update fits the recommended pattern.

sdks/workflow-browser-sdk/.eslintrc.cjs (2)

3-3: Ensuring consistency with custom ESLint configuration.
Great to see you extending from @ballerine/eslint-config. This promotes a single source of ESLint rules across the project.


8-9: Verify the tsconfig location and directory reference.
Specifying tsconfigRootDir: __dirname and project: 'tsconfig.eslint.json' helps ESLint locate the correct TypeScript configuration. Ensure that tsconfig.eslint.json exists at this root directory.

✅ Verification successful

TypeScript configuration file is correctly referenced

The verification confirms that tsconfig.eslint.json exists at the root of the sdks/workflow-browser-sdk directory, which matches the configuration in .eslintrc.cjs. The ESLint configuration correctly uses __dirname to set the root directory and references the existing TypeScript configuration file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that tsconfig.eslint.json is present in sdks/workflow-browser-sdk

fd tsconfig.eslint.json --exact-depth 1 --glob --base-directory=sdks/workflow-browser-sdk

Length of output: 112

packages/workflow-core/.eslintrc.cjs (1)

7-10: Consistent parserOptions usage.
Using the same tsconfigRootDir and project setup throughout all packages is a good practice for consistency. Double-check that your TypeScript compiler options in tsconfig.eslint.json match your project needs.

sdks/web-ui-sdk/.eslintrc.cjs (1)

8-10: Unified approach to TypeScript config resolution.
Switching from an array to a single string for project and adding tsconfigRootDir ensures alignment with the rest of the repository. No issues spotted.

packages/ui/.eslintrc.cjs (1)

14-15: Project path reference update.
Setting tsconfigRootDir: __dirname and simplifying project to 'tsconfig.eslint.json' avoids potential path ambiguity. Looks good for standardizing your TypeScript linting setup.

apps/backoffice-v2/.eslintrc.cjs (1)

13-16: Ensure ESLint successfully detects the updated tsconfig.

This change to use tsconfigRootDir: __dirname and reference tsconfig.eslint.json is generally recommended for monorepos. However, please verify that the file tsconfig.eslint.json exists at this directory level and is properly recognized by ESLint within VSCode, ensuring that lint checks run as expected.

You can run this script to locate all instances of tsconfig.eslint.json in the repository and confirm their relative paths:

✅ Verification successful

ESLint configuration is properly set up with the correct tsconfig files

The verification shows that:

  • tsconfig.eslint.json exists in the correct location
  • It properly extends the main tsconfig.json
  • The configuration includes all necessary source files and config files
  • The ESLint configuration correctly references it with the proper tsconfigRootDir setting
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for 'tsconfig.eslint.json' across the repository,
# and display surrounding lines to gauge usage context.

fd 'tsconfig.eslint.json' --exec rg -A 3 -B 3 'tsconfig.eslint.json' {}

Length of output: 71


Script:

#!/bin/bash
# Let's first check if the file exists in the specified directory
ls -la apps/backoffice-v2/tsconfig.eslint.json

# Also check for any tsconfig files in that directory to see alternatives
ls -la apps/backoffice-v2/tsconfig*

# Let's also check the content of .eslintrc.cjs to understand the full context
cat apps/backoffice-v2/.eslintrc.cjs

Length of output: 842


Script:

#!/bin/bash
# Let's check the content of the tsconfig.eslint.json to ensure it's properly configured
cat apps/backoffice-v2/tsconfig.eslint.json

# Also check the main tsconfig.json for comparison
cat apps/backoffice-v2/tsconfig.json

Length of output: 438


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

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

@r4zendev r4zendev merged commit 13579a4 into dev Dec 31, 2024
10 checks passed
@r4zendev r4zendev deleted the eslint-vscode-issue branch December 31, 2024 18:15
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.

2 participants