Skip to content

fix(nuxt): fix the error when starting the nuxt project #2668

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

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Dec 17, 2024

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Enabled development tools for enhanced application development.
    • Introduced Vite configuration for building the library with TypeScript declaration file generation.
  • Bug Fixes

    • Addressed TypeScript-related issues in several classes, improving error handling and type checking.
  • Documentation

    • Updated TypeScript configuration to modern standards, enhancing module resolution and type-checking capabilities.
  • Chores

    • Removed obsolete files and dependencies, streamlining project structure and build process.

Copy link

coderabbitai bot commented Dec 17, 2024

Walkthrough

The pull request introduces significant updates to the project's configuration and build process, primarily focusing on the packages/utils directory. The changes involve transitioning from Rollup to Vite for building, updating TypeScript configurations, and modernizing the project's module and build strategies. Additionally, there are minor modifications to other package configurations, such as adding and removing dependencies, and updating development tools settings.

Changes

File Change Summary
examples/nuxt/playground/nuxt.config.ts - Enabled devtools
- Removed @ alias to examples/docs/newsrc
examples/nuxt/playground/public/robots.txt - File completely removed
package.json - Updated postinstall script to include pnpm build:utils
packages/mobile/utils/package.json - Added xss dependency (version 1.0.14)
packages/renderless/package.json - Removed xss dependency (version 1.0.11)
packages/utils/package.json - Updated main entry point
- Added types entry
- Simplified build script
- Updated and added dependencies
packages/utils/rollup.config.js - Configuration file completely removed
packages/utils/src/crypt/core.ts - Added methods to Base and WordArray classes
- Updated methods in Hasher class with TypeScript annotations
packages/utils/tsconfig.json - Comprehensive updates to compiler options
- Modified include patterns
- Added project references
packages/utils/tsconfig.node.json - New configuration file added
packages/utils/vite.config.ts - New Vite configuration file added

Poem

🐰 Hoppity hop, through configs we leap,
Vite and TypeScript, our changes run deep
Rollup's goodbye, new tools take flight
Modules dancing with pure delight
A rabbit's build, swift and bright! 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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.

@github-actions github-actions bot added the bug Something isn't working label Dec 17, 2024
Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

Copy link

@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: 4

🔭 Outside diff range comments (1)
packages/utils/src/crypt/core.ts (1)

Line range hint 328-339: Define abstract methods for _doReset and _doFinalize

Replace the @ts-ignore comments with proper TypeScript abstract method declarations.

+  protected abstract _doReset(): void;
+  protected abstract _doFinalize(): WordArray;
🧰 Tools
🪛 eslint

[error] 337-337: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 337-337: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)

🧹 Nitpick comments (3)
examples/nuxt/playground/nuxt.config.ts (1)

11-11: Consider making devtools configuration environment-specific

While enabling devtools is helpful during development, it's recommended to make this configuration environment-aware to ensure it's not accidentally enabled in production.

Consider updating the configuration to be environment-specific:

-  devtools: { enabled: true },
+  devtools: { enabled: process.env.NODE_ENV === 'development' },
packages/utils/tsconfig.json (1)

1-24: Consider adding migration documentation

These TypeScript configuration changes represent a significant modernization that could affect existing code. Consider adding migration documentation to help developers understand and adapt to these changes.

Would you like me to help draft a migration guide that covers:

  • Impact of ES2020 target
  • New strict type checking requirements
  • Vite integration details
packages/renderless/package.json (1)

Line range hint 1-46: Review overall package architecture for Nuxt compatibility

The changes across these packages suggest several potential causes for Nuxt startup issues:

  1. Module resolution might be affected by the new .es.js format
  2. Different build tools (Vite vs tsup) might produce incompatible outputs
  3. The very recent Vite 6.0.0 might have compatibility issues

Consider:

  1. Documenting the minimum Nuxt version supported
  2. Adding a test case specifically for Nuxt integration
  3. Standardizing build tools and module formats across packages
  4. Creating a comprehensive build strategy document
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 926fb6e and 8d9d9aa.

