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

chore: bump typescript #557

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Kodylow
Copy link
Member

@Kodylow Kodylow commented Oct 4, 2024

Bumps typescript / eslint and associated packages to current versions (minus a minor version on TS which isn't supported yet with eslint specifically). Gets rid of all the typescript warnings for the project

Summary by CodeRabbit

  • New Features

    • Introduced a new ESLint configuration that enhances linting capabilities for both JavaScript and TypeScript.
    • Added a script to automate the identification and addition of missing peer dependencies.
  • Bug Fixes

    • Improved error logging for authentication failures in the Guardian API.
    • Added error logging for JSON parsing errors in utility functions.
    • Enhanced error handling in the Network Indicator component for better feedback on URL parsing failures.
  • Refactor

    • Simplified control flow in the Role Selector component for better clarity.
    • Updated the method of removing custom fields in the Meta Manager component for enhanced clarity.
  • Chores

    • Updated various dependencies in the development environment to improve TypeScript and ESLint support.
    • Modified the structure of the Turbo configuration for better organization.

@Kodylow Kodylow requested review from a team as code owners October 4, 2024 03:31
Copy link

vercel bot commented Oct 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2024 5:38pm

Copy link
Contributor

coderabbitai bot commented Oct 4, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request includes modifications to various files, primarily focusing on ESLint configuration, Husky pre-commit hooks, and component updates. The .husky/pre-commit file was simplified by removing the shebang and Husky sourcing command. An ESLint configuration file was deleted, and a new one created, enhancing linting for JavaScript and TypeScript. Several components were updated for better error handling and code readability, while dependencies in package.json were updated or added to improve the development environment.

Changes

File Change Summary
.husky/pre-commit Removed shebang line and Husky sourcing command; retained commands for npx pretty-quick and yarn lint.
apps/router/.eslintrc.js Deleted file that exported ESLint configuration from @fedimint/eslint-config.
eslint.config.mjs Introduced new ESLint configuration for JavaScript and TypeScript, including custom rules and parser options.
package.json Updated eslint version; added several new dependencies for TypeScript and ESLint; reorganized existing dependencies.
apps/router/src/api/GuardianApi.ts Added error logging in testPassword method for authentication failures.
apps/router/src/gateway-ui/components/federations/ViewConfig.tsx Removed ref from ViewConfigModal component's forwardRef function signature.
apps/router/src/guardian-ui/components/NumberFormControl.tsx Expanded onValueChange function's conditional check for better readability; adjusted errorText logic.
apps/router/src/guardian-ui/components/dashboard/tabs/meta/manager/MetaManager.tsx Changed custom field removal logic in removeCustomField function for clarity.
apps/router/src/guardian-ui/components/setup/screens/roleSelector/RoleSelector.tsx Modified onClick handler for clarity in conditional logic.
apps/router/src/guardian-ui/utils/api.ts Updated return type for getModuleParamsFromConfig function for improved type safety.
apps/router/src/guardian-ui/utils/index.ts Added error logging in isJsonString function during JSON parsing.
packages/ui/src/NetworkIndicator.tsx Added error logging in isMutinynet function for URL parsing failures.

Possibly related PRs

  • chore: fix and bump #536: Involves updates to the Header.tsx file, which may relate to project structure and linting practices.

Suggested reviewers

  • bradleystachurski

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c609b2e and 06847b0.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (12)
  • .husky/pre-commit (0 hunks)
  • apps/router/.eslintrc.js (0 hunks)
  • apps/router/src/api/GuardianApi.ts (1 hunks)
  • apps/router/src/gateway-ui/components/federations/ViewConfig.tsx (1 hunks)
  • apps/router/src/guardian-ui/components/NumberFormControl.tsx (1 hunks)
  • apps/router/src/guardian-ui/components/dashboard/tabs/meta/manager/MetaManager.tsx (1 hunks)
  • apps/router/src/guardian-ui/components/setup/screens/roleSelector/RoleSelector.tsx (1 hunks)
  • apps/router/src/guardian-ui/utils/api.ts (1 hunks)
  • apps/router/src/guardian-ui/utils/index.ts (1 hunks)
  • eslint.config.mjs (1 hunks)
  • package.json (2 hunks)
  • packages/ui/src/NetworkIndicator.tsx (1 hunks)
💤 Files with no reviewable changes (2)
  • .husky/pre-commit
  • apps/router/.eslintrc.js
🔇 Additional comments (11)
eslint.config.mjs (3)

1-4: Imports and export look good.


5-6: Base configurations are properly included.


7-20: Configuration for all JS/TS files is correct.

package.json (1)

17-20: ESLint major version update may introduce breaking changes.

The update to ESLint v9 could potentially affect existing lint rules or configurations. Ensure all ESLint-related scripts and configurations are tested thoroughly.

packages/ui/src/NetworkIndicator.tsx (1)

33-33: Error logging added.

The change improves error handling in the isMutinynet function.

apps/router/src/guardian-ui/components/NumberFormControl.tsx (2)

40-42: Improved readability of onChange handling.

The explicit if statement enhances code clarity.


Line range hint 1-85: Verify completeness of changes.

The AI summary mentioned modifications to error handling logic, but these are not visible in the provided code.

Run this script to check for additional changes:

apps/router/src/guardian-ui/utils/index.ts (1)

86-86: Approved: Enhanced error logging.

The added console error improves debugging capabilities.

apps/router/src/guardian-ui/utils/api.ts (1)

10-15: Type safety improvement approved.

The changes enhance type safety without introducing issues.

apps/router/src/guardian-ui/components/setup/screens/roleSelector/RoleSelector.tsx (1)

110-114: Logic change in onClick handler

The modification improves readability by using an if-else statement instead of a ternary operator. This change maintains the existing functionality while making the code more explicit.

apps/router/src/guardian-ui/components/dashboard/tabs/meta/manager/MetaManager.tsx (1)

133-135: Approved: Improved implementation of removeCustomField.

The new implementation correctly removes the custom field while adhering to React's immutability principle.

Comment on lines 21 to 38
{
files: ['**/*.ts', '**/*.tsx'],
plugins: {
'@typescript-eslint': tseslint.plugin,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: './tsconfig.json',
},
},
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' },
],
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove repeated rule in TS-specific configuration.

