Skip to content

Commit

Permalink
chore: lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilfish committed May 15, 2024
1 parent 6fa87c2 commit cd3907d
Show file tree
Hide file tree
Showing 11 changed files with 363 additions and 238 deletions.
2 changes: 1 addition & 1 deletion apps/cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const root = path.resolve(path.resolve(), '../../')

const pkg = await readFile('package.json', 'utf-8')
// 移除 dist 前缀
.then(data => data.replace(/dist\//gm, ''))
.then(data => data.replace(/dist\//g, ''))
// 移除 devDependencies
.then(data => JSON.parse(data))
.then((data) => {
Expand Down
17 changes: 17 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import antfu from '@antfu/eslint-config'

export default antfu({
unocss: true,
formatters: true,
rules: {
'no-console': 'off',
'vue/no-multiple-template-root': 'off',
'node/prefer-global/process': 'off',
'format/prettier': 'off',
'antfu/no-import-dist': 'off',
},
ignores: [
'pnpm-lock.yaml',
],
},
)
23 changes: 0 additions & 23 deletions eslint.config.ts

This file was deleted.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@
"postinstall": "simple-git-hooks"
},
"devDependencies": {
"@antfu/eslint-config": "^2.17.0",
"@antfu/eslint-config": "^2.18.0",
"@unocss/eslint-config": "^0.60.2",
"@unocss/eslint-plugin": "^0.60.2",
"eslint": "npm:eslint-ts-patch@8.55.0-1",
"eslint-plugin-format": "^0.1.1",
"eslint-ts-patch": "8.55.0-1",
"jszip": "3.9.1",
"lint-staged": "^15.2.2",
"pnpm": "^9.1.0",
"pnpm": "^9.1.1",
"simple-git-hooks": "^2.11.1",
"tsx": "^4.10.1",
"tsx": "^4.10.2",
"typescript": "^5.4.5",
"unbuild": "^2.0.0",
"vue-tsc": "^2.0.17"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function replaceImg(img: string, forceCdn = false) {
}

const name = img.split('/').pop()?.replace(/\?.+/, '') // 同时去除 params
const prefix = img.match(/^(?:https?:\/\/)?([^:\/\n]+)/im)?.[1] // 域名
const prefix = img.match(/^(?:https?:\/\/)?([^:/\n]+)/im)?.[1] // 域名

if (!prefix || !name)
return img
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ export class IDB {
.replace(/<[^>]+>/g, ' ') // 移除所有 HTML 标签
.replace(/(undefined|查看图片|查看链接|转发微博)/, '')
.replace(/&[a-z]+;/g, ' ') // 移除 HTML 实体字符
.replace(/[\s\n]+/g, ' ') // 移除多余的空白字符
.replace(/@[\u4E00-\u9FA5a-zA-Z0-9_-]+/g, '') // 移除 @ 用户名
.replace(/\s+/g, ' ') // 移除多余的空白字符
.replace(/@[\u4E00-\u9FA5\w-]+/g, '') // 移除 @ 用户名
.trim(),
}
})
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export function parseText(text?: string) {
/<a[^>]*>(@[^<]+)<\/a>/g, // @用户
(_, user) => link(`${user}`, `${weibo}/n/${user.replace('@', '')}`),
)
.replace(/<img[^>]+alt="([^"]*)"[^>]*>/gm, (_, alt) => alt) // 表情图片
.replace(/<img[^>]*>/gm, '') // 图标
.replace(/<img[^>]+alt="([^"]*)"[^>]*>/g, (_, alt) => alt) // 表情图片
.replace(/<img[^>]*>/g, '') // 图标
.replace(/(https:)?\/\/weibo.cn\/sinaurl\?u=(.+)/, (_, __, href) => decodeURIComponent(href)) // 去掉微博的链接跳转

const retweetImg = /<a[^>]*href="([^"]*)"[^>]*>查看图片<\/a>/gm.exec(parsed)
const retweetImg = /<a[^>]*href="([^"]*)"[^>]*>查看图片<\/a>/.exec(parsed)
let textImg = null

if (retweetImg && retweetImg[1]) {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ProtocolMap } from './types'
export const protocolMap: ProtocolMap = {
img: {
text: '查看图片',
reg: /\[img:\/\/(.+?)]/gm,
reg: /\[img:\/\/(.+?)\]/g,
/**
* 解析包含查看图片协议的文本
* 将返回包含 <ViewImgBtn /> 组件和原文本的 VNode
Expand Down

0 comments on commit cd3907d

Please sign in to comment.