如何在lint阶段使用正则表达式

时间:2020-06-03 11:30:23

标签: regression package.json pre-commit-hook git-husky lint-staged

我想在lint阶段使用正则表达式,该正则表达式列出了文件中图像标签的所有缺少的alt属性。

package.json

"scripts": {
    "postinstall": "find node_modules/ -name \"*.info\" -type f -delete",        
    "img-altchk": "gulp img-altchk",
    "regex": "grep -rl /<img(\s*(?!alt)([\w\-])+=([\"\'])[^\"\']+\3)*\s*\/?>/"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {        
    "**/*.mustache": [
      "npm run regex",
      "git add"
    ]
  },

我没有得到清单。有什么建议。谢谢。

0 个答案:

没有答案