Skip to content

Commit

Permalink
chore: use recommended lint (#3072)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Apr 25, 2021
1 parent 949b818 commit 0423608
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 10 deletions.
36 changes: 28 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ const { defineConfig } = require('eslint-define-config')

module.exports = defineConfig({
root: true,
extends: ['plugin:node/recommended'],
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:@typescript-eslint/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
},
rules: {
'no-debugger': ['error'],
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-process-exit': 'off',
'no-useless-escape': 'off',
'prefer-const': [
'warn',
{
destructuring: 'all'
}
],

'node/no-missing-import': [
'error',
{
Expand Down Expand Up @@ -54,13 +68,19 @@ module.exports = defineConfig({
'node/no-unpublished-import': 'off',
'node/no-unpublished-require': 'off',
'node/no-unsupported-features/es-syntax': 'off',
'no-process-exit': 'off',
'prefer-const': [
'warn',
{
destructuring: 'all'
}
]

'@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
'@typescript-eslint/no-empty-function': [
'error',
{ allow: ['arrowFunctions'] }
],
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-extra-semi': 'off', // conflicts with prettier
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-var-requires': 'off'
},
overrides: [
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@types/jest": "^26.0.19",
"@types/node": "^14.14.10",
"@types/semver": "^7.3.4",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"chalk": "^4.1.0",
"conventional-changelog-cli": "^2.1.1",
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-vue/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { isOnlyTemplateChanged, isEqualBlock } from './handleHotUpdate'
import { RawSourceMap, SourceMapConsumer, SourceMapGenerator } from 'source-map'
import { createRollupError } from './utils/error'

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export async function transformMain(
code: string,
filename: string,
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-vue/src/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { compileStyleAsync, SFCDescriptor } from '@vue/compiler-sfc'
import { TransformPluginContext } from 'rollup'
import { ResolvedOptions } from '.'

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export async function transformStyle(
code: string,
descriptor: SFCDescriptor,
Expand Down
3 changes: 3 additions & 0 deletions packages/plugin-vue/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ResolvedOptions } from '.'
import { getResolvedScript } from './script'
import { createRollupError } from './utils/error'

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function transformTemplateAsModule(
code: string,
descriptor: SFCDescriptor,
Expand Down Expand Up @@ -40,6 +41,7 @@ export function transformTemplateAsModule(
/**
* transform the template directly in the main SFC module
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function transformTemplateInMain(
code: string,
descriptor: SFCDescriptor,
Expand All @@ -57,6 +59,7 @@ export function transformTemplateInMain(
}
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function compile(
code: string,
descriptor: SFCDescriptor,
Expand Down
4 changes: 3 additions & 1 deletion packages/vite/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ async function queueUpdate(p: Promise<(() => void) | undefined>) {
}

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

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

// TODO
// eslint-disable-next-line @typescript-eslint/no-empty-function
decline() {},

invalidate() {
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/node/server/middlewares/indexHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const devHtmlHook: IndexHtmlTransformHook = async (
html,
{ path: htmlPath, server }
) => {
// TODO: solve this design issue
// Optional chain expressions can return undefined by design
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
const config = server?.config!
const base = config.base || '/'

Expand Down
33 changes: 32 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,11 @@
jest-diff "^26.0.0"
pretty-format "^26.0.0"

"@types/json-schema@^7.0.3":
version "7.0.7"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==

"@types/less@^3.0.2":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@types/less/-/less-3.0.2.tgz#2761d477678c8374cb9897666871662eb1d1115e"
Expand Down Expand Up @@ -1134,6 +1139,32 @@
dependencies:
"@types/node" "*"

"@typescript-eslint/eslint-plugin@^4.22.0":
version "4.22.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.0.tgz#3d5f29bb59e61a9dba1513d491b059e536e16dbc"
integrity sha512-U8SP9VOs275iDXaL08Ln1Fa/wLXfj5aTr/1c0t0j6CdbOnxh+TruXu1p4I0NAvdPBQgoPjHsgKn28mOi0FzfoA==
dependencies:
"@typescript-eslint/experimental-utils" "4.22.0"
"@typescript-eslint/scope-manager" "4.22.0"
debug "^4.1.1"
functional-red-black-tree "^1.0.1"
lodash "^4.17.15"
regexpp "^3.0.0"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/experimental-utils@4.22.0":
version "4.22.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.22.0.tgz#68765167cca531178e7b650a53456e6e0bef3b1f"
integrity sha512-xJXHHl6TuAxB5AWiVrGhvbGL8/hbiCQ8FiWwObO3r0fnvBdrbWEDy1hlvGQOAWc6qsCWuWMKdVWlLAEMpxnddg==
dependencies:
"@types/json-schema" "^7.0.3"
"@typescript-eslint/scope-manager" "4.22.0"
"@typescript-eslint/types" "4.22.0"
"@typescript-eslint/typescript-estree" "4.22.0"
eslint-scope "^5.0.0"
eslint-utils "^2.0.0"

"@typescript-eslint/parser@^4.22.0":
version "4.22.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.22.0.tgz#e1637327fcf796c641fe55f73530e90b16ac8fe8"
Expand Down Expand Up @@ -2935,7 +2966,7 @@ eslint-plugin-node@^11.1.0:
resolve "^1.10.1"
semver "^6.1.0"

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

0 comments on commit 0423608

Please sign in to comment.