The unused variables rule is already defined in the previous configuration object which applies to all JS/TS files. It's unnecessary to repeat it here.

Remove lines 32-37 to avoid redundancy.

package.json Outdated
Comment on lines 32 to 33
"@types/node": "^22.7.4",
"@vitalets/google-translate-api": "^9.2.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect @types/node version and placement.

The @types/node package should be in devDependencies, not dependencies. Also, version ^22.7.4 is incorrect; it should match your Node.js version (likely 18.x or 20.x).

package.json Outdated
Comment on lines 34 to 35
"ts-node": "^10.9.2",
"tsup": "^8.3.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Move ts-node and tsup to devDependencies.

These packages are development tools and should be in the devDependencies section.

package.json Outdated
Comment on lines 36 to 37
"typescript": "5.5.4",
"typescript-eslint": "^8.8.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect TypeScript version and misplaced typescript-eslint.

TypeScript 5.5.4 doesn't exist yet. Use the latest 5.3.x version. Move typescript-eslint to devDependencies and use the correct version (latest is 6.x).

@@ -23,8 +23,7 @@ interface ViewConfigModalProps {
export const ViewConfigModal = forwardRef<
HTMLButtonElement,
ViewConfigModalProps
// eslint-disable-next-line @typescript-eslint/no-unused-vars
>(({ federationId, config }, ref) => {
>(({ federationId, config }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Removal of ref forwarding may break existing code.

The ref parameter has been removed from the function signature, indicating that the component no longer supports forwarding refs. This change might break existing code that relies on accessing the ref of this component.

@@ -96,6 +96,7 @@ export class GuardianApi {
return true;
} catch (err) {
// TODO: make sure error is auth error, not unrelated
console.error('Failed to authenticate with password:', err);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Potential security risk in error logging.

Logging the full error object might expose sensitive information. Consider logging only non-sensitive parts of the error.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 06847b0 and 50e6a8d.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (10)
  • apps/router/package.json (2 hunks)
  • apps/router/src/gateway-ui/components/federations/ViewConfig.tsx (1 hunks)
  • eslint.config.mjs (1 hunks)
  • package.json (1 hunks)
  • packages/eslint-config/package.json (1 hunks)
  • packages/types/package.json (1 hunks)
  • packages/ui/package.json (1 hunks)
  • packages/utils/package.json (1 hunks)
  • scripts/add-missing-deps.js (1 hunks)
  • turbo.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/router/src/gateway-ui/components/federations/ViewConfig.tsx
  • eslint.config.mjs
🔇 Additional comments (10)
packages/types/package.json (1)

18-18: Verify build process after major tsup update.

The tsup dependency has been updated from version 5.x to 8.x. This major version jump might affect the build process.

packages/eslint-config/package.json (1)

7-12: Verify compatibility with latest TypeScript-ESLint packages.

The major version updates to @typescript-eslint packages (^5.30.5 to ^8.8.0) may introduce breaking changes. Ensure these updates don't conflict with the PR's intention to avoid upgrading TypeScript to the latest minor version due to ESLint compatibility issues.

packages/utils/package.json (1)

17-19: Caution: Major version updates may introduce breaking changes.

The updates to i18next-browser-languagedetector (7.x to 8.x) and react-i18next (13.x to 15.x) are major version changes. These may introduce breaking changes that require careful testing and potentially code adjustments.

packages/ui/package.json (5)

22-22: @chakra-ui/react update looks good.


23-24: @emotion/react and @emotion/styled updates are fine.


28-29: @types/react and @types/react-dom updates are appropriate.


30-30: React update is acceptable.


31-31: Verify compatibility with tsup major version update.

package.json (1)

8-8: Verify Husky setup after removing "prepare" script.

The "prepare" script, which typically sets up Husky, has been removed. Ensure that Husky is still properly configured for the project.

Also applies to: 16-16

turbo.json (1)

8-8: Verify compatibility with "tasks" key

The change from "pipeline" to "tasks" may impact build processes.

✅ Verification successful

Turbo.json schema compatibility confirmed

The tasks key adheres to the latest schema, ensuring build processes remain unaffected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if turbo.json is using the latest schema version
jq -e '.["$schema"] | contains("https://turbo.build/schema.json")' turbo.json

Length of output: 84

deps.forEach((dep) => console.log(`- ${dep}`));

try {
execSync(`yarn add -D ${deps.join(' ')}`, { stdio: 'inherit' });
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Potential command injection vulnerability.

The deps.join(' ') in the execSync call could lead to command injection if the dependency names contain malicious characters.

Consider using the array form of execSync to avoid shell interpretation:

execSync('yarn', ['add', '-D', ...deps], { stdio: 'inherit' });

Comment on lines +37 to +42
try {
execSync(`yarn add -D ${deps.join(' ')}`, { stdio: 'inherit' });
console.log('Dependencies added successfully.');
} catch (error) {
console.error('Error adding dependencies:', error);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle partial failures in dependency addition.

The current implementation doesn't account for scenarios where some dependencies are successfully added while others fail.

Consider adding each dependency individually and tracking successes and failures:

const results = deps.map(dep => {
  try {
    execSync(`yarn add -D ${dep}`, { stdio: 'inherit' });
    return { dep, success: true };
  } catch (error) {
    return { dep, success: false, error };
  }
});
console.log('Results:', results);

Comment on lines +24 to +25
"react": "^18.3.1",
"react-dom": "^18.3.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

React version 18.3.1 doesn't exist.

The specified React version (18.3.1) is not released yet. Use the latest stable version (18.2.0) instead.

"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"eslint": "^9.11.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

ESLint version 9.11.1 doesn't exist.

The specified ESLint version (9.11.1) is not released yet. Use the latest stable version (8.x) instead.

"@codemirror/view": "^6.34.1",
"@lezer/common": "^1.2.2",
"@testing-library/dom": "^10.4.0",
"@types/node": "^22.7.4",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect @types/node version and placement.

@types/node should match your Node.js version (likely 18.x or 20.x) and be in dependencies, not devDependencies.

"workspaces": [
"apps/*",
"packages/*"
],
"dependencies": {
"@babel/core": "^7.25.7",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Move @babel/core to devDependencies.

@babel/core is a build tool and should be in devDependencies, not dependencies.

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