Skip to content

Commit 5b00573

Browse files
committed
style: format code
1 parent a69cfef commit 5b00573

24 files changed

+529
-419
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
CHANGELOG.md
3+
pnpm-lock.yaml

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true
4+
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const store = new ReplStore({
6464
// specify the default URL to import Vue runtime from in the sandbox
6565
// default is the CDN link from jsdelivr.com with version matching Vue's version
6666
// from peerDependency
67-
defaultVueRuntimeURL: 'cdn link to vue.runtime.esm-browser.js'
67+
defaultVueRuntimeURL: 'cdn link to vue.runtime.esm-browser.js',
6868
})
6969
7070
// persist state to URL hash
@@ -73,8 +73,8 @@ watchEffect(() => history.replaceState({}, '', store.serialize()))
7373
// pre-set import map
7474
store.setImportMap({
7575
imports: {
76-
myLib: 'cdn link to esm build of myLib'
77-
}
76+
myLib: 'cdn link to esm build of myLib',
77+
},
7878
})
7979
8080
// use a specific version of Vue

index-dist.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import Monaco from './dist/monaco-editor'
2121
import './dist/style.css'
2222
createApp(Repl, {
23-
editor: Monaco
23+
editor: Monaco,
2424
}).mount('#app')
2525
</script>
2626
</head>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"dev": "vite",
3333
"build": "vite build",
3434
"build-types": "vue-tsc -p tsconfig.build.json && api-extractor run -c api-extractor.json && node scripts/cleanup.js",
35+
"format": "prettier --write .",
3536
"release": "bumpp -r",
3637
"prepublishOnly": "npm run build && npm run build-types"
3738
},

src/codemirror/CodeMirror.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface Props {
1717
const props = withDefaults(defineProps<Props>(), {
1818
mode: 'htmlmixed',
1919
value: '',
20-
readonly: false
20+
readonly: false,
2121
})
2222
2323
const emit = defineEmits<(e: 'change', value: string) => void>()
@@ -26,13 +26,15 @@ const el = ref()
2626
const needAutoResize = inject('autoresize')
2727
2828
onMounted(() => {
29-
const addonOptions = props.readonly ? {} : {
30-
autoCloseBrackets: true,
31-
autoCloseTags: true,
32-
foldGutter: true,
33-
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
34-
keyMap: 'sublime'
35-
}
29+
const addonOptions = props.readonly
30+
? {}
31+
: {
32+
autoCloseBrackets: true,
33+
autoCloseTags: true,
34+
foldGutter: true,
35+
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
36+
keyMap: 'sublime',
37+
}
3638
3739
const editor = CodeMirror(el.value!, {
3840
value: '',
@@ -41,7 +43,7 @@ onMounted(() => {
4143
tabSize: 2,
4244
lineWrapping: true,
4345
lineNumbers: true,
44-
...addonOptions
46+
...addonOptions,
4547
})
4648
4749
editor.on('change', () => {

src/codemirror/codemirror.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,6 @@ span.CodeMirror-selectedtext {
539539
background: none;
540540
}
541541

542-
.CodeMirror-dialog{
542+
.CodeMirror-dialog {
543543
background-color: var(--bg);
544544
}

src/editor/CodeMirrorEditor.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { computed } from 'vue'
44
import type { PreviewMode } from './types'
55
66
defineOptions({
7-
editorType: 'monaco'
7+
editorType: 'monaco',
88
})
99
1010
const props = defineProps<{
@@ -26,17 +26,17 @@ const modes: Record<string, Props['mode']> = {
2626
css: 'css',
2727
html: 'htmlmixed',
2828
js: {
29-
name: 'javascript'
29+
name: 'javascript',
3030
},
3131
json: {
3232
name: 'javascript',
33-
json: true
33+
json: true,
3434
},
3535
ts: {
3636
name: 'javascript',
37-
typescript: true
37+
typescript: true,
3838
},
39-
vue: 'htmlmixed'
39+
vue: 'htmlmixed',
4040
}
4141
4242
const activeMode = computed(() => {

src/editor/FileSelector.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function doneNameFile() {
6060
6161
if (!/\.(vue|js|ts|css|json)$/.test(filename)) {
6262
store.state.errors = [
63-
`Playground only supports *.vue, *.js, *.ts, *.css, *.json files.`
63+
`Playground only supports *.vue, *.js, *.ts, *.css, *.json files.`,
6464
]
6565
return
6666
}
@@ -101,7 +101,7 @@ function horizontalScroll(e: WheelEvent) {
101101
Math.abs(e.deltaX) >= Math.abs(e.deltaY) ? e.deltaX : e.deltaY
102102
const distance = 30 * (direction > 0 ? 1 : -1)
103103
el.scrollTo({
104-
left: el.scrollLeft + distance
104+
left: el.scrollLeft + distance,
105105
})
106106
}
107107
</script>

src/monaco/Monaco.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
watchEffect,
1515
inject,
1616
watch,
17-
computed
17+
computed,
1818
} from 'vue'
1919
import * as monaco from 'monaco-editor-core'
2020
import { getOrCreateModel } from './utils'
@@ -30,7 +30,7 @@ const props = withDefaults(
3030
mode?: PreviewMode
3131
}>(),
3232
{
33-
readonly: false
33+
readonly: false,
3434
}
3535
)
3636
@@ -96,13 +96,13 @@ onMounted(async () => {
9696
automaticLayout: true,
9797
scrollBeyondLastLine: false,
9898
minimap: {
99-
enabled: false
99+
enabled: false,
100100
},
101101
inlineSuggest: {
102-
enabled: false
102+
enabled: false,
103103
},
104104
'semanticHighlighting.enabled': true,
105-
fixedOverflowWidgets: true
105+
fixedOverflowWidgets: true,
106106
})
107107
editor.value = editorInstance
108108
@@ -119,7 +119,7 @@ onMounted(async () => {
119119
}
120120
121121
return false
122-
}
122+
},
123123
})
124124
125125
// Support for semantic highlighting
@@ -147,7 +147,7 @@ onMounted(async () => {
147147
if (props.readonly) {
148148
watch(
149149
() => props.value,
150-
value => {
150+
(value) => {
151151
editorInstance.setValue(value || '')
152152
monaco.editor.setModelLanguage(editorInstance.getModel()!, lang.value)
153153
}
@@ -185,7 +185,7 @@ onMounted(async () => {
185185
emits('change', editorInstance.getValue())
186186
})
187187
188-
editorInstance.onDidChangeCursorSelection(e => {
188+
editorInstance.onDidChangeCursorSelection((e) => {
189189
const selection = e.selection
190190
const file = store.state.files[props.filename]
191191
if (file) {

0 commit comments

Comments
 (0)