Skip to content

Commit

Permalink
Fix eslint version check for older versions (#26212)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jun 16, 2021
1 parent 947ee9d commit 8610ba4
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/lib/eslint/runLintCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function lint(
const mod = await import(deps.resolved.get('eslint')!)

const { ESLint } = mod
let eslintVersion = ESLint.version
let eslintVersion = ESLint?.version

if (!ESLint) {
eslintVersion = mod?.CLIEngine?.version
Expand Down
4 changes: 4 additions & 0 deletions test/integration/eslint/invalid-eslint-version/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "next",
"root": true
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions test/integration/eslint/invalid-eslint-version/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Home = () => (
<div>
<p>Home</p>
/* Badly formatted comment */
</div>
)

export default Home
13 changes: 13 additions & 0 deletions test/integration/eslint/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const dirCustomConfig = join(__dirname, '../custom-config')
const dirIgnoreDuringBuilds = join(__dirname, '../ignore-during-builds')
const dirCustomDirectories = join(__dirname, '../custom-directories')
const dirConfigInPackageJson = join(__dirname, '../config-in-package-json')
const dirInvalidEslintVersion = join(__dirname, '../invalid-eslint-version')

describe('ESLint', () => {
describe('Next Build', () => {
Expand Down Expand Up @@ -73,6 +74,18 @@ describe('ESLint', () => {
'Warning: External synchronous scripts are forbidden'
)
})

test.only('invalid eslint version', async () => {
const { stdout, stderr } = await nextBuild(dirInvalidEslintVersion, [], {
stdout: true,
stderr: true,
})

const output = stdout + stderr
expect(output).toContain(
'Your project has an older version of ESLint installed'
)
})
})

describe('Next Lint', () => {
Expand Down

0 comments on commit 8610ba4

Please sign in to comment.