2019-10-30 12:35:51 +01:00
|
|
|
const escape = require('shell-quote').quote
|
2020-05-31 21:37:01 +02:00
|
|
|
const { CLIEngine } = require('eslint')
|
|
|
|
|
|
|
|
const cli = new CLIEngine({})
|
2019-11-09 20:54:19 +01:00
|
|
|
const isWin = process.platform === 'win32'
|
2019-10-30 12:35:51 +01:00
|
|
|
|
|
|
|
module.exports = {
|
2020-05-18 21:24:37 +02:00
|
|
|
'**/*.{js,jsx,ts,tsx}': (filenames) => {
|
2019-10-30 12:35:51 +01:00
|
|
|
const escapedFileNames = filenames
|
2020-05-18 21:24:37 +02:00
|
|
|
.map((filename) => `"${isWin ? filename : escape([filename])}"`)
|
2019-10-30 12:35:51 +01:00
|
|
|
.join(' ')
|
|
|
|
return [
|
2020-04-07 15:42:16 +02:00
|
|
|
`prettier --with-node-modules --ignore-path .prettierignore_staged --write ${escapedFileNames}`,
|
2019-12-11 03:29:39 +01:00
|
|
|
`eslint --no-ignore --max-warnings=0 --fix ${filenames
|
2020-05-31 21:37:01 +02:00
|
|
|
.filter((file) => !cli.isPathIgnored(file))
|
2020-05-18 21:24:37 +02:00
|
|
|
.map((f) => `"${f}"`)
|
2019-12-11 03:29:39 +01:00
|
|
|
.join(' ')}`,
|
2019-10-30 12:35:51 +01:00
|
|
|
]
|
|
|
|
},
|
2020-05-18 21:24:37 +02:00
|
|
|
'**/*.{json,md,mdx,css,html,yml,yaml,scss}': (filenames) => {
|
2019-10-30 12:35:51 +01:00
|
|
|
const escapedFileNames = filenames
|
2020-05-18 21:24:37 +02:00
|
|
|
.map((filename) => `"${isWin ? filename : escape([filename])}"`)
|
2019-10-30 12:35:51 +01:00
|
|
|
.join(' ')
|
|
|
|
return [
|
2020-04-07 15:42:16 +02:00
|
|
|
`prettier --with-node-modules --ignore-path .prettierignore_staged --write ${escapedFileNames}`,
|
2019-10-30 12:35:51 +01:00
|
|
|
]
|
2019-11-11 04:24:53 +01:00
|
|
|
},
|
2019-10-30 12:35:51 +01:00
|
|
|
}
|