Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint-staged glob 不生效问题 #100

Open
yubaoquan opened this issue Sep 18, 2023 · 0 comments
Open

lint-staged glob 不生效问题 #100

yubaoquan opened this issue Sep 18, 2023 · 0 comments

Comments

@yubaoquan
Copy link
Owner

"lint-staged": {
  "src/**/*.{vue}": [
    "eslint --fix",
    "stylelint --fix",
    "git add"
  ]
}

这个配置不会对 xxx.vue 文件生效

原因

lint-staged使用了一个叫做 micromatch 的库来解析 glob 模式。这个库有一个特性,就是当 glob 的花括号中只有一种文件类型(如*.{vue})时,它会忽略花括号,而把它当作文件名的一部分。这就意味着,您的配置实际上是匹配src目录下以.{vue}结尾的文件,而不是以 .vue 结尾的文件。这就是为什么这条规则不会对 .vue 文件生效的原因。

另见这个回复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant