Skip to content

Commit

Permalink
lint fix (#79)
Browse files Browse the repository at this point in the history
* ci: add ci yml

* ci: fix check-types

* ci: lint config

* ci: lint fix

* feat: log version

* ci: check more node versions
  • Loading branch information
liuxy0551 authored Dec 3, 2024
1 parent 06ce3ce commit 97a3efd
Show file tree
Hide file tree
Showing 174 changed files with 11,387 additions and 8,363 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ app/web/store
plugins/
app/web/asset/
app/view/
test.js
test.js

config/manifest.json
44 changes: 0 additions & 44 deletions .eslintrc

This file was deleted.

12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
extends: [require.resolve('ko-lint-config/.eslintrc')],
rules: {
'no-param-reassign': 0,
'prefer-rest-params': 0,
'no-octal-escape': 0,
'new-cap': 0,
'no-new': 0,
'react/no-unescaped-entities': 0,
'no-control-regex': 0,
},
};
43 changes: 43 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'

jobs:
setup:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: yarn

- name: Run Prettier
run: yarn prettier

- name: Run Eslint
run: yarn eslint

- name: Run Stylelint
run: yarn stylelint

- name: Run check-types
run: yarn check-types

- name: Run build
run: yarn build
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.vscode
node_modules
config/manifest.json
run
Expand All @@ -7,4 +6,4 @@ cache
.history
public
resources
app/view
app/view
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Please Checkout And Make Sure Patterns Isn't Exist In .gitignore File First
*.md
**/iconfont*/*
*.yml
app/view/
public

config/manifest.json
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const prettier = require('ko-lint-config/.prettierrc');

module.exports = {
...prettier,
};
5 changes: 5 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Please Checkout And Make Sure Patterns Isn't Exist In .gitignore File First

**/iconfont*/*
app/view/
public
6 changes: 6 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ['ko-lint-config/.stylelintrc'],
rules: {
'value-no-vendor-prefix': null,
},
};
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.formatOnSave": true,
"cSpell.words": ["SUBSCRIPTIONSENDTYPE", "SUBSCRIPTIONSENDTYPECN", "SUBSCRIPTIONSTATUS"]
}
37 changes: 18 additions & 19 deletions DingBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const version = require('./package.json').version;
const config = require('./env.json');
const Logger = require('egg-logger').Logger;
const logger = new Logger('DingdingBot');
const botWebhookUrl = config && config.webhookUrls ? config.webhookUrls : []; //钉钉通知群
const botWebhookUrl = config && config.webhookUrls ? config.webhookUrls : []; // 钉钉通知群
const ApplicationTypeHeader = 'application/json;charset=utf-8';
// DingdingBot
class DingdingBot {
Expand All @@ -12,36 +12,35 @@ class DingdingBot {
this._webhookUrl = webhookUrl;
}

pushMsg(msg, atMobiles) {
pushMsg(msg, _atMobiles) {
try {

let options = {
const options = {
headers: {
'Content-Type': ApplicationTypeHeader
'Content-Type': ApplicationTypeHeader,
},
json: {
'msgtype': 'actionCard',
'actionCard': {
'title': 'Doraemon发布通知',
'text': `### Doraemon v${version} 发布成功 ![screenshot](https://img.pngio.com/my-impression-doraemon-is-my-favorite-cartoon-l-like-doraemon-doraemon-png-820_443.png) \n>致力于解放更多生产力,让日常工作变的更加高效、轻松、便捷、愉快~`,
'btnOrientation': '0',
'singleTitle': '阅读全文',
'singleURL': config && config.msgSingleUrl ? config.msgSingleUrl : ''
}
}
msgtype: 'actionCard',
actionCard: {
title: 'Doraemon发布通知',
text: `### Doraemon v${version} 发布成功 ![screenshot](https://img.pngio.com/my-impression-doraemon-is-my-favorite-cartoon-l-like-doraemon-doraemon-png-820_443.png) \n>致力于解放更多生产力,让日常工作变的更加高效、轻松、便捷、愉快~`,
btnOrientation: '0',
singleTitle: '阅读全文',
singleURL: config && config.msgSingleUrl ? config.msgSingleUrl : '',
},
},
};
// eslint-disable-next-line n/handle-callback-err
request.post(this._webhookUrl, options, function (error, response, body) {
logger.debug(`push msg ${msg}, response: ${JSON.stringify(body)}`);
});
}
catch (err) {
} catch (err) {
console.error(err);
return false;
}
}
}
botWebhookUrl.forEach(item => {
let bot = new DingdingBot(item);;
botWebhookUrl.forEach((item) => {
const bot = new DingdingBot(item);
// 直接推送消息
bot.pushMsg('发布通知');
})
});
32 changes: 19 additions & 13 deletions agent.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
const { createTimedTask, changeTimedTask, cancelTimedTask, timedTaskList, timedTaskResult } = require('./app/utils/timedTask')
const {
createTimedTask,
changeTimedTask,
cancelTimedTask,
timedTaskList,
timedTaskResult,
} = require('./app/utils/timedTask');

// 接收 app 发送来的消息并作出反应
module.exports = agent => {
module.exports = (agent) => {
// 创建文章订阅任务
agent.messenger.on('createTimedTask', ({ id, sendCron }) => {
createTimedTask(id, sendCron, agent)
})
createTimedTask(id, sendCron, agent);
});

// 改变文章订阅任务
agent.messenger.on('changeTimedTask', ({ id, sendCron }) => {
changeTimedTask(id, sendCron, agent)
})
changeTimedTask(id, sendCron, agent);
});

// 取消文章订阅任务
agent.messenger.on('cancelTimedTask', ({ id }) => {
cancelTimedTask(id, agent)
})
cancelTimedTask(id, agent);
});

// 文章订阅任务列表
agent.messenger.on('timedTaskList', () => {
timedTaskList(agent)
})
timedTaskList(agent);
});

// 打印文章订阅任务的执行结果
agent.messenger.on('timedTaskResult', ({ result }) => {
timedTaskResult(result, agent)
})
}
timedTaskResult(result, agent);
});
};
16 changes: 8 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ module.exports = class AppBootHook {
this.app = app;
}
async serverDidReady() {
const {app} = this;
const { app } = this;

Check warning on line 9 in app.js

View workflow job for this annotation

GitHub Actions / setup (14.x)

Unexpected aliasing of members of 'this' to local variables

Check warning on line 9 in app.js

View workflow job for this annotation

GitHub Actions / setup (16.x)

Unexpected aliasing of members of 'this' to local variables
app.utils = utils;
const {cacheDirectory} = app.config;
if (!fs.existsSync(cacheDirectory)){
const { cacheDirectory } = app.config;
if (!fs.existsSync(cacheDirectory)) {
fs.mkdirSync(cacheDirectory);
}

// 监听 agent 进程发出的信息并作出反应
app.messenger.on('sendArticleSubscription', (id) => {
// create an anonymous context to access service
const ctx = app.createAnonymousContext()
const ctx = app.createAnonymousContext();
ctx.runInBackground(async () => {
await ctx.service.articleSubscription.sendArticleSubscription(id)
})
})
await ctx.service.articleSubscription.sendArticleSubscription(id);
});
});
}
}
};
12 changes: 6 additions & 6 deletions app/consts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
const SITE_NAME = {
GITHUB: 'Github',
JUEJIN: '掘金',
ENGLISH: '英文'
}
ENGLISH: '英文',
};

// 订阅网站的二级分类 - 话题
const TOPIC_NAME = {
DEV_ARCHITECTURE: 'DEV Architecture',
REACT_STATUS: 'React Status'
}
REACT_STATUS: 'React Status',
};

module.exports = {
SITE_NAME,
TOPIC_NAME
}
TOPIC_NAME,
};
Loading

0 comments on commit 97a3efd

Please sign in to comment.