rsnext/lint-staged.config.js
matamatanot 3821662eb7
Replace CLIEngine with ESLint (#25801)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-06-09 13:54:10 +02:00

28 lines
958 B
JavaScript

const escape = require('shell-quote').quote
const { ESLint } = require('eslint')
const eslint = new ESLint()
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
.filter((file) => !eslint.isPathIgnored(file))
.map((f) => `"${f}"`)
.join(' ')}`,
]
},
'**/*.{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}`,
]
},
}