diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..df3e785 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = 0 +trim_trailing_whitespace = false + +# 4 tab indentation +[Makefile] +indent_style = tab +indent_size = 4 diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..b961a14 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,8 @@ + +const rules = { +} + +module.exports = { + extends: '@chatie', + rules, +} diff --git a/examples/starter-bot.js b/examples/starter-bot.js index d6376ea..3acb550 100644 --- a/examples/starter-bot.js +++ b/examples/starter-bot.js @@ -12,19 +12,19 @@ function onScan (qrcode) { encodeURIComponent(qrcode), ].join('') - console.log(qrcodeImageUrl) + console.info(qrcodeImageUrl) } function onLogin (user) { - console.log(`${user} login`) + console.info(`${user} login`) } -function onLogout(user) { - console.log(`${user} logout`) +function onLogout (user) { + console.info(`${user} logout`) } async function onMessage (msg) { - console.log(msg.toString()) + console.info(msg.toString()) } const bot = new Wechaty({ name: 'wechaty' }) @@ -35,5 +35,5 @@ bot.on('logout', onLogout) bot.on('message', onMessage) bot.start() -.then(() => console.log('Starter Bot Started.')) -.catch(e => console.error(e)) + .then(() => console.info('Starter Bot Started.')) + .catch(e => console.error(e)) diff --git a/examples/starter-bot.ts b/examples/starter-bot.ts index 840c779..dfbbb06 100644 --- a/examples/starter-bot.ts +++ b/examples/starter-bot.ts @@ -2,7 +2,7 @@ * Wechaty - WeChat Bot SDK for Personal Account, Powered by TypeScript, Docker, and 💖 * - https://github.com/chatie/wechaty */ -import { +import { Wechaty, Contact, Message, @@ -19,19 +19,19 @@ function onScan (qrcode: string, status: ScanStatus) { encodeURIComponent(qrcode), ].join('') - console.log(`${ScanStatus[status]}(${status})`, qrcodeImageUrl) + console.info(`${ScanStatus[status]}(${status})`, qrcodeImageUrl) } function onLogin (user: Contact) { - console.log(`${user} login`) + console.info(`${user} login`) } -function onLogout(user: Contact) { - console.log(`${user} logout`) +function onLogout (user: Contact) { + console.info(`${user} logout`) } async function onMessage (msg: Message) { - console.log(msg.toString()) + console.info(msg.toString()) } const bot = new Wechaty({ name: 'wechaty' }) @@ -42,5 +42,5 @@ bot.on('logout', onLogout) bot.on('message', onMessage) bot.start() -.then(() => console.log('Starter Bot Started.')) -.catch(e => console.error(e)) + .then(() => console.info('Starter Bot Started.')) + .catch(e => console.error(e)) diff --git a/package.json b/package.json index 780786d..6117428 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "node": ">= 10" }, "scripts": { - "lint": "", + "lint": "eslint 'examples/*.{js,ts}'", "postinstall": "check-node-version --node \">= 10\"", "start": "node examples/starter-bot.js", "start:ts": "ts-node examples/starter-bot.ts", @@ -29,6 +29,7 @@ "wechaty": "^0.27.26" }, "devDependencies": { + "@chatie/eslint-config": "^0.6.17", "@chatie/git-scripts": "^0.2.5", "@chatie/tsconfig": "^0.6.1", "check-node-version": "^3.2.0"