2021-07-01 17:10:35 -07:00
|
|
|
const escape = require('shell-quote').quote
|
|
|
|
|
|
|
|
/**
|
2021-07-08 23:02:02 -07:00
|
|
|
* Need this to fix a bug where we can't commit this:
|
|
|
|
*
|
|
|
|
* `pages/examples/[example].tsx`.
|
|
|
|
*
|
|
|
|
* because of the square brackets `[` and `]`.
|
2021-07-01 17:10:35 -07:00
|
|
|
*
|
|
|
|
* <https://github.com/okonet/lint-staged/issues/676#issuecomment-574764713>
|
2021-07-01 17:13:56 -07:00
|
|
|
*
|
|
|
|
* NOTE:
|
2021-07-08 23:02:02 -07:00
|
|
|
*
|
2021-07-01 17:13:56 -07:00
|
|
|
* We can remove this entire file if/when we upgrade to Prettier 2+ where this
|
2021-07-08 23:02:02 -07:00
|
|
|
* is no longer necessary according to the `lint-staged` issue shown above.
|
|
|
|
*
|
|
|
|
* Currently, the same configuration without the escaping of the filename
|
|
|
|
* still exists in `package.json` but this takes precedence over that.
|
|
|
|
*
|
|
|
|
* Once this file is removed, `package.json` configuration will be used.
|
2021-07-01 17:10:35 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = {
|
2021-07-08 22:59:12 -07:00
|
|
|
'*.{ts,tsx,js,jsx,json,css,md}': filenames => [
|
|
|
|
...filenames.map(filename => `prettier --write "${escape([filename])}"`),
|
2021-07-01 17:10:35 -07:00
|
|
|
...filenames.map(filename => `git add "${filename}"`),
|
|
|
|
],
|
2021-07-08 22:59:12 -07:00
|
|
|
'*.{ts,tsx,js,jsx,json,css,md}': ['eslint --fix'],
|
2021-07-01 17:10:35 -07:00
|
|
|
}
|