Re-enable ESLint rules (#216)
* Enable and fix ESLint rule no-throw-literal
* Enable ESLint rule operator-linebreak
* Enable and fix ESLint rule padded-blocks
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 0cccb8c..14c1daf 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -5,6 +5,3 @@
- error
- 4
camelcase: off
- padded-blocks: off
- operator-linebreak: off
- no-throw-literal: off
\ No newline at end of file
diff --git a/Gruntfile.js b/Gruntfile.js
index 3f8ae47..4984ad4 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -21,7 +21,6 @@
const { build, collectModules } = require('./build-tools');
module.exports = function (grunt) {
-
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compile: {
diff --git a/src/common/init.js b/src/common/init.js
index 34b253c..031ca9b 100644
--- a/src/common/init.js
+++ b/src/common/init.js
@@ -137,5 +137,4 @@
channel.join(function () {
require('cordova').fireDocumentEvent('deviceready');
}, channel.deviceReadyChannelsArray);
-
}, platformInitChannelsArray);
diff --git a/src/common/utils.js b/src/common/utils.js
index d0edc7f..82274ff 100644
--- a/src/common/utils.js
+++ b/src/common/utils.js
@@ -162,7 +162,6 @@
var F = function () {};
// extend Child from Parent
return function (Child, Parent) {
-
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.__super__ = Parent.prototype;
diff --git a/src/scripts/require.js b/src/scripts/require.js
index 5656bfa..b8c8b2c 100644
--- a/src/scripts/require.js
+++ b/src/scripts/require.js
@@ -48,10 +48,10 @@
require = function (id) {
if (!modules[id]) {
- throw 'module ' + id + ' not found';
+ throw new Error('module ' + id + ' not found');
} else if (id in inProgressModules) {
var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
- throw 'Cycle in require graph: ' + cycle;
+ throw new Error('Cycle in require graph: ' + cycle);
}
if (modules[id].factory) {
try {
@@ -68,7 +68,7 @@
define = function (id, factory) {
if (Object.prototype.hasOwnProperty.call(modules, id)) {
- throw 'module ' + id + ' already defined';
+ throw new Error('module ' + id + ' already defined');
}
modules[id] = {
diff --git a/test/test.builder.js b/test/test.builder.js
index ba71e18..8901d2c 100644
--- a/test/test.builder.js
+++ b/test/test.builder.js
@@ -20,11 +20,9 @@
*/
describe('builder', function () {
-
var builder = cordova.require('cordova/builder');
it('Test#001 : includes the module into the target', function () {
-
var target = {};
var objects = {
foo: {
@@ -47,7 +45,6 @@
});
it('Test#003 : builds out the children', function () {
-
var target = {};
var objects = {
homer: {
diff --git a/test/test.require.js b/test/test.require.js
index ace7616..986f913 100644
--- a/test/test.require.js
+++ b/test/test.require.js
@@ -61,7 +61,7 @@
define('cordova', function () {});
expect(function () {
define('cordova', function () {});
- }).toThrow('module cordova already defined');
+ }).toThrowError('module cordova already defined');
});
it("Test#004 : doesn't call the factory method when defining", function () {
@@ -75,7 +75,7 @@
it("Test#005 : throws an exception when module doesn't exist", function () {
expect(function () {
require('your mom');
- }).toThrow('module your mom not found');
+ }).toThrowError('module your mom not found');
});
it('Test#006 : throws an exception when modules depend on each other', function () {
@@ -88,7 +88,7 @@
expect(function () {
require('ModuleA');
- }).toThrow('Cycle in require graph: ModuleA->ModuleB->ModuleA');
+ }).toThrowError('Cycle in require graph: ModuleA->ModuleB->ModuleA');
});
it('Test#007 : throws an exception when a cycle of requires occurs', function () {
@@ -104,7 +104,7 @@
expect(function () {
require('ModuleA');
- }).toThrow('Cycle in require graph: ModuleA->ModuleB->ModuleC->ModuleA');
+ }).toThrowError('Cycle in require graph: ModuleA->ModuleB->ModuleC->ModuleA');
});
it('Test#008 : calls the factory method when requiring', function () {
@@ -160,7 +160,7 @@
define('submodule.a', function (require, exports, module) {
expect(() => {
require('a');
- }).toThrow('module a not found');
+ }).toThrowError('module a not found');
});
require('submodule.a');
diff --git a/test/test.urlutil.js b/test/test.urlutil.js
index e5749a9..a3a7df6 100644
--- a/test/test.urlutil.js
+++ b/test/test.urlutil.js
@@ -66,5 +66,4 @@
var rootUrl = window.location.href.replace(/:.*/, '');
expect(urlutil.makeAbsolute('//www.foo.com/baz%20?foo#bar')).toBe(rootUrl + '://www.foo.com/baz%20?foo#bar');
});
-
});
diff --git a/test/test.utils.js b/test/test.utils.js
index bde0cb4..30c8f25 100644
--- a/test/test.utils.js
+++ b/test/test.utils.js
@@ -117,7 +117,6 @@
});
it('Test#020 : can clone an object', function () {
-
var orig = {
a: {
b: {
@@ -173,5 +172,4 @@
expect(uuid).toMatch(/^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$/);
expect(uuid).not.toEqual(utils.createUUID());
});
-
});