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