Skip to content

Commit 3f90488

Browse files
Chore: Typos and grammar (vercel#2094)
* chore: processed all high-level texts for grammatical corrections * chore: the sense was incorrectly corrected by the processor * chore: fixed unnecessary commas and grammar correction nuances * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Jiachi Liu <[email protected]>
1 parent 8793ee5 commit 3f90488

32 files changed

+100
-100
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Our Pledge
44

55
In the interest of fostering an open and welcoming environment, we as
6-
contributors and maintainers pledge to making participation in our project and
6+
contributors and maintainers pledge to make participation in our project and
77
our community a harassment-free experience for everyone, regardless of age, body
88
size, disability, ethnicity, sex characteristics, gender identity and expression,
99
level of experience, education, socio-economic status, nationality, personal
@@ -26,7 +26,7 @@ Examples of unacceptable behavior by participants include:
2626
advances
2727
* Trolling, insulting/derogatory comments, and personal or political attacks
2828
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
29+
* Publishing others' private information, such as physical or electronic
3030
address, without explicit permission
3131
* Other conduct which could reasonably be considered inappropriate in a
3232
professional setting
@@ -58,7 +58,7 @@ Instances of abusive, harassing, or otherwise unacceptable behavior may be
5858
reported by contacting the project team at [email protected]. All
5959
complaints will be reviewed and investigated and will result in a response that
6060
is deemed necessary and appropriate to the circumstances. The project team is
61-
obligated to maintain confidentiality with regard to the reporter of an incident.
61+
obligated to maintain confidentiality concerning the reporter of an incident.
6262
Further details of specific enforcement policies may be posted separately.
6363

6464
Project maintainers who do not follow or enforce the Code of Conduct in good

.github/CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ Thank you for reading this guide and we appreciate any contribution.
44

55
## Ask a Question
66

7-
You can use the repository's [Discussions](https://github.com/vercel/swr/discussions) page to ask any questions, post feedback or share your experience on how you use this library.
7+
You can use the repository's [Discussions](https://github.com/vercel/swr/discussions) page to ask any questions, post feedback, or share your experience on how you use this library.
88

99
## Report a Bug
1010

1111
Whenever you find something which is not working properly, please first search the repository's [Issues](https://github.com/vercel/swr/issues) page and make sure it's not reported by someone else already.
1212

13-
If not, feel free to open an issue with the detailed description of the problem and the expected behavior. And reproduction (for example a [CodeSandbox](https://codesandbox.io) link) will be extremely helpful.
13+
If not, feel free to open an issue with a detailed description of the problem and the expected behavior. And reproduction (for example a [CodeSandbox](https://codesandbox.io) link) will be extremely helpful.
1414

1515
## Request for a New Feature
1616

17-
For new features, it would be great to have some discussions from the community before starting working on it. You can either create an issue (if there isn't one) or post a thread in the [Discussions](https://github.com/vercel/swr/discussions) page to describe the feature that you want to have.
17+
For new features, it would be great to have some discussions from the community before starting working on it. You can either create an issue (if there isn't one) or post a thread on the [Discussions](https://github.com/vercel/swr/discussions) page to describe the feature that you want to have.
1818

19-
If possible, you can add other additional context like how this feature can be implemented technically, what other alternative solutions we can have, etc.
19+
If possible, you can add another additional context like how this feature can be implemented technically, what other alternative solutions we can have, etc.
2020

2121
## Open a PR for Bugfix or Feature
2222

2323
### Local Development with Examples
2424

25-
To run SWR locally, you can start it with any example in `examples` folder. You need to setup the example and run command in the root directory for overriding SWR and its dependencies to local assets.
25+
To run SWR locally, you can start it with any example in the `examples` folder. You need to set up the example and run the command in the root directory for overriding SWR and its dependencies to local assets.
2626

2727
First of all, build SWR assets
2828

_internal/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export interface SWRHook {
126126
): SWRResponse<Data, Error>
127127
}
128128

129-
// Middleware guarantee that a SWRHook receives a key, fetcher, and config as the argument
129+
// Middleware guarantees that a SWRHook receives a key, fetcher, and config as the argument
130130
export type Middleware = (
131131
useSWRNext: SWRHook
132132
) => <Data = any, Error = any>(

_internal/utils/cache.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export const initCache = <Data = any>(
3131
| [Cache<Data>, ScopedMutator<Data>]
3232
| undefined => {
3333
// The global state for a specific provider will be used to deduplicate
34-
// requests and store listeners. As well as a mutate function that bound to
34+
// requests and store listeners. As well as a mutate function that is bound to
3535
// the cache.
3636

37-
// Provider's global state might be already initialized. Let's try to get the
37+
// The provider's global state might be already initialized. Let's try to get the
3838
// global state associated with the provider first.
3939
if (!SWRGlobalState.has(provider)) {
4040
const opts = mergeObjects(defaultConfigOptions, options)
@@ -73,7 +73,7 @@ export const initCache = <Data = any>(
7373

7474
const initProvider = () => {
7575
if (!SWRGlobalState.has(provider)) {
76-
// Update the state if it's new, or the provider has been extended.
76+
// Update the state if it's new, or if the provider has been extended.
7777
SWRGlobalState.set(provider, [
7878
EVENT_REVALIDATORS,
7979
{},
@@ -86,7 +86,7 @@ export const initCache = <Data = any>(
8686
if (!IS_SERVER) {
8787
// When listening to the native events for auto revalidations,
8888
// we intentionally put a delay (setTimeout) here to make sure they are
89-
// fired after immediate JavaScript executions, which can possibly be
89+
// fired after immediate JavaScript executions, which can be
9090
// React's state updates.
9191
// This avoids some unnecessary revalidations such as
9292
// https://github.com/vercel/swr/issues/1680.
@@ -114,7 +114,7 @@ export const initCache = <Data = any>(
114114
releaseFocus && releaseFocus()
115115
releaseReconnect && releaseReconnect()
116116
// When un-mounting, we need to remove the cache provider from the state
117-
// storage too because it's a side-effect. Otherwise when re-mounting we
117+
// storage too because it's a side-effect. Otherwise, when re-mounting we
118118
// will not re-register those event listeners.
119119
SWRGlobalState.delete(provider)
120120
}

_internal/utils/helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Key, Cache, State, GlobalState } from '../types'
44
const EMPTY_CACHE = {}
55
export const noop = () => {}
66

7-
// Using noop() as the undefined value as undefined can possibly be replaced
7+
// Using noop() as the undefined value as undefined can be replaced
88
// by something else. Prettier ignore and extra parentheses are necessary here
99
// to ensure that tsc doesn't remove the __NOINLINE__ comment.
1010
// prettier-ignore
@@ -22,7 +22,7 @@ export const mergeObjects = (a: any, b?: any) => OBJECT.assign({}, a, b)
2222

2323
const STR_UNDEFINED = 'undefined'
2424

25-
// NOTE: Use function to guarantee it's re-evaluated between jsdom and node runtime for tests.
25+
// NOTE: Use the function to guarantee it's re-evaluated between jsdom and node runtime for tests.
2626
export const isWindowDefined = typeof window != STR_UNDEFINED
2727
export const isDocumentDefined = typeof document != STR_UNDEFINED
2828
export const hasRequestAnimationFrame = () =>

_internal/utils/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const useStateWithDeps = <S = any>(
1717
const unmountedRef = useRef(false)
1818
const stateRef = useRef(state)
1919

20-
// If a state property (data, error or isValidating) is accessed by the render
20+
// If a state property (data, error, or isValidating) is accessed by the render
2121
// function, we mark the property as a dependency so if it is updated again
2222
// in the future, we trigger a rerender.
2323
// This is also known as dependency-tracking.

_internal/utils/web-preset.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import type { ProviderConfiguration } from '../types'
22
import { isUndefined, noop, isWindowDefined, isDocumentDefined } from './helper'
33

44
/**
5-
* Due to bug https://bugs.chromium.org/p/chromium/issues/detail?id=678075,
5+
* Due to the bug https://bugs.chromium.org/p/chromium/issues/detail?id=678075,
66
* it's not reliable to detect if the browser is currently online or offline
77
* based on `navigator.onLine`.
8-
* As a work around, we always assume it's online on first load, and change
8+
* As a workaround, we always assume it's online on the first load, and change
99
* the status upon `online` or `offline` events.
1010
*/
1111
let online = true

core/use-swr.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export const useSWRHandler = <Data = any, Error = any>(
190190
const data = isUndefined(cachedData) ? fallback : cachedData
191191
const error = cached.error
192192

193-
// Use a ref to store previous returned data. Use the initial data as its initial value.
193+
// Use a ref to store previously returned data. Use the initial data as its initial value.
194194
const laggyDataRef = useRef(data)
195195

196196
const returnedData = keepPreviousData
@@ -211,17 +211,17 @@ export const useSWRHandler = <Data = any, Error = any>(
211211
if (getConfig().isPaused()) return false
212212

213213
// Under suspense mode, it will always fetch on render if there is no
214-
// stale data so no need to revalidate immediately on mount again.
214+
// stale data so no need to revalidate immediately mount it again.
215215
// If data exists, only revalidate if `revalidateIfStale` is true.
216216
if (suspense) return isUndefined(data) ? false : config.revalidateIfStale
217217

218-
// If there is no stale data, we need to revalidate on mount;
218+
// If there is no stale data, we need to revalidate when mount;
219219
// If `revalidateIfStale` is set to true, we will always revalidate.
220220
return isUndefined(data) || config.revalidateIfStale
221221
})()
222222

223223
// Resolve the default validating state:
224-
// If it's able to validate, and it should revalidate on mount, this will be true.
224+
// If it's able to validate, and it should revalidate when mount, this will be true.
225225
const defaultValidatingState = !!(
226226
key &&
227227
fetcher &&
@@ -281,7 +281,7 @@ export const useSWRHandler = <Data = any, Error = any>(
281281
return key === keyRef.current
282282
}
283283

284-
// The final state object when request finishes.
284+
// The final state object when the request finishes.
285285
const finalState: State<Data, Error> = {
286286
isValidating: false,
287287
isLoading: false
@@ -290,7 +290,7 @@ export const useSWRHandler = <Data = any, Error = any>(
290290
setCache(finalState)
291291
}
292292
const cleanupState = () => {
293-
// Check if it's still the same request before deleting.
293+
// Check if it's still the same request before deleting it.
294294
const requestInfo = FETCH[key]
295295
if (requestInfo && requestInfo[1] === startAt) {
296296
delete FETCH[key]
@@ -307,7 +307,7 @@ export const useSWRHandler = <Data = any, Error = any>(
307307
try {
308308
if (shouldStartNewRequest) {
309309
setCache(initialState)
310-
// If no cache being rendered currently (it shows a blank page),
310+
// If no cache is being rendered currently (it shows a blank page),
311311
// we trigger the loading slow event.
312312
if (config.loadingTimeout && isUndefined(getCache().data)) {
313313
setTimeout(() => {
@@ -354,7 +354,7 @@ export const useSWRHandler = <Data = any, Error = any>(
354354
// Clear error.
355355
finalState.error = UNDEFINED
356356

357-
// If there're other mutations(s), overlapped with the current revalidation:
357+
// If there're other mutations(s), that overlapped with the current revalidation:
358358
// case 1:
359359
// req------------------>res
360360
// mutate------>end
@@ -384,7 +384,7 @@ export const useSWRHandler = <Data = any, Error = any>(
384384
}
385385
return false
386386
}
387-
// Deep compare with latest state to avoid extra re-renders.
387+
// Deep compare with the latest state to avoid extra re-renders.
388388
// For local state, compare and assign.
389389
const cacheData = getCache().data
390390

@@ -404,7 +404,7 @@ export const useSWRHandler = <Data = any, Error = any>(
404404
const currentConfig = getConfig()
405405
const { shouldRetryOnError } = currentConfig
406406

407-
// Not paused, we continue handling the error. Otherwise discard it.
407+
// Not paused, we continue handling the error. Otherwise, discard it.
408408
if (!currentConfig.isPaused()) {
409409
// Get a new error, don't use deep comparison for errors.
410410
finalState.error = err as Error
@@ -419,7 +419,7 @@ export const useSWRHandler = <Data = any, Error = any>(
419419
shouldRetryOnError(err as Error))
420420
) {
421421
if (isActive()) {
422-
// If it's inactive, stop. It will auto revalidate when
422+
// If it's inactive, stop. It will auto-revalidate when
423423
// refocusing or reconnecting.
424424
// When retrying, deduplication is always enabled.
425425
currentConfig.onErrorRetry(
@@ -460,7 +460,7 @@ export const useSWRHandler = <Data = any, Error = any>(
460460
[key, cache]
461461
)
462462

463-
// Similar to the global mutate, but bound to the current cache and key.
463+
// Similar to the global mutate but bound to the current cache and key.
464464
// `cache` isn't allowed to change during the lifecycle.
465465
// eslint-disable-next-line react-hooks/exhaustive-deps
466466
const boundMutate: SWRResponse<Data, Error>['mutate'] = useCallback(
@@ -472,7 +472,7 @@ export const useSWRHandler = <Data = any, Error = any>(
472472
[]
473473
)
474474

475-
// Logic for updating refs.
475+
// The logic for updating refs.
476476
useIsomorphicLayoutEffect(() => {
477477
fetcherRef.current = fetcher
478478
configRef.current = config
@@ -554,7 +554,7 @@ export const useSWRHandler = <Data = any, Error = any>(
554554
? refreshInterval(data)
555555
: refreshInterval
556556

557-
// We only start next interval if `refreshInterval` is not 0, and:
557+
// We only start the next interval if `refreshInterval` is not 0, and:
558558
// - `force` is true, which is the start of polling
559559
// - or `timer` is not 0, which means the effect wasn't canceled
560560
if (interval && timer !== -1) {
@@ -564,15 +564,15 @@ export const useSWRHandler = <Data = any, Error = any>(
564564

565565
function execute() {
566566
// Check if it's OK to execute:
567-
// Only revalidate when the page is visible, online and not errored.
567+
// Only revalidate when the page is visible, online, and not errored.
568568
if (
569569
!getCache().error &&
570570
(refreshWhenHidden || getConfig().isVisible()) &&
571571
(refreshWhenOffline || getConfig().isOnline())
572572
) {
573573
revalidate(WITH_DEDUPE).then(next)
574574
} else {
575-
// Schedule next interval to check again.
575+
// Schedule the next interval to check again.
576576
next()
577577
}
578578
}
@@ -591,7 +591,7 @@ export const useSWRHandler = <Data = any, Error = any>(
591591
useDebugValue(returnedData)
592592

593593
// In Suspense mode, we can't return the empty `data` state.
594-
// If there is `error`, the `error` needs to be thrown to the error boundary.
594+
// If there is an `error`, the `error` needs to be thrown to the error boundary.
595595
// If there is no `error`, the `revalidation` promise needs to be thrown to
596596
// the suspense boundary.
597597
if (suspense && isUndefined(data) && key) {

examples/.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// next is loading eslintrc from root directory, adding this to avoid eslint rules been overridden
1+
// next is loading eslintrc from the root directory, adding this to avoid eslint rules being overridden
22
{}

examples/focus-revalidate/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ npm run dev
2727

2828
## The Idea behind the Example
2929

30-
Basic authentication example showing how the revalidate on focus feature works and to trigger a revalidation in a per hook call basis.
30+
Basic authentication example showing how the revalidate on focus feature works and to trigger a revalidation on a per-hook call basis.

0 commit comments

Comments
 (0)