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 @@
"dot-notation": "error",
"eqeqeq": "error",
"guard-for-in": "error",
"indent": ["error", 2],
"no-caller": "error",
"no-case-declarations": "error",
"no-console": [
......
......@@ -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 () {
......@@ -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));
});
......@@ -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;
}
}
......
......@@ -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();
};
......
......@@ -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);
......
......@@ -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() {
......
......@@ -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 = {
......
......@@ -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 () {
......
......@@ -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;
}
}
......
......@@ -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');
......
......@@ -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 () {
......
......@@ -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();
......
......@@ -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) {
......
......@@ -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;
})
......
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