From a1587268cba24afce039ab1cd3b482d2d8639805 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Wed, 11 May 2016 11:38:46 +0100 Subject: [PATCH] MDL-52127 js: check YUI modules with eslint Because we don't have the entire YUI rollup, we can't apply some of the rules safely, so we ignore some rules. At this point I am not 100% certain this configuration is robust enough, to deal with the lack fo rollup knowledge although its a good sign that there are no errors on our entire yui codebase. --- .eslintignore | 3 +++ Gruntfile.js | 13 ++++++++++--- .../moodle-core-notification-ajaxexception-debug.js | 1 + .../moodle-core-notification-ajaxexception.js | 1 + .../moodle-core-notification-alert-debug.js | 1 + .../moodle-core-notification-alert.js | 1 + .../moodle-core-notification-confirm-debug.js | 1 + .../moodle-core-notification-confirm.js | 1 + .../moodle-core-notification-dialogue-debug.js | 1 + .../moodle-core-notification-dialogue.js | 1 + .../moodle-core-notification-exception-debug.js | 1 + .../moodle-core-notification-exception.js | 1 + lib/yui/src/notification/js/shared.js | 1 + 13 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.eslintignore b/.eslintignore index 1db19ddf707..a6821676629 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,6 @@ theme/bootstrapbase/amd/src/bootstrap.js lib/amd/src/mustache.js lib/amd/src/loglevel.js +lib/editor/atto/yui/src/rangy/ +**/yui/src/*/meta/*.js +lib/yui/src/notification/js/shared.js diff --git a/Gruntfile.js b/Gruntfile.js index fb30aceb080..f152d3e1d1f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -77,6 +77,12 @@ module.exports = function(grunt) { options: { quiet: !grunt.option('show-lint-warnings') }, // Check AMD files with standard config amd: { src: amdSrc }, + // Some rules disabled for YUI config, because we don't do rollup magic, so its able to be accurate + // about undefined items. + yui: { + src: ['**/yui/src/**/*.js'], + options: {globals: ['Y', 'YUI'], rules: {'no-undef': 'off', 'no-unused-vars': 'off', 'no-empty': 'off'} } + } }, uglify: { amd: { @@ -112,7 +118,7 @@ module.exports = function(grunt) { }, yui: { files: ['**/yui/src/**/*.js'], - tasks: ['shifter'] + tasks: ['yui'] }, }, shifter: { @@ -215,7 +221,7 @@ module.exports = function(grunt) { tasks.startup = function() { // Are we in a YUI directory? if (path.basename(path.resolve(cwd, '../../')) == 'yui') { - grunt.task.run('shifter'); + grunt.task.run('yui'); // Are we in an AMD directory? } else if (inAMD) { grunt.task.run('amd'); @@ -252,8 +258,9 @@ module.exports = function(grunt) { // Register JS tasks. grunt.registerTask('shifter', 'Run Shifter against the current directory', tasks.shifter); + grunt.registerTask('yui', ['eslint:yui', 'shifter']); grunt.registerTask('amd', ['eslint:amd', 'jshint', 'uglify']); - grunt.registerTask('js', ['amd', 'shifter']); + grunt.registerTask('js', ['amd', 'yui']); // Register CSS taks. grunt.registerTask('css', ['less:bootstrapbase']); diff --git a/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js index bebacc1d174..ecd1ea534c1 100644 --- a/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js +++ b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js @@ -1,5 +1,6 @@ YUI.add('moodle-core-notification-ajaxexception', function (Y, NAME) { +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES, diff --git a/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js index bebacc1d174..ecd1ea534c1 100644 --- a/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js +++ b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js @@ -1,5 +1,6 @@ YUI.add('moodle-core-notification-ajaxexception', function (Y, NAME) { +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES, diff --git a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js index 1fa77324b20..b0115ec8476 100644 --- a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js +++ b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js @@ -1,5 +1,6 @@ YUI.add('moodle-core-notification-alert', function (Y, NAME) { +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES, diff --git a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js index 1fa77324b20..b0115ec8476 100644 --- a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js +++ b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js @@ -1,5 +1,6 @@ YUI.add('moodle-core-notification-alert', function (Y, NAME) { +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES, diff --git a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js index 459e5951b67..b98dfe19fa7 100644 --- a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js +++ b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js @@ -1,5 +1,6 @@ YUI.add('moodle-core-notification-confirm', function (Y, NAME) { +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES, diff --git a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js index 459e5951b67..b98dfe19fa7 100644 --- a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js +++ b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js @@ -1,5 +1,6 @@ YUI.add('moodle-core-notification-confirm', function (Y, NAME) { +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES, diff --git a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js index 86f372cba1c..f2f2ddd2910 100644 --- a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js +++ b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js @@ -1,5 +1,6 @@ YUI.add('moodle-core-notification-dialogue', function (Y, NAME) { +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES, diff --git a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js index 26caaf2a363..92c164348d2 100644 --- a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js +++ b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js @@ -1,5 +1,6 @@ YUI.add('moodle-core-notification-dialogue', function (Y, NAME) { +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES, diff --git a/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js index 6f439323eb1..219d336b5e5 100644 --- a/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js +++ b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js @@ -1,5 +1,6 @@ YUI.add('moodle-core-notification-exception', function (Y, NAME) { +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES, diff --git a/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js index 6f439323eb1..219d336b5e5 100644 --- a/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js +++ b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js @@ -1,5 +1,6 @@ YUI.add('moodle-core-notification-exception', function (Y, NAME) { +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES, diff --git a/lib/yui/src/notification/js/shared.js b/lib/yui/src/notification/js/shared.js index 362bd766c9b..b80eb437a46 100644 --- a/lib/yui/src/notification/js/shared.js +++ b/lib/yui/src/notification/js/shared.js @@ -1,3 +1,4 @@ +/* eslint-disable */ var DIALOGUE_PREFIX, BASE, CONFIRMYES,