Skip to content

Commit

Permalink
Merge pull request #110 from goplus/dev
Browse files Browse the repository at this point in the history
lint: fix eslint errors & warnings & format (#108)
  • Loading branch information
nighca authored Feb 22, 2024
2 parents d4d8c9a + 8b0e71f commit feadb53
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 58 deletions.
6 changes: 2 additions & 4 deletions spx-gui/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')

Expand All @@ -13,7 +12,6 @@ module.exports = {
ecmaVersion: 'latest'
},
rules: {
'no-useless-escape': 'warn',
'@typescript-eslint/naming-convention': 'warn'
'no-useless-escape': 'warn'
}
}
}
3 changes: 1 addition & 2 deletions spx-gui/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_API_BASE: string
readonly VITE_CASDOOR_ENDPOINT: string
Expand Down
1 change: 0 additions & 1 deletion spx-gui/src/class/asset-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export abstract class AssetBase implements AssetBaseInterface {
/**
* Get the name of the asset.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
static NAME = "asset";

/**
Expand Down
1 change: 0 additions & 1 deletion spx-gui/src/class/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class Project implements ProjectDetail, ProjectSummary {
entryCode: string
unidentifiedFile: RawDir

// eslint-disable-next-line @typescript-eslint/naming-convention
static ENTRY_FILE_NAME = 'index.gmx'

static fromRawData(data: ProjectDetail & ProjectSummary): Project {
Expand Down
22 changes: 13 additions & 9 deletions spx-gui/src/components/code-editor-demo/CodeEditorDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
* @Description:
-->
<template>
<div class="demo">
<pre>{{ editorContent }}</pre>
<div>
<button @click="format">format</button>
<button @click="insertSnippet">start snippet</button>
<button @click="toggleReadOnly">{{ editorOptions.readOnly ? 'disable' : 'enable' }} readonly</button>
<div v-for="(item, index) in codeArray" @click="codeIndex = index"> code: {{ index }} </div>
</div>
<div class="demo">
<pre>{{ editorContent }}</pre>
<div>
<button @click="format">format</button>
<button @click="insertSnippet">start snippet</button>
<button @click="toggleReadOnly">
{{ editorOptions.readOnly ? 'disable' : 'enable' }} readonly
</button>
<div v-for="(item, index) in codeArray" :key="index" @click="codeIndex = index">
code: {{ index }}
</div>
</div>

<CodeEditor width="500px" height="500px" ref="codeEditor" :editor-options="editorOptions"

Check warning on line 23 in spx-gui/src/components/code-editor-demo/CodeEditorDemo.vue

View workflow job for this annotation

GitHub Actions / lint

Expected a linebreak before this attribute

Check warning on line 23 in spx-gui/src/components/code-editor-demo/CodeEditorDemo.vue

View workflow job for this annotation

GitHub Actions / lint

Attribute "ref" should go before "height"
:model-value="editorContent" @update:model-value="onCodeChange" />
Expand Down Expand Up @@ -68,4 +72,4 @@ const format = () => {
display: flex;
justify-content: center;
}
</style>
</style>
14 changes: 5 additions & 9 deletions spx-gui/src/components/code-editor/CodeEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const emit = defineEmits<CodeEditorEmits>()
// ----------data related -----------------------------------
// register editor worker
self.MonacoEnvironment = {
getWorker(_: string, label: string) {
getWorker() {
return new EditorWorker()
}
}
Expand Down Expand Up @@ -83,7 +83,7 @@ watch(
* @Author: Zhang Zhi Yang
* @Date: 2024-01-31 13:45:55
*/
const onEditorValueChange = (e: monaco.editor.IModelContentChangedEvent) => {
const onEditorValueChange = () => {
emit('change', editor.getValue())
emit('update:modelValue', editor.getValue())
}
Expand All @@ -109,13 +109,9 @@ const insertSnippet = (snippet: monaco.languages.CompletionItem, position?: mona
const formatCode = async () => {
return new Promise<FormatResponse>((resolve) => {
if (false) {
resolve(formatSPX(editor.getValue()))
} else {
onlineFormatSpxCode(editor.getValue()).then((res) => {
resolve(res.data.data)
})
}
onlineFormatSpxCode(editor.getValue()).then((res) => {
resolve(res.data.data)
})
})
}
Expand Down
14 changes: 7 additions & 7 deletions spx-gui/src/components/code-editor/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const MonarchTokensProviderConfig:
operators,
functions: function_completions.map((e) => e.label),
brackets,
symbols: /[=><!~?:&|+\-*\/\^%]+/,
symbols: /[=><!~?:&|+\-*/^%]+/,
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
// digits
digits: /\d+(_+\d+)*/,
Expand All @@ -160,7 +160,7 @@ export const MonarchTokensProviderConfig:
{ include: '@whitespace' },

// delimiters and operators
[/[{}()\[\]]/, '@brackets'],
[/[{}()[\]]/, '@brackets'],
[/[<>](?!@symbols)/, '@brackets'],
[/@symbols/, {
cases: {
Expand All @@ -170,8 +170,8 @@ export const MonarchTokensProviderConfig:
}],

// numbers
[/(@digits)[eE]([\-+]?(@digits))?/, 'number.float'],
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, 'number.float'],
[/(@digits)[eE]([-+]?(@digits))?/, 'number.float'],
[/(@digits)\.(@digits)([eE][-+]?(@digits))?/, 'number.float'],
[/0[xX](@hexdigits)/, 'number.hex'],
[/0[oO]?(@octaldigits)/, 'number.octal'],
[/0[bB](@binarydigits)/, 'number.binary'],
Expand All @@ -192,10 +192,10 @@ export const MonarchTokensProviderConfig:

],
comment: [
[/[^\/*]+/, 'comment'],
[/[^/*]+/, 'comment'],
[/\/\*/, 'comment', '@push'],
["\\*/", 'comment', '@pop'],
[/[\/*]/, 'comment']
[/[/*]/, 'comment']
],

string: [
Expand Down Expand Up @@ -252,4 +252,4 @@ export {
typeKeywords,
operators,
brackets
}
}
6 changes: 3 additions & 3 deletions spx-gui/src/components/code-editor/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ function completionItem(range: monaco.IRange | monaco.languages.CompletionItemRa

const completionItemProvider: monaco.languages.CompletionItemProvider = {
provideCompletionItems: (model, position) => {
var word = model.getWordUntilPosition(position);
var range = {
const word = model.getWordUntilPosition(position);
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn,
};
let suggestions: monaco.languages.CompletionItem[] = completionItem(range)
const suggestions: monaco.languages.CompletionItem[] = completionItem(range)
return { suggestions }
}
}
Expand Down
3 changes: 2 additions & 1 deletion spx-gui/src/components/loading/Loading.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- eslint-disable vue/multi-word-component-names -->
<!--
* @Author: Zhang Zhi Yang
* @Date: 2024-01-15 09:16:18
Expand Down Expand Up @@ -35,4 +36,4 @@ import Logo from "@/assets/logo.png"
img {
width: 200px;
}
</style>
</style>
1 change: 1 addition & 0 deletions spx-gui/src/components/sounds/SoundEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const props = defineProps({
asset: {
type: Sound,
required: false,
default: null
}
})
Expand Down
3 changes: 2 additions & 1 deletion spx-gui/src/components/stage-viewer/Costume.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- eslint-disable vue/multi-word-component-names -->
<!--
* @Author: Zhang Zhi Yang
* @Date: 2024-01-25 14:19:57
Expand Down Expand Up @@ -130,4 +131,4 @@ const handleDragEnd = (event: { target: { attrs: { x: number, y: number } } }) =
})
}
</script>
</script>
1 change: 1 addition & 0 deletions spx-gui/src/components/stage-viewer/Sprite.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- eslint-disable vue/multi-word-component-names -->
<!--
* @Author: Zhang Zhi Yang
* @Date: 2024-01-24 15:48:38
Expand Down
7 changes: 3 additions & 4 deletions spx-gui/src/components/stage-viewer/SpriteLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
</template>
<script setup lang="ts">
// ----------Import required packages / components-----------
import type { StageSprite, MapConfig, SpriteDragEndTarget, SpriteDragEndEvent } from ".";
import Sprite from "./Sprite.vue"
import { computed } from "vue";
import type { StageSprite, MapConfig, SpriteDragEndTarget, SpriteDragEndEvent } from '.'
import Sprite from './Sprite.vue'
const props = defineProps<{
loading: boolean,
Expand Down Expand Up @@ -54,4 +53,4 @@ const onSpriteDragEnd = (e: SpriteDragEndTarget) => {
targets: [e]
})
}
</script>
</script>
1 change: 0 additions & 1 deletion spx-gui/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ declare global {
/**
* Required to communicate with Go WASM instance.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
project_path: string
}
}
Expand Down
1 change: 1 addition & 0 deletions spx-gui/src/store/modules/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const useEditorStore = defineStore('editor', () => {
* @return {*}
* @author Zhang zhi yang
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const insertSnippet = (snippet: monaco.languages.CompletionItem) => {
// This function is notify code-editor component's insert Function
}
Expand Down
1 change: 0 additions & 1 deletion spx-gui/src/util/casdoor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/naming-convention */
const config: SdkConfig = {
serverUrl: import.meta.env.VITE_CASDOOR_ENDPOINT,
clientId: import.meta.env.VITE_CASDOOR_CLIENT_ID,
Expand Down
13 changes: 0 additions & 13 deletions spx-gui/src/vue-shims.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion spx-gui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* @FilePath: /builder/spx-gui/vite.config.ts
* @Description:
*/
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
Expand Down

0 comments on commit feadb53

Please sign in to comment.