Commit d614ac12 authored by Nick Stenning's avatar Nick Stenning Committed by GitHub

Merge pull request #31 from hypothesis/eslint-best-practices

ESLint - Enable 'Best practices' rules
parents 7b5e1b27 cb4460c2
...@@ -14,18 +14,26 @@ ...@@ -14,18 +14,26 @@
"array-callback-return": "error", "array-callback-return": "error",
"block-scoped-var": "error", "block-scoped-var": "error",
"curly": "error", "curly": "error",
"dot-notation": "error",
"eqeqeq": "error", "eqeqeq": "error",
"guard-for-in": "error",
"no-caller": "error",
"no-case-declarations": "error",
"no-console": [ "no-console": [
"error", "error",
{ allow: ["warn", "error"] }, { allow: ["warn", "error"] },
], ],
"no-extra-bind": "error",
"no-lone-blocks": "error",
"no-self-compare": "error", "no-self-compare": "error",
"no-throw-literal": "error", "no-throw-literal": "error",
"no-undef-init": "error",
"no-unused-expressions": "error", "no-unused-expressions": "error",
"no-use-before-define": [ "no-use-before-define": [
"error", "error",
{"functions": false}, {"functions": false},
], ],
"no-useless-concat": "error",
"semi": "error", "semi": "error",
"strict": ["error", "safe"], "strict": ["error", "safe"],
}, },
......
...@@ -143,7 +143,7 @@ function AnnotationController( ...@@ -143,7 +143,7 @@ function AnnotationController(
vm.annotation.user = vm.annotation.user || session.state.userid; vm.annotation.user = vm.annotation.user || session.state.userid;
vm.annotation.group = vm.annotation.group || groups.focused().id; vm.annotation.group = vm.annotation.group || groups.focused().id;
if (!vm.annotation.permissions) { if (!vm.annotation.permissions) {
vm.annotation.permissions = permissions['default'](vm.annotation.group); vm.annotation.permissions = permissions.default(vm.annotation.group);
} }
vm.annotation.text = vm.annotation.text || ''; vm.annotation.text = vm.annotation.text || '';
if (!Array.isArray(vm.annotation.tags)) { if (!Array.isArray(vm.annotation.tags)) {
...@@ -236,7 +236,7 @@ function AnnotationController( ...@@ -236,7 +236,7 @@ function AnnotationController(
* @name annotation.AnnotationController#delete * @name annotation.AnnotationController#delete
* @description Deletes the annotation. * @description Deletes the annotation.
*/ */
vm['delete'] = function() { vm.delete = function() {
return $timeout(function() { // Don't use confirm inside the digest cycle. return $timeout(function() { // Don't use confirm inside the digest cycle.
var msg = 'Are you sure you want to delete this annotation?'; var msg = 'Are you sure you want to delete this annotation?';
if ($window.confirm(msg)) { if ($window.confirm(msg)) {
......
...@@ -275,7 +275,7 @@ describe('annotation', function() { ...@@ -275,7 +275,7 @@ describe('annotation', function() {
}; };
var originalPermissions = JSON.parse(JSON.stringify( var originalPermissions = JSON.parse(JSON.stringify(
annotation.permissions)); annotation.permissions));
fakePermissions['default'] = function () { fakePermissions.default = function () {
return 'new permissions'; return 'new permissions';
}; };
fakePermissions.isShared = function () {}; fakePermissions.isShared = function () {};
...@@ -604,7 +604,7 @@ describe('annotation', function() { ...@@ -604,7 +604,7 @@ describe('annotation', function() {
var parts = createDirective(); var parts = createDirective();
sandbox.stub($window, 'confirm').returns(true); sandbox.stub($window, 'confirm').returns(true);
fakeAnnotationMapper.deleteAnnotation.returns($q.resolve()); fakeAnnotationMapper.deleteAnnotation.returns($q.resolve());
parts.controller['delete']().then(function() { parts.controller.delete().then(function() {
assert.calledWith(fakeAnnotationMapper.deleteAnnotation, assert.calledWith(fakeAnnotationMapper.deleteAnnotation,
parts.annotation); parts.annotation);
done(); done();
...@@ -618,7 +618,7 @@ describe('annotation', function() { ...@@ -618,7 +618,7 @@ describe('annotation', function() {
function(done) { function(done) {
var parts = createDirective(); var parts = createDirective();
sandbox.stub($window, 'confirm').returns(false); sandbox.stub($window, 'confirm').returns(false);
parts.controller['delete']().then(function() { parts.controller.delete().then(function() {
assert.notCalled(fakeAnnotationMapper.deleteAnnotation); assert.notCalled(fakeAnnotationMapper.deleteAnnotation);
done(); done();
}); });
...@@ -634,7 +634,7 @@ describe('annotation', function() { ...@@ -634,7 +634,7 @@ describe('annotation', function() {
fakeAnnotationMapper.deleteAnnotation.returns($q.reject({ fakeAnnotationMapper.deleteAnnotation.returns($q.reject({
status: 0 status: 0
})); }));
controller['delete']().then(function() { controller.delete().then(function() {
assert.calledWith(fakeFlash.error, assert.calledWith(fakeFlash.error,
'Service unreachable.', 'Deleting annotation failed'); 'Service unreachable.', 'Deleting annotation failed');
done(); done();
...@@ -651,7 +651,7 @@ describe('annotation', function() { ...@@ -651,7 +651,7 @@ describe('annotation', function() {
statusText: 'Server Error', statusText: 'Server Error',
data: {} data: {}
})); }));
controller['delete']().then(function() { controller.delete().then(function() {
assert.calledWith(fakeFlash.error, assert.calledWith(fakeFlash.error,
'500 Server Error', 'Deleting annotation failed'); '500 Server Error', 'Deleting annotation failed');
done(); done();
...@@ -663,7 +663,7 @@ describe('annotation', function() { ...@@ -663,7 +663,7 @@ describe('annotation', function() {
var controller = createDirective().controller; var controller = createDirective().controller;
sandbox.stub($window, 'confirm').returns(true); sandbox.stub($window, 'confirm').returns(true);
fakeAnnotationMapper.deleteAnnotation.returns($q.resolve()); fakeAnnotationMapper.deleteAnnotation.returns($q.resolve());
controller['delete']().then(function() { controller.delete().then(function() {
assert.notCalled(fakeFlash.error); assert.notCalled(fakeFlash.error);
done(); done();
}); });
......
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