Skip to content

Commit

Permalink
chore: add eslint configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fish.yu committed Apr 18, 2024
1 parent d363191 commit ee006ae
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 'latest'
},
env: {
es6: true,
node: true
},
extends: 'eslint:recommended',
rules: {
quotes: [
'error',
'single'
],
'no-unused-vars': 'warn',
}
}
2 changes: 1 addition & 1 deletion lib/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Downloader {
console.log('image src:', src, '\n');
// 按照cdn的url规则,获取图片名称
// https://cdn.nlark.com/yuque/0/2024/png/394019/1713409985862-2a651a60-380a-4227-852c-e81d193340c5.png#averageHue=%23f8f9fa&clientId=u7b4c5a0c-9e50-4&from=ui&id=u0437de00&originHeight=48&originWidth=48&originalType=binary&ratio=2&rotation=0&showTitle=false&size=1428&status=done&style=none&taskId=ufab6517c-e059-4e38-8cef-b2ddf4390f8&title=
const pathname = new URL(url).pathname;
const pathname = new URL(src).pathname;
const fileName = pathname.split('.').shift();
const name = `${repo_name}_${slug}_image_${fileName}`
const imageUrl = await this.uploadImageFromUrl(src, name);
Expand Down
11 changes: 4 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ const { YUQUE_REPOS } = process.env;
async function run () {
if (!YUQUE_REPOS) {
throw new Error ('Need YUQUE_REPOS');
};
}

const repos = YUQUE_REPOS.split(',');
await Promise.all(repos.map((repo) => {
return new Promise(async(resolve) => {
const downloader = new Downloader(repo)
await downloader.autoUpdate();
resolve();
});
await Promise.all(repos.map(async (repo) => {
const downloader = new Downloader(repo)
await downloader.autoUpdate();
}))

const gh = new GitHubClient()
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports.formatRaw = function (body) {
const brBug = /<br \/>/g;
const hiddenContent = /<div style="display:none">[\s\S]*?<\/div>/gi;
// 删除语雀特有的锚点
const emptyAnchor = /<a name=\".*?\"><\/a>/g;
const emptyAnchor = /<a name=".*?"><\/a>/g;
body = body
.replace(hiddenContent, '')
.replace(multiBr, '<br />')
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"main": "lib/index.js",
"scripts": {
"dev": "NODE_ENV=local node lib/index.js",
"start": "node lib/index.js"
"start": "node lib/index.js",
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.vue --format=stylish ./lib",
"lint:fix": "npm lint:js --fix"
},
"author": "",
"license": "ISC",
Expand All @@ -19,5 +21,8 @@
"moment": "^2.22.2",
"prettier": "^2.0.4",
"queue": "^4.5.0"
},
"devDependencies": {
"eslint": "^8.57.0"
}
}

0 comments on commit ee006ae

Please sign in to comment.