ember-cli / ember-cli/eslint-plugin-ember

Lint Gjs/Gts warning only disappears after adding `ember-eslint-parser` as a dev dependency

Open
#2,298 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
263
Forks
214
Avg merge
30m
Merged PRs (30d)
5

Description

I've been trying to get rid of the warning:
```
[lint:js] To lint Gjs/Gts files please follow the setup guide at https://github.com/ember-cli/eslint-plugin-ember#gtsgjs
[lint:js] Note that this error can also happen if you have multiple versions of eslint-plugin-ember in your node_modules
```

I have this bit in my eslintrc overrides
```js
{
files: ['**/*.gjs'],
parser: 'ember-eslint-parser',
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:ember/recommended-gjs',
],
}
```

My first step was to make sure there weren't multiple copies of `eslint-plugin-ember` installed. I used `pnpm why -r eslint-plugin-ember`. There was only one installed, the monorepo workspaces all referenced the same `eslint-plugin-ember`. I double-checked this by checking `node_modules/.pnpm/store`.

I was starting to wonder if it was even being loaded at all. In my eslint config changing `parser: 'ember-eslint-parser'` to `parser: 'ember-eslint-parser-asdf'` caused an error, so it was at least looking for the package. The next step I did was go to the source of `ember-eslint-parser` in my `node_modules` and modify directly the `gjs-gts-parser.js`file:

```js
parseForESLint(code, options) {
throw new Error("Error thrown from `parseForESLint`");
patchTs();
/* ... */
}
```

Since this is the entry point for eslint to use for the parser I thought this would fail, but when I ran my `pnpm lint` I still received the "To lint Gjs/Gts files please follow the setup guide..." warning, and did not see the error being thrown.

After adding `ember-eslint-parser` with `pnpm add --save-dev ember-eslint-parser` and then re-running `pnpm lint`, I got:
```
0:0 error Parsing error: Error thrown from `parseForESLint`
```
So the `throw` I hacked into the `ember-eslint-parser` source was finally showing up. I removed my modification, and re-ran `pnpm lint` and no warnings or errors related to "To lint Gjs/Gts files please follow the setup guide" show up, neither via `pnpm lint` or in vscode.

I know this isn't the correct setup since `ember-eslint-parser` is a dependency of `eslint-plugin-ember` but I don't know why else this worked. Any ideas what's wrong in my setup?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.