javascript - 在 css 中提交 Eslint 错误时
问题描述
在 GIT 上提交代码时出现错误。我正在使用 ESLINT 和 Stylelint 进行设置。我写了简单的 css,但我得到了错误。在第一行和第一列出现问题
2:1 error Parsing error: Unexpected token
1 | /* Form elements style */
> 2 | .flex-wrapper {
| ^
3 | display: flex;
4 | flex-wrap: wrap;
5 | margin: 0px -20px;
✖ 1 problem (1 error, 0 warnings)
husky > pre-commit hook failed (add --no-verify to bypass)
`/* Form elements style */
.flex-wrapper {
display: flex;
flex-wrap: wrap;
margin: 0px -20px;
}`
.stylelintrc
{
"extends": "stylelint-config-recommended"
}
lint-staged.config.js
module.exports = {
linters: {
'**/*.+(js|jsx|md|css|yml|yaml|scss)': [
'./node_modules/.bin/eslint --fix',
'./node_modules/.bin/stylelint *.css --fix',
'./node_modules/.bin/prettier --write',
'git add',
],
},
ignore: ['node_modules', 'package.json', 'package-lock.json'],
};
.eslintrc.js
module.exports = {
extends: ['airbnb', 'prettier', 'prettier/react'],
plugins: ['markdown'],
parser: 'babel-eslint',
env: {
browser: true,
jest: true,
},
rules: {
'react/button-has-type': 0,
'react/require-default-props': 0,
'import/named': 0,
camelcase: 0,
'react/destructuring-assignment': 1,
},
};
解决方案
lint-staged.config.js 文件有问题
module.exports = {
linters: {
'**/*.+(js|jsx|md|yml|yaml)': [
'./node_modules/.bin/eslint --fix',
'./node_modules/.bin/prettier --write',
'git add',
],
'**/*.+(css|scss)': [
'./node_modules/.bin/stylelint *.css --fix',
'./node_modules/.bin/prettier --write',
'git add',
],
},
ignore: ['node_modules', 'package.json', 'package-lock.json'],
};
现在它工作正常
推荐阅读
- android - 无法生成签名的 apk,因为任务 ':app:packageDebug' 的 gradle 失败
- r - 更新多个相关的 selectizeInput() 控制通过这些输入选择过滤的反应数据集
- python - 使 concurrent.futures.ProcessPoolExecutor 跳过所有错误/异常,但继续
- reactjs - 在数组列表中取一个值
- regex - Tcl 正则表达式 - 将所有匹配项复制到列表
- spring-boot - IntelliJ 在 Java11 SpringBoot 项目上设置错误的语言级别
- swift - 在 onAppear 中触发时工作表未打开
- javascript - 谷歌脚本编辑器 || 不能在 IF 语句中工作
- javascript - 排序匈牙利语词典
- css - CSS:如何使两个网格相等(其中一个在另一个之上)