Skip to content

Commit 6360d63

Browse files
committed
configure lint
1 parent 01360bd commit 6360d63

25 files changed

+2124
-2773
lines changed

.eslintrc.cjs

-15
This file was deleted.

.github/workflows/check.yml

+3
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@ jobs:
3333
run: nci
3434

3535
- name: lint
36+
run: nr lint
37+
38+
- name: lint text
3639
run: nr lint:text
3740
# TODO: configure other jobs

.prettierrc.json

-8
This file was deleted.

.vscode/extensions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["Vue.volar", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
2+
"recommendations": ["Vue.volar", "dbaeumer.vscode-eslint"]
33
}

eslint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import antfu from '@antfu/eslint-config'
2+
3+
export default antfu({ vue: true, typescript: true })

package.json

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "@vueyous/monorepo",
3+
"type": "module",
34
"version": "0.0.1-alpha.1",
45
"private": true,
56
"packageManager": "[email protected]",
6-
"type": "module",
77
"scripts": {
88
"dev": "vite",
99
"build": "run-p type-check \"build-only {@}\" --",
1010
"preview": "vite preview",
1111
"build-only": "vite build",
1212
"type-check": "vue-tsc --build --force",
13-
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
13+
"lint": "eslint .",
14+
"lint:fix": "eslint . --fix",
1415
"lint:text": "textlint .",
15-
"fmt": "prettier --write src/",
1616
"docs:dev": "vitepress dev packages",
1717
"docs:build": "vitepress build packages",
1818
"docs:preview": "vitepress preview packages"
@@ -22,24 +22,20 @@
2222
"vue": "^3.4.21"
2323
},
2424
"devDependencies": {
25-
"@rushstack/eslint-patch": "^1.3.3",
25+
"@antfu/eslint-config": "^2.13.3",
2626
"@tsconfig/node20": "^20.1.2",
2727
"@types/fs-extra": "^11.0.4",
2828
"@types/jsdom": "^21.1.6",
2929
"@types/node": "^20.11.28",
3030
"@vitejs/plugin-vue": "^5.0.4",
31-
"@vueyous/core": "workspace:*",
32-
"@vueyous/shared": "workspace:*",
33-
"@vue/eslint-config-prettier": "^8.0.0",
34-
"@vue/eslint-config-typescript": "^12.0.0",
3531
"@vue/test-utils": "^2.4.5",
3632
"@vue/tsconfig": "^0.5.1",
33+
"@vueyous/core": "workspace:*",
34+
"@vueyous/shared": "workspace:*",
3735
"eslint": "^8.49.0",
38-
"eslint-plugin-vue": "^9.17.0",
3936
"fs-extra": "^11.2.0",
4037
"jsdom": "^24.0.0",
4138
"npm-run-all2": "^6.1.2",
42-
"prettier": "^3.0.3",
4339
"textlint": "^14.0.4",
4440
"textlint-rule-ja-space-between-half-and-full-width": "^2.3.1",
4541
"typescript": "~5.4.0",

packages/.vitepress/config.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { defineConfig } from 'vitepress';
1+
import { defineConfig } from 'vitepress'
22

33
const Guide = [
44
{ text: 'はじめに', link: '/guide/' },
55
{ text: 'VueUseとは', link: '/guide/what-is-vueuse' },
6-
{ text: '環境構築', link: '/guide/setup' }
7-
];
6+
{ text: '環境構築', link: '/guide/setup' },
7+
]
88

99
// https://vitepress.dev/reference/site-config
1010
export default defineConfig({
@@ -21,16 +21,16 @@ export default defineConfig({
2121

2222
nav: [
2323
{ text: 'Home', link: '/' },
24-
{ text: 'Guide', items: Guide }
24+
{ text: 'Guide', items: Guide },
2525
],
2626

2727
sidebar: [
2828
{
2929
text: 'Guide',
30-
items: Guide
31-
}
30+
items: Guide,
31+
},
3232
],
3333

34-
socialLinks: [{ icon: 'github', link: 'https://github.com/pei-pay/VueYous' }]
35-
}
36-
});
34+
socialLinks: [{ icon: 'github', link: 'https://github.com/pei-pay/VueYous' }],
35+
},
36+
})

packages/.vitepress/theme/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import DefaultTheme from 'vitepress/theme';
1+
import DefaultTheme from 'vitepress/theme'
22

3-
import './styles/main.css';
3+
import './styles/main.css'
44

5-
export default DefaultTheme;
5+
export default DefaultTheme

packages/core/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { useManualRefHistory } from './useManualRefHistory';
2-
export { useRefHistory } from './useRefHistory';
1+
export { useManualRefHistory } from './useManualRefHistory'
2+
export { useRefHistory } from './useRefHistory'

packages/core/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "@vueyous/core",
3-
"version": "0.0.1-alpha.1",
43
"type": "module",
4+
"version": "0.0.1-alpha.1",
55
"dependencies": {
66
"@vueyous/shared": "workspace:*"
77
}
8-
}
8+
}

packages/core/useCloned/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export type CloneFn<F, T = F> = (x: F) => T;
1+
export type CloneFn<F, T = F> = (x: F) => T
22

33
export function cloneFnJSON<T>(source: T): T {
4-
return JSON.parse(JSON.stringify(source));
4+
return JSON.parse(JSON.stringify(source))
55
}

packages/core/useManualRefHistory/demo.vue

+25-15
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
11
<script setup lang="ts">
2-
import { ref } from 'vue';
2+
import { ref } from 'vue'
33
// TODO: make formatDate
4-
import { formatDate } from '@vueuse/core';
4+
import { formatDate } from '@vueuse/core'
55
6-
import { useManualRefHistory } from '../useManualRefHistory';
6+
import { useManualRefHistory } from '../useManualRefHistory'
77
88
function format(ts: number) {
9-
return formatDate(new Date(ts), 'YYYY-MM-DD HH:mm:ss');
9+
return formatDate(new Date(ts), 'YYYY-MM-DD HH:mm:ss')
1010
}
1111
12-
const count = ref(0);
13-
const inc = () => count.value++;
14-
const dec = () => count.value--;
15-
const { canUndo, canRedo, history, commit, undo, redo } = useManualRefHistory(count);
12+
const count = ref(0)
13+
const inc = () => count.value++
14+
const dec = () => count.value--
15+
const { canUndo, canRedo, history, commit, undo, redo } = useManualRefHistory(count)
1616
</script>
1717

1818
<template>
1919
<div>Count: {{ count }}</div>
20-
<button @click="inc()">Increment</button>
21-
<button @click="dec()">Decrement</button>
20+
<button @click="inc()">
21+
Increment
22+
</button>
23+
<button @click="dec()">
24+
Decrement
25+
</button>
2226
<span class="ml-2">/</span>
23-
<button @click="commit()">Commit</button>
24-
<button :disabled="!canUndo" @click="undo()">Undo</button>
25-
<button :disabled="!canRedo" @click="redo()">Redo</button>
26-
<br />
27-
<br />
27+
<button @click="commit()">
28+
Commit
29+
</button>
30+
<button :disabled="!canUndo" @click="undo()">
31+
Undo
32+
</button>
33+
<button :disabled="!canRedo" @click="redo()">
34+
Redo
35+
</button>
36+
<br>
37+
<br>
2838
<note>History (limited to 10 records for demo)</note>
2939
<div class="code-block mt-4">
3040
<div v-for="i in history" :key="i.timestamp">
+50-49
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// NOTE: 実際は 'vue-demi' からimportされてる
2-
import { computed, markRaw, ref, type Ref } from 'vue';
2+
import { type Ref, computed, markRaw, ref } from 'vue'
33

4-
import { timestamp } from '@vueyous/shared';
4+
import { timestamp } from '@vueyous/shared'
55

66
export interface UseRefHistoryRecord<T> {
7-
snapshot: T;
8-
timestamp: number;
7+
snapshot: T
8+
timestamp: number
99
}
1010

1111
export interface UseManualHistoryOptions<Raw> {
12-
setSource?: (source: Ref<Raw>, v: Raw) => void;
12+
setSource?: (source: Ref<Raw>, v: Raw) => void
1313
}
1414

1515
export interface UseManualRefHistoryReturn<Raw> {
@@ -18,106 +18,107 @@ export interface UseManualRefHistoryReturn<Raw> {
1818
// source: Ref<Raw>;
1919

2020
/** An array of history records for undo, newest comes to first */
21-
history: Ref<UseRefHistoryRecord<Raw>[]>;
21+
history: Ref<UseRefHistoryRecord<Raw>[]>
2222

2323
/** Last history point, source can be different if paused */
24-
last: Ref<UseRefHistoryRecord<Raw>>;
24+
last: Ref<UseRefHistoryRecord<Raw>>
2525

2626
/** Same as {@link UseManualRefHistoryReturn.history | history} */
27-
undoStack: Ref<UseRefHistoryRecord<Raw>[]>;
27+
undoStack: Ref<UseRefHistoryRecord<Raw>[]>
2828

2929
/** Records array for redo */
30-
redoStack: Ref<UseRefHistoryRecord<Raw>[]>;
30+
redoStack: Ref<UseRefHistoryRecord<Raw>[]>
3131

3232
/** A ref representing if undo is possible (non empty undoStack) */
33-
canUndo: Ref<boolean>;
33+
canUndo: Ref<boolean>
3434

3535
/** A ref representing if redo is possible (non empty redoStack) */
36-
canRedo: Ref<boolean>;
36+
canRedo: Ref<boolean>
3737

3838
/** Undo changes */
39-
undo: () => void;
39+
undo: () => void
4040

4141
/** Redo changes */
42-
redo: () => void;
42+
redo: () => void
4343

4444
/** Clear all the history */
45-
clear: () => void;
45+
clear: () => void
4646

4747
/** Create a new history record */
48-
commit: () => void;
48+
commit: () => void
4949

5050
/** Reset ref's value with latest history */
51-
reset: () => void;
51+
reset: () => void
5252
}
5353

5454
function fnSetSource<F>(source: Ref<F>, value: F) {
55-
return (source.value = value);
55+
return (source.value = value)
5656
}
5757

5858
export function useManualRefHistory<Raw>(
5959
source: Ref<Raw>,
60-
options: UseManualHistoryOptions<Raw> = {}
60+
options: UseManualHistoryOptions<Raw> = {},
6161
): UseManualRefHistoryReturn<Raw> {
62-
const { setSource = fnSetSource } = options;
62+
const { setSource = fnSetSource } = options
6363

6464
function _createHistoryRecord(): UseRefHistoryRecord<Raw> {
6565
return markRaw({
6666
snapshot: source.value,
67-
timestamp: timestamp()
68-
});
67+
timestamp: timestamp(),
68+
})
6969
}
7070

7171
const last: Ref<UseRefHistoryRecord<Raw>> = ref(_createHistoryRecord()) as Ref<
7272
UseRefHistoryRecord<Raw>
73-
>;
73+
>
7474

75-
const undoStack: Ref<UseRefHistoryRecord<Raw>[]> = ref([]);
76-
const redoStack: Ref<UseRefHistoryRecord<Raw>[]> = ref([]);
75+
const undoStack: Ref<UseRefHistoryRecord<Raw>[]> = ref([])
76+
const redoStack: Ref<UseRefHistoryRecord<Raw>[]> = ref([])
7777

7878
const _setSource = (record: UseRefHistoryRecord<Raw>) => {
79-
setSource(source, record.snapshot);
80-
last.value = record;
81-
};
79+
setSource(source, record.snapshot)
80+
last.value = record
81+
}
8282

8383
const commit = () => {
84-
undoStack.value.unshift(last.value);
85-
last.value = _createHistoryRecord();
84+
undoStack.value.unshift(last.value)
85+
last.value = _createHistoryRecord()
8686
// commit した際に redoStack に要素がある場合はそれを全削除
87-
if (redoStack.value.length) redoStack.value.splice(0, redoStack.value.length);
88-
};
87+
if (redoStack.value.length)
88+
redoStack.value.splice(0, redoStack.value.length)
89+
}
8990

9091
const clear = () => {
91-
undoStack.value.splice(0, undoStack.value.length);
92-
redoStack.value.splice(0, redoStack.value.length);
93-
};
92+
undoStack.value.splice(0, undoStack.value.length)
93+
redoStack.value.splice(0, redoStack.value.length)
94+
}
9495

9596
const undo = () => {
96-
const state = undoStack.value.shift();
97+
const state = undoStack.value.shift()
9798

9899
if (state) {
99-
redoStack.value.unshift(last.value);
100-
_setSource(state);
100+
redoStack.value.unshift(last.value)
101+
_setSource(state)
101102
}
102-
};
103+
}
103104

104105
const redo = () => {
105-
const state = redoStack.value.shift();
106+
const state = redoStack.value.shift()
106107

107108
if (state) {
108-
undoStack.value.unshift(last.value);
109-
_setSource(state);
109+
undoStack.value.unshift(last.value)
110+
_setSource(state)
110111
}
111-
};
112+
}
112113

113114
const reset = () => {
114-
_setSource(last.value);
115-
};
115+
_setSource(last.value)
116+
}
116117

117-
const history = computed(() => [last.value, ...undoStack.value]);
118+
const history = computed(() => [last.value, ...undoStack.value])
118119

119-
const canUndo = computed(() => undoStack.value.length > 0);
120-
const canRedo = computed(() => redoStack.value.length > 0);
120+
const canUndo = computed(() => undoStack.value.length > 0)
121+
const canRedo = computed(() => redoStack.value.length > 0)
121122

122123
return {
123124
// source,
@@ -132,6 +133,6 @@ export function useManualRefHistory<Raw>(
132133
commit,
133134
reset,
134135
undo,
135-
redo
136-
};
136+
redo,
137+
}
137138
}

0 commit comments

Comments
 (0)