Commit 24a2cee5 authored by Nick Stenning's avatar Nick Stenning Committed by GitHub

Merge pull request #32 from hypothesis/eslint-style

ESLint - Enforce indentation, quote style and `this` style consistency
parents 697758b7 758d4f72
......@@ -13,11 +13,15 @@
"rules": {
"array-callback-return": "error",
"block-scoped-var": "error",
"comma-dangle": ["error", "always-multiline"],
"consistent-this": ["error", "self"],
"consistent-return": "error",
"curly": "error",
"dot-notation": "error",
"eqeqeq": "error",
"guard-for-in": "error",
"indent": ["error", 2],
"new-cap": "error",
"no-caller": "error",
"no-case-declarations": "error",
"no-console": [
......@@ -26,15 +30,20 @@
],
"no-extra-bind": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-multiple-empty-lines": "error",
"no-self-compare": "error",
"no-throw-literal": "error",
"no-undef-init": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-use-before-define": [
"error",
{"functions": false},
],
"no-useless-concat": "error",
"one-var-declaration-per-line": ["error", "always"],
"quotes": ["error", "single", {"avoidEscape": true}],
"semi": "error",
"strict": ["error", "safe"],
},
......
......@@ -68,8 +68,8 @@ function getEnv(key) {
/** A list of all modules included in vendor bundles. */
var vendorModules = Object.keys(vendorBundles.bundles)
.reduce(function (deps, key) {
return deps.concat(vendorBundles.bundles[key]);
}, []);
return deps.concat(vendorBundles.bundles[key]);
}, []);
// Builds the bundles containing vendor JS code
gulp.task('build-vendor-js', function () {
......@@ -293,7 +293,7 @@ function runKarma(baseConfig, opts, done) {
client: {
mocha: {
grep: taskArgs.grep,
}
},
},
};
......@@ -319,8 +319,7 @@ gulp.task('test-watch-app', function (callback) {
runKarma('./h/static/scripts/karma.config.js', {}, callback);
});
gulp.task('upload-sourcemaps',
['build-app-js'], function () {
gulp.task('upload-sourcemaps', ['build-app-js'], function () {
var uploadToSentry = require('./scripts/gulp/upload-to-sentry');
var opts = {
......@@ -331,5 +330,5 @@ gulp.task('upload-sourcemaps',
var release = getEnv('SENTRY_RELEASE_VERSION');
return gulp.src(['build/scripts/*.js', 'build/scripts/*.map'])
.pipe(uploadToSentry(opts, projects, release));
.pipe(uploadToSentry(opts, projects, release));
});
......@@ -48,7 +48,7 @@ function annotationMapper($rootScope, annotationUI, store) {
function deleteAnnotation(annotation) {
return store.annotation.delete({
id: annotation.id
id: annotation.id,
}).then(function () {
$rootScope.$emit(events.ANNOTATION_DELETED, annotation);
return annotation;
......@@ -59,7 +59,7 @@ function annotationMapper($rootScope, annotationUI, store) {
loadAnnotations: loadAnnotations,
unloadAnnotations: unloadAnnotations,
createAnnotation: createAnnotation,
deleteAnnotation: deleteAnnotation
deleteAnnotation: deleteAnnotation,
};
}
......
......@@ -55,7 +55,7 @@ function AnnotationUISync($rootScope, $window, annotationUI, bridge) {
annotationUI.setShowHighlights(state);
bridge.call('setVisibleHighlights', state);
}
}
},
};
for (var channel in channelListeners) {
......
......@@ -111,16 +111,16 @@ function excludeAnnotations(current, annotations) {
function annotationsReducer(state, action) {
switch (action.type) {
case types.ADD_ANNOTATIONS:
return Object.assign({}, state,
case types.ADD_ANNOTATIONS:
return Object.assign({}, state,
{annotations: state.annotations.concat(action.annotations)});
case types.REMOVE_ANNOTATIONS:
return Object.assign({}, state,
case types.REMOVE_ANNOTATIONS:
return Object.assign({}, state,
{annotations: excludeAnnotations(state.annotations, action.annotations)});
case types.CLEAR_ANNOTATIONS:
return Object.assign({}, state, {annotations: []});
default:
return state;
case types.CLEAR_ANNOTATIONS:
return Object.assign({}, state, {annotations: []});
default:
return state;
}
}
......@@ -129,35 +129,35 @@ function reducer(state, action) {
state = annotationsReducer(state, action);
switch (action.type) {
case types.CLEAR_SELECTION:
return Object.assign({}, state, {
filterQuery: null,
selectedAnnotationMap: null,
});
case types.SELECT_ANNOTATIONS:
return Object.assign({}, state, {selectedAnnotationMap: action.selection});
case types.FOCUS_ANNOTATIONS:
return Object.assign({}, state, {focusedAnnotationMap: action.focused});
case types.SET_HIGHLIGHTS_VISIBLE:
return Object.assign({}, state, {visibleHighlights: action.visible});
case types.SET_FORCE_VISIBLE:
return Object.assign({}, state, {forceVisible: action.forceVisible});
case types.SET_EXPANDED:
return Object.assign({}, state, {expanded: action.expanded});
case types.HIGHLIGHT_ANNOTATIONS:
return Object.assign({}, state, {highlighted: action.highlighted});
case types.SELECT_TAB:
return Object.assign({}, state, {selectedTab: action.tab});
case types.SET_FILTER_QUERY:
return Object.assign({}, state, {
filterQuery: action.query,
forceVisible: {},
expanded: {},
});
case types.SET_SORT_KEY:
return Object.assign({}, state, {sortKey: action.key});
default:
return state;
case types.CLEAR_SELECTION:
return Object.assign({}, state, {
filterQuery: null,
selectedAnnotationMap: null,
});
case types.SELECT_ANNOTATIONS:
return Object.assign({}, state, {selectedAnnotationMap: action.selection});
case types.FOCUS_ANNOTATIONS:
return Object.assign({}, state, {focusedAnnotationMap: action.focused});
case types.SET_HIGHLIGHTS_VISIBLE:
return Object.assign({}, state, {visibleHighlights: action.visible});
case types.SET_FORCE_VISIBLE:
return Object.assign({}, state, {forceVisible: action.forceVisible});
case types.SET_EXPANDED:
return Object.assign({}, state, {expanded: action.expanded});
case types.HIGHLIGHT_ANNOTATIONS:
return Object.assign({}, state, {highlighted: action.highlighted});
case types.SELECT_TAB:
return Object.assign({}, state, {selectedTab: action.tab});
case types.SET_FILTER_QUERY:
return Object.assign({}, state, {
filterQuery: action.query,
forceVisible: {},
expanded: {},
});
case types.SET_SORT_KEY:
return Object.assign({}, state, {sortKey: action.key});
default:
return state;
}
}
......
......@@ -53,7 +53,7 @@ PDFMetadata.prototype.getMetadata = function () {
}
var link = [
{href: fingerprintToURN(app.documentFingerprint)}
{href: fingerprintToURN(app.documentFingerprint)},
];
var url = getPDFURL(app);
......
......@@ -39,7 +39,7 @@ describe('pdf-metadata', function () {
metadata: {
metadata: {
'dc:title': 'fakeTitle',
}
},
},
url: 'http://fake.com',
};
......
......@@ -132,7 +132,7 @@ module.exports = function AppController(
$scope.clearSelection = function () {
if (!annotationUI.getState().selectedTab) {
annotationUI.selectTab(uiConstants.TAB_ANNOTATIONS);
annotationUI.selectTab(uiConstants.TAB_ANNOTATIONS);
}
annotationUI.clearSelectedAnnotations();
};
......
......@@ -52,24 +52,24 @@ function configureRoutes($routeProvider) {
controller: 'AnnotationViewerController',
template: VIEWER_TEMPLATE,
reloadOnSearch: false,
resolve: resolve
resolve: resolve,
});
$routeProvider.when('/viewer',
{
controller: 'WidgetController',
template: VIEWER_TEMPLATE,
reloadOnSearch: false,
resolve: resolve
resolve: resolve,
});
$routeProvider.when('/stream',
{
controller: 'StreamController',
template: VIEWER_TEMPLATE,
reloadOnSearch: false,
resolve: resolve
resolve: resolve,
});
return $routeProvider.otherwise({
redirectTo: '/viewer'
redirectTo: '/viewer',
});
}
......@@ -115,7 +115,7 @@ module.exports = angular.module('h', [
['ui.bootstrap', require('./vendor/ui-bootstrap-custom-tpls-0.13.4')][0],
// Local addons
'ngRaven'
'ngRaven',
])
.controller('AppController', require('./app-controller'))
......
......@@ -34,7 +34,7 @@ function fetchToken($http, session, settings) {
skipAuthorization: true,
transformRequest: function (data) {
return queryString.stringify(data);
}
},
};
return $http.get(tokenUrl, config).then(function (response) {
return response.data;
......
......@@ -58,9 +58,9 @@ module.exports = function () {
this.copyToClipboardMessage = 'Select and copy to share.';
} finally {
setTimeout(function () {
this.copyToClipboardMessage = null;
$scope.$digest();
}.bind(this),
this.copyToClipboardMessage = null;
$scope.$digest();
}.bind(this),
1000);
}
}.bind(this);
......@@ -71,6 +71,6 @@ module.exports = function () {
isPrivate: '<',
isOpen: '<',
onClose: '&',
}
},
};
};
/* jshint node: true */
/* eslint consistent-this: ["error", "vm"] */
'use strict';
var annotationMetadata = require('../annotation-metadata');
......@@ -441,7 +442,7 @@ function AnnotationController(
drafts.update(vm.annotation, {
tags: vm.state().tags,
text: vm.state().text,
isPrivate: privacy === 'private'
isPrivate: privacy === 'private',
});
};
......@@ -544,7 +545,7 @@ function annotation() {
showDocumentInfo: '<',
onReplyCountClick: '&',
replyCount: '<',
isCollapsed: '<'
isCollapsed: '<',
},
template: require('../../../templates/client/annotation.html'),
};
......@@ -560,5 +561,5 @@ module.exports = {
// These are meant to be the public API of this module.
directive: annotation,
Controller: AnnotationController
Controller: AnnotationController,
};
......@@ -35,7 +35,7 @@ function groupList( $window, groups, settings) {
},
restrict: 'E',
scope: {
auth: '<'
auth: '<',
},
template: require('../../../templates/client/group_list.html'),
};
......@@ -43,5 +43,5 @@ function groupList( $window, groups, settings) {
module.exports = {
directive: groupList,
Controller: GroupListController
Controller: GroupListController,
};
......@@ -18,6 +18,6 @@ module.exports = function() {
restrict: 'A',
link: function($scope, $element) {
$element[0].focus();
}
},
};
};
......@@ -35,6 +35,6 @@ module.exports = function () {
scope: {
auth: '<',
onClose: '&',
}
},
};
};
......@@ -19,7 +19,8 @@ function Controller($scope, $timeout, flash, session, formRespond, settings) {
}
function failure(form, response) {
var errors, reason;
var errors;
var reason;
try {
errors = response.data.errors;
......
......@@ -116,7 +116,7 @@ module.exports = function($sanitize) {
var shortcuts = {
66: scope.insertBold,
73: scope.insertItalic,
75: scope.insertLink
75: scope.insertLink,
};
var shortcut = shortcuts[e.keyCode];
......
......@@ -34,7 +34,7 @@ module.exports = function () {
isShared: '<',
onCancel: '&',
onSave: '&',
onSetPrivacy: '&'
onSetPrivacy: '&',
},
template: require('../../../templates/client/publish_annotation_btn.html'),
};
......
......@@ -4,19 +4,19 @@ var VIA_PREFIX = 'https://via.hypothes.is/';
// @ngInject
function ShareDialogController($scope, $element, crossframe) {
var ctrl = this;
var self = this;
function updateViaLink(frames) {
if (!frames.length) {
ctrl.viaPageLink = '';
self.viaPageLink = '';
return;
}
// Check to see if we are on a via page. If so, we just return the URI.
if (frames[0].uri.indexOf(VIA_PREFIX) === 0) {
ctrl.viaPageLink = frames[0].uri;
self.viaPageLink = frames[0].uri;
} else {
ctrl.viaPageLink = VIA_PREFIX + frames[0].uri;
self.viaPageLink = VIA_PREFIX + frames[0].uri;
}
}
......
......@@ -2,10 +2,7 @@
// @ngInject
function SidebarTutorialController(session) {
/*jshint validthis:true */
var vm = this;
vm.showSidebarTutorial = function () {
this.showSidebarTutorial = function () {
if (session.state.preferences) {
if (session.state.preferences.show_sidebar_tutorial) {
return true;
......@@ -14,7 +11,7 @@ function SidebarTutorialController(session) {
return false;
};
vm.dismiss = function () {
this.dismiss = function () {
session.dismiss_sidebar_tutorial();
};
}
......@@ -36,5 +33,5 @@ module.exports = {
template: require('../../../templates/client/sidebar_tutorial.html'),
};
},
Controller: SidebarTutorialController
Controller: SidebarTutorialController,
};
......@@ -7,6 +7,6 @@ module.exports = ['$animate', function($animate) {
$animate.enabled(false, elem);
},
restrict: 'C',
template: '<span><span></span></span>'
template: '<span><span></span></span>',
};
}];
......@@ -25,7 +25,7 @@ describe('annotationShareDialog', function () {
describe('The annotation share dialog', function () {
it('has class is-open set when it is open', function () {
element = util.createDirective(document, 'annotationShareDialog', {
isOpen: true
isOpen: true,
});
assert.isOk(element.find('.annotation-share-dialog').hasClass('is-open'));
......@@ -33,7 +33,7 @@ describe('annotationShareDialog', function () {
it('does not have class is-open set when it is not open', function () {
element = util.createDirective(document, 'annotationShareDialog', {
isOpen: false
isOpen: false,
});
assert.isNotOk(element.find('.annotation-share-dialog').hasClass('is-open'));
......@@ -51,7 +51,7 @@ describe('annotationShareDialog', function () {
group: {
name: 'Public',
type: 'public',
public: true
public: true,
},
uri: 'fakeURI',
isPrivate: false,
......@@ -101,9 +101,9 @@ describe('annotationShareDialog', function () {
it('is available to a group', function () {
element = util.createDirective(document, 'annotationShareDialog', {
group: {
public: false
public: false,
},
isPrivate: false
isPrivate: false,
});
var actualMessage = element.find('.annotation-share-dialog-msg').text();
......@@ -116,7 +116,7 @@ describe('annotationShareDialog', function () {
it('is private', function () {
element = util.createDirective(document, 'annotationShareDialog', {
isPrivate: true
isPrivate: true,
});
var actualMessage = element.find('.annotation-share-dialog-msg').text();
......
......@@ -32,7 +32,7 @@ function annotationDirective() {
domainAndTitle: function (annot) { // eslint-disable-line no-unused-vars
return fakeDocumentMeta;
},
}
},
});
return annotation.directive;
......@@ -125,10 +125,10 @@ describe('annotation', function() {
read: ['acct:bill@localhost'],
update: ['acct:bill@localhost'],
destroy: ['acct:bill@localhost'],
admin: ['acct:bill@localhost']
}
admin: ['acct:bill@localhost'],
},
}),
deleteAnnotation: sandbox.stub()
deleteAnnotation: sandbox.stub(),
};
var fakeAnnotationUI = {};
......@@ -136,7 +136,7 @@ describe('annotation', function() {
fakeDrafts = {
update: sandbox.stub(),
remove: sandbox.stub(),
get: sandbox.stub()
get: sandbox.stub(),
};
var fakeFeatures = {
......@@ -152,21 +152,21 @@ describe('annotation', function() {
isPrivate: sandbox.stub().returns(false),
permits: sandbox.stub().returns(true),
shared: sandbox.stub().returns({
read: ['everybody']
read: ['everybody'],
}),
'private': sandbox.stub().returns({
read: ['justme']
read: ['justme'],
}),
'default': sandbox.stub().returns({
read: ['default']
read: ['default'],
}),
setDefault: sandbox.stub()
setDefault: sandbox.stub(),
};
fakeSession = {
state: {
userid: 'acct:bill@localhost'
}
userid: 'acct:bill@localhost',
},
};
var fakeSettings = {
......@@ -177,7 +177,7 @@ describe('annotation', function() {
focused: function() {
return {};
},
get: function() {}
get: function() {},
};
fakeStore = {
......@@ -270,8 +270,8 @@ describe('annotation', function() {
read: ['foo'],
update: ['bar'],
'delete': ['gar'],
admin: ['har']
}
admin: ['har'],
},
};
var originalPermissions = JSON.parse(JSON.stringify(
annotation.permissions));
......@@ -454,7 +454,7 @@ describe('annotation', function() {
createDirective(annotation);
$scope.$digest();
assert.deepEqual(annotation.permissions, {
read: ['justme']
read: ['justme'],
});
});
});
......@@ -468,7 +468,7 @@ describe('annotation', function() {
read: ['acct:joe@localhost'],
update: ['acct:joe@localhost'],
destroy: ['acct:joe@localhost'],
admin: ['acct:joe@localhost']
admin: ['acct:joe@localhost'],
};
});
......@@ -476,7 +476,7 @@ describe('annotation', function() {
var controller = createDirective(annotation).controller;
var reply = sinon.match({
references: [annotation.id],
uri: annotation.uri
uri: annotation.uri,
});
controller.reply();
assert.calledWith(fakeAnnotationMapper.createAnnotation, reply);
......@@ -488,7 +488,7 @@ describe('annotation', function() {
var reply = sinon.match({
references: [annotation.id],
permissions: perms,
uri: annotation.uri
uri: annotation.uri,
});
fakePermissions.isShared.returns(true);
fakePermissions.shared.returns(perms);
......@@ -497,14 +497,14 @@ describe('annotation', function() {
});
it('makes the reply private if the parent is private', function() {
var controller = createDirective(annotation).controller;
fakePermissions.isPrivate.returns(true);
var perms = {read: ['onlyme']};
fakePermissions.private.returns(perms);
var reply = sinon.match({permissions: perms});
controller.reply();
assert.calledWith(fakeAnnotationMapper.createAnnotation, reply);
}
var controller = createDirective(annotation).controller;
fakePermissions.isPrivate.returns(true);
var perms = {read: ['onlyme']};
fakePermissions.private.returns(perms);
var reply = sinon.match({permissions: perms});
controller.reply();
assert.calledWith(fakeAnnotationMapper.createAnnotation, reply);
}
);
it('sets the reply\'s group to be the same as its parent\'s', function() {
......@@ -582,10 +582,10 @@ describe('annotation', function() {
{
selector: [
{
type: 'TextQuoteSelector'
}
]
}
type: 'TextQuoteSelector',
},
],
},
];
var controller = createDirective(annotation).controller;
......@@ -632,7 +632,7 @@ describe('annotation', function() {
var controller = createDirective().controller;
sandbox.stub($window, 'confirm').returns(true);
fakeAnnotationMapper.deleteAnnotation.returns($q.reject({
status: 0
status: 0,
}));
controller.delete().then(function() {
assert.calledWith(fakeFlash.error,
......@@ -649,7 +649,7 @@ describe('annotation', function() {
fakeAnnotationMapper.deleteAnnotation.returns($q.reject({
status: 500,
statusText: 'Server Error',
data: {}
data: {},
}));
controller.delete().then(function() {
assert.calledWith(fakeFlash.error,
......@@ -708,7 +708,7 @@ describe('annotation', function() {
it('flashes a generic error if the server can\'t be reached', function() {
var controller = createController();
fakeStore.annotation.create = sinon.stub().returns(Promise.reject({
status: 0
status: 0,
}));
return controller.save().then(function() {
assert.calledWith(fakeFlash.error,
......@@ -721,7 +721,7 @@ describe('annotation', function() {
fakeStore.annotation.create = sinon.stub().returns(Promise.reject({
status: 500,
statusText: 'Server Error',
data: {}
data: {},
}));
return controller.save().then(function() {
assert.calledWith(fakeFlash.error,
......@@ -782,7 +782,7 @@ describe('annotation', function() {
it('flashes a generic error if the server cannot be reached', function () {
var controller = createController();
fakeStore.annotation.update = sinon.stub().returns(Promise.reject({
status: -1
status: -1,
}));
return controller.save().then(function() {
assert.calledWith(fakeFlash.error,
......@@ -795,7 +795,7 @@ describe('annotation', function() {
fakeStore.annotation.update = sinon.stub().returns(Promise.reject({
status: 500,
statusText: 'Server Error',
data: {}
data: {},
}));
return controller.save().then(function() {
assert.calledWith(fakeFlash.error,
......@@ -815,7 +815,7 @@ describe('annotation', function() {
it('starts editing immediately if there is a draft', function() {
fakeDrafts.get.returns({
tags: ['unsaved'],
text: 'unsaved-text'
text: 'unsaved-text',
});
var controller = createDirective().controller;
assert.isTrue(controller.editing());
......@@ -824,7 +824,7 @@ describe('annotation', function() {
it('uses the text and tags from the draft if present', function() {
fakeDrafts.get.returns({
tags: ['unsaved-tag'],
text: 'unsaved-text'
text: 'unsaved-text',
});
var controller = createDirective().controller;
assert.deepEqual(controller.state().tags, ['unsaved-tag']);
......@@ -947,7 +947,7 @@ describe('annotation', function() {
it('displays links to tags on the stream', function () {
var directive = createDirective({
id: '1234',
tags: ['atag']
tags: ['atag'],
});
var links = [].slice.apply(directive.element[0].querySelectorAll('a'));
var tagLinks = links.filter(function (link) {
......@@ -964,7 +964,7 @@ describe('annotation', function() {
var annotation = Object.assign({}, fixtures.defaultAnnotation(), {
links: {
html: 'https://test.hypothes.is/a/deadbeef',
incontext: 'https://hpt.is/deadbeef'
incontext: 'https://hpt.is/deadbeef',
},
});
var controller = createDirective(annotation).controller;
......@@ -985,7 +985,7 @@ describe('annotation', function() {
var annotation = Object.assign({}, fixtures.defaultAnnotation(), {
links: {
html: 'https://test.hypothes.is/a/deadbeef',
incontext: 'https://hpt.is/deadbeef'
incontext: 'https://hpt.is/deadbeef',
},
});
var controller = createDirective(annotation).controller;
......
......@@ -57,8 +57,8 @@ describe('annotationThread', function () {
id: '1',
annotation: {id: '1'},
visible: false,
children: []
}
children: [],
},
});
var pageObject = new PageObject(element);
assert.equal(pageObject.annotations().length, 1);
......@@ -78,7 +78,7 @@ describe('annotationThread', function () {
visible: true,
}],
collapsed: false,
}
},
});
var pageObject = new PageObject(element);
assert.isFalse(pageObject.isHidden(pageObject.replyList()));
......@@ -97,7 +97,7 @@ describe('annotationThread', function () {
visible: true,
}],
collapsed: true,
}
},
});
var pageObject = new PageObject(element);
assert.isTrue(pageObject.isHidden(pageObject.replyList()));
......@@ -121,7 +121,7 @@ describe('annotationThread', function () {
visible: true,
}],
collapsed: false,
}
},
});
var pageObject = new PageObject(element);
assert.equal(pageObject.visibleReplies().length, 1);
......@@ -140,7 +140,7 @@ describe('annotationThread', function () {
onChangeCollapsed: {
args: ['id', 'collapsed'],
callback: onChangeCollapsed,
}
},
});
element.ctrl.toggleCollapsed();
assert.calledWith(onChangeCollapsed, '123', false);
......
......@@ -30,7 +30,7 @@ describe('excerpt directive', function () {
beforeEach(function () {
function FakeOverflowMonitor(ctrl) {
fakeOverflowMonitor = this;
fakeOverflowMonitor = this; // eslint-disable-line consistent-this
this.ctrl = ctrl;
this.check = sinon.stub();
......@@ -219,7 +219,7 @@ describe('excerpt directive', function () {
onCollapsibleChanged: {
args: ['collapsible'],
callback: callback,
}
},
}, '<span></span>');
fakeOverflowMonitor.ctrl.onOverflowChanged(true);
assert.calledWith(callback, true);
......
......@@ -35,12 +35,12 @@ describe('groupList', function () {
$window = _$window_;
groups = [{
id: 'public',
public: true
id: 'public',
public: true,
},{
id: 'h-devs',
name: 'Hypothesis Developers',
url: GROUP_LINK
id: 'h-devs',
name: 'Hypothesis Developers',
url: GROUP_LINK,
}];
fakeGroups = {
......
......@@ -11,7 +11,7 @@ var fakeLocalStorage = {
},
getItem: function (key) {
return fakeStorage[key];
}
},
};
describe('publishAnnotationBtn', function () {
......@@ -32,16 +32,16 @@ describe('publishAnnotationBtn', function () {
// create a new instance of the directive with default
// attributes
element = util.createDirective(document, 'publishAnnotationBtn', {
group: {
name: 'Public',
type: 'public'
},
canPost: true,
isShared: false,
onSave: function () {},
onSetPrivacy: function () {},
onCancel: function () {}
});
group: {
name: 'Public',
type: 'public',
},
canPost: true,
isShared: false,
onSave: function () {},
onSetPrivacy: function () {},
onCancel: function () {},
});
});
it('should display "Post to Only Me"', function () {
......@@ -54,9 +54,9 @@ describe('publishAnnotationBtn', function () {
element.link({
group: {
name: 'Research Lab',
type: 'group'
type: 'group',
},
isShared: true
isShared: true,
});
var buttons = element.find('button');
assert.equal(buttons[0].innerHTML, 'Post to Research Lab');
......@@ -65,7 +65,7 @@ describe('publishAnnotationBtn', function () {
it('should save when "Post..." is clicked', function () {
var savedSpy = sinon.spy();
element.link({
onSave: savedSpy
onSave: savedSpy,
});
assert.ok(!savedSpy.called);
angular.element(element.find('button')[0]).click();
......@@ -77,7 +77,7 @@ describe('publishAnnotationBtn', function () {
element.link({
// for existing annotations, the privacy should not be changed
// unless the user makes a choice from the list
onSetPrivacy: privacyChangedSpy
onSetPrivacy: privacyChangedSpy,
});
assert.ok(!privacyChangedSpy.called);
......@@ -91,14 +91,14 @@ describe('publishAnnotationBtn', function () {
it('should disable post buttons when posting is not possible', function () {
element.link({
canPost: false
canPost: false,
});
var disabledBtns = element.find('button[disabled]');
assert.equal(disabledBtns.length, 1);
// check that buttons are enabled when posting is possible
element.link({
canPost: true
canPost: true,
});
disabledBtns = element.find('button[disabled]');
assert.equal(disabledBtns.length, 0);
......@@ -107,7 +107,7 @@ describe('publishAnnotationBtn', function () {
it('should revert changes when cancel is clicked', function () {
var cancelSpy = sinon.spy();
element.link({
onCancel: cancelSpy
onCancel: cancelSpy,
});
var cancelBtn = element.find('.publish-annotation-cancel-btn');
assert.equal(cancelBtn.length, 1);
......
......@@ -18,9 +18,9 @@ describe('searchStatusBar', function () {
it('should display the filter count', function () {
var elem = util.createDirective(document, 'searchStatusBar', {
filterActive: true,
filterMatchCount: 5
filterMatchCount: 5,
});
assert.include(elem[0].textContent, "5 search results");
assert.include(elem[0].textContent, '5 search results');
});
});
......
......@@ -27,10 +27,10 @@ describe('selectionTabs', function () {
var tabs = elem[0].querySelectorAll('a');
assert.include(tabs[0].textContent, "Annotations");
assert.include(tabs[1].textContent, "Notes");
assert.include(tabs[0].textContent, "123");
assert.include(tabs[1].textContent, "456");
assert.include(tabs[0].textContent, 'Annotations');
assert.include(tabs[1].textContent, 'Notes');
assert.include(tabs[0].textContent, '123');
assert.include(tabs[1].textContent, '456');
});
it('should display annotations tab as selected', function () {
......
......@@ -9,9 +9,9 @@ describe('SidebarTutorialController', function () {
var session = {
state: {
preferences: {
show_sidebar_tutorial: true
}
}
show_sidebar_tutorial: true,
},
},
};
var controller = new Controller(session);
......@@ -24,9 +24,9 @@ describe('SidebarTutorialController', function () {
var session = {
state: {
preferences: {
show_sidebar_tutorial: false
}
}
show_sidebar_tutorial: false,
},
},
};
var controller = new Controller(session);
......
......@@ -22,7 +22,7 @@ describe('sortDropdown', function () {
onChangeSortKey: {
args: ['sortKey'],
callback: changeSpy,
}
},
});
var links = elem.find('li');
angular.element(links[0]).click();
......
......@@ -25,7 +25,7 @@ describe('tagEditor', function () {
it('converts tags to the form expected by ng-tags-input', function () {
var element = util.createDirective(document, 'tag-editor', {
tags: ['foo', 'bar']
tags: ['foo', 'bar'],
});
assert.deepEqual(element.ctrl.tagList, [{text: 'foo'}, {text: 'bar'}]);
});
......
......@@ -23,7 +23,7 @@ describe('windowScroll', function () {
html = {};
view = {
addEventListener: sinon.spy(),
removeEventListener: sinon.spy()
removeEventListener: sinon.spy(),
};
doc = {documentElement: html, defaultView: view};
......
......@@ -4,25 +4,25 @@ var dateUtil = require('../date-util');
// @ngInject
function TimestampController($scope, time) {
var vm = this;
// A fuzzy, relative (eg. '6 days ago') format of the timestamp.
vm.relativeTimestamp = null;
this.relativeTimestamp = null;
// A formatted version of the timestamp (eg. 'Tue 22nd Dec 2015, 16:00')
vm.absoluteTimestamp = '';
this.absoluteTimestamp = '';
var cancelTimestampRefresh;
var self = this;
function updateTimestamp() {
vm.relativeTimestamp = time.toFuzzyString(vm.timestamp);
vm.absoluteTimestamp = dateUtil.format(new Date(vm.timestamp));
self.relativeTimestamp = time.toFuzzyString(self.timestamp);
self.absoluteTimestamp = dateUtil.format(new Date(self.timestamp));
if (vm.timestamp) {
if (self.timestamp) {
if (cancelTimestampRefresh) {
cancelTimestampRefresh();
}
cancelTimestampRefresh = time.decayingInterval(vm.timestamp, function () {
cancelTimestampRefresh = time.decayingInterval(self.timestamp, function () {
updateTimestamp();
$scope.$digest();
});
......
......@@ -25,6 +25,6 @@ module.exports = function () {
scope.$on('$destroy', function () {
view.removeEventListener('scroll', onScroll);
});
}
},
};
};
......@@ -74,7 +74,7 @@ function DraftStore() {
model: model,
isPrivate: changes.isPrivate,
tags: changes.tags,
text: changes.text
text: changes.text,
};
this.remove(model);
this._drafts.push(newDraft);
......
......@@ -40,7 +40,7 @@ function features($log, session) {
}
return {
flagEnabled: flagEnabled
flagEnabled: flagEnabled,
};
}
......
'use strict';
/* eslint curly: "off" */
/* eslint-disable */
/** This software is released under the MIT license:
......
......@@ -12,7 +12,7 @@ module.exports = function(config) {
'browserify',
'mocha',
'chai',
'sinon'
'sinon',
],
// list of files / patterns to load in the browser
......@@ -35,7 +35,7 @@ module.exports = function(config) {
{ pattern: '**/test/*-test.js', watched: false, included: true, served: true },
// Integration tests
{ pattern: '**/integration/*-test.js', watched: false, included: true, served: true }
{ pattern: '**/integration/*-test.js', watched: false, included: true, served: true },
],
// list of files to exclude
......@@ -60,7 +60,7 @@ module.exports = function(config) {
bundle
.transform('coffeeify')
.plugin('proxyquire-universal');
}
},
},
mochaReporter: {
......
......@@ -24,7 +24,7 @@ function sessionActions(options) {
dismiss_sidebar_tutorial: {
method: 'POST',
params: { path: 'dismiss_sidebar_tutorial' },
}
},
};
Object.keys(actions).forEach(function (action) {
......@@ -54,7 +54,7 @@ function session($http, $resource, $rootScope, flash, raven, settings) {
var actions = sessionActions({
headers: headers,
transformResponse: process,
withCredentials: true
withCredentials: true,
});
var endpoint = new URL('app/:path', settings.serviceUrl).href;
var resource = $resource(endpoint, {}, actions);
......
......@@ -48,14 +48,14 @@ function Streamer($rootScope, annotationMapper, groups, session, settings) {
}
switch (action) {
case 'create':
case 'update':
case 'past':
annotationMapper.loadAnnotations(annotations);
break;
case 'delete':
annotationMapper.unloadAnnotations(annotations);
break;
case 'create':
case 'update':
case 'past':
annotationMapper.loadAnnotations(annotations);
break;
case 'delete':
annotationMapper.unloadAnnotations(annotations);
break;
}
}
......
......@@ -7,7 +7,7 @@ function defaultAnnotation() {
return {
id: 'deadbeef',
document: {
title: 'A special document'
title: 'A special document',
},
target: [{source: 'source', 'selector': []}],
uri: 'http://example.com',
......@@ -26,7 +26,7 @@ function newAnnotation() {
target: ['foo', 'bar'],
references: [],
text: 'Annotation text',
tags: ['tag_1', 'tag_2']
tags: ['tag_1', 'tag_2'],
};
}
......@@ -38,7 +38,7 @@ function newReply() {
target: ['foo', 'bar'],
references: ['parent-id'],
text: 'Annotation text',
tags: ['tag_1', 'tag_2']
tags: ['tag_1', 'tag_2'],
};
}
......@@ -60,7 +60,7 @@ function newEmptyAnnotation() {
function newHighlight() {
return {
id: undefined,
$highlight: true
$highlight: true,
};
}
......@@ -74,7 +74,7 @@ function oldAnnotation() {
target: ['foo', 'bar'],
references: [],
text: 'This is my annotation',
tags: ['tag_1', 'tag_2']
tags: ['tag_1', 'tag_2'],
};
}
......@@ -88,7 +88,7 @@ function oldHighlight() {
target: ['foo', 'bar'],
references: [],
text: '',
tags: []
tags: [],
};
}
......@@ -101,7 +101,7 @@ function oldPageNote() {
target: [],
references: [],
text: '',
tags: []
tags: [],
};
}
......@@ -114,7 +114,7 @@ function oldReply() {
target: ['foo'],
references: ['parent_annotation_id'],
text: '',
tags: []
tags: [],
};
}
......
......@@ -86,7 +86,7 @@ describe('annotationMapper', function() {
assert.called($rootScope.$emit);
assert.calledWith($rootScope.$emit, events.ANNOTATION_UPDATED, {
id: 1,
url: 'http://example.com'
url: 'http://example.com',
});
});
......@@ -118,7 +118,7 @@ describe('annotationMapper', function() {
annotationMapper.unloadAnnotations(annotations);
assert.calledWith($rootScope.$emit, events.ANNOTATIONS_UNLOADED, [{
id: 1,
url: 'http://example.com'
url: 'http://example.com',
}]);
});
});
......
......@@ -12,7 +12,7 @@ describe('annotation-metadata', function () {
it('returns the hostname from model.uri as the domain', function() {
var model = {
document: {},
uri: 'http://example.com/'
uri: 'http://example.com/',
};
assert.equal(documentMetadata(model).domain, 'example.com');
......@@ -22,7 +22,7 @@ describe('annotation-metadata', function () {
it('uses model.uri as the uri', function() {
var model = {
document: {},
uri: 'http://example.com/'
uri: 'http://example.com/',
};
assert.equal(
......@@ -35,7 +35,7 @@ describe('annotation-metadata', function () {
var model = {
uri: 'http://example.com/',
document: {
title: ['My Document', 'My Other Document']
title: ['My Document', 'My Other Document'],
},
};
......@@ -93,7 +93,7 @@ describe('annotation-metadata', function () {
var model = {
links: {
incontext: 'https://example.com',
}
},
};
assert.equal(domainAndTitle(model).titleLink, 'https://example.com');
......@@ -197,8 +197,8 @@ describe('annotation-metadata', function () {
selector: [{
type: 'TextPositionSelector',
start: 100,
}]
}]
}],
}],
}), 100);
});
......@@ -206,7 +206,7 @@ describe('annotation-metadata', function () {
assert.equal(annotationMetadata.location({
target: [{
selector: undefined,
}]
}],
}), Number.POSITIVE_INFINITY);
});
});
......@@ -214,23 +214,23 @@ describe('annotation-metadata', function () {
describe('.isPageNote', function () {
it ('returns true for an annotation with an empty target', function () {
assert.isTrue(annotationMetadata.isPageNote({
target: []
target: [],
}));
});
it ('returns true for an annotation without selectors', function () {
assert.isTrue(annotationMetadata.isPageNote({
target: [{selector: undefined}]
target: [{selector: undefined}],
}));
});
it ('returns true for an annotation without a target', function () {
assert.isTrue(annotationMetadata.isPageNote({
target: undefined
target: undefined,
}));
});
it ('returns false for an annotation which is a reply', function () {
assert.isFalse(annotationMetadata.isPageNote({
target: [],
references: ['xyz']
references: ['xyz'],
}));
});
});
......@@ -238,7 +238,7 @@ describe('annotation-metadata', function () {
describe ('.isAnnotation', function () {
it ('returns true if an annotation is a top level annotation', function () {
assert.isTrue(annotationMetadata.isAnnotation({
target: [{selector: []}]
target: [{selector: []}],
}));
});
it ('returns false if an annotation has no target', function () {
......
......@@ -36,8 +36,8 @@ describe('AnnotationUISync', function () {
links: [
{ window: PARENT_WINDOW, channel: createChannel() },
{ window: 'ANOTHER_WINDOW', channel: createChannel() },
{ window: 'THIRD_WINDOW', channel: createChannel() }
]
{ window: 'THIRD_WINDOW', channel: createChannel() },
],
};
annotationUI = annotationUIFactory($rootScope, {});
......
......@@ -120,7 +120,7 @@ describe('annotationUI', function () {
it('adds the passed annotations to the focusedAnnotationMap', function () {
annotationUI.focusAnnotations([1, 2, 3]);
assert.deepEqual(annotationUI.getState().focusedAnnotationMap, {
1: true, 2: true, 3: true
1: true, 2: true, 3: true,
});
});
......@@ -128,7 +128,7 @@ describe('annotationUI', function () {
annotationUI.focusAnnotations([1]);
annotationUI.focusAnnotations([2, 3]);
assert.deepEqual(annotationUI.getState().focusedAnnotationMap, {
2: true, 3: true
2: true, 3: true,
});
});
......@@ -170,7 +170,7 @@ describe('annotationUI', function () {
it('adds the passed annotations to the selectedAnnotationMap', function () {
annotationUI.selectAnnotations([1, 2, 3]);
assert.deepEqual(annotationUI.getState().selectedAnnotationMap, {
1: true, 2: true, 3: true
1: true, 2: true, 3: true,
});
});
......@@ -178,7 +178,7 @@ describe('annotationUI', function () {
annotationUI.selectAnnotations([1]);
annotationUI.selectAnnotations([2, 3]);
assert.deepEqual(annotationUI.getState().selectedAnnotationMap, {
2: true, 3: true
2: true, 3: true,
});
});
......@@ -194,7 +194,7 @@ describe('annotationUI', function () {
annotationUI.selectAnnotations([1, 2]);
annotationUI.toggleSelectedAnnotations([3, 4]);
assert.deepEqual(annotationUI.getState().selectedAnnotationMap, {
1: true, 2: true, 3: true, 4: true
1: true, 2: true, 3: true, 4: true,
});
});
......@@ -216,7 +216,7 @@ describe('annotationUI', function () {
annotationUI.selectAnnotations([1, 2, 3]);
annotationUI.removeSelectedAnnotation(2);
assert.deepEqual(annotationUI.getState().selectedAnnotationMap, {
1: true, 3: true
1: true, 3: true,
});
});
......
......@@ -16,7 +16,7 @@ function FakeStore(annots) {
});
}
return Promise.resolve(result);
}
},
};
this.search = function (query) {
......@@ -59,7 +59,7 @@ describe('AnnotationViewerController', function () {
annotationUI: {
setCollapsed: sinon.stub(),
highlightAnnotations: sinon.stub(),
subscribe: sinon.stub()
subscribe: sinon.stub(),
},
rootThread: {thread: sinon.stub()},
streamer: { setConfig: function () {} },
......@@ -69,12 +69,12 @@ describe('AnnotationViewerController', function () {
return {
addClause: function () {
return {
addClause: function () {}
addClause: function () {},
};
}
},
};
},
getFilter: function () {}
getFilter: function () {},
},
annotationMapper: {
loadAnnotations: sinon.spy(),
......
......@@ -53,7 +53,7 @@ describe('AppController', function () {
fakeAnnotationUI = {
tool: 'comment',
clearSelectedAnnotations: sandbox.spy()
clearSelectedAnnotations: sandbox.spy(),
};
fakeAuth = {
......@@ -66,16 +66,16 @@ describe('AppController', function () {
all: sandbox.stub().returns([]),
discard: sandbox.spy(),
count: sandbox.stub().returns(0),
unsaved: sandbox.stub().returns([])
unsaved: sandbox.stub().returns([]),
};
fakeFeatures = {
fetch: sandbox.spy(),
flagEnabled: sandbox.stub().returns(false)
flagEnabled: sandbox.stub().returns(false),
};
fakeLocation = {
search: sandbox.stub().returns({})
search: sandbox.stub().returns({}),
};
fakeParams = {id: 'test'};
......@@ -90,7 +90,7 @@ describe('AppController', function () {
fakeWindow = {
top: {},
confirm: sandbox.stub()
confirm: sandbox.stub(),
};
fakeSettings = {
......@@ -237,7 +237,7 @@ describe('AppController', function () {
it('emits "annotationDeleted" for each unsaved draft annotation', function () {
fakeDrafts.unsaved = sandbox.stub().returns(
["draftOne", "draftTwo", "draftThree"]
['draftOne', 'draftTwo', 'draftThree']
);
createController();
$rootScope.$emit = sandbox.stub();
......@@ -246,11 +246,11 @@ describe('AppController', function () {
assert($rootScope.$emit.calledThrice);
assert.deepEqual(
$rootScope.$emit.firstCall.args, ["annotationDeleted", "draftOne"]);
$rootScope.$emit.firstCall.args, ['annotationDeleted', 'draftOne']);
assert.deepEqual(
$rootScope.$emit.secondCall.args, ["annotationDeleted", "draftTwo"]);
$rootScope.$emit.secondCall.args, ['annotationDeleted', 'draftTwo']);
assert.deepEqual(
$rootScope.$emit.thirdCall.args, ["annotationDeleted", "draftThree"]);
$rootScope.$emit.thirdCall.args, ['annotationDeleted', 'draftThree']);
});
it('discards draft annotations', function () {
......
......@@ -81,7 +81,7 @@ describe('build-thread', function () {
references: ['1'],
},{
id: '3',
references: ['1','2']
references: ['1','2'],
}];
var thread = createThread(NESTED_FIXTURE);
......@@ -92,8 +92,8 @@ describe('build-thread', function () {
children: [{
annotation: NESTED_FIXTURE[2],
children: [],
}]
}]
}],
}],
}]);
});
......@@ -210,7 +210,7 @@ describe('build-thread', function () {
filterFn: function (annot) {
return annot.text.match(/first/);
},
forceVisible: ['3']
forceVisible: ['3'],
});
assert.isFalse(thread.children[0].collapsed);
});
......@@ -252,14 +252,14 @@ describe('build-thread', function () {
context('when there is a selection', function () {
it('shows only selected annotations', function () {
var thread = createThread(SIMPLE_FIXTURE, {
selected: ['1']
selected: ['1'],
});
assert.deepEqual(thread, [{
annotation: SIMPLE_FIXTURE[0],
children: [{
annotation: SIMPLE_FIXTURE[2],
children: [],
}]
}],
}]);
});
});
......@@ -284,7 +284,7 @@ describe('build-thread', function () {
assert.deepEqual(thread, [{
annotation: fixture[1],
children: []
children: [],
}]);
});
});
......@@ -322,14 +322,14 @@ describe('build-thread', function () {
},{
id: '3',
references: ['1'],
created: 100
created: 100,
},{
id: '2',
references: ['1'],
created: 50,
}];
var thread = createThread(fixture, {
sortCompareFn: function (a, b) { return a.id < b.id; }
sortCompareFn: function (a, b) { return a.id < b.id; },
});
assert.deepEqual(annots(thread[0].children),
[fixture[2], fixture[1]]);
......@@ -349,7 +349,7 @@ describe('build-thread', function () {
},{
annotation: SIMPLE_FIXTURE[1],
children: [],
replyCount: 0
replyCount: 0,
}]);
});
});
......
......@@ -11,8 +11,8 @@ var sessionWithThreeGroups = function() {
{name: 'Group 1', id: 'id1'},
{name: 'Group 2', id: 'id2'},
{name: 'Group 3', id: 'id3'},
]
}
],
},
};
};
......@@ -22,7 +22,7 @@ describe('groups', function() {
var fakeRootScope;
var fakeHttp;
var fakeSettings = {
serviceUrl: 'https://test.hypothes.is/'
serviceUrl: 'https://test.hypothes.is/',
};
var sandbox;
......@@ -32,7 +32,7 @@ describe('groups', function() {
fakeSession = sessionWithThreeGroups();
fakeLocalStorage = {
getItem: sandbox.stub(),
setItem: sandbox.stub()
setItem: sandbox.stub(),
};
fakeRootScope = {
eventCallbacks: [],
......@@ -43,7 +43,7 @@ describe('groups', function() {
if (event === events.GROUPS_CHANGED) {
this.eventCallbacks.push(callback);
}
}
},
};
fakeHttp = sandbox.stub();
});
......@@ -73,7 +73,7 @@ describe('groups', function() {
assert.deepEqual(groups, [
{name: 'Group 1', id: 'id1'},
{name: 'Group 2', id: 'id2'},
{name: 'Group 3', id: 'id3'}
{name: 'Group 3', id: 'id3'},
]);
});
});
......@@ -122,9 +122,9 @@ describe('groups', function() {
fakeSession.state.groups.slice().filter(function (group) {
return group.id !== id;
});
fakeRootScope.eventCallbacks.forEach(function (callback) {
callback();
});
fakeRootScope.eventCallbacks.forEach(function (callback) {
callback();
});
};
leaveGroup('id3');
......@@ -142,14 +142,14 @@ describe('groups', function() {
assert.equal(s.focused().id, 'id2');
});
it("does nothing if the named group isn't recognised", function() {
it('does nothing if the named group isn\'t recognised', function() {
var s = service();
s.focus('foobar');
assert.equal(s.focused().id, 'id1');
});
it("stores the focused group id in localStorage", function() {
it('stores the focused group id in localStorage', function() {
var s = service();
s.focus('id3');
......@@ -177,7 +177,7 @@ describe('groups', function() {
s.leave('id2');
assert.calledWithMatch(fakeHttp, {
url: fakeSettings.serviceUrl + 'groups/id2/leave',
method: 'POST'
method: 'POST',
});
});
});
......
......@@ -111,7 +111,7 @@ describe('markdown commands', function () {
'one [' + sel + '](<sel>http://insert-your-link-here.com</sel>) three');
},[
{selection: 'two'},
{selection: 'jim:smith'}
{selection: 'jim:smith'},
]);
unroll('converts URLs to links', function (testCase) {
......
......@@ -65,7 +65,7 @@ describe('media-embedder', function () {
assert.equal(element.children[0].tagName, 'IFRAME');
assert.equal(
element.children[0].src, 'https://player.vimeo.com/video/149000090');
});
});
});
it('replaces Vimeo channel links with iframes', function () {
......
......@@ -10,9 +10,9 @@ function fakeExceptionData(scriptURL) {
stacktrace: {
frames: [{
filename: scriptURL,
}]
}
}]
}],
},
}],
},
culprit: scriptURL,
};
......
......@@ -148,7 +148,7 @@ describe('rootThread', function () {
function targetWithPos(pos) {
return [{
selector: [{type: 'TextPositionSelector', start: pos}]
selector: [{type: 'TextPositionSelector', start: pos}],
}];
}
......
"use strict";
'use strict';
var angular = require('angular');
......@@ -63,8 +63,8 @@ describe('h:session', function () {
it('should invoke the flash service with any flash messages', function () {
var response = {
flash: {
error: ['fail']
}
error: ['fail'],
},
};
$httpBackend.expectPOST(url).respond(response);
session.login({});
......@@ -75,12 +75,12 @@ describe('h:session', function () {
it('should assign errors and status reasons to the model', function () {
var response = {
model: {
userid: 'alice'
userid: 'alice',
},
errors: {
password: 'missing'
password: 'missing',
},
reason: 'bad credentials'
reason: 'bad credentials',
};
$httpBackend.expectPOST(url).respond(response);
var result = session.login({});
......@@ -95,7 +95,7 @@ describe('h:session', function () {
var headers = {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json;charset=utf-8',
'X-XSRF-TOKEN': token
'X-XSRF-TOKEN': token,
};
var model = {csrf: token};
$httpBackend.expectPOST(url).respond({model: model});
......@@ -111,8 +111,8 @@ describe('h:session', function () {
it('should expose the model as session.state', function () {
var response = {
model: {
userid: 'alice'
}
userid: 'alice',
},
};
assert.deepEqual(session.state, {});
$httpBackend.expectPOST(url).respond(response);
......@@ -185,7 +185,7 @@ describe('h:session', function () {
$rootScope.$on(events.SESSION_CHANGED, sessionChangeCallback);
session.update({
groups: [{
id: 'groupid'
id: 'groupid',
}],
csrf: 'dummytoken',
});
......@@ -196,9 +196,9 @@ describe('h:session', function () {
sessionChangeCallback.reset();
session.update({
groups: [{
id: 'groupid2'
id: 'groupid2',
}],
csrf: 'dummytoken'
csrf: 'dummytoken',
});
assert.calledWith(sessionChangeCallback, sinon.match({}),
{initialLoad: false});
......@@ -209,9 +209,9 @@ describe('h:session', function () {
$rootScope.$on(events.GROUPS_CHANGED, groupChangeCallback);
session.update({
groups: [{
id: 'groupid'
id: 'groupid',
}],
csrf: 'dummytoken'
csrf: 'dummytoken',
});
assert.calledOnce(groupChangeCallback);
});
......@@ -221,7 +221,7 @@ describe('h:session', function () {
$rootScope.$on(events.USER_CHANGED, userChangeCallback);
session.update({
userid: 'fred',
csrf: 'dummytoken'
csrf: 'dummytoken',
});
assert.calledOnce(userChangeCallback);
});
......
......@@ -41,25 +41,25 @@ describe('store', function () {
$httpBackend.expectGET('http://example.com/api').respond({
links: {
annotation: {
create: {
method: 'POST',
url: 'http://example.com/api/annotations',
},
delete: {
method: 'DELETE',
url: 'http://example.com/api/annotations/:id',
},
read: {},
update: {
method: 'PUT',
url: 'http://example.com/api/annotations/:id',
},
},
search: {
method: 'GET',
url: 'http://example.com/api/search',
},
annotation: {
create: {
method: 'POST',
url: 'http://example.com/api/annotations',
},
delete: {
method: 'DELETE',
url: 'http://example.com/api/annotations/:id',
},
read: {},
update: {
method: 'PUT',
url: 'http://example.com/api/annotations/:id',
},
},
search: {
method: 'GET',
url: 'http://example.com/api/search',
},
},
});
$httpBackend.flush();
......@@ -98,11 +98,11 @@ describe('store', function () {
var annotation = {
$highlight: true,
$notme: 'nooooo!',
allowed: 123
allowed: 123,
};
store.annotation.create({}, annotation);
$httpBackend.expectPOST('http://example.com/api/annotations', {
allowed: 123
allowed: 123,
})
.respond(function () { return {id: 'test'}; });
$httpBackend.flush();
......
......@@ -9,7 +9,7 @@ var proxyquire = require('proxyquire');
var fakeWebSocket = null;
function FakeSocket() {
fakeWebSocket = this;
fakeWebSocket = this; // eslint-disable-line consistent-this
this.messages = [];
this.didClose = false;
......@@ -53,7 +53,7 @@ describe('streamer', function () {
fakeRootScope = {
$apply: function (callback) {
callback();
}
},
};
fakeAnnotationMapper = {
......@@ -110,8 +110,8 @@ describe('streamer', function () {
action: 'create',
},
payload: [{
group: 'public'
}]
group: 'public',
}],
});
assert.ok(fakeAnnotationMapper.loadAnnotations.calledOnce);
});
......@@ -124,8 +124,8 @@ describe('streamer', function () {
action: 'delete',
},
payload: [{
group: 'public'
}]
group: 'public',
}],
});
assert.ok(fakeAnnotationMapper.unloadAnnotations.calledOnce);
});
......@@ -136,8 +136,8 @@ describe('streamer', function () {
createDefaultStreamer();
var model = {
groups: [{
id: 'new-group'
}]
id: 'new-group',
}],
};
fakeWebSocket.notify({
type: 'session-change',
......
......@@ -22,7 +22,7 @@ var FIXTURES_TO_FUZZY_STRING = [
[1 * year, '1 Jan 1970'],
[1 * year + 2 * month, '1 Jan 1970'],
[2 * year, '1 Jan 1970'],
[8 * year, '1 Jan 1970']
[8 * year, '1 Jan 1970'],
];
var FIXTURES_NEXT_FUZZY_UPDATE = [
......@@ -35,7 +35,7 @@ var FIXTURES_NEXT_FUZZY_UPDATE = [
[27 * hour, null],
[3 * day + 30 * minute, null],
[6 * month + 2 * day, null],
[8 * year, null]
[8 * year, null],
];
describe('time', function () {
......@@ -69,9 +69,9 @@ describe('time', function () {
} else {
return '1 Jan 1970';
}
}
},
};
}
},
};
}
......
......@@ -9,7 +9,7 @@ describe('websocket wrapper', function () {
function FakeWebSocket() {
this.close = sinon.stub();
this.send = sinon.stub();
fakeSocket = this;
fakeSocket = this; // eslint-disable-line consistent-this
}
FakeWebSocket.OPEN = 1;
......
......@@ -81,7 +81,7 @@ describe('WidgetController', function () {
fakeAnnotationMapper = {
loadAnnotations: sandbox.spy(),
unloadAnnotations: sandbox.spy()
unloadAnnotations: sandbox.spy(),
};
fakeCrossFrame = {
......@@ -98,13 +98,13 @@ describe('WidgetController', function () {
};
fakeStreamer = {
setConfig: sandbox.spy()
setConfig: sandbox.spy(),
};
fakeStreamFilter = {
resetFilter: sandbox.stub().returnsThis(),
addClause: sandbox.stub().returnsThis(),
getFilter: sandbox.stub().returns({})
getFilter: sandbox.stub().returns({}),
};
fakeGroups = {
......@@ -261,7 +261,7 @@ describe('WidgetController', function () {
it('loads annotations from the focused group instead', function () {
assert.calledWith(fakeGroups.focus, 'private-group');
assert.calledWith(fakeAnnotationMapper.loadAnnotations,
[{group: "private-group", id: "http://example.com456"}]);
[{group: 'private-group', id: 'http://example.com456'}]);
});
});
});
......@@ -334,7 +334,7 @@ describe('WidgetController', function () {
it('does not clear the selection if the new annotation is a reply', function () {
$rootScope.$emit('beforeAnnotationCreated', {
references: ['parent-id']
references: ['parent-id'],
});
assert.notCalled($scope.clearSelection);
});
......@@ -353,7 +353,7 @@ describe('WidgetController', function () {
{
uri: 'http://www.example.com',
searchUris: [],
}
},
];
// There is a direct-linked annotation
......@@ -379,7 +379,7 @@ describe('WidgetController', function () {
assert.isFalse($scope.selectedAnnotationUnavailable());
});
it("doesn't show a message if the document isn't loaded yet", function () {
it('doesn\'t show a message if the document isn\'t loaded yet', function () {
// No search requests have been sent yet.
searchClients = [];
// There is a selection but the selected annotation isn't available.
......@@ -393,7 +393,7 @@ describe('WidgetController', function () {
it('shows logged out message if selection is available', function () {
$scope.auth = {
status: 'logged-out'
status: 'logged-out',
};
annotationUI.addAnnotations([{id: '123'}]);
annotationUI.selectAnnotations(['123']);
......@@ -403,7 +403,7 @@ describe('WidgetController', function () {
it('does not show loggedout message if selection is unavailable', function () {
$scope.auth = {
status: 'logged-out'
status: 'logged-out',
};
annotationUI.selectAnnotations(['missing']);
$scope.$digest();
......@@ -412,7 +412,7 @@ describe('WidgetController', function () {
it('does not show loggedout message if there is no selection', function () {
$scope.auth = {
status: 'logged-out'
status: 'logged-out',
};
annotationUI.selectAnnotations([]);
$scope.$digest();
......@@ -421,7 +421,7 @@ describe('WidgetController', function () {
it('does not show loggedout message if user is not logged out', function () {
$scope.auth = {
status: 'logged-in'
status: 'logged-in',
};
annotationUI.addAnnotations([{id: '123'}]);
annotationUI.selectAnnotations(['123']);
......@@ -431,7 +431,7 @@ describe('WidgetController', function () {
it('does not show loggedout message if not a direct link', function () {
$scope.auth = {
status: 'logged-out'
status: 'logged-out',
};
delete fakeSettings.annotations;
annotationUI.addAnnotations([{id: '123'}]);
......
......@@ -103,33 +103,33 @@ var BREAKPOINTS = [
{
test: lessThanThirtySecondsAgo,
format: function () {return 'Just now';},
nextUpdate: 1
nextUpdate: 1,
},
{
test: lessThanOneMinuteAgo,
format: nSec,
nextUpdate: 1
nextUpdate: 1,
},
{
test: lessThanOneHourAgo,
format: nMin,
nextUpdate: minute
nextUpdate: minute,
},
{
test: lessThanOneDayAgo,
format: nHr,
nextUpdate: hour
nextUpdate: hour,
},
{
test: thisYear,
format: dayAndMonth,
nextUpdate: null
nextUpdate: null,
},
{
test: function () {return true;},
format: dayAndMonthAndYear,
nextUpdate: null
}
nextUpdate: null,
},
];
function getBreakpoint(date, now) {
......
......@@ -14,23 +14,23 @@ var Observable = require('zen-observable');
* @param {EventTarget} src - The event source.
* @param {Array<string>} eventNames - List of events to subscribe to
*/
function listen(src, eventNames) {
return new Observable(function (observer) {
var onNext = function (event) {
observer.next(event);
};
function listen(src, eventNames) {
return new Observable(function (observer) {
var onNext = function (event) {
observer.next(event);
};
eventNames.forEach(function (event) {
src.addEventListener(event, onNext);
});
eventNames.forEach(function (event) {
src.addEventListener(event, onNext);
});
return function () {
eventNames.forEach(function (event) {
src.removeEventListener(event, onNext);
});
};
});
}
return function () {
eventNames.forEach(function (event) {
src.removeEventListener(event, onNext);
});
};
});
}
/**
* Delay events from a source Observable by `delay` ms.
......@@ -62,29 +62,29 @@ function delay(delay, src) {
* @param {Observable<T>} src
* @return {Observable<T>}
*/
function buffer(delay, src) {
return new Observable(function (obs) {
var lastValue;
var timeout;
function buffer(delay, src) {
return new Observable(function (obs) {
var lastValue;
var timeout;
function onNext() {
obs.next(lastValue);
}
function onNext() {
obs.next(lastValue);
}
var sub = src.subscribe({
next: function (value) {
lastValue = value;
clearTimeout(timeout);
timeout = setTimeout(onNext, delay);
}
});
var sub = src.subscribe({
next: function (value) {
lastValue = value;
clearTimeout(timeout);
timeout = setTimeout(onNext, delay);
},
});
return function () {
sub.unsubscribe();
clearTimeout(timeout);
};
});
}
return function () {
sub.unsubscribe();
clearTimeout(timeout);
};
});
}
/**
* Merges multiple streams of values into a single stream.
......@@ -92,23 +92,23 @@ function delay(delay, src) {
* @param {Array<Observable>} sources
* @return Observable
*/
function merge(sources) {
return new Observable(function (obs) {
var subs = sources.map(function (src) {
return src.subscribe({
next: function (value) {
obs.next(value);
},
});
});
function merge(sources) {
return new Observable(function (obs) {
var subs = sources.map(function (src) {
return src.subscribe({
next: function (value) {
obs.next(value);
},
});
});
return function () {
subs.forEach(function (sub) {
sub.unsubscribe();
});
};
});
}
return function () {
subs.forEach(function (sub) {
sub.unsubscribe();
});
};
});
}
/** Drop the first `n` events from the `src` Observable. */
function drop(src, n) {
......
......@@ -50,7 +50,7 @@ function Socket(url) {
// Don't retry forever -- fail permanently after 10 retries
retries: 10,
// Randomize retry times to minimise the thundering herd effect
randomize: true
randomize: true,
});
operation.attempt(function () {
......
......@@ -34,11 +34,11 @@ function extractReleaseNotes(changelog, version) {
const GITHUB_ORG_REPO_PAT = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
if (!pkg.repository || !pkg.repository.match(GITHUB_ORG_REPO_PAT)) {
throw new Error(`package.json is missing a "repository" field of the form :owner/:repo`);
throw new Error('package.json is missing a "repository" field of the form :owner/:repo');
}
if (!process.env.GITHUB_TOKEN) {
throw new Error(`GITHUB_TOKEN env var is not set`);
throw new Error('GITHUB_TOKEN env var is not set');
}
const changelog = fs.readFileSync(require.resolve('../CHANGELOG.md')).toString();
......
......@@ -53,7 +53,7 @@ var stripReturnPatterns = [
// Unit test cases
/it\(/,
// Assignments in setters etc.
/[^=]+=[^=]+/
/[^=]+=[^=]+/,
];
/**
......@@ -141,8 +141,8 @@ function reformat(js) {
}
return typescriptFormatter.processString(inFile, js, {
baseDir: __dirname,
tsfmt: true,
baseDir: __dirname,
tsfmt: true,
}).then(result => {
return result.dest;
})
......
......@@ -73,7 +73,7 @@ function uploadReleaseFile(opts, project, release, file) {
formData: {
file: fs.createReadStream(file.path),
name: path.basename(file.path),
}
},
}).then(function (result) {
if (result.response.statusCode === 201) {
return;
......
......@@ -19,7 +19,7 @@ module.exports = {
'ng-tags-input',
'angular-toastr',
'angulartics/src/angulartics',
'angulartics/src/angulartics-ga'
'angulartics/src/angulartics-ga',
],
katex: ['katex'],
showdown: ['showdown'],
......@@ -39,5 +39,5 @@ module.exports = {
noParseModules: [
'jquery',
'katex',
]
],
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment