Skip to content

Commit

Permalink
feat: ✨ 启用新的 Eslint 配置
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Feb 4, 2024
1 parent 667994d commit 8dfeef3
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 90 deletions.
7 changes: 0 additions & 7 deletions .eslintignore

This file was deleted.

10 changes: 0 additions & 10 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/sync-gitee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: sync-gitee

on:
workflow_run:
workflows: ['release-please']
workflows: [release-please]
types:
- completed

Expand All @@ -18,5 +18,5 @@ jobs:
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
account_type: org
white_list: 'vite-uniapp-template'
white_list: vite-uniapp-template
force_update: true
30 changes: 24 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
{
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,

// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
"eslint.format.enable": true,
"eslint.codeAction.showDocumentation": {
"enable": true
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],

// Enable eslint for all supported languages
"eslint.validate": [
// "jsonc",
"javascript",
"javascriptreact",
"typescript",
Expand All @@ -18,6 +35,7 @@
"html",
"markdown",
"json",
"jsonc",
"yaml"
],
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pnpm dev:app-android

```js
// 使用远程静态资源
import { useAssets } from './utils/assets/remote'
// import { useAssets } from './utils/assets/remote'

// 使用本地静态资源
import { useAssets } from './utils/assets/local'
Expand Down
35 changes: 35 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const uni = require('@uni-helper/eslint-config')

module.exports = uni({
typescript: false,
ignores: [
'src/uni_modules',
'node_modules',
'dist',
'public',
'index.html',
],
}, {
languageOptions: {
globals: {
uni: 'readonly',
wx: 'readonly',
},
},
rules: {
'jsdoc/check-param-names': 'off',
'jsdoc/check-types': 'off',
'jsdoc/require-returns-description': 'off',

'node/prefer-global/process': 'off',

'no-console': 'off',
'curly': 'off',
'eqeqeq': 'off',

'unused-imports/no-unused-vars': 'off',

'vue/html-self-closing': 'off',
'vue/block-order': 'off',
},
})
2 changes: 1 addition & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
},
"types": ["@dcloudio/types", "miniprogram-api-typings", "mini-types"]
}
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"url": "https://viarotel.eu.org/"
},
"scripts": {
"lint": "pnpm lint:js",
"lint:js": "eslint . --ext .vue,.js,.ts,.jsx,.tsx,.md --ignore-path .eslintignore --fix",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"dev:app": "uni -p app",
"dev:app-android": "uni -p app-android",
"dev:app-ios": "uni -p app-ios",
Expand Down Expand Up @@ -85,13 +85,13 @@
"@dcloudio/uni-cli-shared": "3.0.0-3090820231124001",
"@dcloudio/uni-stacktracey": "3.0.0-3090820231124001",
"@dcloudio/vite-plugin-uni": "3.0.0-3090820231124001",
"@uni-helper/eslint-config": "^0.0.6",
"@uni-helper/vite-plugin-uni-pages": "^0.2.9",
"@unocss/preset-wind": "^0.58.0",
"@unocss/transformer-directives": "0.58.0",
"@viarotel-org/eslint-config": "^0.8.2",
"@viarotel-org/unocss-preset-shades": "^0.7.4",
"@vue/runtime-core": "^3.3.12",
"eslint": "^8.56.0",
"eslint": "^8.54.0",
"mini-types": "^0.1.7",
"miniprogram-api-typings": "^3.10.0",
"postcss": "^8.4.24",
Expand Down
5 changes: 3 additions & 2 deletions src/api/base/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ export const getSiteConfig = () => mock({ mockData: {} })
/**
* @desc 上传文件
*/
export const uploadFile = params =>
request.upload({
export function uploadFile(params) {
return request.upload({
url: '/file/upload',
dataType: 'json',
headers: {
'content-type': 'multipart/form-data',
},
...(params || {}),
})
}
10 changes: 6 additions & 4 deletions src/api/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@ import { mock } from '../base/index.js'
/**
* @description 用户登录
*/
export const userLogin = data =>
mock({ ...data, mockData: { token: 'mock-token' } })
export function userLogin(data) {
return mock({ ...data, mockData: { token: 'mock-token' } })
}

/**
* @description 获取当前登录用户信息
* @param realStatus 1-未实名 2-实名中 3--已经实名 4-实名失败
*/
export const getUserInfo = data =>
mock({
export function getUserInfo(data) {
return mock({
...data,
mockData: {
id: 'mock-id',
username: 'viarotel',
realStatus: '1',
},
})
}

/**
* @description 获取当前登录用户菜单
Expand Down
4 changes: 2 additions & 2 deletions src/components/dict-picker/dict-picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export default {
showValue() {
return (
this.modelValue?.[this.labelKey]
|| this.$showDictLabel(this.scopedOptions, this.modelValue)
|| ''
|| this.$showDictLabel(this.scopedOptions, this.modelValue)
|| ''
)
},
},
Expand Down
6 changes: 3 additions & 3 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"versionName": "2.0.0",
"versionCode": "100",
"transformPx": false,
"uniStatistics": {
"enable": false
},
"app-plus": {
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
Expand Down Expand Up @@ -63,8 +66,5 @@
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics": {
"enable": false
},
"vueVersion": "3"
}
8 changes: 4 additions & 4 deletions src/pages/realname/components/Base/AreaPicker/trigger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export default {
return this.modelValue
.map(
item => item?.deptName
|| this.$showDictLabel(this.flatData, item, {
labelKey: this.labelKey,
valueKey: this.valueKey,
}),
|| this.$showDictLabel(this.flatData, item, {
labelKey: this.labelKey,
valueKey: this.valueKey,
}),
)
.join('-')
},
Expand Down
2 changes: 1 addition & 1 deletion src/router/guards/permission/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const loginPath = '/pages/login/phone/index'

const whiteList = [loginPath, '/pages/statement/index', '/pages/webview/index']

const permission = (router) => {
function permission(router) {
const userStore = store.useUserStore()

const loginRoute = to => ({
Expand Down
2 changes: 1 addition & 1 deletion src/router/guards/realname/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import store from '@/store/index.js'
import { useDialog, useToast } from '@/utils/modals'

const realname = (router) => {
function realname(router) {
const userStore = store.useUserStore()

router.beforeEach((to, from, next) => {
Expand Down
6 changes: 3 additions & 3 deletions src/store/dict/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export const useDictStore = defineStore({
tempData = this.dictData[key]
}
else {
const { code, data } = await getDictList(this.dictModel[key] || key)
if (success) {
tempData = data.map(item => ({
const res = await getDictList(this.dictModel[key] || key)
if (res.success) {
tempData = res.data.map(item => ({
...item,
label: item.dictLabel,
value: item.dictValue,
Expand Down
25 changes: 12 additions & 13 deletions src/store/menu/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ export async function getRemoteMenu(params) {
return data
}

export function transformerMenu(data,
{
pathKey = 'menuHref',
titleKey = 'menuName',
iconKey = 'menuIcon',
menuType = 'menuType',
menuSort = 'menuSort',
idKey = 'id',
parentKey = 'parentId',
childrenKey = 'children',
permissionKey = 'permission',
isTree = false,
} = {}) {
export function transformerMenu(data, {
pathKey = 'menuHref',
titleKey = 'menuName',
iconKey = 'menuIcon',
menuType = 'menuType',
menuSort = 'menuSort',
idKey = 'id',
parentKey = 'parentId',
childrenKey = 'children',
permissionKey = 'permission',
isTree = false,
} = {}) {
if (isTree) {
data = tree2List(data, {
key: idKey,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function sleep(time = 1000) {
/**
* 使用indexof方法实现模糊查询
* @param {Array} list 进行查询的数组
* @param {String} keyWord 查询的关键词
* @param {string} keyWord 查询的关键词
* @return {Array} 查询的结果
*/
export function fuzzyQuery(list, keyWord, { keyName = '' } = {}) {
Expand All @@ -30,8 +30,8 @@ export function fuzzyQuery(list, keyWord, { keyName = '' } = {}) {
/**
* 解构对象属性为可响应的计算属性
* @param values 为对象时 对象的值作为计算属性的替换键名
* @param {String} sourcePath 默认值为 '$Route.query'
* @returns {Object} Computeds
* @param {string} sourcePath 默认值为 '$Route.query'
* @returns {object} Computeds
*/
export function mapComputed(keys = [], sourcePath = '$Route.query') {
const arr = Array.isArray(keys)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/modals/uniapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function useDialog(
...moreOptions,
success({ cancel }) {
if (cancel) {
reject({ type: 'cancel' })
reject(new Error('cancel'))
}

resolve({ type: 'confirm' })
Expand Down
12 changes: 5 additions & 7 deletions src/utils/showDictLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import * as dictData from '@/configs/dict/index.js'
/**
* @description 回显数据字典
*/
export function showDictLabel(data,
value,
{
labelKey = 'dictLabel',
valueKey = 'dictValue',
childrenKey = 'children',
} = {}) {
export function showDictLabel(data, value, {
labelKey = 'dictLabel',
valueKey = 'dictValue',
childrenKey = 'children',
} = {}) {
const actions = []
for (let index = 0; index < data.length; index++) {
const item = data[index]
Expand Down

0 comments on commit 8dfeef3

Please sign in to comment.