Skip to content

Commit b76d792

Browse files
committed
chore: add prettier as a formatter
1 parent 6b239e4 commit b76d792

File tree

6 files changed

+41
-8
lines changed

6 files changed

+41
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ pnpm-debug.log*
2525

2626
# Idea/VSCode settings
2727
.idea/
28-
.vscode/
28+
.vscode/*
29+
!.vscode/settings.json
2930

3031
# Miscellaneous
3132
*.tgz

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"singleQuote": true,
3+
"vueIndentScriptAndStyle": true,
4+
"singleAttributePerLine": true,
5+
"htmlWhitespaceSensitivity": "strict",
6+
"arrowParens": "avoid",
7+
"bracketSameLine": true,
8+
"jsxSingleQuote": true,
9+
"proseWrap": "always"
10+
}

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "esbenp.prettier-vscode"
4+
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
"url": "https://github.com/leynier/nuxt-use-async-data-wrapper.git"
2626
},
2727
"peerDependencies": {
28-
"vue": "^3.0.0",
29-
"nuxt": "^3.0.0"
28+
"nuxt": "^3.0.0",
29+
"vue": "^3.0.0"
3030
},
3131
"devDependencies": {
32+
"prettier": "^3.3.3",
3233
"typescript": "^5.7.2",
3334
"vue": "^3.5.13"
3435
},

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export type AsyncDataWrapper<T> = {
3333
* @param options - Optional AsyncDataOptions to configure useAsyncData.
3434
* @returns AsyncDataResult containing the data, pending state, and error.
3535
*/
36-
(argsSupplier: () => Args, options?: AsyncDataOptions<R>) => AsyncDataResult<R>
36+
(
37+
argsSupplier: () => Args,
38+
options?: AsyncDataOptions<R>,
39+
) => AsyncDataResult<R>
3740
: never;
3841
};
3942

@@ -56,13 +59,15 @@ export type AsyncDataWrapper<T> = {
5659
* const wrappedObject = useAsyncDataWrapper(originalObject);
5760
* ```
5861
*/
59-
export function useAsyncDataWrapper<T extends Record<string, any>>(obj: T): AsyncDataWrapper<T> {
62+
export function useAsyncDataWrapper<T extends Record<string, any>>(
63+
obj: T,
64+
): AsyncDataWrapper<T> {
6065
const composable = {} as AsyncDataWrapper<T>;
6166
const proto = Object.getPrototypeOf(obj);
6267

6368
// Get function names from the object's prototype, excluding the constructor
6469
const functionNames = Object.getOwnPropertyNames(proto).filter(
65-
key => key !== 'constructor' && typeof obj[key] === 'function'
70+
key => key !== 'constructor' && typeof obj[key] === 'function',
6671
);
6772

6873
for (const key of functionNames) {
@@ -89,7 +94,9 @@ export function useAsyncDataWrapper<T extends Record<string, any>>(obj: T): Asyn
8994
// Reactive reference to arguments
9095
const argsRef = computed(() => argsSupplier!());
9196
// Unique key for useAsyncData
92-
const dataKeyRef = computed(() => `${key}-${JSON.stringify(argsRef.value)}`);
97+
const dataKeyRef = computed(
98+
() => `${key}-${JSON.stringify(argsRef.value)}`,
99+
);
93100

94101
// Call useAsyncData with the generated key and function
95102
const asyncDataResult = useAsyncData(
@@ -100,7 +107,7 @@ export function useAsyncDataWrapper<T extends Record<string, any>>(obj: T): Asyn
100107
watch: [argsRef],
101108
// Spread additional options
102109
...options,
103-
}
110+
},
104111
);
105112

106113
return asyncDataResult;

0 commit comments

Comments
 (0)