如何为 lint-staged 设置多个模式?

问题描述

例如,我在 .rb 和 .js 文件上匹配。

例如**/*.{js,rb}

并且还想在 GemfileRakefile 上进行匹配。

解决方法

解决方案是递归使用{},例如

  "lint-staged": {
    "{Gemfile,Rakefile,**/*.{js,rb,rake,ru}}": [
      "./node_modules/prettier/bin-prettier.js --write"
    ],"**/*.js": [
      "node_modules/eslint/bin/eslint.js"
    ],"{Gemfile,**/*.{rb,ru}}": [
      "bundle exec rubocop -a"
    ]
  }