Skip to content

Commit 0423608

Browse files
authored
chore: use recommended lint (#3072)
1 parent 949b818 commit 0423608

File tree

8 files changed

+72
-10
lines changed

8 files changed

+72
-10
lines changed

.eslintrc.js

+28-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,28 @@ const { defineConfig } = require('eslint-define-config')
33

44
module.exports = defineConfig({
55
root: true,
6-
extends: ['plugin:node/recommended'],
6+
extends: [
7+
'eslint:recommended',
8+
'plugin:node/recommended',
9+
'plugin:@typescript-eslint/recommended'
10+
],
711
parser: '@typescript-eslint/parser',
812
parserOptions: {
913
sourceType: 'module',
1014
ecmaVersion: 2020
1115
},
1216
rules: {
1317
'no-debugger': ['error'],
18+
'no-empty': ['warn', { allowEmptyCatch: true }],
19+
'no-process-exit': 'off',
20+
'no-useless-escape': 'off',
21+
'prefer-const': [
22+
'warn',
23+
{
24+
destructuring: 'all'
25+
}
26+
],
27+
1428
'node/no-missing-import': [
1529
'error',
1630
{
@@ -54,13 +68,19 @@ module.exports = defineConfig({
5468
'node/no-unpublished-import': 'off',
5569
'node/no-unpublished-require': 'off',
5670
'node/no-unsupported-features/es-syntax': 'off',
57-
'no-process-exit': 'off',
58-
'prefer-const': [
59-
'warn',
60-
{
61-
destructuring: 'all'
62-
}
63-
]
71+
72+
'@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR
73+
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
74+
'@typescript-eslint/no-empty-function': [
75+
'error',
76+
{ allow: ['arrowFunctions'] }
77+
],
78+
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
79+
'@typescript-eslint/no-extra-semi': 'off', // conflicts with prettier
80+
'@typescript-eslint/no-inferrable-types': 'off',
81+
'@typescript-eslint/no-non-null-assertion': 'off', // maybe we should turn this on in a new PR
82+
'@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR
83+
'@typescript-eslint/no-var-requires': 'off'
6484
},
6585
overrides: [
6686
{

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@types/jest": "^26.0.19",
2626
"@types/node": "^14.14.10",
2727
"@types/semver": "^7.3.4",
28+
"@typescript-eslint/eslint-plugin": "^4.22.0",
2829
"@typescript-eslint/parser": "^4.22.0",
2930
"chalk": "^4.1.0",
3031
"conventional-changelog-cli": "^2.1.1",

packages/plugin-vue/src/main.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { isOnlyTemplateChanged, isEqualBlock } from './handleHotUpdate'
1414
import { RawSourceMap, SourceMapConsumer, SourceMapGenerator } from 'source-map'
1515
import { createRollupError } from './utils/error'
1616

17+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1718
export async function transformMain(
1819
code: string,
1920
filename: string,

packages/plugin-vue/src/style.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { compileStyleAsync, SFCDescriptor } from '@vue/compiler-sfc'
22
import { TransformPluginContext } from 'rollup'
33
import { ResolvedOptions } from '.'
44

5+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
56
export async function transformStyle(
67
code: string,
78
descriptor: SFCDescriptor,

packages/plugin-vue/src/template.ts

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ResolvedOptions } from '.'
1010
import { getResolvedScript } from './script'
1111
import { createRollupError } from './utils/error'
1212

13+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1314
export function transformTemplateAsModule(
1415
code: string,
1516
descriptor: SFCDescriptor,
@@ -40,6 +41,7 @@ export function transformTemplateAsModule(
4041
/**
4142
* transform the template directly in the main SFC module
4243
*/
44+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4345
export function transformTemplateInMain(
4446
code: string,
4547
descriptor: SFCDescriptor,
@@ -57,6 +59,7 @@ export function transformTemplateInMain(
5759
}
5860
}
5961

62+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
6063
export function compile(
6164
code: string,
6265
descriptor: SFCDescriptor,

packages/vite/src/client/client.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ async function queueUpdate(p: Promise<(() => void) | undefined>) {
172172
}
173173

174174
async function waitForSuccessfulPing(ms = 1000) {
175+
// eslint-disable-next-line no-constant-condition
175176
while (true) {
176177
try {
177178
await fetch(`${base}__vite_ping`)
@@ -335,7 +336,7 @@ const ctxToListenersMap = new Map<
335336
>()
336337

337338
// Just infer the return type for now
338-
// _This would have to be activated when used `plugin:@typescript-eslint/recommended`_ eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
339+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
339340
export const createHotContext = (ownerPath: string) => {
340341
if (!dataMap.has(ownerPath)) {
341342
dataMap.set(ownerPath, {})
@@ -412,6 +413,7 @@ export const createHotContext = (ownerPath: string) => {
412413
},
413414

414415
// TODO
416+
// eslint-disable-next-line @typescript-eslint/no-empty-function
415417
decline() {},
416418

417419
invalidate() {

packages/vite/src/node/server/middlewares/indexHtml.ts

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ const devHtmlHook: IndexHtmlTransformHook = async (
4545
html,
4646
{ path: htmlPath, server }
4747
) => {
48+
// TODO: solve this design issue
49+
// Optional chain expressions can return undefined by design
50+
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
4851
const config = server?.config!
4952
const base = config.base || '/'
5053

yarn.lock

+32-1
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,11 @@
10321032
jest-diff "^26.0.0"
10331033
pretty-format "^26.0.0"
10341034

1035+
"@types/json-schema@^7.0.3":
1036+
version "7.0.7"
1037+
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
1038+
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==
1039+
10351040
"@types/less@^3.0.2":
10361041
version "3.0.2"
10371042
resolved "https://registry.yarnpkg.com/@types/less/-/less-3.0.2.tgz#2761d477678c8374cb9897666871662eb1d1115e"
@@ -1134,6 +1139,32 @@
11341139
dependencies:
11351140
"@types/node" "*"
11361141

1142+
"@typescript-eslint/eslint-plugin@^4.22.0":
1143+
version "4.22.0"
1144+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.0.tgz#3d5f29bb59e61a9dba1513d491b059e536e16dbc"
1145+
integrity sha512-U8SP9VOs275iDXaL08Ln1Fa/wLXfj5aTr/1c0t0j6CdbOnxh+TruXu1p4I0NAvdPBQgoPjHsgKn28mOi0FzfoA==
1146+
dependencies:
1147+
"@typescript-eslint/experimental-utils" "4.22.0"
1148+
"@typescript-eslint/scope-manager" "4.22.0"
1149+
debug "^4.1.1"
1150+
functional-red-black-tree "^1.0.1"
1151+
lodash "^4.17.15"
1152+
regexpp "^3.0.0"
1153+
semver "^7.3.2"
1154+
tsutils "^3.17.1"
1155+
1156+
"@typescript-eslint/experimental-utils@4.22.0":
1157+
version "4.22.0"
1158+
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.22.0.tgz#68765167cca531178e7b650a53456e6e0bef3b1f"
1159+
integrity sha512-xJXHHl6TuAxB5AWiVrGhvbGL8/hbiCQ8FiWwObO3r0fnvBdrbWEDy1hlvGQOAWc6qsCWuWMKdVWlLAEMpxnddg==
1160+
dependencies:
1161+
"@types/json-schema" "^7.0.3"
1162+
"@typescript-eslint/scope-manager" "4.22.0"
1163+
"@typescript-eslint/types" "4.22.0"
1164+
"@typescript-eslint/typescript-estree" "4.22.0"
1165+
eslint-scope "^5.0.0"
1166+
eslint-utils "^2.0.0"
1167+
11371168
"@typescript-eslint/parser@^4.22.0":
11381169
version "4.22.0"
11391170
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.22.0.tgz#e1637327fcf796c641fe55f73530e90b16ac8fe8"
@@ -2935,7 +2966,7 @@ eslint-plugin-node@^11.1.0:
29352966
resolve "^1.10.1"
29362967
semver "^6.1.0"
29372968

2938-
eslint-scope@^5.1.1:
2969+
eslint-scope@^5.0.0, eslint-scope@^5.1.1:
29392970
version "5.1.1"
29402971
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
29412972
integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==

0 commit comments

Comments
 (0)