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

[codemod][FP] nuxt/4/migration-recipe #1247

Open
xmatthias opened this issue Aug 18, 2024 · 3 comments
Open

[codemod][FP] nuxt/4/migration-recipe #1247

xmatthias opened this issue Aug 18, 2024 · 3 comments
Labels
codemod-issue Any issues related to a codemod, FP or FN.

Comments

@xmatthias
Copy link

xmatthias commented Aug 18, 2024

Original

import withNuxt from './.nuxt/eslint.config.mjs';

Expected

import withNuxt from './.nuxt/eslint.config.mjs';

Actual

import withNuxt from '.nuxt/eslint.config.mjs';

(nothing else in the eslint file was modified).

Estimated impact

Numbers about your specific codemod run:

  • Total number of files/instances transformed: 1
  • Number of files/instances missed by the codemod (FN): 0
  • Number of files/instances mistakenly transformed (FP): 1

Logs:

// Please insert the contents of a log file generated by the codemod run here.

Additional context

In a regular nuxt project with eslint using flatconfig configured, i'm running the following migration script (according to the nuxt docs).

npx codemod@latest nuxt/4/migration-recipe

This also updates eslint.config.mjs (wrongly)

image
Result:
image

Now unfortunately - the modification causes eslint to complain (quite loudly)

Oops! Something went wrong! :(c to cancel.

ESLint: 9.9.0

TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module ".nuxt/eslint.config.mjs" is not a valid package name imported from /home/xmatt/devel/javascript/nuxtfast/eslint.config.mjs
    at parsePackageName (node:internal/modules/esm/resolve:782:11)
    at packageResolve (node:internal/modules/esm/resolve:805:5)
    at moduleResolve (node:internal/modules/esm/resolve:927:18)
    at defaultResolve (node:internal/modules/esm/resolve:1169:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
    at link (node:internal/modules/esm/module_job:86:36)
 ELIFECYCLE  Command failed with exit code 2.

Reverting this line fixes the problem - though i guess this shouldn't happen for a smooth migration between nuxt3 to nuxt4.

@xmatthias xmatthias added the codemod-issue Any issues related to a codemod, FP or FN. label Aug 18, 2024
@alexbit-codemod alexbit-codemod changed the title [codemod][FP/FN] nuxt/4/migration-recipe [codemod][FP] nuxt/4/migration-recipe Aug 18, 2024
@mohab-sameh
Copy link
Contributor

Thanks for reporting this! We'll investigate this issue.

@all-contributors add @xmatthias for bugs

Copy link
Contributor

@mohab-sameh

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

I've put up a pull request to add @xmatthias! 🎉

@xmatthias
Copy link
Author

Adding a bit more details here - it seems to happen in nuxt/4/file-structure - only leaving that part ticked yields the following output - somewhere in the middle.

Moving /home/xmatt/devel/javascript/projectdir/components/Pricing/Plans.vue to /home/xmatt/devel/javascript/projectdir/app/components/Pricing/Plans.vue

FILE /home/xmatt/devel/javascript/projectdir/eslint.config.mjs
import withNuxt from './.nuxt/eslint.config.mjs';
import withNuxt from '.nuxt/eslint.config.mjs';

Moving /home/xmatt/devel/javascript/projectdir/composables/useToast.ts to /home/xmatt/devel/javascript/projectdir/app/composables/useToast.ts
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codemod-issue Any issues related to a codemod, FP or FN.
Projects
None yet
Development

No branches or pull requests

2 participants