From 6f601313f048a762dd05bbd142e40f6b2fa7b09e Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Tue, 8 Aug 2017 14:27:55 +0100 Subject: [PATCH] MDL-59761 eslint: support glob-based configuration Since ESlint 4.1.0 [1], it's possible to support glob-based configuration, this means we can move glob configuration out of grunt and into the config file, which means tools will respect the glob rules now too. :) [1] http://eslint.org/blog/2017/06/eslint-v4.1.0-released --- .eslintrc | 22 ++++++++++++++++++++-- Gruntfile.js | 21 ++------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.eslintrc b/.eslintrc index 4915621168067..961467d66f484 100644 --- a/.eslintrc +++ b/.eslintrc @@ -68,7 +68,6 @@ 'no-fallthrough': 'error', 'no-floating-decimal': 'warn', 'no-global-assign': 'warn', - // Enabled by grunt for AMD modules: 'no-implicit-globals': 'error', 'no-implied-eval': 'error', 'no-invalid-this': 'error', 'no-iterator': 'error', @@ -192,5 +191,24 @@ 'message': 'Use AMD module "core/str" or M.util.get_string()' }], - } + }, + overrides: [ + { + files: ["**/yui/src/**/*.js"], + // Disable some rules which we can't safely define for YUI rollups. + rules: { + 'no-undef': 'off', + 'no-unused-vars': 'off', + 'no-unused-expressions': 'off' + } + }, + { + files: ["**/amd/src/*.js"], + // Check AMD with some slightly stricter rules. + rules: { + 'no-unused-vars': 'error', + 'no-implicit-globals': 'error' + } + } + ] } diff --git a/Gruntfile.js b/Gruntfile.js index 2026c238607df..e0afa2dd8a1e5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -112,26 +112,9 @@ module.exports = function(grunt) { // Even though warnings dont stop the build we don't display warnings by default because // at this moment we've got too many core warnings. options: {quiet: !grunt.option('show-lint-warnings')}, - amd: { - src: amdSrc, - // Check AMD with some slightly stricter rules. - rules: { - 'no-unused-vars': 'error', - 'no-implicit-globals': 'error' - } - }, + amd: {src: amdSrc}, // Check YUI module source files. - yui: { - src: ['**/yui/src/**/*.js', '!*/**/yui/src/*/meta/*.js'], - options: { - // Disable some rules which we can't safely define for YUI rollups. - rules: { - 'no-undef': 'off', - 'no-unused-vars': 'off', - 'no-unused-expressions': 'off' - } - } - } + yui: {src: ['**/yui/src/**/*.js', '!*/**/yui/src/*/meta/*.js']} }, uglify: { amd: {