我在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"
}
掉毛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'],
};
现在它工作正常