From 02f96f3541065caaa3fe465bacfa6f929e045f58 Mon Sep 17 00:00:00 2001 From: Stefan Probst Date: Sat, 29 Aug 2020 11:50:14 +0200 Subject: [PATCH] fix: support src/pages folder in eslint rule --- .../lib/rules/no-html-link-for-pages.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/eslint-plugin-next/lib/rules/no-html-link-for-pages.js b/packages/eslint-plugin-next/lib/rules/no-html-link-for-pages.js index 75cf68c103de0..947850a6f5afe 100644 --- a/packages/eslint-plugin-next/lib/rules/no-html-link-for-pages.js +++ b/packages/eslint-plugin-next/lib/rules/no-html-link-for-pages.js @@ -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` ) }