MDL-52127 js: switch to a more YUI tolerant eslint config
authorDan Poltawski <dan@moodle.com>
Sat, 14 May 2016 10:10:13 +0000 (11:10 +0100)
committerDan Poltawski <dan@moodle.com>
Mon, 13 Jun 2016 23:37:28 +0000 (00:37 +0100)
Instead of having the stricter configuration for all files, use
the less strict default config and switch to the stricter config
for building AMD modules.

This means that the eslint commandline/editor inspections will work
better for all files and not generate false positives when using editor
integrations. But since grunt is required to build AMD modules we still
get the stricter checking for those files on build.

13 files changed:
.eslintrc
Gruntfile.js
lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js
lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js
lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js
lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js
lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js
lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js
lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js
lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js
lib/yui/src/notification/js/shared.js

index 05a6283..31bd8ab 100644 (file)
--- a/.eslintrc
+++ b/.eslintrc
@@ -21,7 +21,7 @@
     'no-dupe-args': 'error',
     'no-dupe-keys': 'error',
     'no-duplicate-case': 'error',
-    'no-empty': 'error',
+    // Disabled for YUI rollups, enabled by grunt for AMD: 'no-empty': 'error',
     'no-empty-character-class': 'error',
     'no-ex-assign': 'error',
     'no-extra-boolean-cast': 'error',
@@ -76,7 +76,7 @@
     'no-self-assign': 'error',
     'no-self-compare': 'error',
     'no-unmodified-loop-condition': 'error',
-    'no-unused-expressions': 'error',
+    // Disabled for YUI rollups, enabled by grunt for AMD: 'no-unused-expressions': 'error',
     'no-unused-labels': 'error',
     //DEFINE POLICY: 'no-useless-call': 'error',
     'no-useless-escape': 'warn',
@@ -85,9 +85,9 @@
 
     // === Variables ===
     'no-delete-var': 'error',
-    'no-undef': 'error',
+    // Disabled for YUI rollups, enabled by grunt for AMD: 'no-undef': 'off',
     //DEFINE POLICY: 'no-undef-init': 'error',
-    'no-unused-vars': 'error',
+    // Disabled for YUI rollups, enabled by grunt for AMD: 'no-unused-vars': 'error',
 
     // === Stylistic Issues ===
     'array-bracket-spacing': 'warn',
index f152d3e..2ec167e 100644 (file)
@@ -75,13 +75,15 @@ module.exports = function(grunt) {
             // * It will complain about ignored files (https://github.com/sindresorhus/grunt-eslint/issues/119)
             // * It's better experience to use editor integrations or eslint natively
             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.
+            // Check AMD files. We add some stricter rules which we can't apply to the default configuration due
+            // to YUI rollups.
+            amd: {
+              src: amdSrc,
+              options: { rules: {'no-undef': 'error', 'no-unused-vars': 'error', 'no-empty': 'error', 'no-unused-expressions': 'error'} }
+            },
+            // Check YUI module source files.
             yui: {
-               src: ['**/yui/src/**/*.js'],
-               options: {globals: ['Y', 'YUI'], rules: {'no-undef': 'off', 'no-unused-vars': 'off', 'no-empty': 'off'} }
+               src: ['**/yui/src/**/*.js']
             }
         },
         uglify: {
index ecd1ea5..bebacc1 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js and b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js differ
index ecd1ea5..bebacc1 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js and b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js differ
index b0115ec..1fa7732 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js and b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js differ
index b0115ec..1fa7732 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js and b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js differ
index b98dfe1..459e595 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js and b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js differ
index b98dfe1..459e595 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js and b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js differ
index f2f2ddd..86f372c 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js and b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js differ
index 92c1643..26caaf2 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js and b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js differ
index 219d336..6f43932 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js and b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js differ
index 219d336..6f43932 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js and b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js differ
index b80eb43..362bd76 100644 (file)
@@ -1,4 +1,3 @@
-/* eslint-disable */
 var DIALOGUE_PREFIX,
     BASE,
     CONFIRMYES,