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

avoid false positive with correct setup and multiple eslint plugins t… #112

Conversation

void-mAlex
Copy link

…hat use the same parser

setting up gjs on a v2 addon monorepo causes what appears to be a false positive as best as I can tell
with this change patched using pnpm I get correct linting for the projects in a pnpm monorepo, otherwise just a single warning shows up at the start of the file with the message inside the preprocessor

@NullVoxPopuli
Copy link
Member

setting up gjs on a v2 addon monorepo causes what appears to be a false positive as best as I can tell

this generally means your dependencies are wrong.

can you provide the output of:

pnpm why ember-eslint-parser -r

there should hopefully only be one version

@NullVoxPopuli
Copy link
Member

it's likely that you have two different versions of eslint-plugin-ember

@void-mAlex
Copy link
Author

there is only one version of ember-eslint-parser 0.5.6
there are NO direct dependencies of it just as a dependency of eslint-plugin-ember
only one instance of eslint-plugin-ember is present as part of devDeps and even for that it's all the same version 12.3.3

@patricklx
Copy link
Collaborator

Maybe the deps are not fully correct. But we also do not need to log the message in that case.
If we can prevent it by doing this. I would be okay with this.
It's supposed to log a message if the parser is not used. If some version of the parser is used it could be okay.
Maybe later we could add a warning if a different parser is used

@NullVoxPopuli
Copy link
Member

@void-mAlex do you have a repro? I'd like to see because this would be the first time a non-duplicate dependency has caused this! It's very puzzling!

@void-mAlex
Copy link
Author

I can set up up tomorrow but simply setting up a new v2 addon with the current bp (non ts) and following the gjs lint setup for the test app will do the trick

@void-mAlex
Copy link
Author

@NullVoxPopuli
https://github.com/void-mAlex/repro-eslint-plugin
check vs code feedback vs pnpm lint output
only cli is correct which shows that the setup works
you will notice the errors coming up twice, once from the direct invocation of template-lint and once from the eslint pass that shows the setup is correct just not reflected in vscode correctly as there are multiple instances of the plugin floating around, hence the need for this change

@NullVoxPopuli
Copy link
Member

NullVoxPopuli commented Nov 26, 2024

exploration

I had to delete the lockfile, as it was made with pnpm 8.

Using pnpm 9.12.3, i get:

❯ pnpm why ember-eslint-parser -r
Legend: production dependency, optional only, dev only

[email protected] <repo>/repro-eslint-plugin

devDependencies:
eslint-plugin-ember 12.3.3
└── ember-eslint-parser 0.5.6
eslint-plugin-ember-template-lint 0.19.0
└── ember-eslint-parser 0.5.6

[email protected] <repo>/test-app (PRIVATE)

devDependencies:
eslint-plugin-ember 12.3.3
└── ember-eslint-parser 0.5.6

and

❯ pnpm why eslint-plugin-ember -r
Legend: production dependency, optional only, dev only

[email protected] <repo>/repro-eslint-plugin

devDependencies:
eslint-plugin-ember 12.3.3

[email protected] <repo>/test-app (PRIVATE)

devDependencies:
eslint-plugin-ember 12.3.3

so that seems fine.

but the error still exists -- which is perplexing. To date, the above output would confirm workingness.

So..... that's weird.
I wonder if specific npm settings are needed.

Using this (from another project):

####################
# super strict mode
####################
auto-install-peers=false
strict-peer-dependents=true
resolve-peers-from-workspace-root=false

################
# Optimizations
################
# Less strict, but required for tooling to not barf on duplicate peer trees.
# (many libraries declare the same peers, which resolve to the same
#  versions)
dedupe-peer-dependents=true
public-hoist-pattern[]=ember-source

################
# Compatibility
################
# highest is what everyone is used to, but
# not ensuring folks are actually compatible with declared ranges.
resolution-mode=highest

the issue is still not resolved.

Looking at the error more closely, it looks like you didn't set the parser

  3:0  error  Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): "jsx", "flow", "typescript". (3:0)
To lint Gjs/Gts files please follow the setup guide at https://github.com/ember-cli/eslint-plugin-ember#gtsgjs
Note that this error can also happen if you have multiple versions of eslint-plugin-ember in your node_modules

the eslint config was not updated to suppert gjs.

For testing purposes, I just had this in the eslint config (and it works):

'use strict';

module.exports = {
	root: true,
	overrides: [
		{
			parser: 'ember-eslint-parser',
			parserOptions: {
				ecmaVersion: 'latest',
				sourceType: 'module',
				requireConfigFile: false,
				babelOptions: {
					plugins: [[require.resolve('decorator-transforms')]],
				},
			},
			plugins: ['ember'],
			extends: ['eslint:recommended', 'plugin:ember/recommended'],
			env: {
				browser: true,
			},
			files: ['*.gjs'],
		},
	],
};

So, you're saying that in this PR, you don't have to configure the parser somehow?

Starting in ember-cli 6.1, the eslint config will be a flat config, and using eslint 9 -- gjs is also already set up there.

@NullVoxPopuli
Copy link
Member

Gonna close for now. Lemme know if this still needs addressing after using the latest configs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants