diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f50add61..3495f8e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: sudo apt-get -qq -y install gettext pip install -U pip wheel pip install -U -r requirements-test.txt - sudo npm install -g jshint + sudo npm install -g prettier pip install -e .[rest] pip install -U ${{ matrix.django-version }} diff --git a/.jshint b/.jshint deleted file mode 100644 index 11a8681a..00000000 --- a/.jshint +++ /dev/null @@ -1,49 +0,0 @@ -{ - "predef": [ - "document", - "navigator", - "console", - "alert", - "django", - "gettext" - ], - - "adsafe": false, - "safe": false, - - "bitwise": false, - "cap": false, - "confusion": true, - "continue": true, - "css": true, - "debug": false, - "eqeq": false, - "es5": true, - "evil": false, - "forin": false, - "fragment": true, - "newcap": false, - "nomen": false, - "on": false, - "plusplus": false, - "regexp": true, - "sloppy": false, - "sub": false, - "undef": false, - "unparam": true, - "vars": true, - "white": false, - "validthis": true, - "strict_mode":true, - - "browser": false, - "devel": false, - "node": false, - "rhino": false, - "widget": false, - "windows": false, - "indent": 2, - "maxerr": 50, - "maxlen": 120, - "passfail": false -} diff --git a/.stylelintrc.json b/.stylelintrc.json deleted file mode 100644 index 54c467e9..00000000 --- a/.stylelintrc.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "rules": { - "block-no-empty": null, - "color-no-invalid-hex": true, - "comment-empty-line-before": ["always", { - "ignore": ["stylelint-commands", "after-comment"] - }], - "rule-empty-line-before": ["never-multi-line", { - "except": ["first-nested"], - "ignore": ["after-comment", "inside-block"] - }], - "unit-allowed-list": ["em", "rem", "%", "s", "px", "vh", "deg", "dpi", "fr"], - "property-no-unknown": true - } -} diff --git a/openwisp_users/static/openwisp-users/css/admin.css b/openwisp_users/static/openwisp-users/css/admin.css index b95ee5b4..b70b3aa8 100644 --- a/openwisp_users/static/openwisp-users/css/admin.css +++ b/openwisp_users/static/openwisp-users/css/admin.css @@ -1,4 +1,4 @@ -input.readonly{ +input.readonly { border: 1px solid rgba(0, 0, 0, 0.05) !important; - background-color: rgba(0, 0, 0, 0.070); + background-color: rgba(0, 0, 0, 0.07); } diff --git a/openwisp_users/static/openwisp-users/js/addform.js b/openwisp_users/static/openwisp-users/js/addform.js index 4432c6f9..d9d4d17c 100644 --- a/openwisp_users/static/openwisp-users/js/addform.js +++ b/openwisp_users/static/openwisp-users/js/addform.js @@ -1,33 +1,35 @@ (function ($) { - 'use strict'; + "use strict"; $(document).ready(function () { - var superuser = $('#id_is_superuser'), - staff = $('#id_is_staff'), - orgs = $('#openwisp_users_organizationuser-group'); + var superuser = $("#id_is_superuser"), + staff = $("#id_is_staff"), + orgs = $("#openwisp_users_organizationuser-group"); superuser.change(function (e) { // when enabling superuser - if (superuser.is(':checked')) { + if (superuser.is(":checked")) { // hide organization details because they're not needed orgs.hide(); // reset all org fields - orgs.find('.field-is_admin input').prop('checked', false); - orgs.find('.field-organization select').val(''); + orgs.find(".field-is_admin input").prop("checked", false); + orgs.find(".field-organization select").val(""); // enable staff too - if (!staff.is(':checked')) { - staff.trigger('click'); + if (!staff.is(":checked")) { + staff.trigger("click"); } - // when disabling superuser, show organizations + // when disabling superuser, show organizations } else { orgs.show(); } }); staff.change(function (e) { // enable also is_admin in org unless superuser - if (!superuser.is(':checked')) { - orgs.find('.field-is_admin input').prop('checked', staff.is(':checked')); + if (!superuser.is(":checked")) { + orgs + .find(".field-is_admin input") + .prop("checked", staff.is(":checked")); } }); - staff.trigger('change'); - superuser.trigger('change'); + staff.trigger("change"); + superuser.trigger("change"); }); -}(django.jQuery)); +})(django.jQuery); diff --git a/openwisp_users/static/openwisp-users/js/org-autocomplete.js b/openwisp_users/static/openwisp-users/js/org-autocomplete.js index 6053ebd8..08b78c7b 100644 --- a/openwisp_users/static/openwisp-users/js/org-autocomplete.js +++ b/openwisp_users/static/openwisp-users/js/org-autocomplete.js @@ -1,5 +1,5 @@ (function ($) { - 'use strict'; + "use strict"; $(document).ready(function () { // The select2 library requires data in a specific format // https://select2.org/data-sources/formats. @@ -9,51 +9,56 @@ // Django expects an empty string (for None) or a UUID string. // Hence, we need to update the value of selected option before // submission of form. - var formElement = $('select#id_organization'); - while (formElement.prop('tagName') !== 'FORM'){ + var formElement = $("select#id_organization"); + while (formElement.prop("tagName") !== "FORM") { formElement = formElement.parent(); } - formElement.submit(function(){ - var target = $('select#id_organization option:selected'); - if (target.val() === 'null') { - target.val(''); + formElement.submit(function () { + var target = $("select#id_organization option:selected"); + if (target.val() === "null") { + target.val(""); } }); - if (!$('select#id_organization').val()) { - var orgField = $('#id_organization'), - pathName = window.location.pathname.split('/'); + if (!$("select#id_organization").val()) { + var orgField = $("#id_organization"), + pathName = window.location.pathname.split("/"); // If the field is rendered empty on a change form, then the // the object is shared systemwide (no organization). - if (pathName[pathName.length - 2] == 'change') { - orgField.val('null'); - orgField.trigger('change'); + if (pathName[pathName.length - 2] == "change") { + orgField.val("null"); + orgField.trigger("change"); return; } // If only one organization option is available, then select that // organization automatically $.ajax({ - url: orgField.data('ajax--url'), + url: orgField.data("ajax--url"), data: { - app_label: orgField.data('app-label'), - model_name: orgField.data('model-name'), - field_name: orgField.data('field-name') + app_label: orgField.data("app-label"), + model_name: orgField.data("model-name"), + field_name: orgField.data("field-name"), }, success: function (data) { if (data.results.length === 1) { - var option = new Option(data.results[0].text, data.results[0].id, true, true); - orgField.append(option).trigger('change'); + var option = new Option( + data.results[0].text, + data.results[0].id, + true, + true, + ); + orgField.append(option).trigger("change"); // manually trigger the `select2:select` event orgField.trigger({ - type: 'select2:select', + type: "select2:select", params: { - data: data.results[0] - } + data: data.results[0], + }, }); } - } + }, }); } }); -}(django.jQuery)); +})(django.jQuery); diff --git a/run-qa-checks b/run-qa-checks index a6e5991a..a3e4a3be 100755 --- a/run-qa-checks +++ b/run-qa-checks @@ -1,8 +1,6 @@ #!/bin/bash set -e -jshint ./openwisp_users/static/openwisp-users/js/*.js - echo '' echo 'Compiling translations' cd openwisp_users @@ -12,7 +10,9 @@ cd .. openwisp-qa-check \ --migrations-to-ignore 2 \ --migration-path './openwisp_users/migrations' \ - --migration-module openwisp_users + --migration-module openwisp_users \ + --csslinter \ + --jslinter echo '' echo 'Running checks for testapp'