diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..e291365
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,9 @@
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 4
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..a261f29
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1 @@
+dist/*
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000..52a2552
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,41 @@
+module.exports = {
+ root: true,
+ parser: 'babel-eslint',
+ parserOptions: {
+ sourceType: 'module'
+ },
+ env: {
+ browser: true
+ },
+ // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
+ extends: 'standard',
+ // required to lint *.wpy files
+ plugins: [
+ 'html'
+ ],
+ settings: {
+ 'html/html-extensions': ['.html', '.wpy']
+ },
+ 'globals': {
+ 'wx': true
+ },
+ // add your custom rules here
+ 'rules': {
+ // allow paren-less arrow functions
+ 'arrow-parens': 0,
+ // allow async-await
+ 'generator-star-spacing': 0,
+ "semi": [
+ "error",
+ "always"
+ ],
+ 'comma-dangle': ["error", "only-multiline"],
+ 'padded-blocks': 0,
+ 'one-var': 0,
+ 'no-return-assign': 0,
+ 'indent': ['error', 4],
+ // allow debugger during development
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
+ 'space-before-function-paren': 0
+ }
+}
diff --git a/package.json b/package.json
index 7892fad..d414db7 100644
--- a/package.json
+++ b/package.json
@@ -9,17 +9,26 @@
"author": "",
"license": "ISC",
"dependencies": {
- "babel-plugin-syntax-export-extensions": "^6.13.0",
- "babel-plugin-transform-export-extensions": "^6.8.0",
- "babel-plugin-transform-runtime": "^6.15.0",
- "babel-preset-es2015": "^6.18.0",
- "babel-preset-stage-1": "^6.16.0",
- "wepy": "^1.4.7",
+ "wepy": "^1.5.1",
"wepy-async-function": "^1.4.4",
"wepy-com-toast": "^1.0.1"
},
"devDependencies": {
- "wepy-compiler-babel": "0.0.3",
- "wepy-compiler-sass": "0.0.3"
+ "babel-eslint": "^7.2.1",
+ "babel-plugin-syntax-export-extensions": "^6.13.0",
+ "babel-plugin-transform-export-extensions": "^6.22.0",
+ "babel-preset-es2015": "^6.24.0",
+ "babel-preset-stage-1": "^6.22.0",
+ "cross-env": "^3.2.4",
+ "eslint": "^3.18.0",
+ "eslint-config-standard": "^7.1.0",
+ "eslint-friendly-formatter": "^2.0.7",
+ "eslint-plugin-html": "^2.0.1",
+ "eslint-plugin-promise": "^2.0.1",
+ "eslint-plugin-standard": "^2.0.1",
+ "wepy-compiler-babel": "^1.5.1",
+ "wepy-compiler-less": "^1.3.10",
+ "wepy-compiler-sass": "0.0.3",
+ "wepy-eslint": "^1.5.2"
}
}
diff --git a/src/app.wpy b/src/app.wpy
index 1b96e2d..14f9340 100644
--- a/src/app.wpy
+++ b/src/app.wpy
@@ -1,51 +1,51 @@
-
-
-
+
+
+
diff --git a/src/components/alpha.wpy b/src/components/alpha.wpy
index 224963f..3a47565 100644
--- a/src/components/alpha.wpy
+++ b/src/components/alpha.wpy
@@ -36,7 +36,7 @@
export default class Message extends wepy.component {
data = {
- tags: table
+ tags: table,
};
methods = {
diff --git a/src/components/chartboard.wpy b/src/components/chartboard.wpy
index 66e27c0..533f716 100644
--- a/src/components/chartboard.wpy
+++ b/src/components/chartboard.wpy
@@ -90,13 +90,13 @@
let userinfo, message;
try {
userinfo = await api.getUserInfo();
- } catch(e) {
+ } catch (e) {
console.log(e);
userinfo = {
nickName: 'Gcaufy',
id: 'gcaufy',
avatarUrl: '../images/myheader.png',
- }
+ };
}
this.current = userinfo;
try {
@@ -121,7 +121,6 @@
async sendMessage (msg) {
let id = this.to;
- let contact = global.getContact(id);
let msgObj = await api.sendMsg(id, msg);
msgObj.name = this.current.nickName;
diff --git a/src/components/contact.wpy b/src/components/contact.wpy
index 6333fbe..f373b5d 100644
--- a/src/components/contact.wpy
+++ b/src/components/contact.wpy
@@ -121,30 +121,34 @@
export default class Message extends wepy.component {
components = {
- alpha: Alpha,
+ alpha: Alpha
};
data = {
- toplist: [{
- header: '../images/new_friend.png',
- name: '新的朋友',
- },{
- header: '../images/group_chat.png',
- name: '群聊',
- },{
- header: '../images/tag.png',
- name: '标签',
- },{
- header: '../images/public.png',
- name: '公众号',
- },],
+ toplist: [
+ {
+ header: '../images/new_friend.png',
+ name: '新的朋友',
+ },
+ {
+ header: '../images/group_chat.png',
+ name: '群聊',
+ },
+ {
+ header: '../images/tag.png',
+ name: '标签',
+ },
+ {
+ header: '../images/public.png',
+ name: '公众号',
+ },
+ ],
contacts: {},
total: 0,
};
methods = {
select (id, evt) {
- //console.log(`${id} is selected`);
- wx.navigateTo({url: 'chat?id=' + id});
+ this.$root.$navigate({url: 'chat?id=' + id});
}
};
@@ -153,7 +157,7 @@
}
format (arr) {
- let obj = {}, c;
+ let c, obj = {};
arr.forEach((item) => {
c = item.id[0].toUpperCase();
if (obj[c]) {
diff --git a/src/components/discovery.wpy b/src/components/discovery.wpy
index 2649d28..61fbf59 100644
--- a/src/components/discovery.wpy
+++ b/src/components/discovery.wpy
@@ -32,17 +32,16 @@
\ No newline at end of file
+
diff --git a/src/components/group.wpy b/src/components/group.wpy
index 464c4a5..c982026 100644
--- a/src/components/group.wpy
+++ b/src/components/group.wpy
@@ -50,7 +50,7 @@
}
components = {
- item: Item,
+ item: Item
};
}
diff --git a/src/components/input.wpy b/src/components/input.wpy
index 91d6f9f..fd80dce 100644
--- a/src/components/input.wpy
+++ b/src/components/input.wpy
@@ -105,4 +105,4 @@
onLoad () {
}
}
-
\ No newline at end of file
+
diff --git a/src/components/item.wpy b/src/components/item.wpy
index a6a7bbf..81de03d 100644
--- a/src/components/item.wpy
+++ b/src/components/item.wpy
@@ -12,15 +12,15 @@
props = {
item: {},
- index: {}
+ index: {},
}
methods = {
click (evt) {
console.log(`[clicked]GroupIndex:(${this.$parent.$index}) Index:(${this.$index}) Title:(${this.item.title})`);
- if (this.item.action)
+ if (this.item.action) {
this.item.action.call(this.$parent);
- else {
+ } else {
this.$root.showToast(this.item.title);
}
}
diff --git a/src/components/list.wpy b/src/components/list.wpy
index 7a9efd9..9f58386 100644
--- a/src/components/list.wpy
+++ b/src/components/list.wpy
@@ -56,9 +56,9 @@
methods = {
click (index, item, evt) {
console.log('index: ' + index + 'clicked: ' + item.title);
- if (this.list[index].action)
+ if (this.list[index].action) {
this.list[index].action.call(this.$parent);
- else {
+ } else {
this.$root.showToast(item.title);
}
}
diff --git a/src/components/me.wpy b/src/components/me.wpy
index 1263b52..ffc2aea 100644
--- a/src/components/me.wpy
+++ b/src/components/me.wpy
@@ -86,7 +86,7 @@
userInfo: {
nickName: 'Gcaufy',
id: 'gcaufy',
- avatarUrl: '../images/myheader.png',
+ avatarUrl: '../images/myheader.png'
},
dAlbum: [
{icon: '../images/album.png', title: '相册'},
@@ -94,10 +94,17 @@
{icon: '../images/wallet.png', title: '钱包'},
{icon: '../images/card.png', title: '卡包'},
],
- dSetting: [{id: 'clear', icon: '../images/setting.png', title: '清除本地聊天记录', action() {
- this.clearHistory();
- }}],
- dEmoji: [{icon: '../images/emoji.png', title: '表情'}]
+ dSetting: [
+ {
+ id: 'clear',
+ icon: '../images/setting.png',
+ title: '清除本地聊天记录',
+ action() {
+ this.clearHistory();
+ }
+ }
+ ],
+ dEmoji: [{icon: '../images/emoji.png', title: '表情'}],
};
methods = {
@@ -119,10 +126,9 @@
this.$apply();
}
-
async clearHistory (id) {
await api.clearMsg(id);
- wx.navigateTo({url: 'index'});
+ this.$root.$navigate({url: 'index'});
}
}
-
\ No newline at end of file
+
diff --git a/src/components/message.wpy b/src/components/message.wpy
index f65e3cf..cca8e94 100644
--- a/src/components/message.wpy
+++ b/src/components/message.wpy
@@ -62,13 +62,12 @@
export default class Message extends wepy.component {
data = {
- list: []
+ list: [],
};
-
methods = {
select (id, evt) {
- wx.navigateTo({url: 'chat?id=' + id});
+ this.$root.$navigate({url: 'chat?id=' + id});
}
};
diff --git a/src/components/tab.wpy b/src/components/tab.wpy
index cbd06c0..c191204 100644
--- a/src/components/tab.wpy
+++ b/src/components/tab.wpy
@@ -66,8 +66,6 @@
methods = {
change (idx, evt) {
this.active = +idx;
-
- //this.$parent.changeTab(idx);
}
};
diff --git a/src/pages/chat.wpy b/src/pages/chat.wpy
index bff754b..65bab5d 100644
--- a/src/pages/chat.wpy
+++ b/src/pages/chat.wpy
@@ -20,19 +20,18 @@
import global from '../common/global';
export default class Chat extends wepy.page {
-
config = {
- "navigationBarTitleText": "wepy - 微信",
- "navigationBarTextStyle": "white",
- "navigationBarBackgroundColor": "#3b3a40"
+ 'navigationBarTitleText': 'wepy - 微信',
+ 'navigationBarTextStyle': 'white',
+ 'navigationBarBackgroundColor': '#3b3a40'
};
components = {
input: Input,
- chartboard: Chartboard,
+ chartboard: Chartboard
};
data = {
- currentTab: 0,
+ currentTab: 0
};
methods = {
};
@@ -44,12 +43,12 @@
onLoad (p) {
let contact = global.getContact(p.id);
if (!contact) {
- wx.navigateBack();
+ this.$back();
return;
}
wx.setNavigationBarTitle({title: contact.name});
this.$invoke('chartboard', 'loadMessage', p.id);
- }
+ }
}
-
\ No newline at end of file
+
diff --git a/src/pages/index.wpy b/src/pages/index.wpy
index 3119564..d0f1135 100644
--- a/src/pages/index.wpy
+++ b/src/pages/index.wpy
@@ -1,78 +1,75 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/wepy.config.js b/wepy.config.js
index 9d1c0f0..0477f7f 100644
--- a/wepy.config.js
+++ b/wepy.config.js
@@ -2,6 +2,7 @@
let prod = process.env.NODE_ENV === 'production';
module.exports = {
+ eslint: true,
"wpyExt": ".wpy",
"compilers": {
"sass": {