javascript - 跨平台 ESLint 命令以递归方式在当前目录上运行?

标签 javascript eslint

我想创建一个跨平台 package.json 命令来递归地检查当前目录中的所有 .js、.ts、.tsx 文件。

这是我尝试过的。

  1. 这直接来自 ESLint CLI docs .
"scripts": {
  "lint": "eslint . --ext .js,.ts,.tsx",
}

*nix - ✅ Windows - 🚫

在 Windows 上...

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


2. GLOB匹配模式。

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

*nix - 🚫 Windows - ✅


3. 带引号的 GLOB 匹配模式。

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

*nix - ✅ Windows - 🚫


这是一个跨平台项目,开发人员使用 Mac、Linux 和 Windows。

如何让这个命令同时作用于所有三个?

最佳答案

我现在正在处理类似的问题。 我在类似的事情上取得了成功。

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

或更短

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

用转义双引号替换单引号实际上是一种非 eslint 特定的模式。

也许有帮助。

关于javascript - 跨平台 ESLint 命令以递归方式在当前目录上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57750884/

相关文章:

javascript - 如何在 React native Jest 测试中模拟推送通知 native 模块?

reactjs - PropTypes : PropTypes. 数组 VS PropTypes.arrayOf(PropTypes.any)

javascript - ESLint 和 Prettier 冲突,无法为代码块禁用 Prettier

javascript - 为什么数组显示为字符串,但当我将其打印到控制台时,它却将其打印为数组? ReactJS 功能组件

javascript - 从 react 数组中删除

javascript/typescript - 强制通过 eslint 规则将对象作为函数参数传递

javascript - 定义常量时出现错误 ESLint : Use the rest parameters instead of 'arguments' . (prefer-rest-params)

angular - 如何禁用 Angular 7 typescript 中的 eslint 错误

javascript - 脊椎、node.js (express) 和 Access-Control-Allow-Origin

javascript - Document.execCommand() 仅适用于开发人员工具