Upgrade ESLint to v2

This commit also tweak the code style following backward-incompatible v2 rules.
This commit is contained in:
Maxime Quandalle 2016-02-13 03:12:01 +01:00
parent b8aefedcc3
commit 90601eacae
14 changed files with 161 additions and 164 deletions

129
.eslintrc
View file

@ -1,129 +0,0 @@
ecmaFeatures:
experimentalObjectRestSpread: true
rules:
strict: 0
no-undef: 2
accessor-pairs: 2
comma-dangle: [2, 'always-multiline']
consistent-return: 2
dot-notation: 2
eqeqeq: 2
indent: [2, 2]
no-cond-assign: 2
no-constant-condition: 2
no-eval: 2
no-inner-declarations: [0]
no-unneeded-ternary: 2
radix: 2
semi: [2, always]
# Stylistic Issues
camelcase: 2
comma-spacing: 2
comma-style: 2
eol-last: 2
linebreak-style: [2, unix]
new-parens: 2
no-lonely-if: 2
no-multiple-empty-lines: 2
no-nested-ternary: 2
no-spaced-func: 2
no-trailing-spaces: 2
operator-linebreak: 2
quotes: [2, single]
semi-spacing: 2
space-unary-ops: 2
spaced-comment: [2, always, markers: ['/']]
# ECMAScript 6
arrow-parens: 2
arrow-spacing: 2
no-class-assign: 2
no-dupe-class-members: 2
no-var: 2
object-shorthand: 2
prefer-const: 2
prefer-spread: 2
prefer-template: 2
globals:
# Meteor globals
Meteor: false
Session: false
HTML: false
check: false
Tracker: false
Blaze: false
Accounts: false
Match: false
Mongo: false
Random: false
ReactiveVar: false
Email: false
Template: false
# Exported by packages we use
'$': false
_: false
autosize: false
Avatar: true
Avatars: true
BlazeComponent: false
BlazeLayout: false
DocHead: false
ESSearchResults: false
FastRender: false
FlowRouter: false
FS: false
getSlug: false
Migrations: false
moment: false
Mousetrap: false
Picker: false
Presence: true
presences: true
Ps: true
ReactiveTabs: false
Restivus: false
SimpleSchema: false
SubsManager: false
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
Filter: true
Mixins: true
Modal: true
MultiSelection: true
Popup: true
Sidebar: true
Utils: true
InlinedForm: true
UnsavedEdits: true
Notifications: true
# XXX Temp, we should remove these
allowIsBoardAdmin: true
allowIsBoardMember: true
Emoji: true
env:
es6: true
node: true
browser: true
extends: 'eslint:recommended'

121
.eslintrc.json Normal file
View file

