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

Linter configuration errors (typescript template) #1712

Closed
obasille opened this issue Jul 15, 2022 · 8 comments
Closed

Linter configuration errors (typescript template) #1712

obasille opened this issue Jul 15, 2022 · 8 comments

Comments

@obasille
Copy link

What is the current behaviour?
Linter failing to run.

Steps to Reproduce
Steps to reproduce the behavior:

npx preact-cli create typescript myproject
cd myproject
npm i
npm run lint

I'm getting:

Oops! Something went wrong! :(

ESLint: 6.8.0.

No files matching the pattern "'src/**/*.{js,jsx,ts,tsx}'" were found.

But then, running "eslint ." gives another error:

Oops! Something went wrong! :(

ESLint: 6.8.0.

ESLint couldn't find the plugin "eslint-plugin-jest".

Both installing the latest eslint-plugin-jest or version 25.7.0 (which is the one I got inside eslint-config-preact) fail because of dependency conflicts.

Thanks for your help!

Please mention any other relevant information

Environment Info:
  System:
    OS: Windows 10 10.0.19043
  Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.5.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 103.0.5060.114
    Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.49)
  npmPackages:
    preact: ^10.3.1 => 10.10.0
    preact-cli: ^3.0.0 => 3.4.0
    preact-render-to-string: ^5.1.4 => 5.2.1
    preact-router: ^3.2.1 => 3.2.1
@rschristian
Copy link
Member

I'm getting:

Oops! Something went wrong! :(

ESLint: 6.8.0.

No files matching the pattern "'src/**/*.{js,jsx,ts,tsx}'" were found.

Hm, odd. There most certainly are files matching that pattern, and I can't reproduce.

But then, running "eslint ." gives another error:

Oops! Something went wrong! :(

ESLint: 6.8.0.

ESLint couldn't find the plugin "eslint-plugin-jest".

Duplicate of preactjs-templates/typescript#67

I have no idea what causes this, as eslint-pluin-jest is labeled as a dependency of the preact config. Why this only happens for that specific dependency is beyond me.

@obasille
Copy link
Author

obasille commented Jul 16, 2022 via email

@rschristian
Copy link
Member

No, Linux.

Regardless, there's nothing actionable here for preact-cli, so I'm going to close this out. If you ever track down the problem you can open an issue on the template(s), the ESLint config, ESLint or NPM themselves, wherever it fits.

All I can do at the moment is point out the file patterns are correct and the eslint config does list the jest plugin as a dependency.

@rschristian rschristian closed this as not planned Won't fix, can't repro, duplicate, stale Jul 16, 2022
@obasille
Copy link
Author

obasille commented Jul 18, 2022

Hi @rschristian,

I did a bit of digging and found more info about this issue which I wanted to share with you and anyone stumbling on the same errors. The problem with eslint pattern error is Windows specific, arguments in single quotes just don't work.
See this issue discussed on eslint project.

A solution is to replace the single quotes by double quotes (with an escape character):
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",

For the eslint-plugin-jest error, I've installed version 25.7 (the one that comes with the preact eslint plugin) while forcing npm to ignore legacy dependencies. It's working fine so far.
npm install eslint-plugin-jest@25.7 --legacy-peer-deps --save-dev

I've posted a comment on the issue you mentioned.

@rschristian
Copy link
Member

Ugh, goddamit Windows.

Thanks! I'll try to push out that fix to the templates later today.

That peer dep issue (which I see now, thanks!) is rather annoying. Really don't want to have to continually update the templates just to satisfy a linter of all things, though might just be able to rip out @typescript-eslint/eslint-plugin and let the Jest plugin install whatever version it needs.

Will have to consider ripping out ESLint entirely and leaving it up to users to configure as they wish.

@rschristian
Copy link
Member

Both issues should be fixed as of preactjs-templates/typescript#74

@obasille
Copy link
Author

Just tried it and it works like a charm, thank you @rschristian!

@rschristian
Copy link
Member

Yay! Thanks so much for tracking those issues down!

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

No branches or pull requests

2 participants