Skip to content

Commit

Permalink
style: update eslint (e-dialect#207)
Browse files Browse the repository at this point in the history
* style: update eslint

* style: update eslint

* style: update eslint

* style: beautify u-parse
  • Loading branch information
sheeplin authored Mar 9, 2024
1 parent bacf028 commit 4ed9da4
Show file tree
Hide file tree
Showing 39 changed files with 258 additions and 230 deletions.
15 changes: 5 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ module.exports = {
rules: {
// override/add rules settings here, such as:
'vue/multi-word-component-names': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'no-continue': 'off',
'no-restricted-syntax': 'off',
// 禁止不必要的转义字符
'no-useless-escape': 0,
// ignore for vue-cli-service
'import/extensions': ['error', 'always', {
js: 'never',
}],
},
settings: {
'import/resolver': {
Expand All @@ -29,4 +19,9 @@ module.exports = {
parserOptions: {
ecmaVersion: 'latest',
},
globals: {
uni: true,
getApp: true,
getCurrentPages: true,
},
};
5 changes: 4 additions & 1 deletion src/components/WordListShowing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ export default {
window.location.href = 'https://hinghwa.cn/words/Create';
break;
default:
setClipboard('https://hinghwa.cn/words/Create');
uni.setClipboardData({
data: 'https://hinghwa.cn/words/Create',
success: () => uni.showToast({ title: '网址已复制' }),
});
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/pages/articles/comments/details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default {
* 发送评论
*/
createComment() {
const comment = this.text;
const details = this.text;
const { parent } = this;
const { id } = this;
if (details.length === 0) {
Expand Down
1 change: 0 additions & 1 deletion src/pages/articles/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import { toArticleEditPage } from '@/routers/article';
import ArticleList from '@/components/ArticleList.vue';
import { getLoginStatusSync } from '@/services/login';
const app = getApp();
export default {
components: {
ArticleList,
Expand Down
1 change: 0 additions & 1 deletion src/pages/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ import { toArticlePage } from '@/routers/article';
import { toLoginPage } from '@/routers/login';
import { toMailsPage } from '@/routers/mail';
const app = getApp();
export default {
data() {
return {
Expand Down
1 change: 0 additions & 1 deletion src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import tools from './tools/index.vue';
import InteractionPage from './articles/index.vue';
import me from './users/me.vue';
const app = getApp();
export default {
components: {
basics,
Expand Down
1 change: 0 additions & 1 deletion src/pages/login/forget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ import { getEmailByUsername, resetPassword } from '@/services/user';
import CuCustom from '@/colorui/components/cu-custom.vue';
import getCodeMixin from './mixin/getCodeMixin';
const app = getApp();
export default {
components: { CuCustom },
mixins: [getCodeMixin],
Expand Down
1 change: 0 additions & 1 deletion src/pages/login/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import { mpLogin, normalLogin } from '@/services/login';
import { toForgetPage, toRegisterPage, toWechatRegisterPage } from '@/routers/login';
import CuCustom from '@/colorui/components/cu-custom.vue';
const app = getApp();
export default {
components: { CuCustom },
data() {
Expand Down
1 change: 0 additions & 1 deletion src/pages/login/register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ import { registerUser } from '@/services/user';
import CuCustom from '@/colorui/components/cu-custom.vue';
import getCodeMixin from './mixin/getCodeMixin';
const app = getApp();
export default {
components: { CuCustom },
mixins: [getCodeMixin],
Expand Down
1 change: 0 additions & 1 deletion src/pages/login/register/wechat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import { registerWechatUser } from '@/services/user';
import CuCustom from '@/colorui/components/cu-custom.vue';
const app = getApp();
export default {
components: { CuCustom },
data() {
Expand Down
4 changes: 0 additions & 4 deletions src/pages/mails/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@
</view>
</template>
<script>
import { ref, onMounted } from 'vue';
import { getAllMails } from '@/services/mail';
const app = getApp();
export default {
data() {
return {
Expand Down Expand Up @@ -113,7 +110,6 @@ export default {
// 加载更多邮件
loadMoreEmails() {
uni.showLoading();
const { page } = this;
const originEmails = this.showEmails;
getAllMails(this.page + 1).then((res) => {
this.showEmails = originEmails.concat(res.notifications);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/mails/send.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default {
},
methods: {
async sendEmail() {
postMail(this.Notification).then((response) => {
postMail(this.Notification).then(() => {
uni.showToast({
title: '邮件发送成功!',
icon: 'success',
Expand All @@ -57,7 +57,7 @@ export default {
this.receiverId = '';
this.emailTitle = '';
this.emailContent = '';
}).catch((err) => {
}).catch(() => {
uni.showToast({
title: '邮件发送失败!',
icon: 'none',
Expand Down
3 changes: 1 addition & 2 deletions src/pages/quizzes/details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ import { getQuiz } from '@/services/quiz';
import { playAudio } from '@/utils/audio';
import { defaultMessage } from '@/services/shareMessages';
const app = getApp();
export default {
data() {
return {
Expand Down Expand Up @@ -200,7 +199,7 @@ export default {
/**
* 提交
*/
submitResult(e) {
submitResult() {
if (this.current === 99) {
uni.showToast({
title: '还没有做出选择哦',
Expand Down
2 changes: 0 additions & 2 deletions src/pages/quizzes/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@
import { toRandomQuizPage, toSearchQuizPage, toTestPage } from '@/routers/quiz';
import { defaultMessage } from '@/services/shareMessages';
const app = getApp();
export default {
data() {
return {
Expand Down
4 changes: 1 addition & 3 deletions src/pages/quizzes/random.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@
import { getRandomQuiz } from '@/services/quiz';
import { playAudio } from '@/utils/audio';
const app = getApp();
export default {
data() {
return {
Expand Down Expand Up @@ -212,7 +210,7 @@ export default {
/**
* 提交
*/
submitResult(e) {
submitResult() {
if (this.current === 99) {
uni.showToast({
title: '还没有做出选择哦',
Expand Down
2 changes: 0 additions & 2 deletions src/pages/quizzes/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@
import { searchQuiz } from '@/services/quiz';
import { toOneQuizPage } from '@/routers/quiz';
const app = getApp();
export default {
data() {
return {
Expand Down
32 changes: 14 additions & 18 deletions src/pages/tools/condition.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,14 @@ export default {
};
},
onLoad(options) {
// 声母
// 声母
const shengmu = [];
for (const k in utils.shengmu) {
if ({}.hasOwnProperty.call(utils.shengmu, k)) {
shengmu.push({
value: k,
text: utils.shengmu[k],
});
}
}
Object.keys(utils.shengmu).forEach((k) => {
shengmu.push({
value: k,
text: utils.shengmu[k],
});
});
this.shengmu = [...shengmu];
for (let i = 0; i < this.shengmu.length; i += 1) {
if (this.shengmu[i].value === options.shengmu) {
Expand All @@ -152,14 +150,12 @@ export default {
// 声调
const shengdiao = [];
for (const k in utils.shengdiao) {
if ({}.hasOwnProperty.call(utils.shengdiao, k)) {
shengdiao.push({
value: k,
text: utils.shengdiao[k],
});
}
}
Object.keys(utils.shengdiao).forEach((k) => {
shengdiao.push({
value: k,
text: utils.shengdiao[k],
});
});
shengdiao.unshift(shengdiao.pop()); // make 'all' at the first
this.shengdiao = [...shengdiao];
for (let i = 0; i < this.shengdiao.length; i += 1) {
Expand All @@ -171,7 +167,7 @@ export default {
// 韵母
if (options.yunmu) {
// check if options.yunmu is valid
// check if options.yunmu is valid
for (let i = 0; i < this.yunmu.length; i += 1) {
if (this.yunmuValue !== 'all') break;
if (this.yunmu[i].value === options.yunmu) {
Expand Down
31 changes: 11 additions & 20 deletions src/pages/tools/dictionary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,29 +141,20 @@ export default {
nextNodeList() {
const { record } = this;
const ans = {};
for (const i in record) {
if (i === 'word_count') continue;
Object.keys(record).forEach((i) => {
if (i === 'word_count') return;
if (i[0] in ans) {
ans[i[0]] = [...ans[i[0]], i];
} else {
ans[i[0]] = [i];
}
}
// sort ans
for (const i in ans) {
if ({}.hasOwnProperty.call(ans, i)) {
ans[i].sort();
}
}
// convert to array
const ansArray = [];
for (const i in ans) {
if ({}.hasOwnProperty.call(ans, i)) {
ansArray.push([i, ans[i]]);
}
}
ansArray.sort();
return ansArray;
});
Object.keys(ans).forEach((i) => {
ans[i].sort();
});
return Object.entries(ans).sort();
},
},
watch: {
Expand Down Expand Up @@ -213,9 +204,9 @@ export default {
popPinyin(index) {
this.order.splice(index);
let record = this.fullRecord;
for (const i of this.order) {
this.order.forEach((i) => {
record = record[i];
}
});
this.record = record;
this.prefix = '';
},
Expand Down
10 changes: 5 additions & 5 deletions src/pages/tools/relative.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ export default {
},
},
watch: {
/* eslint-disable no-await-in-loop */
async top(value) {
const ans = [];
for (const item of value.words) {
await Promise.all(value.words.map(async (item) => {
let tmp = {
word: item.word,
id: null,
Expand All @@ -145,9 +144,10 @@ export default {
tmp = { ...item };
}
ans.push(tmp);
}
}));
this.words = ans;
},
},
async onLoad() {
await getWordDetails(1966).then((res) => {
Expand All @@ -166,9 +166,9 @@ export default {
if (!this.top.relations[field]) { return false; }
const ans = [];
if (typeof this.top.relations[field] !== 'string') {
for (const i in this.top.relations[field]) {
Object.keys(this.top.relations[field]).forEach((i) => {
if (this.top.relations[field]) { ans.push(find(this.top.relations[field][i])); }
}
});
} else {
ans.push(find(this.top.relations[field]));
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/users/details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ import { toPronunciationsPage, toUserWordsPage } from '@/routers/user';
import { defaultMessage } from '@/services/shareMessages';
import ArticleList from '@/components/ArticleList.vue';
const app = getApp();
export default {
components: {
ArticleList,
Expand Down
1 change: 0 additions & 1 deletion src/pages/users/pronunciations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ import { playAudio } from '@/utils/audio';
import { toVoiceRankListPage, toWordPage } from '@/routers/word';
import CuCustom from '@/colorui/components/cu-custom.vue';
const app = getApp();
export default {
components: { CuCustom },
data() {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/users/settings/information.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@

<script>
import { changeUserInfo, getUserInfo } from '@/services/user';
import { chooseAndUploadAnImage, uploadFile } from '@/services/file';
import { uploadFile } from '@/services/file';
import {
toChangeEmailPage, toChangeNicknamePage, toChangePhonePage, toChangeUsernamePage,
} from '@/routers/user';
import { loadUserInfo } from '@/services/login';
const app = getApp();
const counties = ['城厢区', '涵江区', '荔城区', '秀屿区', '仙游县'];
Expand Down
2 changes: 1 addition & 1 deletion src/pages/users/settings/nickname.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</template>

<script>
import { changeUserInfo, getUserInfo } from '@/services/user';
import { changeUserInfo } from '@/services/user';
import { toLoginPage } from '@/routers/login';
const app = getApp();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/users/settings/password.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
return;
} // 修改密码
changeUserPassword(app.globalData.id, old, new1).then(async (res) => {
changeUserPassword(app.globalData.id, old, new1).then(async () => {
setTimeout(() => {
uni.navigateBack({
delta: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/users/settings/telephone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default {
showCancel: false,
});
} else {
changeUserInfo(app.globalData.id, userInfo.user).then(async (res) => {
changeUserInfo(app.globalData.id, userInfo.user).then(async () => {
setTimeout(() => {
// 返回上一个页面
uni.navigateBack();
Expand Down
1 change: 0 additions & 1 deletion src/pages/words/characters/details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<script>
import { getCharacterDetails } from '@/services/character';
const app = getApp();
export default {
data() {
return {
Expand Down
Loading

0 comments on commit 4ed9da4

Please sign in to comment.