Enforce a consistent ES6 coding style

Replace the old (and broken) jshint + jscsrc by eslint and configure
it to support some of the ES6 features.

The command `eslint` currently has one error which is a bug that was
discovered by its static analysis and should be fixed (usage of a
dead object).
This commit is contained in:
Maxime Quandalle 2015-09-03 23:12:46 +02:00
parent 039cfe7edf
commit b3851817ec
60 changed files with 1604 additions and 1692 deletions

View file

@ -13,66 +13,66 @@
// // the content when the form is close (optional)
// We can only have one inlined form element opened at a time
currentlyOpenedForm = new ReactiveVar(null);
const currentlyOpenedForm = new ReactiveVar(null);
InlinedForm = BlazeComponent.extendComponent({
template: function() {
template() {
return 'inlinedForm';
},
onCreated: function() {
onCreated() {
this.isOpen = new ReactiveVar(false);
},
onDestroyed: function() {
onDestroyed() {
currentlyOpenedForm.set(null);
},
open: function() {
open() {
// Close currently opened form, if any
EscapeActions.executeUpTo('inlinedForm');
this.isOpen.set(true);
currentlyOpenedForm.set(this);
},
close: function() {
close() {
this.isOpen.set(false);
currentlyOpenedForm.set(null);
},
getValue: function() {
var input = this.find('textarea,input[type=text]');
getValue() {
const input = this.find('textarea,input[type=text]');
return this.isOpen.get() && input && input.value;
},
events: function() {
events() {
return [{
'click .js-close-inlined-form': this.close,
'click .js-open-inlined-form': this.open,
// Pressing Ctrl+Enter should submit the form
'keydown form textarea': function(evt) {
'keydown form textarea'(evt) {
if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) {
this.find('button[type=submit]').click();
}
},
// Close the inlined form when after its submission
submit: function() {
submit() {
if (this.currentData().autoclose !== false) {
Tracker.afterFlush(() => {
this.close();
});
}
}
},
}];
}
},
}).register('inlinedForm');
// Press escape to close the currently opened inlinedForm
EscapeActions.register('inlinedForm',
function() { currentlyOpenedForm.get().close(); },
function() { return currentlyOpenedForm.get() !== null; }, {
noClickEscapeOn: '.js-inlined-form'
() => { currentlyOpenedForm.get().close(); },
() => { return currentlyOpenedForm.get() !== null; }, {
noClickEscapeOn: '.js-inlined-form',
}
);