Skip to content

Commit

Permalink
Merge pull request #3 from OVINC-CN/style_eslint
Browse files Browse the repository at this point in the history
style: use google eslint
  • Loading branch information
OrenZhang authored Sep 14, 2023
2 parents bae6e70 + 6da8a3a commit 02b1e10
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 3,842 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: ESLint

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "*" ]

jobs:
eslint:
name: Run eslint scanning
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install ESLint
run: |
npm install [email protected]
npm install @microsoft/[email protected]
- name: Run ESLint
run: npx eslint .
--ext .js,.jsx,.ts,.tsx
--format @microsoft/eslint-formatter-sarif
--output-file eslint-results.sarif
continue-on-error: true
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: eslint-results.sarif
wait-for-processing: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# build
dist
node_modules
yarn.lock

# eslint
eslint-results.sarif
Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@
},
"extends": [
"plugin:vue/vue3-strongly-recommended",
"@tencent/eslint-config-tencent"
"eslint-config-google"
],
"rules": {
"vue/no-side-effects-in-computed-properties": "off",
"vue/multi-word-component-names": "off",
"max-len": "off",
"no-param-reassign": "off",
"no-unused-vars": "off"
"max-len": "off"
},
"ignorePatterns": [
"dist/",
Expand All @@ -55,9 +52,9 @@
"devDependencies": {
"@arco-design/web-vue": "^2.51.0",
"@microsoft/eslint-formatter-sarif": "3.0.0",
"@tencent/eslint-config-tencent": "^1.0.4",
"@vitejs/plugin-vue": "^4.3.4",
"eslint": "8.48.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-vue": "^9.17.0",
"standard": "^17.1.0",
"vite": "^4.4.9",
Expand Down
3,771 changes: 0 additions & 3,771 deletions pnpm-lock.yaml

This file was deleted.

27 changes: 13 additions & 14 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@
</template>

<script setup>
import { computed, onMounted, ref } from 'vue';
import { useStore } from 'vuex';
import { locale, langOption, changeLangAndReload } from './locale';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { signOutAPI } from './api/user';
import {computed, onMounted, ref} from 'vue';
import {useStore} from 'vuex';
import {locale, langOption, changeLangAndReload} from './locale';
import {useI18n} from 'vue-i18n';
import {useRouter} from 'vue-router';
import {signOutAPI} from './api/user';
import Aegis from 'aegis-web-sdk';
import { getRUMConfigAPI } from './api/trace';
import {getRUMConfigAPI} from './api/trace';
// locale
const i18n = useI18n();
Expand All @@ -101,11 +101,10 @@ const menu = ref([
path_match: '/',
},
]);
const route = useRoute();
const router = useRouter();
const currentMenuItem = ref(menu.value[0].key);
const goTo = (key) => {
router.push({ name: key });
router.push({name: key});
};
menu.value.forEach((item, index) => {
if (index === 0) return;
Expand Down Expand Up @@ -137,11 +136,11 @@ const handlerUserDropDown = (key) => {
// aegis
const initRUM = () => {
getRUMConfigAPI()
.then((res) => {
if (res.data.id) {
new Aegis(res.data);
}
});
.then((res) => {
if (res.data.id) {
new Aegis(res.data);
}
});
};
onMounted(() => initRUM());
</script>
Expand Down
4 changes: 2 additions & 2 deletions src/api/home.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import http from './index';

export const changeLangAPI = language => new Promise((resolve, reject) => {
http.post('/i18n/', { language }).then(res => resolve(res), err => reject(err));
export const changeLangAPI = (language) => new Promise((resolve, reject) => {
http.post('/i18n/', {language}).then((res) => resolve(res), (err) => reject(err));
});
4 changes: 2 additions & 2 deletions src/api/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import axios from 'axios';
import globalContext from '../context';
import { redirectToLogin } from '../utils/login';
import {redirectToLogin} from '../utils/login';

const http = axios;

http.defaults.timeout = 10000;
http.defaults.baseURL = globalContext.backendUrl;
http.defaults.withCredentials = true;

http.interceptors.response.use(res => res.data, (err) => {
http.interceptors.response.use((res) => res.data, (err) => {
// 401 redirect to log in
if (err.response.status === 401) {
// check code
Expand Down
4 changes: 2 additions & 2 deletions src/api/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import http from './index';

export const getRUMConfigAPI = () => new Promise((resolve, reject) => {
http.get('/rum/config/').then(
res => resolve(res),
err => reject(err),
(res) => resolve(res),
(err) => reject(err),
);
});
8 changes: 4 additions & 4 deletions src/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import http from './index';
import globalContext from '../context';

export const getUserInfoAPI = () => new Promise((resolve, reject) => {
http.get(`${globalContext.backendUrl}/account/user_info/`).then(res => resolve(res), err => reject(err));
http.get(`${globalContext.backendUrl}/account/user_info/`).then((res) => resolve(res), (err) => reject(err));
});

export const signInAPI = data => new Promise((resolve, reject) => {
http.post(`${globalContext.backendUrl}/account/sign_in/`, data).then(res => resolve(res), err => reject(err));
export const signInAPI = (data) => new Promise((resolve, reject) => {
http.post(`${globalContext.backendUrl}/account/sign_in/`, data).then((res) => resolve(res), (err) => reject(err));
});

export const signOutAPI = () => new Promise((resolve, reject) => {
http.get(`${globalContext.backendUrl}/account/sign_out/`).then(res => resolve(res), err => reject(err));
http.get(`${globalContext.backendUrl}/account/sign_out/`).then((res) => resolve(res), (err) => reject(err));
});
22 changes: 11 additions & 11 deletions src/components/UserAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
</template>

<script setup>
import { useStore } from 'vuex'
import { computed } from 'vue'
import {useStore} from 'vuex';
import {computed} from 'vue';
// props
const props = defineProps({
size: {
type: Number,
default: null
}
})
default: null,
},
});
//store
const store = useStore()
const isLogin = computed(() => store.state.isLogin)
const user = computed(() => store.state.user)
const userAvatar = computed(() => store.state.userProperties.avatar)
// store
const store = useStore();
const isLogin = computed(() => store.state.isLogin);
const user = computed(() => store.state.user);
const userAvatar = computed(() => store.state.userProperties.avatar);
</script>

<style scoped>
Expand All @@ -50,4 +50,4 @@ const userAvatar = computed(() => store.state.userProperties.avatar)
.app-menu-avatar-backgroud {
background: rgb(var(--arcoblue-5));
}
</style>
</style>
5 changes: 2 additions & 3 deletions src/locale/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createI18n } from 'vue-i18n';
import {createI18n} from 'vue-i18n';
import enUS from '@arco-design/web-vue/es/locale/lang/en-us';
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
import mZhCN from './zh-cn';
import mEnUS from './en-us';
import { changeLangAPI } from '../api/home';
import {changeLangAPI} from '../api/home';

// language option
export const langOption = [
Expand All @@ -26,7 +26,6 @@ const userLangKey = 'user-language';

// default language
let mLocal = 'zhCN';
// eslint-disable-next-line import/no-mutable-exports
export let locale = zhCN;

// change language
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createApp } from 'vue';
import {createApp} from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
Expand Down
10 changes: 5 additions & 5 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createStore } from 'vuex';
import { getUserInfoAPI } from '../api/user';
import {createStore} from 'vuex';
import {getUserInfoAPI} from '../api/user';

const store = createStore({
state() {
Expand Down Expand Up @@ -31,14 +31,14 @@ const store = createStore({
state.isLogin = payload;
},
setUserProperty(state, payload) {
payload.forEach(item => state.userProperties[item.property_key] = item.property_val);
payload.forEach((item) => state.userProperties[item.property_key] = item.property_val);
},
setUserPropertyRaw(state, payload) {
state.userPropertiesRaw = payload;
},
},
actions: {
setMainLoading({ commit }, payload) {
setMainLoading({commit}, payload) {
if (payload) {
commit('setMainLoading', true);
} else {
Expand All @@ -47,7 +47,7 @@ const store = createStore({
}, 600);
}
},
getUserInfo({ commit }) {
getUserInfo({commit}) {
getUserInfoAPI().then((res) => {
commit('setUser', res.data);
commit('setIsLogin', true);
Expand Down
40 changes: 20 additions & 20 deletions src/views/Login.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<script setup>
import { signInAPI } from '../api/user'
import { onMounted } from 'vue'
import { Message } from '@arco-design/web-vue'
import {signInAPI} from '../api/user';
import {onMounted} from 'vue';
import {Message} from '@arco-design/web-vue';
const doLogin = () => {
const url = new URL(window.location.href)
const next = url.searchParams.get('next')
const code = url.searchParams.get('code')
console.log(next)
const url = new URL(window.location.href);
const next = url.searchParams.get('next');
const code = url.searchParams.get('code');
console.log(next);
signInAPI({code}).then(
() => {},
err => {
Message.error(err.response.data.message)
}
(err) => {
Message.error(err.response.data.message);
},
)
.finally(
() => {
setTimeout(() => {
window.location.href = next
}, 2000)
}
)
}
.finally(
() => {
setTimeout(() => {
window.location.href = next;
}, 2000);
},
);
};
onMounted(() => doLogin())
onMounted(() => doLogin());
</script>

<template>
Expand All @@ -37,4 +37,4 @@ onMounted(() => doLogin())

<style scoped>
</style>
</style>
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'vite';
import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
Expand Down

0 comments on commit 02b1e10

Please sign in to comment.