Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove eslint warning when no eslint config is present #39872

Merged
merged 3 commits into from Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions packages/next/lib/eslint/runLintCheck.ts
Expand Up @@ -321,13 +321,17 @@ export async function runLintCheck(
outputFile
)
} else {
// Display warning if no ESLint configuration is present during "next build"
// Display warning if no ESLint configuration is present inside
// config file during "next build", no warning is shown when
// no eslintrc file is present
if (lintDuringBuild) {
Log.warn(
`No ESLint configuration detected. Run ${chalk.bold.cyan(
'next lint'
)} to begin setup`
)
if (eslintrcFile) {
ijjk marked this conversation as resolved.
Show resolved Hide resolved
Log.warn(
`No ESLint configuration detected. Run ${chalk.bold.cyan(
'next lint'
)} to begin setup`
)
}
return null
} else {
// Ask user what config they would like to start with for first time "next lint" setup
Expand Down
33 changes: 33 additions & 0 deletions test/e2e/no-eslint-warn-with-no-eslint-config/index.test.ts
@@ -0,0 +1,33 @@
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'

describe('no-eslint-warn-with-no-eslint-config', () => {
let next: NextInstance

beforeAll(async () => {
next = await createNext({
files: {
'pages/index.js': `
export default function Page() {
return <p>hello world</p>
}
`,
},
dependencies: {},
})
})
afterAll(() => next.destroy())

it('should render', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('hello world')
})

it('should not have eslint warnings when no eslint config', async () => {
expect(next.cliOutput).not.toContain(
'No ESLint configuration detected. Run next lint to begin setup'
)
expect(next.cliOutput).not.toBe('warn')
})
})