Skip to content

Commit

Permalink
Merge pull request #28 from Jam3/fix-lint-staged-with-dynamic-page
Browse files Browse the repository at this point in the history
fix: lint-staged issue when having dynamic pages
  • Loading branch information
iranreyes committed May 3, 2020
2 parents c39b6a6 + dccc00d commit ee245f4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
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

0 comments on commit ee245f4

Please sign in to comment.