优化lint规则

This commit is contained in:
范鹏 2025-03-28 10:00:27 +08:00
parent 78951cb380
commit 985d359789
8 changed files with 151 additions and 152 deletions

View File

@ -27,6 +27,7 @@ module.exports = {
'plugin:prettier/recommended', 'plugin:prettier/recommended',
'./.eslintrc-auto-import.json' './.eslintrc-auto-import.json'
], ],
ignorePatterns: ['utils/log.js', 'unpackage/**/*'],
/** /**
* "off" 0 ==> 关闭规则 * "off" 0 ==> 关闭规则
* "warn" 1 ==> 打开的规则作为警告不影响代码执行 * "warn" 1 ==> 打开的规则作为警告不影响代码执行
@ -73,7 +74,7 @@ module.exports = {
'vue/singleline-html-element-content-newline': 'off', // 在单行元素的内容之前和之后需要换行符 'vue/singleline-html-element-content-newline': 'off', // 在单行元素的内容之前和之后需要换行符
'vue/attribute-hyphenation': 'off', // 对模板中的自定义组件强制执行属性命名样式 'vue/attribute-hyphenation': 'off', // 对模板中的自定义组件强制执行属性命名样式
'vue/require-default-prop': 'off', // 此规则要求为每个 prop 为必填时,必须提供默认值 'vue/require-default-prop': 'off', // 此规则要求为每个 prop 为必填时,必须提供默认值
'vue/multi-word-component-names': 'off', // 要求组件名称始终为 “-” 链接的单词 'vue/multi-word-component-names': 'off', // 要求组件名称始终为 "-" 链接的单词
'vue.prefer-template': 'off', 'vue.prefer-template': 'off',
'vuejs-accessibility/click-events-have-key-events': 'off', 'vuejs-accessibility/click-events-have-key-events': 'off',
'no-console': 'off', 'no-console': 'off',

View File

@ -1,9 +1,4 @@
{ {
"src/**/*.{vue,js}": [ "src/**/*.{vue,js}": ["npm run prettier", "npm run eslint"],
"npm run prettier", "src/**/*.{vue,scss,css,less}": ["npm run stylelint:out"]
"npm run eslint"
],
"src/**/*.{vue,scss,css,less}": [
"npm run stylelint:out"
]
} }

View File

@ -15,8 +15,5 @@
"embeddedLanguageFormatting": "auto", "embeddedLanguageFormatting": "auto",
"vueIndentScriptAndStyle": true, "vueIndentScriptAndStyle": true,
"singleAttributePerLine": false, "singleAttributePerLine": false,
"htmlWhitespaceSensitivity": "css", "htmlWhitespaceSensitivity": "css"
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve"
} }

View File

@ -5,9 +5,22 @@
"stylelint-config-recess-order", "stylelint-config-recess-order",
"stylelint-config-html/vue" "stylelint-config-html/vue"
], ],
"ignoreFiles": ["**/*.js", "**/*.ts", "unpackage/**/*"],
"overrides": [ "overrides": [
{ {
"files": ["**/*.(scss|css|vue|html)"], "files": ["**/*.vue"],
"customSyntax": "postcss-html",
"rules": {
"at-rule-no-unknown": null,
"no-unknown-custom-properties": null
}
},
{
"files": ["**/*.vue/*.scss"],
"customSyntax": "postcss-scss"
},
{
"files": ["**/*.(scss|css|html)"],
"customSyntax": "postcss-scss" "customSyntax": "postcss-scss"
} }
], ],
@ -23,32 +36,20 @@
} }
], ],
"color-hex-length": null, "color-hex-length": null,
"declaration-property-value-no-unknown": [ "declaration-property-value-no-unknown": null,
true,
{
"ignoreProperties": [
"font-size",
"width",
"height",
"margin",
"padding",
"border-radius",
"line-height",
"box-shadow"
]
}
],
"shorthand-property-no-redundant-values": null, "shorthand-property-no-redundant-values": null,
"alpha-value-notation": null, "alpha-value-notation": null,
"color-function-notation": null, "color-function-notation": null,
"declaration-property-value-allowed-list": { "at-rule-no-unknown": null,
"font-size": ["/rpx$/"], "property-no-unknown": null,
"width": ["/rpx$/"], "no-unknown-custom-properties": null,
"height": ["/rpx$/"], "value-keyword-case": null,
"margin": ["/rpx$/"], "custom-property-pattern": null,
"padding": ["/rpx$/"], "selector-pseudo-class-no-unknown": [
"border-radius": ["/rpx$/"], true,
"line-height": ["/rpx$/"] {
"ignorePseudoClasses": ["deep", "global"]
} }
]
} }
} }

View File

@ -30,5 +30,12 @@
"unocss-preset-weapp": "^65.4.1", "unocss-preset-weapp": "^65.4.1",
"vite-plugin-eslint": "^1.8.1", "vite-plugin-eslint": "^1.8.1",
"postcss-scss": "^4.0.9" "postcss-scss": "^4.0.9"
},
"scripts": {
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,vue,json,css,scss}\"",
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,vue,json,css,scss}\"",
"lint": "eslint --fix \"**/*.{js,jsx,ts,tsx,vue}\"",
"lint:style": "stylelint --fix \"**/*.{css,scss,vue}\"",
"lint:all": "npm run format && npm run lint && npm run lint:style"
} }
} }

View File

@ -54,10 +54,10 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.title { .title {
text-align: center;
margin-top: 200rpx; margin-top: 200rpx;
font-size: 36rpx; font-size: 36rpx;
font-weight: bold; font-weight: bold;
text-align: center;
} }
.icon { .icon {
@ -67,22 +67,22 @@
} }
.tips { .tips {
text-align: center;
font-size: 28rpx;
color: #999;
margin-bottom: 100rpx; margin-bottom: 100rpx;
font-size: 28rpx;
font-weight: bold; font-weight: bold;
color: #999;
text-align: center;
} }
.button { .button {
width: 600rpx; width: 600rpx;
height: 100rpx; height: 100rpx;
line-height: 100rpx;
text-align: center;
background-color: #63b8af;
color: #fff;
border-radius: 50rpx;
margin: 0 auto; margin: 0 auto;
font-size: 36rpx; font-size: 36rpx;
line-height: 100rpx;
color: #fff;
text-align: center;
background-color: #63b8af;
border-radius: 50rpx;
} }
</style> </style>

View File

@ -1,6 +1,6 @@
<template> <template>
<view> <view>
<view v-if="!penging"> <view v-if="!pending">
<view v-if="isLogin"> <view v-if="isLogin">
<scroll-view <scroll-view
v-if="deviceInfo" v-if="deviceInfo"
@ -31,7 +31,7 @@
maxlength="50" maxlength="50"
></up-search> ></up-search>
</view> </view>
<view class="lock-list" v-if="!penging"> <view class="lock-list" v-if="!pending">
<view v-if="lockList.length === 0 && lockSearch.searchStr === '' && !focus"> <view v-if="lockList.length === 0 && lockSearch.searchStr === '' && !focus">
<image <image
src="https://oss-lock.xhjcn.ltd/mp/icon_add_round.png" src="https://oss-lock.xhjcn.ltd/mp/icon_add_round.png"
@ -42,7 +42,7 @@
<view class="text">添加锁时手机必须在锁旁边</view> <view class="text">添加锁时手机必须在锁旁边</view>
</view> </view>
<view v-else> <view v-else>
<view class="group" v-for="(group, grounIndex) in lockList" :key="group.groupId"> <view class="group" v-for="(group, groupIndex) in lockList" :key="group.groupId">
<view class="group-name"> <view class="group-name">
<view class="group-name-text">{{ group.groupName }}</view> <view class="group-name-text">{{ group.groupName }}</view>
<view class="group-name-line"></view> <view class="group-name-line"></view>
@ -50,14 +50,14 @@
<up-swipe-action> <up-swipe-action>
<up-swipe-action-item <up-swipe-action-item
class="lock" class="lock"
:ref="'swipeItem' + grounIndex" :ref="'swipeItem' + groupIndex"
:options="options" :options="options"
v-for="(lock, lockIndex) in group.lockList" v-for="(lock, lockIndex) in group.lockList"
:key="lock.lockId" :key="lock.lockId"
:threshold="50" :threshold="50"
@click="deleteLock(lock, grounIndex, lockIndex)" @click="deleteLock(lock, groupIndex, lockIndex)"
> >
<view class="lock" @click="toLockDeatil(lock)"> <view class="lock" @click="toLockDetail(lock)">
<view class="lock-top"> <view class="lock-top">
<image <image
class="lock-image-lock" class="lock-image-lock"
@ -174,7 +174,7 @@
<script> <script>
import { timeFormat } from 'uview-plus' import { timeFormat } from 'uview-plus'
import { mapState, mapActions } from 'pinia' import { mapState, mapActions } from 'pinia'
import { getUserInfoRequest, loginRequest } from '@/api/user' import { loginRequest } from '@/api/user'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
@ -188,7 +188,7 @@
return { return {
refresherTriggered: false, refresherTriggered: false,
focus: false, focus: false,
penging: true, pending: true,
deviceInfo: null, deviceInfo: null,
options: [ options: [
{ {
@ -225,7 +225,7 @@
const token = getStorage('token') const token = getStorage('token')
if (token) { if (token) {
await Promise.all([this.getLockList(this.lockSearch), this.getUserInfo()]).then(res => { await Promise.all([this.getLockList(this.lockSearch), this.getUserInfo()]).then(res => {
this.penging = false this.pending = false
uni.hideLoading() uni.hideLoading()
const list = getStorage('lockList') const list = getStorage('lockList')
const userInfo = getStorage('userInfo') const userInfo = getStorage('userInfo')
@ -241,7 +241,7 @@
}) })
} else { } else {
await this.homeLogin() await this.homeLogin()
this.penging = false this.pending = false
uni.hideLoading() uni.hideLoading()
} }
const _data = JSON.parse(JSON.stringify(data)) const _data = JSON.parse(JSON.stringify(data))
@ -481,11 +481,11 @@
}, },
async nextPage() { async nextPage() {
if (this.lockList.length < this.lockTotal) { if (this.lockList.length < this.lockTotal) {
const sreach = { const search = {
...this.lockSearch, ...this.lockSearch,
pageNo: this.lockSearch.pageNo + 1 pageNo: this.lockSearch.pageNo + 1
} }
const { code } = await this.getLockList(search) const { code, message } = await this.getLockList(search)
if (code !== 0) { if (code !== 0) {
uni.showToast({ uni.showToast({
title: message, title: message,
@ -534,7 +534,7 @@
name: 'addLockGuid' name: 'addLockGuid'
}) })
}, },
async toLockDeatil(lock) { async toLockDetail(lock) {
if (!(this.bluetoothStatus === 0 || this.bluetoothStatus === -1)) { if (!(this.bluetoothStatus === 0 || this.bluetoothStatus === -1)) {
this.getBluetoothStatus() this.getBluetoothStatus()
return return
@ -592,20 +592,20 @@
} }
.u-swipe-action { .u-swipe-action {
overflow: inherit !important;
padding-bottom: 32rpx;
width: 672rpx;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
width: 672rpx;
padding-bottom: 32rpx;
overflow: inherit !important;
} }
.u-swipe-action-item { .u-swipe-action-item {
width: 320rpx;
height: 300rpx;
margin-top: 32rpx; margin-top: 32rpx;
overflow: inherit !important; overflow: inherit !important;
border-radius: 32rpx !important; border-radius: 32rpx !important;
width: 320rpx;
height: 300rpx;
} }
.u-swipe-action-item__right { .u-swipe-action-item__right {
@ -623,61 +623,60 @@
<style scoped lang="scss"> <style scoped lang="scss">
.search { .search {
margin-top: 32rpx;
width: 686rpx !important; width: 686rpx !important;
margin-top: 32rpx;
margin-left: 32rpx; margin-left: 32rpx;
} }
.button-login { .button-login {
border-radius: 46rpx;
width: 650rpx; width: 650rpx;
height: 120rpx; height: 120rpx;
line-height: 120rpx;
text-align: center;
margin-left: 50rpx; margin-left: 50rpx;
background: #63b8af;
color: #ffffff;
font-size: 48rpx; font-size: 48rpx;
font-weight: bold; font-weight: bold;
line-height: 120rpx;
color: #ffffff;
text-align: center;
background: #63b8af;
border-radius: 46rpx;
} }
.button-add { .button-add {
width: 120rpx;
height: 120rpx;
position: fixed; position: fixed;
right: 50rpx; right: 50rpx;
bottom: 50rpx; bottom: 50rpx;
width: 120rpx;
height: 120rpx;
border-radius: 50%; border-radius: 50%;
} }
.lock-list { .lock-list {
padding-bottom: 32rpx;
width: 672rpx;
margin-left: 39rpx;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
width: 672rpx;
padding-bottom: 32rpx;
margin-left: 39rpx;
.lock { .lock {
width: 320rpx; width: 320rpx;
height: 300rpx; height: 300rpx;
background: #ffffff; background: #ffffff;
box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12);
border-radius: 32rpx; border-radius: 32rpx;
box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12);
.lock-name { .lock-name {
padding: 0 24rpx;
font-size: 32rpx;
font-weight: bold;
word-break: break-all;
line-height: 38rpx;
display: -webkit-box; display: -webkit-box;
-webkit-box-orient: vertical; padding: 0 24rpx;
-webkit-line-clamp: 2;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
-webkit-line-clamp: 2;
font-size: 32rpx;
font-weight: bold;
line-height: 38rpx;
word-break: break-all;
white-space: normal; white-space: normal;
-webkit-box-orient: vertical;
} }
.lock-time { .lock-time {
@ -712,16 +711,16 @@
} }
.group { .group {
width: 672rpx;
margin-top: 32rpx;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
width: 672rpx;
margin-top: 32rpx;
.group-name { .group-name {
width: 672rpx;
display: flex; display: flex;
align-items: center; align-items: center;
width: 672rpx;
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
} }
@ -748,31 +747,31 @@
.text { .text {
width: 672rpx; width: 672rpx;
margin-top: 32rpx;
font-size: 32rpx; font-size: 32rpx;
font-weight: bold;
color: #999999; color: #999999;
text-align: center; text-align: center;
margin-top: 32rpx;
font-weight: bold;
} }
.tips { .tips {
margin-top: 40vh;
padding: 32rpx 0; padding: 32rpx 0;
text-align: center; margin-top: 40vh;
font-size: 28rpx; font-size: 28rpx;
color: #999999; color: #999999;
text-align: center;
} }
.lock-status { .lock-status {
margin-top: 5rpx;
margin-left: 24rpx;
color: #ffffff;
border-radius: 8rpx;
font-size: 22rpx;
font-weight: bold;
display: inline-block; display: inline-block;
padding: 4rpx 8rpx; padding: 4rpx 8rpx;
background-color: #ecab1f; margin-top: 5rpx;
margin-left: 24rpx;
font-size: 22rpx;
font-weight: bold;
color: #ffffff;
text-align: center; text-align: center;
background-color: #ecab1f;
border-radius: 8rpx;
} }
</style> </style>

View File

@ -443,86 +443,85 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.popup { .popup {
display: flex;
position: relative; position: relative;
display: flex;
flex-wrap: wrap;
width: 400rpx; width: 400rpx;
height: 389rpx; height: 389rpx;
text-align: center; text-align: center;
flex-wrap: wrap;
.popup-background { .popup-background {
position: absolute;
z-index: -1; z-index: -1;
width: 400rpx; width: 400rpx;
height: 389rpx; height: 389rpx;
position: absolute;
} }
.popup-name { .popup-name {
margin-left: 30rpx;
z-index: 9; z-index: 9;
margin-top: 180rpx; display: -webkit-box;
color: #676b6d;
width: 340rpx; width: 340rpx;
max-height: 80rpx; max-height: 80rpx;
line-height: 40rpx; margin-top: 180rpx;
margin-left: 30rpx;
word-break: break-all;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
-webkit-line-clamp: 2;
line-height: 40rpx;
color: #676b6d;
word-break: break-all;
white-space: normal; white-space: normal;
-webkit-box-orient: vertical;
} }
.popup-time { .popup-time {
margin-top: 10rpx;
width: 400rpx; width: 400rpx;
margin-top: 10rpx;
} }
} }
.days { .days {
line-height: 60rpx;
background: #faecc9;
color: #bc9839;
text-align: center;
font-size: 32rpx;
width: 750rpx; width: 750rpx;
height: 60rpx; height: 60rpx;
font-size: 32rpx;
line-height: 60rpx;
color: #bc9839;
text-align: center;
background: #faecc9;
} }
.lock-name { .lock-name {
text-align: center;
font-size: 32rpx;
padding: 32rpx 32rpx 0 32rpx; padding: 32rpx 32rpx 0 32rpx;
font-size: 32rpx;
font-weight: bold; font-weight: bold;
text-align: center;
word-break: break-all; word-break: break-all;
} }
.top { .top {
margin-top: 32rpx; position: relative;
margin-left: 32rpx;
width: 686rpx; width: 686rpx;
height: 464rpx; height: 464rpx;
margin-top: 32rpx;
margin-left: 32rpx;
border-radius: 32rpx; border-radius: 32rpx;
position: relative;
.top-background { .top-background {
z-index: -1;
position: absolute; position: absolute;
z-index: -1;
width: 686rpx; width: 686rpx;
height: 464rpx; height: 464rpx;
border-radius: 32rpx; border-radius: 32rpx;
} }
.switch { .switch {
margin-top: 20rpx;
margin-left: 218rpx;
display: flex; display: flex;
justify-content: center;
align-items: center; align-items: center;
justify-content: center;
width: 250rpx; width: 250rpx;
height: 250rpx; height: 250rpx;
margin-top: 20rpx;
margin-left: 218rpx;
background: #ffffff; background: #ffffff;
border-radius: 50%; border-radius: 50%;
box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12); box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12);
@ -530,30 +529,30 @@
.power { .power {
float: right; float: right;
padding-top: 18rpx;
//width: 100%; //width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
height: 50rpx;
justify-content: flex-end; justify-content: flex-end;
height: 50rpx;
padding-top: 18rpx;
.power-icon { .power-icon {
width: 50rpx; width: 50rpx;
margin-right: 10rpx;
height: 30rpx; height: 30rpx;
margin-right: 10rpx;
} }
.power-text { .power-text {
margin-right: 10rpx;
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
margin-right: 10rpx;
line-height: 50rpx; line-height: 50rpx;
} }
.power-tips { .power-tips {
margin-right: 32rpx;
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
margin-right: 32rpx;
} }
} }
@ -564,18 +563,18 @@
} }
.bottom { .bottom {
width: 686rpx;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
display: flex; display: flex;
align-items: center; align-items: center;
background-color: rgba(0, 0, 0, 0.1);
height: 48rpx;
line-height: 48rpx;
font-size: 32rpx;
color: #63b8af;
border-radius: 0 0 32rpx 32rpx;
justify-content: space-around; justify-content: space-around;
width: 686rpx;
height: 48rpx;
font-size: 32rpx;
line-height: 48rpx;
color: #63b8af;
background-color: rgba(0, 0, 0, 0.1);
border-radius: 0 0 32rpx 32rpx;
.bottom-side { .bottom-side {
display: flex; display: flex;
@ -590,75 +589,75 @@
} }
.menu { .menu {
width: 686rpx;
margin-top: 32rpx; margin-top: 32rpx;
margin-left: 32rpx; margin-left: 32rpx;
width: 686rpx; font-size: 40rpx;
background-color: #ffffff; background-color: #ffffff;
border-radius: 32rpx; border-radius: 32rpx;
box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12); box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12);
font-size: 40rpx;
.menu-title { .menu-title {
padding: 24rpx 32rpx;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 24rpx 32rpx;
} }
.menu-image { .menu-image {
margin-right: 40rpx;
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
margin-right: 40rpx;
} }
.menu-main { .menu-main {
padding-top: 32rpx;
display: flex; display: flex;
align-items: center;
font-size: 28rpx;
flex-wrap: wrap; flex-wrap: wrap;
text-align: center; align-items: center;
padding-top: 32rpx;
margin-left: 43rpx; margin-left: 43rpx;
font-size: 28rpx;
text-align: center;
.menu-main-view { .menu-main-view {
width: 150rpx; width: 150rpx;
margin-bottom: 48rpx; margin-bottom: 48rpx;
.menu-main-image { .menu-main-image {
margin-bottom: 10rpx;
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
margin-bottom: 10rpx;
} }
} }
} }
} }
.setting { .setting {
padding: 24rpx 0;
margin-top: 32rpx;
margin-left: 32rpx;
display: flex; display: flex;
align-items: center; align-items: center;
width: 686rpx; width: 686rpx;
padding: 24rpx 0;
margin-top: 32rpx;
margin-left: 32rpx;
font-size: 40rpx;
background-color: #ffffff; background-color: #ffffff;
border-radius: 32rpx; border-radius: 32rpx;
box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12); box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12);
font-size: 40rpx;
.setting-text { .setting-text {
margin-left: 32rpx; margin-left: 32rpx;
} }
.setting-arrow { .setting-arrow {
margin-right: 32rpx;
width: 48rpx; width: 48rpx;
height: 48rpx; height: 48rpx;
margin-right: 32rpx;
margin-left: auto; margin-left: auto;
} }
.setting-image { .setting-image {
margin-left: 32rpx;
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
margin-left: 32rpx;
} }
} }
</style> </style>