From eb7712b92c86db3669d986e66a7c9e48ed289405 Mon Sep 17 00:00:00 2001 From: Nick Freear Date: Tue, 22 Aug 2017 00:24:19 +0100 Subject: [PATCH] Bug #6/#7, Javascript eslint fixes [iet:9820855][iet:9702401] * Plus, add `eslintConfig` and `jshintConfig` to `package` JSON * Code date: 15 August 2017. --- js/index.js | 4 +--- js/src/analytics.js | 4 ---- js/src/local-fixes.js | 6 +++--- js/src/moodle-user-profile.js | 4 ++-- js/src/ouop-utils.js | 2 -- js/src/survey-embed-link.js | 2 -- package.json | 20 ++++++++++++++++++-- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/js/index.js b/js/index.js index 498af08..ebef9b3 100644 --- a/js/index.js +++ b/js/index.js @@ -6,8 +6,6 @@ // IMPORTANT: console.debug() does NOT print output !! -'use strict'; - var util = require('./src/ouop-utils'); var userJsonUrl = '/auth/ouopenid/user/ajax.php?r=' + util.rand(); @@ -63,7 +61,7 @@ require('./src/when-call')( // .. - require('./src/local-fixes')($, data); + require('./src/local-fixes')($); require('./src/survey-embed-link')($, data); diff --git a/js/src/analytics.js b/js/src/analytics.js index 7fb858d..6cf3e73 100644 --- a/js/src/analytics.js +++ b/js/src/analytics.js @@ -2,10 +2,6 @@ OU-OpenID. © Nick Freear. © The Open University. (NDF / 02-April-2017) */ -/* global ga: false */ - -'use strict'; - module.exports = { run: function ($, resp) { include_ga_javascript(); diff --git a/js/src/local-fixes.js b/js/src/local-fixes.js index 26a511d..a463f76 100644 --- a/js/src/local-fixes.js +++ b/js/src/local-fixes.js @@ -1,10 +1,10 @@ // TeSLA-specific fixes ~~ usability and clarity. // OUOP.local_fixes = function -module.exports = function ($, resp) { +module.exports = function ($) { fix_typing_enrollment_page($); - fix_enrollment_start_page($, resp); + fix_enrollment_start_page($); console.warn('ouop: tesla-local-fixes'); }; @@ -42,7 +42,7 @@ function fix_typing_enrollment_page($) { } // 14-August-2017. -function fix_enrollment_start_page($, resp) { +function fix_enrollment_start_page($) { var $alert = $('#page-local-tesla-views-enrollment #user-notifications .alert'); var message = $alert.text(); var m_enroll = message ? message.match(/The required enrollments are: ([\w ]+)/) : null; diff --git a/js/src/moodle-user-profile.js b/js/src/moodle-user-profile.js index 6c43712..c5c685d 100644 --- a/js/src/moodle-user-profile.js +++ b/js/src/moodle-user-profile.js @@ -33,7 +33,7 @@ function complete_user_profile_form ($, resp) { } C.debug('ouop: complete-user-profile-form'); -}; +} function user_profile_form_redirect ($, resp) { var $form = $('#page-user-edit #region-main form'); @@ -53,7 +53,7 @@ function user_profile_form_redirect ($, resp) { } else { $form.before(util.alert(util.str('form_redirect_msg'), 'ouop-form-disable')); } -}; +} function user_profile_continue_link ($, resp) { var $pages = $('#page-user-profile, #page-user-preferences'); diff --git a/js/src/ouop-utils.js b/js/src/ouop-utils.js index 93e913c..659a7dd 100644 --- a/js/src/ouop-utils.js +++ b/js/src/ouop-utils.js @@ -1,7 +1,5 @@ // Utility functions. -'use strict'; - // Javascript translation/localisation [i18n]. var trans = {}; diff --git a/js/src/survey-embed-link.js b/js/src/survey-embed-link.js index abd0ebb..e57aef7 100644 --- a/js/src/survey-embed-link.js +++ b/js/src/survey-embed-link.js @@ -1,7 +1,5 @@ // Embed or link to BOS pilot surveys. -'use strict'; - module.exports = function ($, resp) { embed_pilot_surveys($, resp); diff --git a/package.json b/package.json index 251e098..4a36409 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": true, "name": "moodle-auth-ouopenid", "description": "(See - 'composer.json') | © The Open University.", - "version": "1.3.0-beta", + "version": "2.0.0-beta", "license": "UNLICENSED", "main": "js/index.js", "devDependencies": { @@ -22,9 +22,25 @@ "uglify-2": "uglifyjs js/src/_comment.js dist.js --comments -co dist.min.js", "uglify": "uglifyjs user/*.js --comments='/^!/' -bo ouop.min.js", "less": "lessc style/*.less style/ouop-styles.css", - "eslint": "eslint js/ src/ user/*.js && echo eslint OK!", + "eslint": "eslint js/ js/src/ user/*.js && echo eslint OK!", "semi": "semistandard" }, + + "eslintConfig": { + "extends": "eslint:recommended", + "env": { "commonjs": true }, + "globals": { "window": false, "console": false, "ga": false } + }, + "jshintConfig": { + "browserify": true, + "curly": true, + "eqeqeq": true, + "nocomma": true, + "undef": true, + "unused": true, + "onecase": true, + "globals": { "window": false, "console": false, "ga": false } + }, "semistandard": { "ignore": [ "bundle.js",