Skip to content

Commit

Permalink
fix(shared): resolve internal circular reference
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 12, 2022
1 parent e2a7828 commit 0fdbbf4
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 48 deletions.
40 changes: 28 additions & 12 deletions .eslintrc.js
@@ -1,5 +1,19 @@
const { resolve } = require('path')

const restricted = [
'vue',
'@vue/composition-api',
'..',
'../..',
resolve(__dirname, 'packages/core/index.ts'),
resolve(__dirname, 'packages/shared/index.ts'),
{
name: 'vue-demi',
importNames: ['onMounted', 'onUnmounted'],
message: 'Use tryOnMounted and tryOnScopeDispose instead.',
},
]

module.exports = {
root: true,
env: {
Expand All @@ -19,18 +33,7 @@ module.exports = {
'no-restricted-imports': [
'error',
{
paths: [
'vue',
'@vue/composition-api',
'..',
'../..',
resolve(__dirname, 'packages/core/index.ts'),
{
name: 'vue-demi',
importNames: ['onMounted', 'onUnmounted'],
message: 'Use tryOnMounted and tryOnScopeDispose instead.',
},
],
paths: restricted,
},
],
'node/no-callback-literal': 'off',
Expand All @@ -40,6 +43,19 @@ module.exports = {
'import/no-named-as-default-member': 'off',
},
overrides: [
{
files: ['packages/shared/**/*.ts'],
rules: {
'no-restricted-imports': ['error',
{
paths: [
...restricted,
'@vueuse/shared',
],
},
],
},
},
{
files: ['**/*.md', '**/*.md/*.*', 'demo.vue', 'scripts/*.ts', '*.test.ts'],
rules: {
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,5 +12,6 @@ packages/*/LICENSE
packages/contributing.md
packages/core/README.md
packages/public/badge-*
packages/*/index.mjs
playgrounds/*/pnpm-lock.yaml
types
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -50,10 +50,10 @@
"@vitest/ui": "^0.18.1",
"@vue/compiler-sfc": "^3.2.37",
"@vue/test-utils": "^2.0.2",
"@vueuse/core": "link:packages/core",
"@vueuse/integrations": "link:packages/integrations",
"@vueuse/math": "link:packages/math",
"@vueuse/shared": "link:packages/shared",
"@vueuse/core": "workspace:*",
"@vueuse/integrations": "workspace:*",
"@vueuse/math": "workspace:*",
"@vueuse/shared": "workspace:*",
"axios": "^0.27.2",
"bumpp": "^8.2.1",
"consola": "^2.15.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/ecosystem.md
Expand Up @@ -26,7 +26,7 @@ import * as console from 'vue-chemistry/console'
const a = ref(1)
const b = ref(2)

let c = sum(a, b) // c = a + b = 3
const c = sum(a, b) // c = a + b = 3

set(a, 2) // shorthand for a.value = 2

Expand Down
@@ -1,5 +1,5 @@
import { computed, ref } from 'vue-demi'
import { createInjectionState } from '@vueuse/shared'
import { createInjectionState } from '../../createInjectionState'

const [useProvideCounterStore, useCounterStore] = createInjectionState((initialValue: number) => {
// state
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/refAutoReset/index.ts
@@ -1,7 +1,7 @@
import type { Ref } from 'vue-demi'
import { customRef } from 'vue-demi'
import { resolveUnref } from '@vueuse/shared'
import type { MaybeComputedRef } from '@vueuse/shared'
import type { MaybeComputedRef } from '../utils'
import { resolveUnref } from '../resolveUnref'
import { tryOnScopeDispose } from '../tryOnScopeDispose'

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/useArrayEvery/index.ts
@@ -1,7 +1,7 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import { resolveUnref } from '@vueuse/shared'
import type { ComputedRef } from 'vue-demi'
import { computed } from 'vue-demi'
import type { MaybeComputedRef } from '../utils'
import { resolveUnref } from '../resolveUnref'

/**
* Reactive `Array.every`
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/useArrayFilter/index.ts
@@ -1,7 +1,7 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import { resolveUnref } from '@vueuse/shared'
import type { ComputedRef } from 'vue-demi'
import { computed } from 'vue-demi'
import type { MaybeComputedRef } from '../utils'
import { resolveUnref } from '../resolveUnref'

/**
* Reactive `Array.filter`
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/useArrayFind/index.ts
@@ -1,7 +1,7 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import type { ComputedRef } from 'vue-demi'
import { resolveUnref } from '@vueuse/shared'
import { computed } from 'vue-demi'
import type { MaybeComputedRef } from '../utils'
import { resolveUnref } from '../resolveUnref'

/**
* Reactive `Array.find`
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/useArrayFindIndex/index.ts
@@ -1,7 +1,7 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import { resolveUnref } from '@vueuse/shared'
import type { ComputedRef } from 'vue-demi'
import { computed } from 'vue-demi'
import type { MaybeComputedRef } from '../utils'
import { resolveUnref } from '../resolveUnref'

/**
* Reactive `Array.findIndex`
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/useArrayJoin/index.ts
@@ -1,7 +1,7 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import { resolveUnref } from '@vueuse/shared'
import type { ComputedRef } from 'vue-demi'
import { computed } from 'vue-demi'
import type { MaybeComputedRef } from '../utils'
import { resolveUnref } from '../resolveUnref'

/**
* Reactive `Array.join`
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/useArrayMap/index.ts
@@ -1,7 +1,7 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import { resolveUnref } from '@vueuse/shared'
import type { ComputedRef } from 'vue-demi'
import { computed } from 'vue-demi'
import type { MaybeComputedRef } from '../utils'
import { resolveUnref } from '../resolveUnref'

/**
* Reactive `Array.map`
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/useArrayReduce/index.ts
@@ -1,7 +1,7 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import { resolveUnref } from '@vueuse/shared'
import type { ComputedRef } from 'vue-demi'
import { computed } from 'vue-demi'
import type { MaybeComputedRef } from '../utils'
import { resolveUnref } from '../resolveUnref'

export type UseArrayReducer<PV, CV, R> = (previousValue: PV, currentValue: CV, currentIndex: number) => R

Expand Down
4 changes: 2 additions & 2 deletions packages/shared/useArraySome/index.ts
@@ -1,7 +1,7 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import { resolveUnref } from '@vueuse/shared'
import type { ComputedRef } from 'vue-demi'
import { computed } from 'vue-demi'
import type { MaybeComputedRef } from '../utils'
import { resolveUnref } from '../resolveUnref'

/**
* Reactive `Array.some`
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/useDateFormat/index.ts
@@ -1,6 +1,6 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import { resolveUnref } from '@vueuse/shared'
import { computed } from 'vue-demi'
import type { MaybeComputedRef } from '../utils'
import { resolveUnref } from '../resolveUnref'

export type DateLike = Date | number | string | undefined

Expand Down
3 changes: 1 addition & 2 deletions packages/shared/useDebounceFn/index.ts
@@ -1,5 +1,4 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import type { DebounceFilterOptions, FunctionArgs } from '../utils'
import type { DebounceFilterOptions, FunctionArgs, MaybeComputedRef } from '../utils'
import { createFilterWrapper, debounceFilter } from '../utils'

/**
Expand Down
5 changes: 2 additions & 3 deletions packages/shared/useTimeoutFn/index.ts
@@ -1,8 +1,7 @@
import { ref } from 'vue-demi'
import type { MaybeComputedRef } from '@vueuse/shared'
import { resolveUnref } from '@vueuse/shared'
import type { MaybeComputedRef, Stoppable } from '../utils'
import { resolveUnref } from '../resolveUnref'
import { tryOnScopeDispose } from '../tryOnScopeDispose'
import type { Stoppable } from '../utils'
import { isClient } from '../utils'

export interface UseTimeoutFnOptions {
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0fdbbf4

Please sign in to comment.