Просмотр исходного кода

[CI] Lint JS scripts with jshint (#2315)

Frans de Jonge 7 лет назад
Родитель
Сommit
c2a339f2f8
4 измененных файлов с 28 добавлено и 7 удалено
  1. 4 0
      .jshintignore
  2. 8 0
      .jshintrc
  3. 9 0
      .travis.yml
  4. 7 7
      p/scripts/install.js

+ 4 - 0
.jshintignore

@@ -0,0 +1,4 @@
+node_modules
+p/scripts/bcrypt.min.js
+p/scripts/flotr2.min.js
+p/scripts/jquery.min.js

+ 8 - 0
.jshintrc

@@ -0,0 +1,8 @@
+{
+	"esversion" : 6,
+	"browser" : true,
+	"globals": {
+		"confirm": true,
+		"console": true
+	}
+}

+ 9 - 0
.travis.yml

@@ -34,6 +34,15 @@ matrix:
       dist: precise
     - php: "7.2"
       env: CHECK_TRANSLATION=yes VALIDATE_STANDARD=no
+    - language: node_js
+      node_js:
+        - "node"
+      php:
+        # none
+      install:
+        - npm install jshint
+      script:
+        - node_modules/jshint/bin/jshint .
   allow_failures:
     - env: CHECK_TRANSLATION=yes VALIDATE_STANDARD=no
     - dist: precise

+ 7 - 7
p/scripts/install.js

@@ -1,15 +1,15 @@
 "use strict";
 /* jshint globalstrict: true */
 
-function show_password() {
-	var button = this;
+function show_password(ev) {
+	var button = ev.target;
 	var passwordField = document.getElementById(button.getAttribute('data-toggle'));
 	passwordField.setAttribute('type', 'text');
 	button.className += ' active';
 	return false;
 }
-function hide_password() {
-	var button = this;
+function hide_password(ev) {
+	var button = ev.target;
 	var passwordField = document.getElementById(button.getAttribute('data-toggle'));
 	passwordField.setAttribute('type', 'password');
 	button.className = button.className.replace(/(?:^|\s)active(?!\S)/g , '');
@@ -61,10 +61,10 @@ if (bd_type) {
 	bd_type.addEventListener('change', mySqlShowHide);
 }
 
-function ask_confirmation(e) {
-	var str_confirmation = this.getAttribute('data-str-confirm');
+function ask_confirmation(ev) {
+	var str_confirmation = ev.target.getAttribute('data-str-confirm');
 	if (!confirm(str_confirmation)) {
-		e.preventDefault();
+		ev.preventDefault();
 	}
 }
 var confirms = document.getElementsByClassName('confirm');