📒 Files selected for processing (11)
  • examples/nuxt/playground/nuxt.config.ts (1 hunks)
  • examples/nuxt/playground/public/robots.txt (0 hunks)
  • package.json (2 hunks)
  • packages/mobile/utils/package.json (1 hunks)
  • packages/renderless/package.json (1 hunks)
  • packages/utils/package.json (1 hunks)
  • packages/utils/rollup.config.js (0 hunks)
  • packages/utils/src/crypt/core.ts (4 hunks)
  • packages/utils/tsconfig.json (1 hunks)
  • packages/utils/tsconfig.node.json (1 hunks)
  • packages/utils/vite.config.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • examples/nuxt/playground/public/robots.txt
  • packages/utils/rollup.config.js
✅ Files skipped from review due to trivial changes (2)
  • packages/utils/vite.config.ts
  • packages/utils/tsconfig.node.json
🧰 Additional context used
🪛 Biome (1.9.4)
packages/utils/src/crypt/core.ts

[error] 52-52: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

🪛 eslint
packages/utils/src/crypt/core.ts

[error] 49-49: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 49-49: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)


[error] 51-51: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 51-51: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)


[error] 56-56: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 56-56: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)


[error] 283-283: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 283-283: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)


[error] 328-328: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 328-328: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)


[error] 337-337: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 337-337: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)

🔇 Additional comments (11)
examples/nuxt/playground/nuxt.config.ts (1)

Line range hint 14-29: Verify the impact of virtual template plugin configuration

The virtual template plugin is configured to include all index.ts files under packages/vue with a 'develop' environment setting. Please ensure this pattern correctly captures all necessary files and the environment setting is appropriate.

✅ Verification successful

Based on the output, I can now generate the final response as I have sufficient information to verify the virtual template plugin configuration.

Virtual template plugin configuration correctly captures necessary files

The pattern **/packages/vue/**/src/index.ts effectively captures all the component entry points in the Vue package:

  • All Vue components have their main entry point as index.ts files
  • The pattern matches both direct component entries (packages/vue/src/[component]/index.ts) and their implementations (packages/vue/src/[component]/src/index.ts)
  • No critical template files are being missed, as other .ts files are primarily implementation details, types, utilities, and tests

The 'develop' environment setting is appropriate for this context as it's being used in a playground configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and pattern of files that would be processed by the virtual template plugin

# Check for matching files
echo "Files matching the virtual template plugin pattern:"
fd --type f "index.ts$" "packages/vue"

# Verify if any potential template files might be missed
echo -e "\nAll .ts files under packages/vue for comparison:"
fd --type f ".ts$" "packages/vue" | grep -v "index.ts"

Length of output: 29564

packages/utils/tsconfig.json (4)

23-24: Verify the referenced tsconfig.node.json

The configuration references tsconfig.node.json. This split configuration approach is good for separating concerns, but we need to ensure the referenced file exists and is properly configured.

Let's check the referenced configuration:

✅ Verification successful

Let me verify the specific tsconfig.node.json that's being referenced from the utils package.


Split TypeScript configuration is properly set up

The referenced tsconfig.node.json exists in the utils package and is correctly configured for Node.js/Vite specific settings. It includes:

  • Proper module settings for ESNext and bundler
  • Composite project configuration enabled
  • Correct inclusion of vite.config.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and content of tsconfig.node.json
fd -t f "tsconfig.node.json" -x cat {}

Length of output: 1722


Script:

#!/bin/bash
# Find the specific tsconfig.node.json in the utils package
fd -p "packages/utils/tsconfig.node.json" -x cat {}

Length of output: 266


9-15: Verify Vite configuration alignment

The bundler mode settings are aligned with Vite requirements. However, ensure that the corresponding Vite configuration is properly set up.

Let's check for the Vite configuration:

✅ Verification successful

Bundler mode settings are correctly configured

The Vite configuration in packages/utils is properly set up with library build mode and TypeScript support via vite-plugin-dts. The tsconfig.json bundler mode settings are correctly aligned with this Vite configuration, particularly for:

  • Library builds with ES module format
  • TypeScript declaration file generation
  • Module resolution strategy
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Vite configuration exists and is properly set up
fd -t f "vite.config" 

Length of output: 535


Script:

#!/bin/bash
# Check the Vite configuration for packages/utils
cat packages/utils/vite.config.ts

Length of output: 333


3-8: Verify browser compatibility requirements

The upgrade from ES5 to ES2020 and module changes to ESNext could impact browser compatibility. Ensure this aligns with your project's browser support requirements.

Let's check the browser targets configuration:

✅ Verification successful

Browser compatibility is well-supported with appropriate configuration

