未验证 提交 fa035163 编写于 作者: S stefanprobst 提交者: GitHub

fix(eslint-plugin-next): support src/pages folder in no-html-link-for-pages rule (#16743)

currently, the `no-html-link-for-pages` eslint rule will look for the pages folder in either `pages`, or a custom folder provided via rule option. this PR adds support for also looking in `src/pages` by default.

(sidenote: not sure about the custom pagesfolder path: does next support locations other than `pages` and `src/pages`)?)

fixes  #16426
上级 67b67b28
......@@ -17,11 +17,18 @@ module.exports = {
},
create: function (context) {
const [pagesDirectory] = context.options
const pagesDir = pagesDirectory || path.join(context.getCwd(), 'pages')
if (!fs.existsSync(pagesDir)) {
const [customPagesDirectory] = context.options
const pagesDirs = customPagesDirectory
? [customPagesDirectory]
: [
path.join(context.getCwd(), 'pages'),
path.join(context.getCwd(), 'src', 'pages'),
]
const pagesDir = pagesDirs.find((dir) => fs.existsSync(dir))
if (!pagesDir) {
throw new Error(
`Pages directory cannot be found at ${pagesDir}, if using a custom path, please configure with the no-html-link-for-pages rule`
`Pages directory cannot be found at ${pagesDirs.join(' or ')}. ` +
`If using a custom path, please configure with the no-html-link-for-pages rule`
)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册