Skip to content

Commit

Permalink
Add .eslintrc.cjs to list of supported next lint config files (#3…
Browse files Browse the repository at this point in the history
…5440)

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](eslint/eslint#14137 (comment)), 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`
  • Loading branch information
jakejarvis committed Apr 7, 2022
1 parent 049bb22 commit f308826
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/next/lib/eslint/runLintCheck.ts
Expand Up @@ -265,10 +265,12 @@ export async function runLintCheck(
): ReturnType<typeof lint> {
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',
Expand Down
1 change: 1 addition & 0 deletions test/integration/eslint/test/index.test.js
Expand Up @@ -348,6 +348,7 @@ describe('ESLint', () => {
(await findUp(
[
'.eslintrc.js',
'.eslintrc.cjs',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.json',
Expand Down

0 comments on commit f308826

Please sign in to comment.