Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prettier glob matching multiple file types

I have added a prettier script in my package.json so I can run it as part of my tests:

"prettier": "prettier --list-different \"**/*.{ts, js, css, scss, md}\""

I want all files from the above types to be checked by Prettier.
* --list-difference just prints out the files that are not prettified and returns an error code so it's convenient to run in CI.

When I run

$ npm run prettier

Prettier returns 0 results even though I know there are files that are not prettified.

I am not sure what's going on, can someone please help me understand what's wrong with my glob matching ?

(Running in Ubuntu 18.04 with bash)

like image 363
Michael Avatar asked Jan 06 '19 08:01

Michael


1 Answers

Found the issue.

In case anyone else is trying to match more than one file type, syntax is right but you cannot have spaces in the curly braces. So instead

"**/*.{js, ts, css, scss, md}"

It should be

"**/*.{js,ts,css,scss,md}"

This website helped me debug it easily: http://www.globtester.com/

like image 53
Michael Avatar answered Nov 16 '22 06:11

Michael