nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.52k stars 2.35k forks source link

Migration "update-17-2-7" fails if a project does not have .eslintrc.json #20920

Closed paustint closed 10 months ago

paustint commented 10 months ago

Current Behavior

I have a project that does not have an eslint file in it and the migration did not account for the file not existing

Error: Cannot find apps/docs/.eslintrc.json
    at readJson (/Users/foo/dev/node/foo/node_modules/nx/src/generators/utils/json.js:14:15)
    at updateJson (/Users/foo/dev/node/foo/node_modules/nx/src/generators/utils/json.js:45:34)
    at updateOverrideInLintConfig (/Users/foo/dev/node/foo/node_modules/@nx/eslint/src/generators/utils/eslint-file.js:142:33)
    at /Users/foo/dev/node/foo/node_modules/@nx/next/src/migrations/update-17-2-7/remove-eslint-rules-patch.js:8:54
    at Map.forEach (<anonymous>)
    at update (/Users/foo/dev/node/foo/node_modules/@nx/next/src/migrations/update-17-2-7/remove-eslint-rules-patch.js:7:14)
    at runNxMigration (/Users/foo/dev/node/foo/node_modules/nx/src/command-line/migrate/migrate.js:1017:11)
    at executeMigrations (/Users/foo/dev/node/foo/node_modules/nx/src/command-line/migrate/migrate.js:880:39)
    at async runMigrations (/Users/foo/dev/node/foo/node_modules/nx/src/command-line/migrate/migrate.js:965:37)
    at async /Users/foo/dev/node/foo/node_modules/nx/src/command-line/migrate/migrate.js:1034:13
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Command failed: yarn nx _migrate --run-migrations --verbose
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected Behavior

The migration should not fail if eslint file does not exist in a given application, instead it should skip the application/library and move on.

GitHub Repo

https://github.com/jetstreamapp/jetstream/tree/v3.7.0

Steps to Reproduce

  1. On provided repository, upgrade nx npx nx migrate latest
  2. Run yarn
  3. Run npx nx migrate --run-migrations

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.16.0
   OS     : darwin-arm64
   yarn   : 1.22.19

   nx                 : 17.2.7
   @nx/js             : 17.2.7
   @nx/jest           : 17.2.7
   @nx/linter         : 17.2.7
   @nx/eslint         : 17.2.7
   @nx/workspace      : 17.2.7
   @nx/cypress        : 17.2.7
   @nx/devkit         : 17.2.7
   @nx/eslint-plugin  : 17.2.7
   @nx/express        : 17.2.7
   @nx/next           : 17.2.7
   @nx/node           : 17.2.7
   @nx/plugin         : 17.2.7
   @nx/react          : 17.2.7
   @nx/storybook      : 17.2.7
   @nrwl/tao          : 17.2.7
   @nx/vite           : 17.2.7
   @nx/web            : 17.2.7
   @nx/webpack        : 17.2.7
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   @mands/nx-playwright : 0.6.2
   nx-electron          : 15.0.0
   ---------------------------------------
   Local workspace plugins:
         @jetstream/workspace-plugin

Failure Logs

>  NX   Running migrations from 'migrations.json'

 >  NX   Failed to run update-17-2-7 from @nx/next. This workspace is NOT up to date!

 >  NX   Cannot find apps/docs/.eslintrc.json

Error: Cannot find apps/docs/.eslintrc.json
    at readJson (/Users/foo/dev/node/foo/node_modules/nx/src/generators/utils/json.js:14:15)
    at updateJson (/Users/foo/dev/node/foo/node_modules/nx/src/generators/utils/json.js:45:34)
    at updateOverrideInLintConfig (/Users/foo/dev/node/foo/node_modules/@nx/eslint/src/generators/utils/eslint-file.js:142:33)
    at /Users/foo/dev/node/foo/node_modules/@nx/next/src/migrations/update-17-2-7/remove-eslint-rules-patch.js:8:54
    at Map.forEach (<anonymous>)
    at update (/Users/foo/dev/node/foo/node_modules/@nx/next/src/migrations/update-17-2-7/remove-eslint-rules-patch.js:7:14)
    at runNxMigration (/Users/foo/dev/node/foo/node_modules/nx/src/command-line/migrate/migrate.js:1017:11)
    at executeMigrations (/Users/foo/dev/node/foo/node_modules/nx/src/command-line/migrate/migrate.js:880:39)
    at async runMigrations (/Users/foo/dev/node/foo/node_modules/nx/src/command-line/migrate/migrate.js:965:37)
    at async /Users/foo/dev/node/foo/node_modules/nx/src/command-line/migrate/migrate.js:1034:13
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Command failed: yarn nx _migrate --run-migrations --verbose
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Package Manager Version

yarn 1.22.19

Operating System

Additional Information

The migration was developed in this PR: https://github.com/nrwl/nx/pull/20863

cyrus-za commented 10 months ago

Also running into this, but we DO have a eslint file. We using .eslintrc.js though and not .eslintrc.json

Not sure if that's the reason

jaysoo commented 10 months ago

We'll patch this, in the meantime you can remove the migration from migrations.json as it does not seem applicable.

github-actions[bot] commented 9 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.