@ -0,0 +1,121 @@
{
"extends": "eslint:recommended",
"env": {
"es6": true,
"node": true,
"browser": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"rules": {
"strict": 0,
"no-undef": 2,
"accessor-pairs": 2,
"comma-dangle": [2, "always-multiline"],
"consistent-return": 2,
"dot-notation": 2,
"eqeqeq": 2,
"indent": [2, 2],
"no-cond-assign": 2,
"no-constant-condition": 2,
"no-eval": 2,
"no-inner-declarations": [0],
"no-unneeded-ternary": 2,
"radix": 2,
"semi": [2, "always"],
"camelcase": 2,
"comma-spacing": 2,
"comma-style": 2,
"eol-last": 2,
"linebreak-style": [2, "unix"],
"new-parens": 2,
"no-lonely-if": 2,
"no-multiple-empty-lines": 2,
"no-nested-ternary": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"operator-linebreak": 2,
"quotes": [2, "single"],
"semi-spacing": 2,
"space-unary-ops": 2,
"arrow-parens": 2,
"arrow-spacing": 2,
"no-class-assign": 2,
"no-dupe-class-members": 2,
"no-var": 2,
"object-shorthand": 2,
"prefer-const": 2,
"prefer-spread": 2,
"prefer-template": 2
},
"globals": {
"Meteor": false,
"Session": false,
"HTML": false,
"check": false,
"Tracker": false,
"Blaze": false,
"Accounts": false,
"Match": false,
"Mongo": false,
"Random": false,
"ReactiveVar": false,
"Email": false,
"Template": false,
"$": false,
"_": false,
"autosize": false,
"Avatar": true,
"Avatars": true,
"BlazeComponent": false,
"BlazeLayout": false,
"DocHead": false,
"ESSearchResults": false,
"FastRender": false,
"FlowRouter": false,
"FS": false,
"getSlug": false,
"Migrations": false,
"moment": false,
"Mousetrap": false,
"Picker": false,
"Presence": true,
"presences": true,
"Ps": true,
"ReactiveTabs": false,
"Restivus": false,
"SimpleSchema": false,
"SubsManager": false,
"T9n": false,
"TAPi18n": false,
"AccountsTemplates": true,
"Activities": true,
"Attachments": true,
"Boards": true,
"CardComments": true,
"Cards": true,
"Lists": true,
"UnsavedEditCollection": true,
"Users": true,
"CSSEvents": true,
"EscapeActions": true,
"Filter": true,
"Mixins": true,
"Modal": true,
"MultiSelection": true,
"Popup": true,
"Sidebar": true,
"Utils": true,
"InlinedForm": true,
"UnsavedEdits": true,
"Notifications": true,
"allowIsBoardAdmin": true,
"allowIsBoardMember": true,
"Emoji": true
}
}

View file

@ -208,11 +208,12 @@ BlazeComponent.extendComponent({
label.color.indexOf(term) > -1) {
return label;
}
return null;
}));
},
template(label) {
return Blaze.toHTMLWithData(Template.autocompleteLabelLine, {
hasNoName: !Boolean(label.name),
hasNoName: !label.name,
colorName: label.color,
labelName: label.name || label.color,
});
@ -233,6 +234,7 @@ BlazeComponent.extendComponent({
evt.stopPropagation();
return commands.KEY_ENTER;
}
return null;
},
});
},

View file

@ -61,18 +61,20 @@ Blaze.Template.registerHelper('mentions', new Template('mentions', function() {
const mentionRegex = /\B@(\w*)/gi;
let content = Blaze.toHTML(view.templateContentBlock);
let currentMention, knowedUser, linkClass, linkValue, link;
while (Boolean(currentMention = mentionRegex.exec(content))) {
knowedUser = _.findWhere(knowedUsers, { username: currentMention[1] });
if (!knowedUser)
let currentMention;
while ((currentMention = mentionRegex.exec(content)) !== null) {
const [fullMention, username] = currentMention;
const knowedUser = _.findWhere(knowedUsers, { username });
if (!knowedUser) {
continue;
}
linkValue = [' ', at, knowedUser.username];
linkClass = 'atMention js-open-member';
if (knowedUser.userId === Meteor.userId())
const linkValue = [' ', at, knowedUser.username];
let linkClass = 'atMention js-open-member';
if (knowedUser.userId === Meteor.userId()) {
linkClass += ' me';
link = HTML.A({
}
const link = HTML.A({
'class': linkClass,
// XXX Hack. Since we stringify this render function result below with
// `Blaze.toHTML` we can't rely on blaze data contexts to pass the
@ -81,7 +83,7 @@ Blaze.Template.registerHelper('mentions', new Template('mentions', function() {
'data-userId': knowedUser.userId,
}, linkValue);
content = content.replace(currentMention[0], Blaze.toHTML(link));
content = content.replace(fullMention, Blaze.toHTML(link));
}
return HTML.Raw(content);

View file

@ -68,7 +68,7 @@ BlazeComponent.extendComponent({
const popup = Popup.open('disambiguateMultiLabel');
// XXX We need to have a better integration between the popup and the
// UI components systems.
return popup.call(this.currentData(), evt);
popup.call(this.currentData(), evt);
}
},
'click .js-toggle-member-multiselection'(evt) {
@ -82,7 +82,7 @@ BlazeComponent.extendComponent({
const popup = Popup.open('disambiguateMultiMember');
// XXX We need to have a better integration between the popup and the
// UI components systems.
return popup.call(this.currentData(), evt);
popup.call(this.currentData(), evt);
}
},
'click .js-move-selection': Popup.open('moveSelection'),

View file

@ -2,6 +2,8 @@ Blaze.registerHelper('currentBoard', () => {
const boardId = Session.get('currentBoard');
if (boardId) {
return Boards.findOne(boardId);
} else {
return null;
}
});
@ -9,6 +11,8 @@ Blaze.registerHelper('currentCard', () => {
const cardId = Session.get('currentCard');
if (cardId) {
return Cards.findOne(cardId);
} else {
return null;
}
});

View file

@ -15,6 +15,7 @@ function whichTransitionEvent() {
return transitions[t];
}
}
return null;
}
function whichAnimationEvent() {
@ -32,6 +33,7 @@ function whichAnimationEvent() {
return transitions[t];
}
}
return null;
}
CSSEvents = {

View file

@ -64,6 +64,7 @@ EscapeActions = {
clickExecute(target, maxLabel) {
if (this._nextclickPrevented) {
this._nextclickPrevented = false;
return false;
} else {
return this._execute({
maxLabel,

View file

@ -109,12 +109,11 @@ MultiSelection = {
toggleRange(cardId) {
const selectedCards = this._selectedCards.get();
let startRange;
this.reset();
if (!this.isActive() || selectedCards.length === 0) {
this.toggle(cardId);
} else {
startRange = selectedCards[selectedCards.length - 1];
const startRange = selectedCards[selectedCards.length - 1];
this.toggle(getCardsBetween(startRange, cardId));
}
},

View file

@ -38,7 +38,8 @@ window.Popup = new class {
if (self.isOpen()) {
const previousOpenerElement = self._getTopStack().openerElement;
if (previousOpenerElement === evt.currentTarget) {
return self.close();
self.close();
return;
} else {
$(previousOpenerElement).removeClass('is-active');
}

View file

@ -14,6 +14,7 @@ $.fn.escapeableTextComplete = function(strategies, options, ...otherArgs) {
evt.stopPropagation();
return commands.KEY_ENTER;
}
return null;
},
...options,
};

View file

@ -201,6 +201,7 @@ Boards.mutations({
const _id = Random.id(6);
return { $push: {labels: { _id, name, color }}};
}
return {};
},
editLabel(labelId, name, color) {
@ -213,6 +214,7 @@ Boards.mutations({
},
};
}
return {};
},
removeLabel(labelId) {
@ -397,8 +399,9 @@ if (Meteor.isServer) {
if (!_.contains(fieldNames, 'labels') ||
!modifier.$pull ||
!modifier.$pull.labels ||
!modifier.$pull.labels._id)
!modifier.$pull.labels._id) {
return;
}
const removedLabelId = modifier.$pull.labels._id;
Cards.update(
@ -414,8 +417,9 @@ if (Meteor.isServer) {
// Add a new activity if we add or remove a member to the board
Boards.after.update((userId, doc, fieldNames, modifier) => {
if (!_.contains(fieldNames, 'members'))
if (!_.contains(fieldNames, 'members')) {
return;
}
let memberId;

View file

@ -397,8 +397,7 @@ class TrelloCreator {
parseActions(trelloActions) {
trelloActions.forEach((action) => {
switch (action.type) {
case 'addAttachmentToCard':
if (action.type === 'addAttachmentToCard') {
// We have to be cautious, because the attachment could have been removed later.
// In that case Trello still reports its addition, but removes its 'url' field.
// So we test for that
@ -412,30 +411,22 @@ class TrelloCreator {
}
this.attachments[trelloCardId].push(trelloAttachment);
}
break;
case 'commentCard':
} else if (action.type === 'commentCard') {
const id = action.data.card.id;
if (this.comments[id]) {
this.comments[id].push(action);
} else {
this.comments[id] = [action];
}
break;
case 'createBoard':
} else if (action.type === 'createBoard') {
this.createdAt.board = action.date;
break;
case 'createCard':
} else if (action.type === 'createCard') {
const cardId = action.data.card.id;
this.createdAt.cards[cardId] = action.date;
this.createdBy.cards[cardId] = action.idMemberCreator;
break;
case 'createList':
} else if (action.type === 'createList') {
const listId = action.data.list.id;
this.createdAt.lists[listId] = action.date;
break;
default:
// do nothing
break;
}
});
}

View file

@ -17,8 +17,6 @@
},
"homepage": "https://wekan.io",
"devDependencies": {
"babel-eslint": "4.1.3",
"eslint": "1.7.3",
"eslint-plugin-meteor": "1.7.0"
"eslint": "^2.0.0"
}
}