nx icon indicating copy to clipboard operation
nx copied to clipboard

Can't run nx g @nx/vue:library my-lib because "Error: Cannot parse eslint.config.js: InvalidSymbol in JSON at 1:1"

Open mklueh opened this issue 1 year ago • 4 comments

Current Behavior

Error: Cannot parse my-lib/eslint.config.js: InvalidSymbol in JSON at 1:1
> 1 | const FlatCompat = require("@eslint/eslintrc");
    | ^^^^^
  2 | const js = require("@eslint/js");
  3 | const baseConfig = require("../../eslint.config.js");
  4 |

    at readJson (C:\Users\MyUser\Workspace\monorepo\node_modules\nx\src\generators\utils\json.js:20:15)
    at updateJson (C:\Users\MyUser\Workspace\monorepo\node_modules\nx\src\generators\utils\json.js:45:34)
    at editEslintConfigFiles (C:\Users\MyUser\Workspace\monorepo\node_modules\@nx\vue\src\utils\add-linting.js:46:33)
    at addLinting (C:\Users\MyUser\Workspace\monorepo\node_modules\@nx\vue\src\utils\add-linting.js:31:9)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at libraryGeneratorInternal (C:\Users\MyUser\Workspace\monorepo\node_modules\@nx\vue\src\generators\library\library.js:41:16)
    at C:\Users\MyUser\Workspace\monorepo\node_modules\nx\src\command-line\generate\generate.js:241:26
    at handleErrors (C:\Users\MyUser\Workspace\monorepo\node_modules\nx\src\utils\params.js:9:16)
    at Object.handler (C:\Users\MyUser\Workspace\monorepo\node_modules\nx\src\command-line\generate\command-object.js:13:22)

Expected Behavior

To generate the library without failures within the process

GitHub Repo

No response

Steps to Reproduce

By running the command to generate a new vue library

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 21.4.0
   OS     : win32-x64
   yarn   : 4.1.0

   nx              : 18.0.3
   @nx/js          : 18.0.3
   @nx/linter      : 18.0.3
   @nx/eslint      : 18.0.3
   @nx/workspace   : 18.0.3
   @nx/devkit      : 18.0.3
   @nrwl/devkit    : 17.2.7
   @nx/playwright  : 18.0.3
   @nrwl/tao       : 15.9.7
   @nx/vite        : 18.0.3
   @nx/vue         : 18.0.3
   @nx/web         : 18.0.3
   typescript      : 5.3.3
   ---------------------------------------
   Community plugins:
   @jnxplus/nx-gradle                  : 0.19.7
   @jscutlery/semver                   : 5.1.0
   @nx/nuxt                            : 18.0.3
   @nxrocks/nx-quarkus                 : 7.2.2
   @theunderscorer/nx-semantic-release : 2.10.0
   @trumbitta/nx-plugin-openapi        : 1.12.1
   @trumbitta/nx-plugin-unused-deps    : 1.12.1
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nrwl/[email protected]
     - @nrwl/[email protected]

   To fix this, run `nx migrate [email protected]`

Failure Logs

No response

Package Manager Version

yarn 4.1.0

Operating System

  • [ ] macOS
  • [ ] Linux
  • [X] Windows
  • [ ] Other (Please specify)

Additional Information

No response

mklueh avatar Feb 09 '24 07:02 mklueh

I have the same issue! Seems to be an issue with nx expecting a eslint config in json format, but you have it in a eslint.config.js file. It seems to be an issue here. https://github.com/nrwl/nx/blob/3b21cefd8cea62eaf1756f26083e618e8e525b97/packages/vue/src/utils/add-linting.ts#L76 It wants to parse the js file as json but that will never work.

JulianMar avatar Feb 09 '24 09:02 JulianMar

any news?

mklueh avatar Feb 26 '24 07:02 mklueh

Temporary solution is to skip lint config generation

https://nx.dev/nx-api/vue/generators/application#linter

litingyes avatar Feb 29 '24 14:02 litingyes

yeah, i did the same.

JulianMar avatar Mar 01 '24 07:03 JulianMar

Temporary solution is to skip lint config generation

Setting linter=none did not work for me. I had to replace the content of my .eslintrc.js with an empty {} JSON content temporarily. 😞

EDIT:

@nx version 19.0.4 for the record

dhlavaty avatar Jun 03 '24 10:06 dhlavaty

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.

github-actions[bot] avatar Jul 06 '24 00:07 github-actions[bot]