Browse Source

Add jshint

brantje 2 years ago
parent
commit
4ef3943e7a
No account linked to committer's email address

+ 1
- 0
.gitignore View File

@@ -1,2 +1,3 @@
1 1
 .idea
2 2
 .DS_Storecss/*.map
3
+node_modules

+ 2
- 0
.jshintignore View File

@@ -0,0 +1,2 @@
1
+js/vendor
2
+js/lib/passwordgen.js

+ 4
- 1
.jshintrc View File

@@ -5,6 +5,9 @@
5 5
     "angular": true,
6 6
     "PassmanImporter": true,
7 7
     "C_Promise": true,
8
-    "window": true
8
+    "window": true,
9
+    "PAPI": true,
10
+    "API": true,
11
+    "OTP": true
9 12
   }        // additional predefined global variables
10 13
 }

+ 45
- 0
Gruntfile.js View File

@@ -0,0 +1,45 @@
1
+module.exports = function (grunt) {
2
+    var jsResources = [];
3
+    // Project configuration.
4
+    grunt.initConfig({
5
+        jsResources: [],
6
+        cssResources: [],
7
+        pkg: grunt.file.readJSON('package.json'),
8
+        jshint: {
9
+            options: {
10
+                reporter: require('jshint-stylish'),
11
+                curly: false,
12
+                eqeqeq: true,
13
+                eqnull: true,
14
+                browser: true,
15
+                globals: {
16
+                    "angular": true,
17
+                    "PassmanImporter": true,
18
+                    "PassmanExporter": true,
19
+                    "OC": true,
20
+                    "window": true,
21
+                    "console": true,
22
+                    "CRYPTO": true,
23
+                    "C_Promise": true,
24
+                    "forge": true,
25
+                    "sjcl": true,
26
+                    "jQuery": true,
27
+                    "$": true,
28
+                    "_": true,
29
+                    "oc_requesttoken": true
30
+                }
31
+            },
32
+            all: ['js/*','!js/vendor']
33
+        }
34
+
35
+    });
36
+
37
+    // Load the plugin that provides the "uglify" task.
38
+    grunt.loadNpmTasks('grunt-contrib-jshint');
39
+
40
+
41
+    // Default task(s).
42
+
43
+    grunt.registerTask('hint', ['jshint']);
44
+
45
+};

+ 5
- 4
js/background/inject/inject.js View File

@@ -229,11 +229,13 @@ $j(document).ready(function () {
229 229
             for (var i = 0; i < logins.length; i++) {
230 230
                 var login = logins[i];
231 231
                 var row = $j('<div class="account">' + login.label + '<br /><small>' + login.username + '</small></div>');
232
+                /* jshint ignore:start */
232 233
                 row.click((function (login) {
233 234
                     return function () {
234 235
                         enterLoginDetails(login);
235 236
                     };
236 237
                 })(login));
238
+                /* jshint ignore:end*/
237 239
 
238 240
                 picker.find('.tab-list-content').append(row);
239 241
             }
@@ -336,10 +338,7 @@ $j(document).ready(function () {
336 338
             return;
337 339
         }
338 340
         var picker = $j('#password_picker');
339
-        if (!picker.is(e.target)
340
-            && picker.has(e.target).length === 0
341
-
342
-        ) {
341
+        if (!picker.is(e.target) && picker.has(e.target).length === 0) {
343 342
             if (picker) {
344 343
                 picker.remove();
345 344
             }
@@ -468,11 +467,13 @@ $j(document).ready(function () {
468 467
                         createPasswordPicker(loginFields[i], form);
469 468
                     }
470 469
                     //Password miner
470
+                    /* jshint ignore:start */
471 471
                     $j(form).submit((function (loginFields) {
472 472
                         return function () {
473 473
                             formSubmitted(loginFields);
474 474
                         };
475 475
                     })(loginFields[i]));
476
+                    /* jshint ignore:end */
476 477
                 }
477 478
 
478 479
                 var url = window.location.href; //@TODO use a extension function

+ 1
- 1
js/background/service/background.js View File

@@ -419,7 +419,7 @@
419 419
         if (error === "Data not found") {
420 420
             getSettings();
421 421
         }
422
-    })
422
+    });
423 423
 