The upgrade to ES2020 is safe because:

  1. The project has browserslist configuration targeting "> 1%, last 2 versions"
  2. The build toolchain (Vite) handles transpilation and polyfills automatically
  3. Multiple configurations across the monorepo consistently use ES2020/ESNext targets
  4. The project uses modern module bundling with appropriate browser targeting
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check browser targets configuration
# Look for browserslist config or similar browser target specifications
fd -t f -e json package.json -x jq -r '.browserslist // .targets // empty'
fd -t f "browserslist|.browserslistrc" 

Length of output: 202


Script:

#!/bin/bash
# Let's check if there are any explicit browser compatibility requirements in the documentation
rg -i "browser.*support|compatibility" README.md docs/ -l

# Check for any Vite configuration that might override TypeScript settings
fd -t f "vite.config" -x cat {}

# Check if there are any other TypeScript configurations that might be extending this one
fd -t f tsconfig.json -x cat {}

Length of output: 29184


17-21: Verify impact of strict TypeScript checks

The addition of strict type checking and unused code checks is beneficial for code quality. However, these strict checks might reveal existing issues in the codebase.

Let's check for potential TypeScript errors:

packages/mobile/utils/package.json (1)

7-9: Verify XSS package version consistency across packages

The addition of xss@1.0.14 while it's being removed from renderless package suggests a dependency reorganization. However, this could impact the Nuxt startup if not handled correctly.

Consider:

  1. Document why this dependency is needed specifically in mobile-utils
  2. Ensure proper tree-shaking since this is marked as "sideEffects": false
✅ Verification successful

XSS package version is consistent and properly utilized

The verification shows:

  • Version 1.0.14 is consistently used across packages (utils and mobile/utils)
  • The package is actively used in mobile/utils for:
    • HTML content filtering with configurable whitelists
    • URL sanitization in upload functionality
    • Attribute filtering
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other xss package versions in the codebase
rg '"xss":' -g 'package.json'

# Check for direct xss usage in mobile utils
rg 'xss' packages/mobile/utils/

Length of output: 1900

packages/utils/package.json (2)

24-26: Review dependency version constraints

The dependency versions raise some concerns:

  • Vite v6.0.0 is extremely new and might be unstable
  • TypeScript ^5.2.2 is quite recent and might need compatibility testing

Consider:

  1. Pinning Vite to a more stable version (e.g., ^5.0.0)
  2. Documenting the minimum required TypeScript version for Nuxt compatibility

11-12: Verify module format compatibility with Nuxt

The change from esm.js to es.js and addition of types declaration needs verification with Nuxt's module resolution.

✅ Verification successful

Let me gather more information about the module format and build configuration to ensure compatibility.


Let me check the source files to understand the exports and usage patterns.


Based on the comprehensive analysis of the codebase, I can now provide the final response:

Module format is compatible with Nuxt and existing imports

The change from esm.js to es.js is safe because:

  • The Vite build config explicitly sets formats: ['es'] which is compatible with modern bundlers including Nuxt
  • All existing imports of @opentiny/utils are using named imports which work with ES modules
  • The package is only used by internal renderless components for utility functions like xss, log, and crypt
  • TypeScript types are properly configured with vite-plugin-dts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any imports of this package
rg '@opentiny/utils' -g '*.{js,ts,vue}'

Length of output: 2677


Script:

#!/bin/bash
# Check the build configuration and exports
cat packages/utils/vite.config.ts || cat packages/utils/vite.config.js
cat packages/utils/index.ts || cat packages/utils/index.js

Length of output: 505


Script:

#!/bin/bash
# Check the source files and exports
fd -t f . packages/utils/src/ -x cat {}

Length of output: 23532

packages/renderless/package.json (1)

Line range hint 31-33: Consider build tool consistency across packages

While utils package moved to Vite, this package uses tsup. Having different build tools across packages might complicate the build process and potentially affect Nuxt startup.

Consider:

  1. Standardizing build tools across packages
  2. Document why different build tools are necessary if they must be maintained

Also applies to: 38-39

packages/utils/src/crypt/core.ts (1)

Line range hint 67-106: LGTM! Robust type handling implementation

The WordArray class properly handles various array types and includes appropriate type conversions.

🧰 Tools
🪛 Biome (1.9.4)

[error] 52-52: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

🪛 eslint

[error] 49-49: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 49-49: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)


[error] 51-51: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 51-51: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)


[error] 56-56: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 56-56: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)

package.json (1)

35-35: LGTM! Verify build order dependencies

The addition of pnpm build:utils to postinstall script is appropriate. However, ensure that build:internals doesn't depend on the utils package to avoid circular dependencies.

✅ Verification successful

Based on the gathered information, I can now generate the final response:

LGTM! No circular dependencies found

The build order in postinstall script is correct. The utils package has minimal dependencies (only xss) and none of the internal packages depend on @opentiny/utils, confirming there are no circular dependencies between internals and utils.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential circular dependencies between internals and utils
rg -l "require.*@opentiny/utils|from.*@opentiny/utils" "internals/"

Length of output: 67


Script:

#!/bin/bash
# Let's first check if the internals directory exists and its structure
fd . internals/

# Then check for any imports or requires in the internals directory
rg -g '!*.{json,md}' "import|require" internals/

# Also check the build scripts in package.json to understand the build order
cat package.json | jq '.scripts'

Length of output: 56844


Script:

#!/bin/bash
# Let's check the build:internals and build:utils scripts' dependencies
cat packages/utils/package.json | jq '.dependencies'

# Also check if utils is used in any of the internals packages
fd package.json internals/ -x cat {} | jq -c 'select(.dependencies != null) | {name: .name, dependencies: .dependencies}'

Length of output: 1359

"build": "rimraf dist && npm run build:dev && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:prod",
"release": "node scripts/release.js",
"lint": "eslint src/**/*{.js,.ts,.json} --fix",
"build": "vite build",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider using a more stable Vite version

The switch to Vite build system is good for modern development, but using vite build alone might need additional configuration for Nuxt compatibility.

Consider:

  1. Adding Nuxt-specific build configuration
  2. Using a more stable Vite version (6.0.0 is very recent and might have stability issues)

Comment on lines +49 to 53
// @ts-ignore
static create(...args) {
// @ts-ignore
return new this(...args)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace @ts-ignore with proper type definitions

The @ts-ignore comments should be replaced with proper TypeScript type definitions. Additionally, using this in a static context could be confusing.

Consider this implementation:

-  // @ts-ignore
-  static create(...args) {
-    // @ts-ignore
-    return new this(...args)
+  static create<T extends new (...args: any[]) => any>(...args: ConstructorParameters<T>): InstanceType<T> {
+    return new (this as any)(...args)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// @ts-ignore
static create(...args) {
// @ts-ignore
return new this(...args)
}
static create<T extends new (...args: any[]) => any>(...args: ConstructorParameters<T>): InstanceType<T> {
return new (this as any)(...args)
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 52-52: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

🪛 eslint

[error] 49-49: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 49-49: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)


[error] 51-51: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 51-51: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)

@@ -277,6 +280,7 @@

if (mWordsReady) {
for (let offset = 0; offset < mWordsReady; offset += blockSize) {
// @ts-ignore
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Define abstract method instead of using @ts-ignore

Replace the @ts-ignore with proper TypeScript abstract method declaration.

+  protected abstract _doProcessBlock(dataWords: any[], offset: number): void;

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 eslint

[error] 283-283: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 283-283: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)

Comment on lines +56 to 59
// @ts-ignore
const clone = new this.constructor()
Object.assign(clone, this)
return clone
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Implement proper deep cloning

The current implementation using Object.assign performs a shallow clone, which might not correctly handle nested objects or arrays.

Consider using a deep clone implementation:

-    // @ts-ignore
-    const clone = new this.constructor()
-    Object.assign(clone, this)
-    return clone
+    const clone = new (this.constructor as new () => typeof this)()
+    for (const key in this) {
+      if (Object.prototype.hasOwnProperty.call(this, key)) {
+        if (this[key] && typeof this[key] === 'object') {
+          clone[key] = Array.isArray(this[key])
+            ? [...this[key]]
+            : { ...this[key] }
+        } else {
+          clone[key] = this[key]
+        }
+      }
+    }
+    return clone

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 eslint

[error] 56-56: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)


[error] 56-56: Use "@ts-expect-error" to ensure an error is actually being suppressed.

(@typescript-eslint/prefer-ts-expect-error)

@kagol kagol merged commit a649587 into dev Dec 18, 2024
11 of 13 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 26, 2024
13 tasks
@kagol kagol deleted the fix-nuxt-error-1217 branch April 14, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants