WebStorm is unable to parse HTML in NX project


We recently merged a couple repositories and to manage them we decided to use Nx (https://nx.dev) but now the IDE is unable to even correctly parse an HTML template, I always get the error, "unexpected token <".

1 comment

The error comes from ESLint, not fromthe IDE. Looks like the needed ESLint parser is not configured, must be a problem with either the dependencies or ESLint configuration. The issue that looks related: https://stackoverflow.com/questions/67770549/migrated-from-tslint-to-eslint-and-eslint-causes-parsing-error-unexpected-token

If the error only occurs when using ESLint integration in the IDE and doesn't occur when you run the linter in the terminal, it can be caused by the wrong working directory being used. With monorepos, the IDE can start multiple ESlint processes - by default, it starts a separate process for each package.json with eslint dependency and processes everything below it, using the .eslintrc.* configuration file nearest to the current file. Also, with Automatic configuration, the ESlint working folder is set to a folder where the nearest .eslintrc or eslintignore resides (as described in https://www.jetbrains.com/help/webstorm/eslint.html#ws_js_eslint_manual_configuration)
You can try changing the configuration to Manual and choosing the eslint package, configuration file and working directory explicitly to match the command you use when running the linter in terminal


Please sign in to leave a comment.