Skip to content

Commit 9278d6e

Browse files
authored
chore: clean up eslint config (#558)
* chore: remove extreneous lint rules and ignore statements * chore: add rule to sort imports alphabetically
1 parent 4ef70ce commit 9278d6e

File tree

15 files changed

+55
-102
lines changed

15 files changed

+55
-102
lines changed

Diff for: .eslintrc.cjs

+32-57
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,36 @@ module.exports = {
88
},
99
rules: {
1010
'arrow-body-style': 'off',
11-
'no-param-reassign': ['error', { props: false }],
12-
'no-underscore-dangle': 'off',
13-
'no-magic-numbers': 'off',
14-
'n/prefer-global/process': 'off',
15-
'unicorn/numeric-separators-style': 'off',
16-
'unicorn/filename-case': ['error', { case: 'kebabCase' }],
17-
'import/no-extraneous-dependencies': 'off',
18-
'import/no-namespace': 'off',
11+
'class-methods-use-this': 'off',
12+
complexity: 'off',
13+
'func-style': 'off',
1914
'import/extensions': 'off',
15+
'line-comment-position': 'off',
2016
'max-depth': 'off',
21-
'func-style': 'off',
22-
'class-methods-use-this': 'off',
23-
'promise/prefer-await-to-then': 'off',
24-
'promise/prefer-await-to-callbacks': 'off',
25-
'promise/catch-or-return': 'off',
26-
'promise/always-return': 'off',
17+
'max-lines': 'off',
18+
'max-lines-per-function': 'off',
2719
'max-nested-callbacks': 'off',
2820
'max-statements': 'off',
29-
'require-await': 'off',
21+
'n/prefer-global/process': 'off',
3022
'no-inline-comments': 'off',
31-
'line-comment-position': 'off',
32-
complexity: 'off',
33-
'max-lines': 'off',
23+
'no-magic-numbers': 'off',
24+
'no-param-reassign': ['error', { props: false }],
25+
'no-underscore-dangle': 'off',
26+
'promise/always-return': 'off',
27+
'promise/catch-or-return': 'off',
28+
'promise/prefer-await-to-callbacks': 'off',
29+
'promise/prefer-await-to-then': 'off',
30+
'require-await': 'off',
31+
'sort-imports': [
32+
'error',
33+
{
34+
allowSeparatedGroups: true,
35+
ignoreCase: true,
36+
ignoreDeclarationSort: true,
37+
},
38+
],
39+
'unicorn/filename-case': ['error', { case: 'kebabCase' }],
40+
'unicorn/numeric-separators-style': 'off',
3441
},
3542
overrides: [
3643
...overrides,
@@ -46,55 +53,23 @@ module.exports = {
4653
'@typescript-eslint/no-floating-promises': 'error',
4754
},
4855
},
49-
{
50-
files: ['src/run/**'],
51-
rules: {
52-
'no-restricted-imports': [
53-
'error',
54-
{
55-
paths: [
56-
{
57-
name: '@opentelemetry/api',
58-
importNames: ['trace'],
59-
message: 'Please use `getTracer()` from `./handlers/tracer.cjs` instead',
60-
},
61-
],
62-
},
63-
],
64-
},
65-
},
6656
{
6757
files: ['src/run/handlers/**'],
6858
rules: {
69-
'max-statements': ['error', 30],
7059
'import/no-anonymous-default-export': 'off',
7160
},
7261
},
7362
{
74-
files: ['src/**/*.test.*'],
75-
rules: {
76-
'max-statements': 'off',
77-
'max-lines-per-function': 'off',
78-
},
79-
},
80-
{
81-
files: ['src/build/**/*.ts'],
63+
files: ['src/run/**'],
8264
rules: {
8365
'no-restricted-imports': [
8466
'error',
8567
{
8668
paths: [
8769
{
88-
name: 'path',
89-
importNames: ['resolve'],
90-
message:
91-
'Please use `PluginContext.resolve` instead to comply with our monorepo support',
92-
},
93-
{
94-
name: 'node:path',
95-
importNames: ['resolve'],
96-
message:
97-
'Please use `PluginContext.resolve` instead to comply with our monorepo support',
70+
name: '@opentelemetry/api',
71+
importNames: ['trace'],
72+
message: 'Please use `getTracer()` from `./handlers/tracer.cjs` instead',
9873
},
9974
],
10075
},
@@ -104,10 +79,10 @@ module.exports = {
10479
{
10580
files: ['src/build/templates/**/*'],
10681
rules: {
107-
'n/no-missing-import': 'off',
108-
'import/no-unresolved': 'off',
109-
'import/no-anonymous-default-export': 'off',
11082
'func-names': 'off',
83+
'import/no-anonymous-default-export': 'off',
84+
'import/no-unresolved': 'off',
85+
'n/no-missing-import': 'off',
11186
},
11287
},
11388
],

Diff for: e2e-report/app/layout.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-disable-next-line import/no-unassigned-import
21
import './globals.scss'
32

43
export const metadata = {

Diff for: edge-runtime/lib/routing.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { Key } from '../vendor/deno.land/x/[email protected]/index.ts'
1010
import { compile, pathToRegexp } from '../vendor/deno.land/x/[email protected]/index.ts'
1111
import { getCookies } from '../vendor/deno.land/[email protected]/http/cookie.ts'
1212

13-
/*
13+
/*
1414
┌─────────────────────────────────────────────────────────────────────────┐
1515
│ Inlined/re-implemented types │
1616
└─────────────────────────────────────────────────────────────────────────┘
@@ -86,7 +86,7 @@ export type RoutesManifest = {
8686
dynamicRoutes: DynamicRoute[]
8787
}
8888

89-
/*
89+
/*
9090
┌─────────────────────────────────────────────────────────────────────────┐
9191
│ packages/next/src/shared/lib/escape-regexp.ts │
9292
└─────────────────────────────────────────────────────────────────────────┘
@@ -104,7 +104,7 @@ export function escapeStringRegexp(str: string) {
104104
return str
105105
}
106106

107-
/*
107+
/*
108108
┌─────────────────────────────────────────────────────────────────────────┐
109109
│ packages/next/src/shared/lib/router/utils/querystring.ts │
110110
└─────────────────────────────────────────────────────────────────────────┘
@@ -125,7 +125,7 @@ export function searchParamsToUrlQuery(searchParams: URLSearchParams): ParsedUrl
125125
return query
126126
}
127127

128-
/*
128+
/*
129129
┌─────────────────────────────────────────────────────────────────────────┐
130130
│ packages/next/src/shared/lib/router/utils/parse-url.ts │
131131
└─────────────────────────────────────────────────────────────────────────┘
@@ -156,7 +156,7 @@ export function parseUrl(url: string): ParsedUrl {
156156
}
157157
}
158158

159-
/*
159+
/*
160160
┌─────────────────────────────────────────────────────────────────────────┐
161161
│ packages/next/src/shared/lib/router/utils/prepare-destination.ts │
162162
│ — Changed to use WHATWG Fetch `Request` instead of │
@@ -392,7 +392,7 @@ function unescapeSegments(str: string) {
392392
return str.replace(/__ESC_COLON_/gi, ':')
393393
}
394394

395-
/*
395+
/*
396396
┌─────────────────────────────────────────────────────────────────────────┐
397397
│ packages/next/src/shared/lib/router/utils/is-dynamic.ts │
398398
└─────────────────────────────────────────────────────────────────────────┘
@@ -404,7 +404,7 @@ export function isDynamicRoute(route: string): boolean {
404404
return TEST_ROUTE.test(route)
405405
}
406406

407-
/*
407+
/*
408408
┌─────────────────────────────────────────────────────────────────────────┐
409409
│ packages/next/shared/lib/router/utils/middleware-route-matcher.ts │
410410
└─────────────────────────────────────────────────────────────────────────┘

Diff for: src/build/content/prerendered.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { encodeBlobKey } from '../../shared/blobkey.js'
1111
import type {
1212
CachedFetchValue,
1313
CachedPageValue,
14-
NetlifyCacheHandlerValue,
1514
NetlifyCachedRouteValue,
15+
NetlifyCacheHandlerValue,
1616
NetlifyIncrementalCacheValue,
1717
} from '../../shared/cache-types.cjs'
1818
import type { PluginContext } from '../plugin-context.js'

Diff for: src/build/content/server.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { readFile } from 'node:fs/promises'
22
import { join } from 'node:path'
33

44
import { NetlifyPluginOptions } from '@netlify/build'
5-
import { expect, test, vi, describe, beforeEach } from 'vitest'
5+
import { beforeEach, describe, expect, test, vi } from 'vitest'
66

77
import { mockFileSystem } from '../../../tests/index.js'
88
import { PluginContext, RequiredServerFilesManifest } from '../plugin-context.js'
99

1010
import {
11-
NextInternalModuleReplacement,
1211
copyNextServerCode,
1312
getPatchesToApply,
13+
NextInternalModuleReplacement,
1414
verifyHandlerDirStructure,
1515
} from './server.js'
1616

Diff for: src/build/content/server.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import {
33
access,
44
cp,
55
mkdir,
6-
readFile,
76
readdir,
7+
readFile,
88
readlink,
99
symlink,
1010
writeFile,
1111
} from 'node:fs/promises'
1212
import { createRequire } from 'node:module'
13-
// eslint-disable-next-line no-restricted-imports
1413
import { dirname, join, resolve, sep } from 'node:path'
1514
import { join as posixJoin, sep as posixSep } from 'node:path/posix'
1615

Diff for: src/build/content/static.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { inspect } from 'node:util'
44

55
import type { NetlifyPluginOptions } from '@netlify/build'
66
import glob from 'fast-glob'
7-
import { Mock, beforeEach, describe, expect, test, vi } from 'vitest'
7+
import { beforeEach, describe, expect, Mock, test, vi } from 'vitest'
88

99
import { mockFileSystem } from '../../../tests/index.js'
1010
import { type FixtureTestContext } from '../../../tests/utils/contexts.js'

Diff for: src/build/image-cdn.test.ts

+7-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* eslint-disable id-length */
21
import type { NetlifyPluginOptions } from '@netlify/build'
32
import type { NextConfigComplete } from 'next/dist/server/config-shared.js'
4-
import { TestContext, beforeEach, describe, expect, test } from 'vitest'
3+
import { beforeEach, describe, expect, test, TestContext } from 'vitest'
54

65
import { setImageConfig } from './image-cdn.js'
76
import { PluginContext, type RequiredServerFilesManifest } from './plugin-context.js'
@@ -35,11 +34,8 @@ describe('Image CDN', () => {
3534
expect.arrayContaining([
3635
{
3736
from: '/_next/image',
38-
query: {
39-
q: ':quality',
40-
url: ':url',
41-
w: ':width',
42-
},
37+
// eslint-disable-next-line id-length
38+
query: { q: ':quality', url: ':url', w: ':width' },
4339
to: '/.netlify/images?url=:url&w=:width&q=:quality',
4440
status: 200,
4541
},
@@ -64,11 +60,8 @@ describe('Image CDN', () => {
6460
expect.arrayContaining([
6561
{
6662
from: '/_next/image',
67-
query: {
68-
q: ':quality',
69-
url: ':url',
70-
w: ':width',
71-
},
63+
// eslint-disable-next-line id-length
64+
query: { q: ':quality', url: ':url', w: ':width' },
7265
to: '/.netlify/images?url=:url&w=:width&q=:quality',
7366
status: 200,
7467
},
@@ -97,16 +90,12 @@ describe('Image CDN', () => {
9790
expect.arrayContaining([
9891
{
9992
from: '/base/path/_custom/image/endpoint',
100-
query: {
101-
q: ':quality',
102-
url: ':url',
103-
w: ':width',
104-
},
93+
// eslint-disable-next-line id-length
94+
query: { q: ':quality', url: ':url', w: ':width' },
10595
to: '/.netlify/images?url=:url&w=:width&q=:quality',
10696
status: 200,
10797
},
10898
]),
10999
)
110100
})
111101
})
112-
/* eslint-enable id-length */

Diff for: src/build/plugin-context.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { existsSync, readFileSync } from 'node:fs'
22
import { readFile } from 'node:fs/promises'
3-
// Here we need to actually import `resolve` from node:path as we want to resolve the paths
4-
// eslint-disable-next-line no-restricted-imports
53
import { join, relative, resolve } from 'node:path'
64
import { fileURLToPath } from 'node:url'
75

Diff for: src/run/handlers/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Context } from '@netlify/functions'
55
import type { NextConfigComplete } from 'next/dist/server/config-shared.js'
66
import type { WorkerRequestHandler } from 'next/dist/server/lib/types.js'
77

8-
import { TagsManifest, getTagsManifest } from '../config.js'
8+
import { getTagsManifest, TagsManifest } from '../config.js'
99
import {
1010
adjustDateHeader,
1111
setCacheControlHeaders,

Diff for: src/run/handlers/tracer.cts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Here we need to actually import `trace` from @opentelemetry/api to add extra wrappers
22
// other places should import `getTracer` from this module
33
// eslint-disable-next-line no-restricted-imports
4-
import { trace, Tracer, Span } from '@opentelemetry/api'
4+
import { Span, trace, Tracer } from '@opentelemetry/api'
55
import { SugaredTracer, wrapTracer } from '@opentelemetry/api/experimental'
66

7-
import { RequestContext, getRequestContext } from './request-context.cjs'
7+
import { getRequestContext, RequestContext } from './request-context.cjs'
88

99
const spanMeta = new WeakMap<Span, { start: number; name: string }>()
1010
const spanCounter = new WeakMap<RequestContext, number>()

Diff for: src/shared/cache-types.cts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type {
33
IncrementalCache,
44
} from 'next/dist/server/lib/incremental-cache/index.js'
55
import type {
6-
IncrementalCacheValue,
76
CachedRouteValue,
7+
IncrementalCacheValue,
88
} from 'next/dist/server/response-cache/types.js'
99

1010
export type {

Diff for: tests/e2e/simple-app.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ test.skip('streams stale responses', async ({ simple }) => {
8181

8282
const res = await fetch(path)
8383

84-
// eslint-disable-next-line no-loop-func
8584
await new Promise<void>((resolve) => {
8685
res.body?.pipeTo(
8786
new WritableStream({

Diff for: tests/fixtures/nx-integrated/apps/custom-dist-dir/next.config.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//@ts-check
2-
3-
// eslint-disable-next-line @typescript-eslint/no-var-requires
41
const { composePlugins, withNx } = require('@nx/next')
52

63
/**

Diff for: tests/fixtures/nx-integrated/apps/next-app/next.config.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//@ts-check
2-
3-
// eslint-disable-next-line @typescript-eslint/no-var-requires
41
const { composePlugins, withNx } = require('@nx/next')
52

63
/**

0 commit comments

Comments
 (0)