Skip to content

refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions #4907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3dc5bd2
refactor: add treeshake annotation for `State` category
serkodev Jul 22, 2025
f4aee15
refactor: add treeshake annotation for `Elements` category
serkodev Jul 22, 2025
d34b929
refactor: add treeshake annotation for `Browser` category
serkodev Jul 23, 2025
70aaab1
refactor: add treeshake annotation for `Sensors` category
serkodev Jul 23, 2025
90135ee
chore: move `__NO_SIDE_EFFECTS__` into JSDocs
serkodev Jul 24, 2025
4a3917b
refactor: add treeshake annotation for `Animation` category
serkodev Jul 24, 2025
e3349f4
fix: `useVModel` JSDocs position
serkodev Jul 24, 2025
f64bff9
refactor: add treeshake annotation for `Component` category
serkodev Jul 24, 2025
331ba11
refactor: add treeshake annotation for `Reactivity` category
serkodev Jul 24, 2025
81d784e
refactor: add treeshake annotation for `Time` category
serkodev Jul 24, 2025
3cf0213
refactor: add treeshake annotation for `Array` category
serkodev Jul 24, 2025
79e5e4a
refactor: add full JSDocs to function overloads
serkodev Jul 24, 2025
83e0bdf
refactor: add treeshake annotation for lazy getter resolver functions
serkodev Jul 24, 2025
878d00a
refactor: add treeshake annotation for `Utilities` category
serkodev Jul 24, 2025
541af36
refactor: add treeshake annotation for `
serkodev Jul 24, 2025
a7d92d3
refactor: add treeshake annotation for `@Integrations` category
serkodev Jul 24, 2025
04f9b80
fix: update `useClamp` JSDocs position
serkodev Jul 24, 2025
bde435c
refactor: add treeshake annotation for `@Math` category
serkodev Jul 24, 2025
09bb0cf
refactor: add treeshake annotation for `@Router`, `@RxJS` category
serkodev Jul 24, 2025
e9e3936
Merge branch 'main' into refactor/side-effects
serkodev Jul 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: move __NO_SIDE_EFFECTS__ into JSDocs
  • Loading branch information
serkodev committed Jul 24, 2025
commit 90135ee204b6809d04116f6f11d92def159cf3a7
3 changes: 2 additions & 1 deletion packages/core/useActiveElement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export interface UseActiveElementOptions extends ConfigurableWindow, Configurabl
*
* @see https://vueuse.org/useActiveElement
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useActiveElement<T extends HTMLElement>(
options: UseActiveElementOptions = {},
) {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useBattery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ type NavigatorWithBattery = Navigator & {
* Reactive Battery Status API.
*
* @see https://vueuse.org/useBattery
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useBattery(options: ConfigurableNavigator = {}) {
const { navigator = defaultNavigator } = options
const events = ['chargingchange', 'chargingtimechange', 'dischargingtimechange', 'levelchange']
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useBluetooth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface UseBluetoothOptions extends UseBluetoothRequestDeviceOptions, C
acceptAllDevices?: boolean
}

/* #__NO_SIDE_EFFECTS__ */
/* @__NO_SIDE_EFFECTS__ */
export function useBluetooth(options?: UseBluetoothOptions): UseBluetoothReturn {
let {
acceptAllDevices = false,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useBrowserLocation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ export interface BrowserLocationState {
* Reactive browser location.
*
* @see https://vueuse.org/useBrowserLocation
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useBrowserLocation(options: ConfigurableWindow = {}) {
const { window = defaultWindow } = options
const refs = Object.fromEntries(
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useDeviceOrientation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import { useSupported } from '../useSupported'
*
* @see https://vueuse.org/useDeviceOrientation
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useDeviceOrientation(options: ConfigurableWindow = {}) {
const { window = defaultWindow } = options
const isSupported = useSupported(() => window && 'DeviceOrientationEvent' in window)
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useDevicePixelRatio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { useMediaQuery } from '../useMediaQuery'
* Reactively track `window.devicePixelRatio`.
*
* @see https://vueuse.org/useDevicePixelRatio
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useDevicePixelRatio(options: ConfigurableWindow = {}) {
const {
window = defaultWindow,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useDocumentVisibility/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { useEventListener } from '../useEventListener'
* Reactively track `document.visibilityState`.
*
* @see https://vueuse.org/useDocumentVisibility
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useDocumentVisibility(options: ConfigurableDocument = {}): ShallowRef<DocumentVisibilityState> {
const { document = defaultDocument } = options
if (!document)
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useEyeDropper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export interface UseEyeDropperOptions {
* Reactive [EyeDropper API](https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper_API)
*
* @see https://vueuse.org/useEyeDropper
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useEyeDropper(options: UseEyeDropperOptions = {}) {
const { initialValue = '' } = options
const isSupported = useSupported(() => typeof window !== 'undefined' && 'EyeDropper' in window)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useFps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface UseFpsOptions {
every?: number
}

/* #__NO_SIDE_EFFECTS__ */
/* @__NO_SIDE_EFFECTS__ */
export function useFps(options?: UseFpsOptions): ShallowRef<number> {
const fps = shallowRef(0)
if (typeof performance === 'undefined')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useGamepad/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function mapGamepadToXbox360Controller(gamepad: Ref<Gamepad | undefined>)
})
}

/* #__NO_SIDE_EFFECTS__ */
/* @__NO_SIDE_EFFECTS__ */
export function useGamepad(options: UseGamepadOptions = {}) {
const {
navigator = defaultNavigator,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useKeyModifier/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface UseModifierOptions<Initial> extends ConfigurableDocument {

export type UseKeyModifierReturn<Initial> = ShallowRef<Initial extends boolean ? boolean : boolean | null>

/* #__NO_SIDE_EFFECTS__ */
/* @__NO_SIDE_EFFECTS__ */
export function useKeyModifier<Initial extends boolean | null>(modifier: KeyModifier, options: UseModifierOptions<Initial> = {}): UseKeyModifierReturn<Initial> {
const {
events = defaultEvents,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useMemory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ type PerformanceMemory = Performance & {
*
* @see https://vueuse.org/useMemory
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useMemory(options: UseMemoryOptions = {}) {
const memory = deepRef<MemoryInfo>()
const isSupported = useSupported(() => typeof performance !== 'undefined' && 'memory' in performance)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useNavigatorLanguage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export interface NavigatorLanguageState {
* Detects the currently selected user language and returns a reactive language
* @see https://vueuse.org/useNavigatorLanguage
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useNavigatorLanguage(options: ConfigurableWindow = {}): Readonly<NavigatorLanguageState> {
const { window = defaultWindow } = options

Expand Down
3 changes: 2 additions & 1 deletion packages/core/useNetwork/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ export interface NetworkState {
*
* @see https://vueuse.org/useNetwork
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useNetwork(options: ConfigurableWindow = {}): Readonly<NetworkState> {
const { window = defaultWindow } = options
const navigator = window?.navigator
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useOnline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { useNetwork } from '../useNetwork'
*
* @see https://vueuse.org/useOnline
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useOnline(options: ConfigurableWindow = {}) {
const { isOnline } = useNetwork(options)
return isOnline
Expand Down
3 changes: 2 additions & 1 deletion packages/core/usePageLeave/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { useEventListener } from '../useEventListener'
*
* @see https://vueuse.org/usePageLeave
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function usePageLeave(options: ConfigurableWindow = {}) {
const { window = defaultWindow } = options
const isLeft = shallowRef(false)
Expand Down
4 changes: 3 additions & 1 deletion packages/core/usePermission/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export interface UsePermissionReturnWithControls {
* Reactive Permissions API.
*
* @see https://vueuse.org/usePermission
*
* @__NO_SIDE_EFFECTS__
*/
export function usePermission(
permissionDesc: GeneralPermissionDescriptor | GeneralPermissionDescriptor['name'],
Expand All @@ -57,7 +59,7 @@ export function usePermission(
permissionDesc: GeneralPermissionDescriptor | GeneralPermissionDescriptor['name'],
options: UsePermissionOptions<true>,
): UsePermissionReturnWithControls
/* #__NO_SIDE_EFFECTS__ */
/* @__NO_SIDE_EFFECTS__ */
export function usePermission(
permissionDesc: GeneralPermissionDescriptor | GeneralPermissionDescriptor['name'],
options: UsePermissionOptions<boolean> = {},
Expand Down
3 changes: 2 additions & 1 deletion packages/core/usePreferredColorScheme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export type ColorSchemeType = 'dark' | 'light' | 'no-preference'
*
* @see https://vueuse.org/usePreferredColorScheme
* @param [options]
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function usePreferredColorScheme(options?: ConfigurableWindow) {
const isLight = useMediaQuery('(prefers-color-scheme: light)', options)
const isDark = useMediaQuery('(prefers-color-scheme: dark)', options)
Expand Down
3 changes: 2 additions & 1 deletion packages/core/usePreferredContrast/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export type ContrastType = 'more' | 'less' | 'custom' | 'no-preference'
*
* @see https://vueuse.org/usePreferredContrast
* @param [options]
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function usePreferredContrast(options?: ConfigurableWindow) {
const isMore = useMediaQuery('(prefers-contrast: more)', options)
const isLess = useMediaQuery('(prefers-contrast: less)', options)
Expand Down
3 changes: 2 additions & 1 deletion packages/core/usePreferredDark/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { useMediaQuery } from '../useMediaQuery'
*
* @see https://vueuse.org/usePreferredDark
* @param [options]
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function usePreferredDark(options?: ConfigurableWindow) {
return useMediaQuery('(prefers-color-scheme: dark)', options)
}
3 changes: 2 additions & 1 deletion packages/core/usePreferredLanguages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { useEventListener } from '../useEventListener'
*
* @see https://vueuse.org/usePreferredLanguages
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function usePreferredLanguages(options: ConfigurableWindow = {}): Ref<readonly string[]> {
const { window = defaultWindow } = options
if (!window)
Expand Down
3 changes: 2 additions & 1 deletion packages/core/usePreferredReducedMotion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export type ReducedMotionType = 'reduce' | 'no-preference'
*
* @see https://vueuse.org/usePreferredReducedMotion
* @param [options]
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function usePreferredReducedMotion(options?: ConfigurableWindow) {
const isReduced = useMediaQuery('(prefers-reduced-motion: reduce)', options)

Expand Down
3 changes: 2 additions & 1 deletion packages/core/usePreferredReducedTransparency/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export type ReducedTransparencyType = 'reduce' | 'no-preference'
*
* @see https://vueuse.org/usePreferredReducedTransparency
* @param [options]
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function usePreferredReducedTransparency(options?: ConfigurableWindow) {
const isReduced = useMediaQuery('(prefers-reduced-transparency: reduce)', options)

Expand Down
2 changes: 1 addition & 1 deletion packages/core/useSSRWidth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { hasInjectionContext } from 'vue'

const ssrWidthSymbol = Symbol('vueuse-ssr-width') as InjectionKey<number | null>

/* #__NO_SIDE_EFFECTS__ */
/* @__NO_SIDE_EFFECTS__ */
export function useSSRWidth() {
// Avoid injection warning outside of components
const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useScreenOrientation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export interface ScreenOrientation extends EventTarget {
* Reactive screen orientation
*
* @see https://vueuse.org/useScreenOrientation
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useScreenOrientation(options: ConfigurableWindow = {}) {
const {
window = defaultWindow,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useTextDirection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export interface UseTextDirectionOptions extends ConfigurableDocument {
* Reactive dir of the element's text.
*
* @see https://vueuse.org/useTextDirection
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useTextDirection(options: UseTextDirectionOptions = {}) {
const {
document = defaultDocument,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useTextSelection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ function getRangesFromSelection(selection: Selection) {
* Reactively track user text selection based on [`Window.getSelection`](https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection).
*
* @see https://vueuse.org/useTextSelection
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useTextSelection(options: ConfigurableWindow = {}) {
const {
window = defaultWindow,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useWakeLock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ export type UseWakeLockOptions = ConfigurableNavigator & ConfigurableDocument
*
* @see https://vueuse.org/useWakeLock
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useWakeLock(options: UseWakeLockOptions = {}) {
const {
navigator = defaultNavigator,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useWindowFocus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { useEventListener } from '../useEventListener'
* Reactively track window focus with `window.onfocus` and `window.onblur`.
*
* @see https://vueuse.org/useWindowFocus
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useWindowFocus(options: ConfigurableWindow = {}): ShallowRef<boolean> {
const { window = defaultWindow } = options
if (!window)
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useWindowSize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ export interface UseWindowSizeOptions extends ConfigurableWindow {
*
* @see https://vueuse.org/useWindowSize
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function useWindowSize(options: UseWindowSizeOptions = {}) {
const {
window = defaultWindow,
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/createGlobalState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export type CreateGlobalStateReturn<Fn extends AnyFn = AnyFn> = Fn
*
* @see https://vueuse.org/createGlobalState
* @param stateFactory A factory function to create the state
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function createGlobalState<Fn extends AnyFn>(
stateFactory: Fn,
): CreateGlobalStateReturn<Fn> {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/createInjectionState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export interface CreateInjectionStateOptions<Return> {
*
* @see https://vueuse.org/createInjectionState
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function createInjectionState<Arguments extends Array<any>, Return>(
composable: (...args: Arguments) => Return,
options?: CreateInjectionStateOptions<Return>,
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/createSharedComposable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export type SharedComposableReturn<T extends AnyFn = AnyFn> = T
* Make a composable function usable with multiple Vue instances.
*
* @see https://vueuse.org/createSharedComposable
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
export function createSharedComposable<Fn extends AnyFn>(composable: Fn): SharedComposableReturn<Fn> {
let subscribers = 0
let state: ReturnType<Fn> | undefined
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/injectLocal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { localProvidedStateMap } from '../provideLocal/map'
* injectLocal('MyInjectionKey', 1)
* const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
* ```
*
* @__NO_SIDE_EFFECTS__
*/
/* #__NO_SIDE_EFFECTS__ */
// @ts-expect-error overloads are not compatible
export const injectLocal: typeof inject = (...args) => {
const key = args[0] as string | symbol
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy