使用 create-react-app 模板。视窗,开放服务器。
包.json
{
"name": "league-finder",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-scripts": "1.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"pre-commit": "lint-staged",
"eslint": "./node_modules/.bin/eslint src/"
},
"devDependencies": {
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-prettier": "^2.7.0",
"husky": "^1.0.1",
"lint-staged": "^7.3.0",
"prettier": "^1.14.3"
}
}
.lintstagedrc
{
"*.js": ["eslint --fix", "git add"],
}
结果:截图
为什么“没有暂存文件匹配 *.js”?