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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

serkodev
Copy link

@serkodev serkodev commented Jul 23, 2025

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Description

Resolve #4906

Symbol Meaning
🟢 No side effects
🤔🟢 No side effects in most situations
🟠 Potentially side effects
🔴 Side effects

I will add annotations to all functions that has "No side effects 🟢" only.
For other cases, I’d like to gather feedback from the community first.

Side Effects Notes

ℹ Click to open

ref param

The param contains getter ref. This may contains side effects inside the closure.

const foo = computed(() => {
  someSideEffects()
  return 1
})

useRefHistory(foo)

object param

The param contains object. This may contains side effects inside the object getter.

const options = {
  get initialValue() {
    someSideEffects()
    return '#000'
  }
}

useEyeDropper(options)

State Pure Notes
createGlobalState 🟢
createInjectionState 🟢
createSharedComposable 🟢
injectLocal 🟢
provideLocal 🔴 provide data
useAsyncState 🔴 callbacks
useDebouncedRefHistory 🤔🟢 ref param
useLastChanged 🤔🟢 ref param
useLocalStorage 🔴 create storage when init
useManualRefHistory 🤔🟢 ref param
useRefHistory 🤔🟢 ref param
useSessionStorage 🔴 create storage when init
useStorage 🔴 create storage when init
useStorageAsync 🔴 create storage when init
useThrottledRefHistory 🤔🟢 ref param
Elements Pure Notes
useActiveElement 🟢
useDocumentVisibility 🟢 object param (options)
useDraggable 🔴 make elements draggable
useDropZone 🔴 add listener to element
useElementBounding 🤔🟢 ref param (target)
useElementSize 🤔🟢 ref param (target)
useElementVisibility 🤔🟢 ref param (element)
useIntersectionObserver 🔴 callback
useMouseInElement 🤔🟢 closure param (options.eventFilter)
useMutationObserver 🔴 callback
useParentElement 🤔🟢 ref param (element)
useResizeObserver 🔴 callback
useWindowFocus 🟢 object param (options)
useWindowScroll 🔴 callback (options.onScroll)
useWindowSize 🟢 object param (options)
Browser Pure Notes
useBluetooth 🟢 run after requestDevice
useBreakpoints 🤔🟢 ref param (breakpoints)
useBroadcastChannel 🤔🟢 create BroadcastChannel
useBrowserLocation 🟢
useClipboard 🤔🟢 ref param (options.source)
useClipboardItems 🤔🟢 ref param (options.source)
useColorMode 🔴 possibly use useStorage
useCssVar 🔴 possibly set css var
useDark 🔴 possibly use useStorage
useEventListener 🔴 callback
useEyeDropper 🟢 object param (options)
useFavicon 🔴 set favicon
useFileDialog 🤔🟢 ref param (options.input)
useFileSystemAccess 🤔🟢 ref param (options.dataType)
useFullscreen 🤔🟢 ref param (target)
useGamepad 🟢 called navigator.getGamepads()
useImage 🔴 request Image
useMediaControls 🔴 set media src
useMediaQuery 🤔🟢 ref param (query)
useMemory 🟢
useObjectUrl 🤔🟢 ref param (object)
usePerformanceObserver 🔴 callback
usePermission 🟢 object param (options)
usePreferredColorScheme 🟢 object param (options)
usePreferredContrast 🟢 object param (options)
usePreferredDark 🟢 object param (options)
usePreferredLanguages 🟢 object param (options)
usePreferredReducedMotion 🟢 object param (options)
usePreferredReducedTransparency 🟢 object param (options)
useScreenOrientation 🟢 object param (options)
useScreenSafeArea 🟠 created --vueuse-safe-area-* CSS var
useScriptTag 🔴 callback (onLoaded)
useShare 🤔🟢 ref param (shareOptions)
useSSRWidth 🟢
useStyleTag 🔴 create style tag
useTextareaAutosize 🔴 callback (options.onResize)
useTextDirection 🟢 object param (options)
useTitle 🔴 set title immediately
useUrlSearchParams 🤔🟢 closure param (options.stringify)
useVibrate 🤔🟢 ref param (options.pattern)
useWakeLock 🟢
useWebNotification 🔴 request permission immediately
useWebWorker 🔴 load worker immediately
useWebWorkerFn 🔴 terminate worker immediately
Sensors Pure Notes
onClickOutside 🔴 callback
onElementRemoval 🔴 callback
onKeyStroke 🔴 callback
onLongPress 🔴 callback
onStartTyping 🔴 callback
useBattery 🟢 object param (options)
useDeviceMotion 🤔🟢 closure param (options.eventFilter)
useDeviceOrientation 🟢 object param (options)
useDevicePixelRatio 🟢 object param (options)
useDevicesList 🔴 possible requestPermissions immediately
useDisplayMedia 🤔🟢 ref param (enabled)
useElementByPoint 🤔🟢 ref param (x, y, ...)
useElementHover 🤔🟢 ref param (el)
useFocus 🤔🟢 ref param (target)
useFocusWithin 🤔🟢 ref param (target)
useFps 🟢 object param (options)
useGeolocation 🔴 grant permission
useIdle 🤔🟢 closure param (options.eventFilter)
useInfiniteScroll 🔴 make element infinite scroll
useKeyModifier 🟢 object param (options)
useMagicKeys 🟠 callback (onEventFired)
useMouse 🤔🟢 ref param (target)
useMousePressed 🔴 callback (onPressed)
useNavigatorLanguage 🟢 object param (options)
useNetwork 🟢 object param (options)
useOnline 🟢 object param (options)
usePageLeave 🟢 object param (options)
useParallax 🤔🟢 ref param (target)
usePointer 🤔🟢 ref param (target)
usePointerLock 🤔🟢 ref param (target)
usePointerSwipe 🔴 callback (onSwipe)
useScroll 🔴 possible set scroll behavior
useScrollLock 🤔🟢 ref param (element)
useSpeechRecognition 🤔🟢 ref param (lang)
useSpeechSynthesis 🤔🟢 ref param (lang)
useSwipe 🔴 callback (onSwipe)
useTextSelection 🟢 object param (options)
useUserMedia 🤔🟢 ref param (enabled)

⏳ Categories Progress

@serkodev serkodev changed the title refactor: add #__NO_SIDE_EFFECTS__ to all pure functions refactor: add #__NO_SIDE_EFFECTS__ annotations to all pure functions Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure unused values created by pure functions (like createGlobalState) are tree-shakeable
1 participant
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