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

fix: lint-staged issue when having dynamic pages #28

Merged
merged 2 commits into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .adviserrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"package-json-properties": [
"error",
{
"required": ["name", "private", "scripts", "engines", "dependencies", "lint-staged", "husky", "browserslist"]
"required": ["name", "private", "scripts", "engines", "dependencies", "husky", "browserslist"]
}
],
"root-files": [
Expand Down
20 changes: 20 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const escape = require('shell-quote').quote;
const isWin = process.platform === 'win32';

module.exports = {
'**/*.{js,jsx,ts,tsx}': filenames => {
const escapedFileNames = filenames.map(filename => `"${isWin ? filename : escape([filename])}"`).join(' ');
return [
`prettier --with-node-modules --ignore-path .prettierignore_staged --write ${escapedFileNames}`,
`eslint --no-ignore --max-warnings=0 --fix ${filenames.map(f => `"${f}"`).join(' ')}`,
`git add ${escapedFileNames}`
];
},
'**/*.{json,md,mdx,css,html,yml,yaml,scss}': filenames => {
const escapedFileNames = filenames.map(filename => `"${isWin ? filename : escape([filename])}"`).join(' ');
return [
`prettier --with-node-modules --ignore-path .prettierignore_staged --write ${escapedFileNames}`,
`git add ${escapedFileNames}`
];
}
};
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"component": "node scripts/component.js",
"page": "node scripts/component.js --page",
"\n ###################### Automation Tools ######################": "",
"lint-staged": "lint-staged",
"linters": "npm-run-all -p js-lint sass-lint adviser-dev",
"adviser-dev": "adviser --tags dev --verbose",
"adviser-ci": "adviser --tags lighthouse,stage --verbose --quiet",
Expand Down Expand Up @@ -112,6 +113,7 @@
"prop-types": "^15.7.2",
"redux-devtools-extension": "2.13.8",
"serve": "^11.3.0",
"shell-quote": "^1.7.2",
"stylelint": "13.0.0",
"stylelint-config-jam3": "0.1.2",
"webp-loader": "0.6.0"
Expand All @@ -123,11 +125,6 @@
"node": ">=10.15.0",
"npm": ">=6.5.0"
},
"lint-staged": {
"src/**/*.{js,json,scss}": [
"prettier --write"
]
},
"husky": {
"hooks": {
"pre-commit": "echo 'Pre-commit checks...' && lint-staged",
Expand Down