b5d911c92c
Old logic from the pages router was previously being hit during development. This was more apparent when PPR was enabled as it was mixing dynamic + static rendering in development which propagated to errors. This change ensures that requests that are made with `RSC: 1` are not marked as `/_next/data` URL's, and don't use the same logic paths. Previously it was a bit confusing because we used the variable `isDataReq` in a few places that made it hard to tell what it was referring to. In this case, the `isDataReq` is actually only used by the pages router. This renames the `isDataReq` to `isNextDataRequest` to make it clearer, as well as refactors to ensure that it's not used in the paths for app routes. Also to better represent the rendering modes the `supportsDynamicHTML` variable was renamed to `supportsDynamicResponse`. Fixes #66241
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
const { quote } = require('shell-quote')
|
|
const { ESLint } = require('eslint')
|
|
|
|
const eslint = new ESLint()
|
|
|
|
/**
|
|
* Escape filenames to ensure that spaces and such aren't interpreted as
|
|
* separators.
|
|
*
|
|
* @param {string[]} filenames
|
|
* @returns {string[]}
|
|
*/
|
|
function escape(filenames) {
|
|
if (process.platform === 'win32') {
|
|
return filenames
|
|
}
|
|
|
|
return filenames.map((filename) => quote([filename]).replace(/\\@/g, '@'))
|
|
}
|
|
|
|
module.exports = {
|
|
'**/*.{js,jsx,mjs,ts,tsx,mts}': async (filenames) => {
|
|
const escapedFileNames = escape(filenames).join(' ')
|
|
const eslintFileNames = await Promise.all(
|
|
filenames.map(async (filename) => {
|
|
const ignored = await eslint.isPathIgnored(filename)
|
|
return ignored ? null : filename
|
|
})
|
|
)
|
|
|
|
return [
|
|
`prettier --with-node-modules --ignore-path .prettierignore --write ${escapedFileNames}`,
|
|
`eslint --no-ignore --max-warnings=0 --fix ${eslintFileNames
|
|
.filter((filename) => filename !== null)
|
|
.map((filename) => {
|
|
return `"${filename}"`
|
|
})
|
|
.join(' ')}`,
|
|
`git add ${escapedFileNames}`,
|
|
]
|
|
},
|
|
'**/*.{json,md,mdx,css,html,yml,yaml,scss}': (filenames) => {
|
|
const escapedFileNames = escape(filenames).join(' ')
|
|
return [
|
|
`prettier --with-node-modules --ignore-path .prettierignore --write ${escapedFileNames}`,
|
|
`git add ${escapedFileNames}`,
|
|
]
|
|
},
|
|
'**/*.rs': (filenames) => {
|
|
const escapedFileNames = escape(filenames).join(' ')
|
|
return [`cargo fmt -- ${escapedFileNames}`, `git add ${escapedFileNames}`]
|
|
},
|
|
}
|