Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross platform ESLint command to run on current directory recursively?

I'm looking to create a cross-platform package.json command to lint all .js, .ts, .tsx files in the current directory, recursively.

Here's what I've tried.

  1. This is directly from the ESLint CLI docs.
"scripts": {
  "lint": "eslint . --ext .js,.ts,.tsx",
}

*nix - ✅ Windows - 🚫

On Windows...

No files matching the pattern "." were found.
Please check for typing mistakes in the pattern.


2. GLOB matching pattern.

"scripts": {
  "lint": "eslint **/*.js **/*.ts **/*.tsx",
}

*nix - 🚫 Windows - ✅


3. GLOB matching pattern with quotes.

"scripts": {
  "lint": "eslint '**/*.js' '**/*.ts' '**/*.tsx'",
}

*nix - ✅ Windows - 🚫


This is a cross-platform project with developers using Mac, Linux, and Windows.

How do I get this single command to work on all three?

like image 935
GollyJer Avatar asked Sep 02 '19 02:09

GollyJer


1 Answers

Im working on similar problems right now. I had success with something like.

"scripts": {
  "lint": "eslint \"**/*.js\" \"**/*.ts\" \"**/*.tsx\"",
}

or shorter

"scripts": {
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
}

Replacing single quotes with escaped double quotes is actually a pattern not eslint specific.

Maybe it helps.

like image 108
Aligertor Avatar answered Sep 27 '22 19:09

Aligertor