Commit c09f49f4 authored by Robert Knight's avatar Robert Knight

Fix indentation inconsistencies

Use 2-space indents everywhere and fix up non-conforming code with
ESLint's --fix tool.
parent 1ef5e770
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
"dot-notation": "error", "dot-notation": "error",
"eqeqeq": "error", "eqeqeq": "error",
"guard-for-in": "error", "guard-for-in": "error",
"indent": ["error", 2],
"no-caller": "error", "no-caller": "error",
"no-case-declarations": "error", "no-case-declarations": "error",
"no-console": [ "no-console": [
......
...@@ -68,8 +68,8 @@ function getEnv(key) { ...@@ -68,8 +68,8 @@ function getEnv(key) {
/** A list of all modules included in vendor bundles. */ /** A list of all modules included in vendor bundles. */
var vendorModules = Object.keys(vendorBundles.bundles) var vendorModules = Object.keys(vendorBundles.bundles)
.reduce(function (deps, key) { .reduce(function (deps, key) {
return deps.concat(vendorBundles.bundles[key]); return deps.concat(vendorBundles.bundles[key]);
}, []); }, []);
// Builds the bundles containing vendor JS code // Builds the bundles containing vendor JS code
gulp.task('build-vendor-js', function () { gulp.task('build-vendor-js', function () {
...@@ -319,8 +319,7 @@ gulp.task('test-watch-app', function (callback) { ...@@ -319,8 +319,7 @@ gulp.task('test-watch-app', function (callback) {
runKarma('./h/static/scripts/karma.config.js', {}, callback); runKarma('./h/static/scripts/karma.config.js', {}, callback);
}); });
gulp.task('upload-sourcemaps', gulp.task('upload-sourcemaps', ['build-app-js'], function () {
['build-app-js'], function () {
var uploadToSentry = require('./scripts/gulp/upload-to-sentry'); var uploadToSentry = require('./scripts/gulp/upload-to-sentry');
var opts = { var opts = {
...@@ -331,5 +330,5 @@ gulp.task('upload-sourcemaps', ...@@ -331,5 +330,5 @@ gulp.task('upload-sourcemaps',
var release = getEnv('SENTRY_RELEASE_VERSION'); var release = getEnv('SENTRY_RELEASE_VERSION');
return gulp.src(['build/scripts/*.js', 'build/scripts/*.map']) return gulp.src(['build/scripts/*.js', 'build/scripts/*.map'])
.pipe(uploadToSentry(opts, projects, release)); .pipe(uploadToSentry(opts, projects, release));
}); });
...@@ -111,16 +111,16 @@ function excludeAnnotations(current, annotations) { ...@@ -111,16 +111,16 @@ function excludeAnnotations(current, annotations) {
function annotationsReducer(state, action) { function annotationsReducer(state, action) {
switch (action.type) { switch (action.type) {
case types.ADD_ANNOTATIONS: case types.ADD_ANNOTATIONS:
return Object.assign({}, state, return Object.assign({}, state,
{annotations: state.annotations.concat(action.annotations)}); {annotations: state.annotations.concat(action.annotations)});
case types.REMOVE_ANNOTATIONS: case types.REMOVE_ANNOTATIONS:
return Object.assign({}, state, return Object.assign({}, state,
{annotations: excludeAnnotations(state.annotations, action.annotations)}); {annotations: excludeAnnotations(state.annotations, action.annotations)});
case types.CLEAR_ANNOTATIONS: case types.CLEAR_ANNOTATIONS:
return Object.assign({}, state, {annotations: []}); return Object.assign({}, state, {annotations: []});
default: default:
return state; return state;
} }
} }
...@@ -129,35 +129,35 @@ function reducer(state, action) { ...@@ -129,35 +129,35 @@ function reducer(state, action) {
state = annotationsReducer(state, action); state = annotationsReducer(state, action);
switch (action.type) { switch (action.type) {
case types.CLEAR_SELECTION: case types.CLEAR_SELECTION:
return Object.assign({}, state, { return Object.assign({}, state, {
filterQuery: null, filterQuery: null,
selectedAnnotationMap: null, selectedAnnotationMap: null,
}); });
case types.SELECT_ANNOTATIONS: case types.SELECT_ANNOTATIONS:
return Object.assign({}, state, {selectedAnnotationMap: action.selection}); return Object.assign({}, state, {selectedAnnotationMap: action.selection});
case types.FOCUS_ANNOTATIONS: case types.FOCUS_ANNOTATIONS:
return Object.assign({}, state, {focusedAnnotationMap: action.focused}); return Object.assign({}, state, {focusedAnnotationMap: action.focused});
case types.SET_HIGHLIGHTS_VISIBLE: case types.SET_HIGHLIGHTS_VISIBLE:
return Object.assign({}, state, {visibleHighlights: action.visible}); return Object.assign({}, state, {visibleHighlights: action.visible});
case types.SET_FORCE_VISIBLE: case types.SET_FORCE_VISIBLE:
return Object.assign({}, state, {forceVisible: action.forceVisible}); return Object.assign({}, state, {forceVisible: action.forceVisible});
case types.SET_EXPANDED: case types.SET_EXPANDED:
return Object.assign({}, state, {expanded: action.expanded}); return Object.assign({}, state, {expanded: action.expanded});
case types.HIGHLIGHT_ANNOTATIONS: case types.HIGHLIGHT_ANNOTATIONS:
return Object.assign({}, state, {highlighted: action.highlighted}); return Object.assign({}, state, {highlighted: action.highlighted});
case types.SELECT_TAB: case types.SELECT_TAB:
return Object.assign({}, state, {selectedTab: action.tab}); return Object.assign({}, state, {selectedTab: action.tab});
case types.SET_FILTER_QUERY: case types.SET_FILTER_QUERY:
return Object.assign({}, state, { return Object.assign({}, state, {
filterQuery: action.query, filterQuery: action.query,
forceVisible: {}, forceVisible: {},
expanded: {}, expanded: {},
}); });
case types.SET_SORT_KEY: case types.SET_SORT_KEY:
return Object.assign({}, state, {sortKey: action.key}); return Object.assign({}, state, {sortKey: action.key});
default: default:
return state; return state;
} }
} }
......
...@@ -132,7 +132,7 @@ module.exports = function AppController( ...@@ -132,7 +132,7 @@ module.exports = function AppController(
$scope.clearSelection = function () { $scope.clearSelection = function () {
if (!annotationUI.getState().selectedTab) { if (!annotationUI.getState().selectedTab) {
annotationUI.selectTab(uiConstants.TAB_ANNOTATIONS); annotationUI.selectTab(uiConstants.TAB_ANNOTATIONS);
} }
annotationUI.clearSelectedAnnotations(); annotationUI.clearSelectedAnnotations();
}; };
......
...@@ -58,9 +58,9 @@ module.exports = function () { ...@@ -58,9 +58,9 @@ module.exports = function () {
this.copyToClipboardMessage = 'Select and copy to share.'; this.copyToClipboardMessage = 'Select and copy to share.';
} finally { } finally {
setTimeout(function () { setTimeout(function () {
this.copyToClipboardMessage = null; this.copyToClipboardMessage = null;
$scope.$digest(); $scope.$digest();
}.bind(this), }.bind(this),
1000); 1000);
} }
}.bind(this); }.bind(this);
......
...@@ -497,14 +497,14 @@ describe('annotation', function() { ...@@ -497,14 +497,14 @@ describe('annotation', function() {
}); });
it('makes the reply private if the parent is private', function() { it('makes the reply private if the parent is private', function() {
var controller = createDirective(annotation).controller; var controller = createDirective(annotation).controller;
fakePermissions.isPrivate.returns(true); fakePermissions.isPrivate.returns(true);
var perms = {read: ['onlyme']}; var perms = {read: ['onlyme']};
fakePermissions.private.returns(perms); fakePermissions.private.returns(perms);
var reply = sinon.match({permissions: perms}); var reply = sinon.match({permissions: perms});
controller.reply(); controller.reply();
assert.calledWith(fakeAnnotationMapper.createAnnotation, reply); assert.calledWith(fakeAnnotationMapper.createAnnotation, reply);
} }
); );
it('sets the reply\'s group to be the same as its parent\'s', function() { it('sets the reply\'s group to be the same as its parent\'s', function() {
......
...@@ -35,12 +35,12 @@ describe('groupList', function () { ...@@ -35,12 +35,12 @@ describe('groupList', function () {
$window = _$window_; $window = _$window_;
groups = [{ groups = [{
id: 'public', id: 'public',
public: true, public: true,
},{ },{
id: 'h-devs', id: 'h-devs',
name: 'Hypothesis Developers', name: 'Hypothesis Developers',
url: GROUP_LINK, url: GROUP_LINK,
}]; }];
fakeGroups = { fakeGroups = {
......
...@@ -32,16 +32,16 @@ describe('publishAnnotationBtn', function () { ...@@ -32,16 +32,16 @@ describe('publishAnnotationBtn', function () {
// create a new instance of the directive with default // create a new instance of the directive with default
// attributes // attributes
element = util.createDirective(document, 'publishAnnotationBtn', { element = util.createDirective(document, 'publishAnnotationBtn', {
group: { group: {
name: 'Public', name: 'Public',
type: 'public', type: 'public',
}, },
canPost: true, canPost: true,
isShared: false, isShared: false,
onSave: function () {}, onSave: function () {},
onSetPrivacy: function () {}, onSetPrivacy: function () {},
onCancel: function () {}, onCancel: function () {},
}); });
}); });
it('should display "Post to Only Me"', function () { it('should display "Post to Only Me"', function () {
......
...@@ -48,14 +48,14 @@ function Streamer($rootScope, annotationMapper, groups, session, settings) { ...@@ -48,14 +48,14 @@ function Streamer($rootScope, annotationMapper, groups, session, settings) {
} }
switch (action) { switch (action) {
case 'create': case 'create':
case 'update': case 'update':
case 'past': case 'past':
annotationMapper.loadAnnotations(annotations); annotationMapper.loadAnnotations(annotations);
break; break;
case 'delete': case 'delete':
annotationMapper.unloadAnnotations(annotations); annotationMapper.unloadAnnotations(annotations);
break; break;
} }
} }
......
...@@ -122,9 +122,9 @@ describe('groups', function() { ...@@ -122,9 +122,9 @@ describe('groups', function() {
fakeSession.state.groups.slice().filter(function (group) { fakeSession.state.groups.slice().filter(function (group) {
return group.id !== id; return group.id !== id;
}); });
fakeRootScope.eventCallbacks.forEach(function (callback) { fakeRootScope.eventCallbacks.forEach(function (callback) {
callback(); callback();
}); });
}; };
leaveGroup('id3'); leaveGroup('id3');
......
...@@ -65,7 +65,7 @@ describe('media-embedder', function () { ...@@ -65,7 +65,7 @@ describe('media-embedder', function () {
assert.equal(element.children[0].tagName, 'IFRAME'); assert.equal(element.children[0].tagName, 'IFRAME');
assert.equal( assert.equal(
element.children[0].src, 'https://player.vimeo.com/video/149000090'); element.children[0].src, 'https://player.vimeo.com/video/149000090');
}); });
}); });
it('replaces Vimeo channel links with iframes', function () { it('replaces Vimeo channel links with iframes', function () {
......
...@@ -41,25 +41,25 @@ describe('store', function () { ...@@ -41,25 +41,25 @@ describe('store', function () {
$httpBackend.expectGET('http://example.com/api').respond({ $httpBackend.expectGET('http://example.com/api').respond({
links: { links: {
annotation: { annotation: {
create: { create: {
method: 'POST', method: 'POST',
url: 'http://example.com/api/annotations', url: 'http://example.com/api/annotations',
}, },
delete: { delete: {
method: 'DELETE', method: 'DELETE',
url: 'http://example.com/api/annotations/:id', url: 'http://example.com/api/annotations/:id',
}, },
read: {}, read: {},
update: { update: {
method: 'PUT', method: 'PUT',
url: 'http://example.com/api/annotations/:id', url: 'http://example.com/api/annotations/:id',
}, },
}, },
search: { search: {
method: 'GET', method: 'GET',
url: 'http://example.com/api/search', url: 'http://example.com/api/search',
}, },
}, },
}); });
$httpBackend.flush(); $httpBackend.flush();
......
...@@ -14,23 +14,23 @@ var Observable = require('zen-observable'); ...@@ -14,23 +14,23 @@ var Observable = require('zen-observable');
* @param {EventTarget} src - The event source. * @param {EventTarget} src - The event source.
* @param {Array<string>} eventNames - List of events to subscribe to * @param {Array<string>} eventNames - List of events to subscribe to
*/ */
function listen(src, eventNames) { function listen(src, eventNames) {
return new Observable(function (observer) { return new Observable(function (observer) {
var onNext = function (event) { var onNext = function (event) {
observer.next(event); observer.next(event);
}; };
eventNames.forEach(function (event) { eventNames.forEach(function (event) {
src.addEventListener(event, onNext); src.addEventListener(event, onNext);
}); });
return function () { return function () {
eventNames.forEach(function (event) { eventNames.forEach(function (event) {
src.removeEventListener(event, onNext); src.removeEventListener(event, onNext);
}); });
}; };
}); });
} }
/** /**
* Delay events from a source Observable by `delay` ms. * Delay events from a source Observable by `delay` ms.
...@@ -62,29 +62,29 @@ function delay(delay, src) { ...@@ -62,29 +62,29 @@ function delay(delay, src) {
* @param {Observable<T>} src * @param {Observable<T>} src
* @return {Observable<T>} * @return {Observable<T>}
*/ */
function buffer(delay, src) { function buffer(delay, src) {
return new Observable(function (obs) { return new Observable(function (obs) {
var lastValue; var lastValue;
var timeout; var timeout;
function onNext() { function onNext() {
obs.next(lastValue); obs.next(lastValue);
} }
var sub = src.subscribe({ var sub = src.subscribe({
next: function (value) { next: function (value) {
lastValue = value; lastValue = value;
clearTimeout(timeout); clearTimeout(timeout);
timeout = setTimeout(onNext, delay); timeout = setTimeout(onNext, delay);
}, },
}); });
return function () { return function () {
sub.unsubscribe(); sub.unsubscribe();
clearTimeout(timeout); clearTimeout(timeout);
}; };
}); });
} }
/** /**
* Merges multiple streams of values into a single stream. * Merges multiple streams of values into a single stream.
...@@ -92,23 +92,23 @@ function delay(delay, src) { ...@@ -92,23 +92,23 @@ function delay(delay, src) {
* @param {Array<Observable>} sources * @param {Array<Observable>} sources
* @return Observable * @return Observable
*/ */
function merge(sources) { function merge(sources) {
return new Observable(function (obs) { return new Observable(function (obs) {
var subs = sources.map(function (src) { var subs = sources.map(function (src) {
return src.subscribe({ return src.subscribe({
next: function (value) { next: function (value) {
obs.next(value); obs.next(value);
}, },
}); });
}); });
return function () { return function () {
subs.forEach(function (sub) { subs.forEach(function (sub) {
sub.unsubscribe(); sub.unsubscribe();
}); });
}; };
}); });
} }
/** Drop the first `n` events from the `src` Observable. */ /** Drop the first `n` events from the `src` Observable. */
function drop(src, n) { function drop(src, n) {
......
...@@ -141,8 +141,8 @@ function reformat(js) { ...@@ -141,8 +141,8 @@ function reformat(js) {
} }
return typescriptFormatter.processString(inFile, js, { return typescriptFormatter.processString(inFile, js, {
baseDir: __dirname, baseDir: __dirname,
tsfmt: true, tsfmt: true,
}).then(result => { }).then(result => {
return result.dest; return result.dest;
}) })
......
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