424 424
 }());
425 425
 

+ 5
- 3
js/background/service/contextMenu.js View File

@@ -112,16 +112,18 @@ window.contextMenu = (function () {
112 112
                 login.autoFill = (!login.hasOwnProperty('autoFill')) ? true : login.autoFill;
113 113
                 for (f = 0; f < fields.length; f++) {
114 114
                     field = fields[f];
115
-                    if (field['field'] === 'totp' && login.otp) {
115
+                    if (field.field === 'totp' && login.otp) {
116 116
                         login.totp = login.otp.secret;
117 117
                     }
118
-                    if (login[field['field']]) {
118
+                    if (login[field.field]) {
119 119
                         fields[f].found = true;
120
-                        createMenuItem(field['menu'], field['menu'] + ':' + login.guid, login.label, (function (field, login) {
120
+                        /* jshint ignore:start */
121
+                        createMenuItem(field.menu, field.menu + ':' + login.guid, login.label, (function (field, login) {
121 122
                             return function () {
122 123
                                 itemClickCallback(field, login);
123 124
                             };
124 125
                         })(field, login));
126
+                        /* jshint ignore:end */
125 127
                     }
126 128
                 }
127 129
             }

+ 2
- 3
js/lib/API/base.js View File

@@ -6,14 +6,13 @@
6 6
 
7 7
 
8 8
 /* global browser, chrome */
9
-
10
-'use strict';
11 9
 if (typeof API === "undefined") {
12 10
     var API = {};
13 11
 }
14
-
12
+/* jshint ignore:start */
15 13
 API.api;
16 14
 API.promise = true;     // Chrome does not return promises
15
+/* jshint ignore:end */
17 16
 
18 17
 // Workaround chrome's uniqueness
19 18
 if (typeof browser === 'undefined') {

+ 0
- 1
js/lib/API/browser_action.js View File

@@ -6,7 +6,6 @@
6 6
 
7 7
 
8 8
 /* global API */
9
-'use strict';
10 9
 
11 10
 API.browserAction = {
12 11
     setTitle: API.api.browserAction.setTitle,

+ 0
- 1
js/lib/API/cookies.js View File

@@ -6,7 +6,6 @@
6 6
 
7 7
 
8 8
 /* global API */
9
-'use strict';
10 9
 
11 10
 API.cookies = {
12 11
     get: function (details) {

+ 0
- 1
js/lib/API/runtime.js View File

@@ -6,7 +6,6 @@
6 6
 
7 7
 /* global API */
8 8
 
9
-'use strict';
10 9
 API.runtime = {
11 10
     getBackgroundPage: function() {
12 11
         if (API.promise) {

+ 6
- 1
js/lib/API/storage.js View File

@@ -1,6 +1,5 @@
1 1
 /* global browser, chrome */
2 2
 
3
-'use strict';
4 3
 if (typeof API === "undefined") {
5 4
     var API = {};
6 5
 }
@@ -19,9 +18,11 @@ API.Storage = function() {
19 18
             return new C_Promise(function(){
20 19
                 if (API.promise) {
21 20
                     localStorage.get(key).then((function(item){
21
+                        /* jshint ignore:start */
22 22
                         if (typeof key === "[object Array]") {
23 23
                             this.call_then(item);
24 24
                         }
25
+
25 26
                         else {
26 27
                             if (item[key] === undefined) {
27 28
                                 this.call_error("Data not found");
@@ -30,15 +31,18 @@ API.Storage = function() {
30 31
                                 this.call_then(item[key]);
31 32
                             }
32 33
                         }
34
+                        /* jshint ignore:end */
33 35
                     }).bind(this), (function(error){
34 36
                         this.call_error(error);
35 37
                     }).bind(this));
36 38
                 }
37 39
                 else{
38 40
                     localStorage.get(key, (function(item){
41
+                        /* jshint ignore:start */
39 42
                         if (typeof key === "[object Array]") {
40 43
                             this.call_then(item);
41 44
                         }
45
+
42 46
                         else {
43 47
                             if (item[key] === undefined) {
44 48
                                 this.call_error("Data not found");
@@ -47,6 +51,7 @@ API.Storage = function() {
47 51
                                 this.call_then(item[key]);
48 52
                             }
49 53
                         }
54
+                        /* jshint ignore:end */
50 55
                     }).bind(this));
51 56
                 }
52 57
             });

+ 0
- 1
js/lib/API/tabs.js View File

@@ -6,7 +6,6 @@
6 6
 
7 7
 
8 8
 /* global API */
9
-'use strict';
10 9
 
11 10
 API.tabs = {
12 11
     connect: function(tabId, connectInfo) {

+ 0
- 1
js/lib/font-awesome.js View File

@@ -7,7 +7,6 @@ function insertFontCSS() {
7 7
         "font-weight: normal;",
8 8
         "font-style: normal;",
9 9
         "}"];
10
-    var browser = jQuery.browser;
11 10
     if (window.navigator.userAgent.indexOf('Firefox') !== -1) {
12 11
         fontCss[2] = "src: url('" + fontPath + "fonts/fontawesome-webfont.eot?v=4.7.0');";
13 12
         fontCss[3] = "src: url('" + fontPath + "fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('" + fontPath + "fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('" + fontPath + "fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('" + fontPath + "fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('" + fontPath + "fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');";

+ 3
- 2
js/lib/jQuerytoObject.js View File

@@ -3,15 +3,16 @@ jQuery.fn.serializeObject = function()
3 3
     var o = {};
4 4
     var a = this.serializeArray();
5 5
     jQuery.each(a, function() {
6
+        var value;
6 7
         if (o[this.name] !== undefined) {
7 8
             if (!o[this.name].push) {
8 9
                 o[this.name] = [o[this.name]];
9 10
             }
10
-            var value = (this.value === 'on') ? true : this.value;
11
+            value = (this.value === 'on') ? true : this.value;
11 12
             value = (value === 'off') ? false : value;
12 13
             o[this.name].push(value || '');
13 14
         } else {
14
-            var value = (this.value === 'on') ? true : this.value;
15
+            value = (this.value === 'on') ? true : this.value;
15 16
             value = (value === 'off') ? false : value;
16 17
             o[this.name] = value;
17 18
         }

+ 1
- 1
js/ui/popup/factories/debounce.js View File

@@ -41,6 +41,6 @@
41 41
                 });
42 42
             }
43 43
         };
44
-    });;
44
+    });
45 45
 }());
46 46
 

+ 26
- 0
package.json View File

@@ -0,0 +1,26 @@
1
+{
2
+  "name": "passman-web-extension",
3
+  "version": "1.0.0",
4
+  "description": "Tested on:    - Chrome - Firefox - Safari",
5
+  "main": "Gruntfile.js",
6
+  "dependencies": {
7
+    "grunt": "~0.4.5",
8
+    "grunt-cli": "~1.2.0",
9
+    "grunt-contrib-jshint": "^0.12.0",
10
+    "jshint-stylish": "^2.2.1"
11
+  },
12
+  "devDependencies": {},
13
+  "scripts": {
14
+    "test": "echo \"Error: no test specified\" && exit 1"
15
+  },
16
+  "repository": {
17
+    "type": "git",
18
+    "url": "git+https://github.com/nextcloud/passman-webextension.git"
19
+  },
20
+  "author": "",
21
+  "license": "ISC",
22
+  "bugs": {
23
+    "url": "https://github.com/nextcloud/passman-webextension/issues"
24
+  },
25
+  "homepage": "https://github.com/nextcloud/passman-webextension#readme"
26
+}