From 3ad672a20b8e216684bbcb932b792d67548c2484 Mon Sep 17 00:00:00 2001 From: Dominik Ferber Date: Tue, 27 Oct 2015 17:38:04 +0100 Subject: Add missing semicolon --- client/components/activities/comments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/activities/comments.js b/client/components/activities/comments.js index f9bbcff8..18bf9ef0 100644 --- a/client/components/activities/comments.js +++ b/client/components/activities/comments.js @@ -23,7 +23,7 @@ BlazeComponent.extendComponent({ commentFormIsOpen.set(true); }, 'submit .js-new-comment-form'(evt) { - const input = this.getInput() + const input = this.getInput(); const text = input.val().trim(); if (text) { CardComments.insert({ -- cgit v1.2.3-1-g7c22 From 3956a6ec205b753c55a2d11f8f780acb996bb461 Mon Sep 17 00:00:00 2001 From: Dominik Ferber Date: Tue, 27 Oct 2015 17:40:38 +0100 Subject: Add eslint-plugin-meteor Add rules for eslint-plugin-meteor. Use local version of eslint and eslint-plugin-meteor, instead of relying on global versions. Ensures consistent versions of eslint and eslint-plugin-meteor for all developers. --- .eslintrc | 73 ++++++++++++++++++++++++--------------------------- .gitignore | 1 + models/attachments.js | 2 +- models/users.js | 32 +++++++++++++--------- package.json | 24 +++++++++++++++++ sandstorm.js | 2 +- 6 files changed, 80 insertions(+), 54 deletions(-) create mode 100644 package.json diff --git a/.eslintrc b/.eslintrc index c952e5e0..14a9e667 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,7 +1,14 @@ ecmaFeatures: experimentalObjectRestSpread: true +plugins: + - meteor + +parser: babel-eslint + rules: + strict: 0 + no-undef: 2 accessor-pairs: 2 comma-dangle: [2, 'always-multiline'] consistent-return: 2 @@ -43,36 +50,35 @@ rules: prefer-spread: 2 prefer-template: 2 -globals: - # Meteor globals - Meteor: false - DDP: false - Mongo: false - Session: false - Accounts: false - Template: false - Blaze: false - UI: false - Match: false - check: false - Tracker: false - Deps: false - ReactiveVar: false - EJSON: false - HTTP: false - Email: false - Assets: false - Handlebars: false - Package: false - App: false - Npm: false - Tinytest: false - Random: false - HTML: false + # eslint-plugin-meteor + meteor/globals: 2 + meteor/no-zero-timeout: 2 + meteor/no-session: 0 + meteor/pubsub: 2 + meteor/core: 2 + meteor/methods: 2 + meteor/check: 2 + meteor/connections: 2 + meteor/collections: 2 + meteor/session: [2, 'no-equal'] + +settings: + meteor: + # Our collections + collections: + - AccountsTemplates + - Activities + - Attachments + - Boards + - CardComments + - Cards + - Lists + - UnsavedEditCollection + - Users + +globals: # Exported by packages we use - '$': false - _: false autosize: false Avatar: true Avatars: true @@ -97,17 +103,6 @@ globals: T9n: false TAPi18n: false - # Our collections - AccountsTemplates: true - Activities: true - Attachments: true - Boards: true - CardComments: true - Cards: true - Lists: true - UnsavedEditCollection: true - Users: true - # Our objects CSSEvents: true EscapeActions: true diff --git a/.gitignore b/.gitignore index 986a8b46..7c40fcd4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .tx/ *.sublime-workspace tmp/ +node_modules/ diff --git a/models/attachments.js b/models/attachments.js index 8ef0fef0..01e467ff 100644 --- a/models/attachments.js +++ b/models/attachments.js @@ -1,4 +1,4 @@ -Attachments = new FS.Collection('attachments', { +Attachments = new FS.Collection('attachments', { // eslint-disable-line meteor/collections stores: [ // XXX Add a new store for cover thumbnails so we don't load big images in diff --git a/models/users.js b/models/users.js index b35104ec..1e69564d 100644 --- a/models/users.js +++ b/models/users.js @@ -1,4 +1,4 @@ -Users = Meteor.users; +Users = Meteor.users; // eslint-disable-line meteor/collections // Search a user in the complete server database by its name or username. This // is used for instance to add a new user to a board. @@ -8,6 +8,24 @@ Users.initEasySearch(searchInFields, { returnFields: [...searchInFields, 'profile.avatarUrl'], }); +if (Meteor.isClient) { + Users.helpers({ + isBoardMember() { + const board = Boards.findOne(Session.get('currentBoard')); + return board && + _.contains(_.pluck(board.members, 'userId'), this._id) && + _.where(board.members, {userId: this._id})[0].isActive; + }, + + isBoardAdmin() { + const board = Boards.findOne(Session.get('currentBoard')); + return board && + this.isBoardMember(board) && + _.where(board.members, {userId: this._id})[0].isAdmin; + }, + }); +} + Users.helpers({ boards() { return Boards.find({ userId: this._id }); @@ -23,18 +41,6 @@ Users.helpers({ return _.contains(starredBoards, boardId); }, - isBoardMember() { - const board = Boards.findOne(Session.get('currentBoard')); - return board && _.contains(_.pluck(board.members, 'userId'), this._id) && - _.where(board.members, {userId: this._id})[0].isActive; - }, - - isBoardAdmin() { - const board = Boards.findOne(Session.get('currentBoard')); - return board && this.isBoardMember(board) && - _.where(board.members, {userId: this._id})[0].isAdmin; - }, - getAvatarUrl() { // Although we put the avatar picture URL in the `profile` object, we need // to support Sandstorm which put in the `picture` attribute by default. diff --git a/package.json b/package.json new file mode 100644 index 00000000..821f4619 --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "wekan", + "version": "1.0.0", + "description": "The open-source Trello-like kanban", + "private": true, + "scripts": { + "lint": "eslint .", + "test": "npm run lint" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/wekan/wekan.git" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/wekan/wekan/issues" + }, + "homepage": "https://github.com/wekan/wekan#readme", + "devDependencies": { + "babel-eslint": "4.1.3", + "eslint": "1.7.3", + "eslint-plugin-meteor": "1.5.0" + } +} diff --git a/sandstorm.js b/sandstorm.js index 51f8ba34..65f24866 100644 --- a/sandstorm.js +++ b/sandstorm.js @@ -109,7 +109,7 @@ if (isSandstorm && Meteor.isClient) { // sandstorm client to return relative paths instead of absolutes. const _absoluteUrl = Meteor.absoluteUrl; const _defaultOptions = Meteor.absoluteUrl.defaultOptions; - Meteor.absoluteUrl = (path, options) => { + Meteor.absoluteUrl = (path, options) => { // eslint-disable-line meteor/core const url = _absoluteUrl(path, options); return url.replace(/^https?:\/\/127\.0\.0\.1:[0-9]{2,5}/, ''); }; -- cgit v1.2.3-1-g7c22 From 6e87d50941821dec7c8be5d77211fa5c5836733d Mon Sep 17 00:00:00 2001 From: Dominik Ferber Date: Tue, 27 Oct 2015 18:01:44 +0100 Subject: Adapt CI --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 55f8ed48..a8724631 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: node_js node_js: - "0.10.40" install: - - "npm install -g eslint" - - "npm install -g eslint-plugin-meteor" + - "npm install" script: - - "eslint ./" + - "npm test" -- cgit v1.2.3-1-g7c22 From c9130324f6c337d0393bf37fe72b67b47ece8322 Mon Sep 17 00:00:00 2001 From: Dominik Ferber Date: Tue, 27 Oct 2015 18:34:09 +0100 Subject: Enable more ESLint-plugin-Meteor rules --- .eslintrc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index 14a9e667..a8017e66 100644 --- a/.eslintrc +++ b/.eslintrc @@ -51,17 +51,21 @@ rules: prefer-template: 2 # eslint-plugin-meteor + ## Meteor API meteor/globals: 2 - meteor/no-zero-timeout: 2 - meteor/no-session: 0 - meteor/pubsub: 2 meteor/core: 2 + meteor/pubsub: 2 meteor/methods: 2 meteor/check: 2 meteor/connections: 2 meteor/collections: 2 meteor/session: [2, 'no-equal'] + ## Best practices + meteor/no-session: 0 + meteor/no-zero-timeout: 2 + meteor/no-blaze-lifecycle-assignment: 2 + settings: meteor: -- cgit v1.2.3-1-g7c22