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

lint commands dont match files and weirdness.. #5325

Closed
1 of 6 tasks
0neMiss opened this issue Jun 20, 2023 · 5 comments
Closed
1 of 6 tasks

lint commands dont match files and weirdness.. #5325

0neMiss opened this issue Jun 20, 2023 · 5 comments

Comments

@0neMiss
Copy link
Contributor

0neMiss commented Jun 20, 2023

Description

When i ran the lint commands I expected it to match files and lint the project. instead it said it cant find any files matching that pattern

URL of Issue(s)

relates to a locally ran script

Steps to replicate

  1. Fork and Clone repo
  2. npm i
  3. npm run lint:markdown or any of the lint related commands
  4. receive below error
PS C:\Users\jorda\cypress-documentation> npm run lint

> [email protected] lint
> npm run lint:markdown


> [email protected] lint:markdown
> prettier --check '**/*.{md,mdx}'

Checking formatting...
[error] No files matching the pattern were found: "'**/*.{md,mdx}'".
All matched files use Prettier code style!

I was able to get the command to work by replacing

"lint:markdown:fix": "prettier --write '**/*.{md,mdx}'",

with

 "lint:markdown:fix": "prettier --write **/*.{md,mdx}",

however after running npm run lint-fix with the updated command I'm showing over 250 files of diff.
image

Even stranger, after checking what prettier had modified. I see no observable changes in any of the files.

Curious if I should make a pr to fix these 4 commands

{
     ...
     "lint": "npm run lint:markdown",
    "lint:fix": "npm run lint:markdown:fix",
    "lint:markdown": "prettier --check '**/*.{md,mdx}'",
    "lint:markdown:fix": "prettier --write '**/*.{md,mdx}'",
     ....  
 }

Browser

N/A

Device

  • PC
  • Mac
  • iPhone
  • iPad
  • Android Phone
  • Android Tablet

Additional Information

Some extra crap that might be useful if its not reproducable for everyone.

node and npm versions:
image

OS:
image

@MikeMcC399
Copy link
Contributor

@0neMiss

The prettier linting under Windows is awkward and the changes it makes are whitespace changes only if you run it on the unchanged main branch.

The restrictions of running lint under Windows should probably be mentioned in the CONTRIBUTING guide.

I personally use Ubuntu if I need to run lint on the repo, where it works fine.

I do not see the issue on Windows that no files are found by npm run lint when I use a git bash terminal window. Which type of terminal window were you using?

@0neMiss
Copy link
Contributor Author

0neMiss commented Jun 20, 2023

@MikeMcC399 Thanks for the response!

I'm using powershell from vscode. I could update the CONTRIBUTING guide if you'd like.

image

What is suggested that windows users do in this case when trying to prepare a pr to pass the lint check in the pipeline?

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Jun 20, 2023

@0neMiss

I couldn't reproduce your problem using the same version of Windows PowerShell which you are using, however this is not a shell which I normally use, so I don't know if there are some settings which might affect the way that the commands are interpreted.

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22621.1778
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.1778
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


npm run lint

> [email protected] lint
> npm run lint:markdown


> [email protected] lint:markdown
> prettier --check '**/*.{md,mdx}'

Checking formatting...
[warn] CODE_OF_CONDUCT.md
[warn] CONTRIBUTING.md
[warn] docs\api\actions\actionability-guide.mdx
[warn] docs\api\actions\check.mdx
[warn] docs\api\actions\clear.mdx
[warn] docs\api\actions\click.mdx
[warn] docs\api\actions\dblclick.mdx

I guess that most contributors are running a POSIX compatible operating system such as Ubuntu or macOS, otherwise this issue would have been mentioned before.

What is suggested that windows users do in this case when trying to prepare a pr to pass the lint check in the pipeline?

In the past, I have either done the linting on Ubuntu or I have run

npx prettier --check
npx prettier --write

against the single file which I have edited. Assuming that you have git set up in the default way, then committing to git will sort out the line terminators appropriately (Windows => Unix).

That is however only my personal workaround. I don't know whether that should be published as a general recommendation. You should probably wait first for other comments.

Edit: WSL2 under Windows is also a possibility as a POSIX-compatible environment.

@0neMiss
Copy link
Contributor Author

0neMiss commented Jun 20, 2023

Thats what I ended up doing as well. Just pointing prettier to write the file I edited specifically.

Not sure why its behaving this way on my machine, even looking at the docs of powershell it seems like this should be working.

image

I'm good to close this out pending the potential update to the contributing guide. I feel like it might be good to have a section on lint commands and this behavior it has on non POSIX compatible operating systems.

@mike-plummer
Copy link
Contributor

@0neMiss Since we don't have a specific recommendation to add to the CONTRIBUTING guide here, and the fact that the majority of our contributors are on POSIX systems, I'm going to close this out. If you do figure out what was going on with your Powershell setup I'm happy to reopen and consider adding a hint to the guide

@mike-plummer mike-plummer closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants