From f3088266038543814b3151ab0965c6c9f961596d Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Thu, 7 Apr 2022 11:03:40 -0400 Subject: [PATCH] Add `.eslintrc.cjs` to list of supported `next lint` config files (#35440) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The logic for finding a user's custom `.eslintrc` config file is missing a check for `.eslintrc.cjs`, which is listed as one of the valid filenames in ESLint's docs: https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats ...so this PR makes `next lint`'s list of possible config files consistent with ESLint's. I stumbled upon this when trying to rename my own config file, since I've pretty much moved completely to ESM by now... but [ESLint doesn't support modules yet](https://github.com/eslint/eslint/issues/14137#issuecomment-785421664), so renaming the file to `.cjs` just keeps things cleaner (and VS Code happier). This is my first PR here so even though I've only changed a couple of lines, please let me know if I'm overlooking something! 😊 ## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` --- packages/next/lib/eslint/runLintCheck.ts | 2 ++ test/integration/eslint/test/index.test.js | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/next/lib/eslint/runLintCheck.ts b/packages/next/lib/eslint/runLintCheck.ts index 8a50e8fab71e701..5a654d9f9e2538a 100644 --- a/packages/next/lib/eslint/runLintCheck.ts +++ b/packages/next/lib/eslint/runLintCheck.ts @@ -265,10 +265,12 @@ export async function runLintCheck( ): ReturnType { try { // Find user's .eslintrc file + // See: https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats const eslintrcFile = (await findUp( [ '.eslintrc.js', + '.eslintrc.cjs', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json', diff --git a/test/integration/eslint/test/index.test.js b/test/integration/eslint/test/index.test.js index b6467f1cf5f7502..31c7be9898851f5 100644 --- a/test/integration/eslint/test/index.test.js +++ b/test/integration/eslint/test/index.test.js @@ -348,6 +348,7 @@ describe('ESLint', () => { (await findUp( [ '.eslintrc.js', + '.eslintrc.cjs', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json',