Skip to content

Commit

Permalink
Temporarily remove experimental ESLint integration (vercel#23521)
Browse files Browse the repository at this point in the history
This pull request **temporarily** removes ESLint, as it was not landed in accordance with our standard experimental policies. We are fully committed to landing this change again.

This is being reverted because:

- Next.js has very strict goals for its install size. This feature resulted in adding over 17MB, or a 43.6% increase.
- The feature was not first landed under the `experimental` key in `next.config.js`, rather, it was added under the stable namespace (top-level)
- Using the feature doesn't do a "guided setup" like TypeScript, it should ask you to "bring your own" dependencies for ESLint
- It uses a undesirable ESLint plugin name: `plugin:@next/next/recommended`. This should read out as strictly `next`, or as short as we can get it.
- Does not provide actionable warnings (missing link to resolve issue)
- Does not follow appropriate console output styling. We need to revisit how these are presented.

To re-land this, we need to ensure the following minimums are met:
- Very minor change in install size
- Fully experimental (i.e. flagged) with warnings
- Finalized package name and configuration shape, preferably so we can do ` { extends: 'next' } `.
  • Loading branch information
Timer authored Mar 30, 2021
1 parent cd46241 commit eecc334
Show file tree
Hide file tree
Showing 36 changed files with 25 additions and 903 deletions.
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ node_modules
**/.next/**
**/_next/**
**/dist/**
e2e-tests/**
examples/with-typescript-eslint-jest/**
examples/with-kea/**
packages/next/bundles/webpack/packages/*.runtime.js
Expand All @@ -17,5 +16,4 @@ packages/next-codemod/**/*.js
packages/next-codemod/**/*.d.ts
packages/next-env/**/*.d.ts
test/integration/async-modules/**
test/integration/eslint/**
test-timings.json
70 changes: 0 additions & 70 deletions docs/api-reference/next.config.js/eslint-warnings-errors.md

This file was deleted.

49 changes: 0 additions & 49 deletions docs/basic-features/eslint.md

This file was deleted.

8 changes: 0 additions & 8 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
"title": "Fast Refresh",
"path": "/docs/basic-features/fast-refresh.md"
},
{
"title": "ESLint",
"path": "/docs/basic-features/eslint.md"
},
{
"title": "TypeScript",
"path": "/docs/basic-features/typescript.md"
Expand Down Expand Up @@ -340,10 +336,6 @@
"title": "Configuring onDemandEntries",
"path": "/docs/api-reference/next.config.js/configuring-onDemandEntries.md"
},
{
"title": "ESLint Warnings and Errors",
"path": "/docs/api-reference/next.config.js/eslint-warnings-errors.md"
},
{
"title": "Ignoring TypeScript Errors",
"path": "/docs/api-reference/next.config.js/ignoring-typescript-errors.md"
Expand Down
22 changes: 8 additions & 14 deletions packages/eslint-plugin-next/lib/rules/no-html-link-for-pages.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
const path = require('path')
const fs = require('fs')
const {
getUrlFromPagesDirectory,
normalizeURL,
execOnce,
} = require('../utils/url')

const pagesDirWarning = execOnce((pagesDirs) => {
console.warn(
`Pages directory cannot be found at ${pagesDirs.join(' or ')}. ` +
`If using a custom path, please configure with the no-html-link-for-pages rule in your eslint config file`
)
})
const { getUrlFromPagesDirectory, normalizeURL } = require('../utils/url')

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
meta: {
docs: {
Expand All @@ -34,8 +26,10 @@ module.exports = {
]
const pagesDir = pagesDirs.find((dir) => fs.existsSync(dir))
if (!pagesDir) {
pagesDirWarning(pagesDirs)
return {}
throw new Error(
`Pages directory cannot be found at ${pagesDirs.join(' or ')}. ` +
`If using a custom path, please configure with the no-html-link-for-pages rule`
)
}

const urls = getUrlFromPagesDirectory('/', pagesDir)
Expand Down
14 changes: 0 additions & 14 deletions packages/eslint-plugin-next/lib/utils/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,7 @@ function normalizeURL(url) {
return url
}

function execOnce(fn) {
let used = false
let result

return (...args) => {
if (!used) {
used = true
result = fn(...args)
}
return result
}
}

module.exports = {
getUrlFromPagesDirectory,
normalizeURL,
execOnce,
}
35 changes: 0 additions & 35 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,41 +180,6 @@ export default async function build(
telemetry.record(events)
)

if (config.eslint?.build) {
await nextBuildSpan
.traceChild('verify-and-lint')
.traceAsyncFn(async () => {
const lintWorkers = new Worker(
require.resolve('../lib/verifyAndLint'),
{
numWorkers: config.experimental.cpus,
enableWorkerThreads: config.experimental.workerThreads,
}
) as Worker & {
verifyAndLint: typeof import('../lib/verifyAndLint').verifyAndLint
}

lintWorkers.getStdout().pipe(process.stdout)
lintWorkers.getStderr().pipe(process.stderr)

const lintResults = await lintWorkers.verifyAndLint(
dir,
pagesDir,
null
)

if (lintResults.hasErrors) {
console.error(chalk.red('Failed to compile.'))
console.error(lintResults.results)
process.exit(1)
} else if (lintResults.hasMessages) {
console.log(lintResults.results)
}

lintWorkers.end()
})
}

const ignoreTypeScriptErrors = Boolean(config.typescript?.ignoreBuildErrors)
await nextBuildSpan
.traceChild('verify-typescript-setup')
Expand Down
68 changes: 0 additions & 68 deletions packages/next/lib/eslint/customFormatter.ts

This file was deleted.

Loading

0 comments on commit eecc334

Please sign in to comment.