Skip to content

Commit

Permalink
fix: update linter rule, close #729
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 8, 2021
1 parent d0fa468 commit 4fbe8d5
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 38 deletions.
29 changes: 16 additions & 13 deletions .eslintrc.js
Expand Up @@ -11,33 +11,36 @@ module.exports = {
'jest',
],
rules: {
'no-alert': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/no-null': 'off',
'unicorn/filename-case': 'off',
'react/react-in-jsx-scope': 'off',
'react/no-string-refs': 'off',
'no-new': 'off',
'import/named': 'off',
'react/no-unknown-property': 'off',
'vue/no-deprecated-functional-template': 'off',
'vue/one-component-per-file': 'off',
'vue/no-template-shadow': 'off',
'vue/require-prop-types': 'off',
'spaced-comment': ['error', 'always', { exceptions: ['@__PURE__'] }],
'spaced-comment': ['error', 'always', { exceptions: ['#__PURE__'] }],
'no-restricted-imports': [
'error',
{
paths: ['vue', '@vue/composition-api'],
},
],
},
overrides: [
{
files: ['*.md', 'demo.vue', 'scripts/*.ts'],
files: ['*.md', 'demo.vue', 'scripts/*.ts', '*.test.ts'],
rules: {
'no-alert': 'off',
'no-console': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-restricted-imports': 'off',
},
},
{
files: ['packages/.vitepress/**/*.*'],
rules: {
'no-restricted-imports': 'off',
},
},
],
Expand Down
1 change: 1 addition & 0 deletions packages/.vitepress/config.js
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
// @ts-check
require('esbuild-register')
const indexes = require('../../indexes.json')
Expand Down
3 changes: 2 additions & 1 deletion packages/.vitepress/theme/components/SideBarLink.ts
@@ -1,4 +1,5 @@
import { FunctionalComponent, h, VNode } from 'vue'
import { h } from 'vue'
import type { VNode, FunctionalComponent } from 'vue'
import { useRoute, useData } from 'vitepress'
import { DefaultTheme } from '../config'
import { joinUrl, isActive } from '../utils'
Expand Down
3 changes: 2 additions & 1 deletion packages/.vitepress/theme/composables/navLink.ts
@@ -1,4 +1,5 @@
import { computed, Ref } from 'vue'
import { computed } from 'vue'
import type { Ref } from 'vue'
import { useRoute, withBase } from 'vitepress'
import { isExternal as isExternalCheck } from '../utils'
import type { DefaultTheme } from '../config'
Expand Down
2 changes: 1 addition & 1 deletion packages/.vitepress/theme/composables/repo.ts
Expand Up @@ -38,7 +38,7 @@ function getRepoText(url: string, text?: string): string {
if (!hosts)
return 'Source'

const platform = platforms.find(([_p, re]) => re.test(hosts[0]))
const platform = platforms.find(([, re]) => re.test(hosts[0]))

if (platform && platform[0])
return platform[0]
Expand Down
4 changes: 1 addition & 3 deletions packages/.vitepress/theme/index.ts
Expand Up @@ -14,11 +14,9 @@ import 'windi.css'
const theme = {
Layout,
NotFound,
enhanceApp({ app, router }) {
enhanceApp({ router }) {
if (typeof window !== 'undefined')
handleRedirects(router)
// @ts-ignore: TODO: bring it back
// import('vite-plugin-editor-nav/client').then(i => i.default(router))
},
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/useDraggable/index.ts
@@ -1,4 +1,4 @@
import { Ref, ref, unref, computed } from 'vue'
import { Ref, ref, unref, computed } from 'vue-demi'
import { MaybeRef, toRefs } from '@vueuse/shared'
import { useEventListener } from '../useEventListener'
import { MaybeElementRef } from '../unrefElement'
Expand Down
2 changes: 2 additions & 0 deletions packages/core/useEventBus/index.ts
Expand Up @@ -5,7 +5,9 @@ import { events } from './internal'
export type EventBusListener<T = unknown> = (event: T) => void
export type EventBusEvents<T> = EventBusListener<T>[]

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface EventBusKey<T> extends Symbol { }

export type EventBusIdentifier<T = unknown> = EventBusKey<T> | string | number

export interface UseEventBusReturn<T> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useVModel/index.test.ts
Expand Up @@ -9,7 +9,7 @@ describe('useVModel', () => {
[defaultKey]: defaultValue,
})

const emitMock = jest.fn((event: string, values: any[]) => {})
const emitMock = jest.fn(() => {})
beforeEach(() => emitMock.mockClear())

it('should work with default value', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/useWakeLock/index.test.ts
Expand Up @@ -36,7 +36,7 @@ describe('useWakeLock', () => {
}

Object.defineProperty(navigator, 'wakeLock', {
value: { request: (_: 'screen') => createWakeLock() },
value: { request: () => createWakeLock() },
writable: true,
})
const { isActive, request, release } = useWakeLock()
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('useWakeLock', () => {
}

Object.defineProperty(navigator, 'wakeLock', {
value: { request: (_: 'screen') => createWakeLock() },
value: { request: () => createWakeLock() },
writable: true,
})
const { isActive, request } = useWakeLock({ document: defaultDocument })
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useWebSocket/index.md
Expand Up @@ -18,7 +18,7 @@ See the [Type Declarations](#type-declarations) for more options.

### Immediate

Auto connect (enabled by default).
Auto-connect (enabled by default).

This will call `open()` automatically for you and you don't need to call it by yourself.

Expand Down
7 changes: 1 addition & 6 deletions packages/firebase/useRTDB/index.md
Expand Up @@ -43,10 +43,5 @@ export const useTodos = createGlobalState(
// app.js
import { useTodos } from './store'

new Vue({
setup() {
const todos = useTodos()
return { todos }
},
})
const todos = useTodos()
```
3 changes: 2 additions & 1 deletion packages/integrations/useFocusTrap/index.ts
@@ -1,6 +1,7 @@
import { MaybeElementRef, unrefElement, tryOnScopeDispose, Fn } from '@vueuse/core'
import { watch, ref, Ref } from 'vue-demi'
import { ActivateOptions, createFocusTrap, DeactivateOptions, FocusTrap, Options } from 'focus-trap'
import { createFocusTrap } from 'focus-trap'
import type { ActivateOptions, DeactivateOptions, FocusTrap, Options } from 'focus-trap'

export interface UseFocusTrapOptions extends Options {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/useJwt/index.test.ts
@@ -1,4 +1,4 @@
import { JwtHeader, JwtPayload } from 'jwt-decode'
import type { JwtHeader, JwtPayload } from 'jwt-decode'
import { ref } from 'vue-demi'
import { useSetup } from '../../.test'
import { useJwt } from '.'
Expand Down
3 changes: 2 additions & 1 deletion packages/integrations/useJwt/index.ts
@@ -1,6 +1,7 @@
import { computed, ComputedRef, ref } from 'vue-demi'
import { MaybeRef } from '@vueuse/shared'
import jwt_decode, { JwtDecodeOptions, JwtHeader, JwtPayload } from 'jwt-decode'
import jwt_decode from 'jwt-decode'
import type { JwtDecodeOptions, JwtHeader, JwtPayload } from 'jwt-decode'

export interface JwtOptions<Fallback> {
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/from/index.ts
@@ -1,4 +1,5 @@
import { from as fromRxjs, fromEvent as fromEventRx, ObservableInput, Observable } from 'rxjs'
import { from as fromRxjs, fromEvent as fromEventRx, Observable } from 'rxjs'
import type { ObservableInput } from 'rxjs'
import { filter, mergeMap } from 'rxjs/operators'
import { Ref, isRef, watch } from 'vue-demi'

Expand Down
4 changes: 2 additions & 2 deletions packages/rxjs/toObserver/index.ts
@@ -1,5 +1,5 @@
import { NextObserver } from 'rxjs'
import { Ref } from 'vue-demi'
import type { NextObserver } from 'rxjs'
import type { Ref } from 'vue-demi'

export function toObserver<T>(value: Ref<T>): NextObserver<T> {
return {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/set/index.ts
Expand Up @@ -14,6 +14,7 @@ export function set(...args: any[]) {
if (args.length === 3) {
if (isVue2) {
// use @vue/composition-api's set API
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('vue-demi').set(...args)
}
else {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/toReactive/index.ts
@@ -1,4 +1,4 @@
import { isRef, toRefs as _toRefs, reactive } from 'vue-demi'
import { isRef, reactive } from 'vue-demi'
import { MaybeRef } from '../utils'

/**
Expand Down
2 changes: 1 addition & 1 deletion scripts/rollup.config.ts
Expand Up @@ -3,7 +3,7 @@ import { resolve } from 'path'
import typescript from 'rollup-plugin-typescript2'
import { terser } from 'rollup-plugin-terser'
import dts from 'rollup-plugin-dts'
import { OutputOptions, Plugin, RollupOptions } from 'rollup'
import type { OutputOptions, Plugin, RollupOptions } from 'rollup'
import fg from 'fast-glob'
import { activePackages } from '../meta/packages'

Expand Down

0 comments on commit 4fbe8d5

Please sign in to comment.