Skip to content

Commit

Permalink
MDL-54944 eslint: make the .eslintrc default stricter
Browse files Browse the repository at this point in the history
Instead of using the more rollup-tolerant config for all files, make the
configuration stricter by default but lower in grunt for yui modules.

This means that manual runs (prechecker) or editor integrations will
flag up the errors as well as grunt.

Also add ignore lines to the core files so that eslint isn't noisy when
not running with grunt.
  • Loading branch information
danpoltawski committed Jul 11, 2016
1 parent 6e30492 commit ad3f8cd
Show file tree
Hide file tree
Showing 100 changed files with 274 additions and 42 deletions.
8 changes: 4 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
'no-extra-bind': 'warn',
'no-fallthrough': 'error',
'no-floating-decimal': 'warn',
// Disabled for YUI rollups, enabled by grunt for AMD: 'no-implicit-globals': 'warn',
// Enabled by grunt for AMD modules: 'no-implicit-globals': 'error',
'no-implied-eval': 'error',
'no-invalid-this': 'error',
'no-iterator': 'error',
Expand All @@ -85,7 +85,7 @@
'no-sequences': 'warn',
'no-throw-literal': 'warn',
'no-unmodified-loop-condition': 'error',
// Disabled for YUI rollups, enabled by grunt for AMD: 'no-unused-expressions': 'error',
'no-unused-expressions': 'error',
'no-unused-labels': 'error',
'no-useless-call': 'warn',
'no-useless-escape': 'warn',
Expand All @@ -94,9 +94,9 @@

// === Variables ===
'no-delete-var': 'error',
// Disabled for YUI rollups, enabled by grunt for AMD: 'no-undef': 'off',
'no-undef': 'error',
'no-undef-init': 'error',
// Disabled for YUI rollups, enabled by grunt for AMD: 'no-unused-vars': 'error',
'no-unused-vars': ['error', { 'caughtErrors': 'none', 'argsIgnorePattern': "(e|event)" }],

// === Stylistic Issues ===
'array-bracket-spacing': 'warn',
Expand Down
21 changes: 12 additions & 9 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,25 @@ 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')},
// 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-unused-expressions': 'error',
'no-implicit-globals': 'error'
}
// Check AMD with some slightly stricter rules.
rules: {
'no-unused-vars': 'error',
'no-implicit-globals': 'error'
}
},
// 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'
}
}
}
},
uglify: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
YUI.add('moodle-course-dragdrop', function (Y, NAME) {

/* eslint-disable no-unused-vars */
/**
* Drag and Drop for course sections and course modules.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
YUI.add('moodle-course-dragdrop', function (Y, NAME) {

/* eslint-disable no-unused-vars */
/**
* Drag and Drop for course sections and course modules.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
YUI.add('moodle-course-management', function (Y, NAME) {

/* global DragDrop, Category, Course */

/**
* Provides drop down menus for list of action links.
*
Expand Down Expand Up @@ -588,6 +590,8 @@ M.course.management.console = null;
M.course.management.init = function(config) {
M.course.management.console = new Console(config);
};
/* global Console */

/**
* Drag and Drop handler
*
Expand Down Expand Up @@ -1173,6 +1177,8 @@ Item.prototype = {
}
};
Y.extend(Item, Y.Base, Item.prototype);
/* global Item */

/**
* A managed category.
*
Expand Down Expand Up @@ -1616,6 +1622,8 @@ Category.prototype = {
}
};
Y.extend(Category, Item, Category.prototype);
/* global Item */

/**
* A managed course.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
YUI.add('moodle-course-management', function (Y, NAME) {

/* global DragDrop, Category, Course */

/**
* Provides drop down menus for list of action links.
*
Expand Down Expand Up @@ -581,6 +583,8 @@ M.course.management.console = null;
M.course.management.init = function(config) {
M.course.management.console = new Console(config);
};
/* global Console */

/**
* Drag and Drop handler
*
Expand Down Expand Up @@ -1147,6 +1151,8 @@ Item.prototype = {
}
};
Y.extend(Item, Y.Base, Item.prototype);
/* global Item */

/**
* A managed category.
*
Expand Down Expand Up @@ -1575,6 +1581,8 @@ Category.prototype = {
}
};
Y.extend(Category, Item, Category.prototype);
/* global Item */

/**
* A managed course.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
YUI.add('moodle-course-toolboxes', function (Y, NAME) {

/* eslint-disable no-unused-vars */
/**
* Resource and activity toolbox class.
*
Expand Down Expand Up @@ -198,6 +199,7 @@ Y.extend(TOOLBOX, Y.Base, {
}
}
);
/* global TOOLBOX, BODY, SELECTOR, INDENTLIMITS */

/**
* Resource and activity toolbox class.
Expand Down Expand Up @@ -749,6 +751,8 @@ M.course.init_resource_toolbox = function(config) {
M.course.resource_toolbox = new RESOURCETOOLBOX(config);
return M.course.resource_toolbox;
};
/* global SELECTOR, TOOLBOX */

/**
* Resource and activity toolbox class.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
YUI.add('moodle-course-toolboxes', function (Y, NAME) {

/* eslint-disable no-unused-vars */
/**
* Resource and activity toolbox class.
*
Expand Down Expand Up @@ -198,6 +199,7 @@ Y.extend(TOOLBOX, Y.Base, {
}
}
);
/* global TOOLBOX, BODY, SELECTOR, INDENTLIMITS */

/**
* Resource and activity toolbox class.
Expand Down Expand Up @@ -749,6 +751,8 @@ M.course.init_resource_toolbox = function(config) {
M.course.resource_toolbox = new RESOURCETOOLBOX(config);
return M.course.resource_toolbox;
};
/* global SELECTOR, TOOLBOX */

/**
* Resource and activity toolbox class.
*
Expand Down
1 change: 1 addition & 0 deletions course/yui/src/dragdrop/js/dragdrop.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
/**
* Drag and Drop for course sections and course modules.
*
Expand Down
2 changes: 2 additions & 0 deletions course/yui/src/management/js/category.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global Item */

/**
* A managed category.
*
Expand Down
2 changes: 2 additions & 0 deletions course/yui/src/management/js/console.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global DragDrop, Category, Course */

/**
* Provides drop down menus for list of action links.
*
Expand Down
2 changes: 2 additions & 0 deletions course/yui/src/management/js/course.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global Item */

/**
* A managed course.
*
Expand Down
2 changes: 2 additions & 0 deletions course/yui/src/management/js/dd.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global Console */

/**
* Drag and Drop handler
*
Expand Down
2 changes: 2 additions & 0 deletions course/yui/src/toolboxes/js/resource.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global TOOLBOX, BODY, SELECTOR, INDENTLIMITS */

/**
* Resource and activity toolbox class.
*
Expand Down
2 changes: 2 additions & 0 deletions course/yui/src/toolboxes/js/section.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global SELECTOR, TOOLBOX */

/**
* Resource and activity toolbox class.
*
Expand Down
2 changes: 1 addition & 1 deletion course/yui/src/toolboxes/js/toolbox.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
/**
* Resource and activity toolbox class.
*
Expand Down Expand Up @@ -196,4 +197,3 @@ Y.extend(TOOLBOX, Y.Base, {
}
}
);

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ YUI.add('moodle-gradereport_grader-gradereporttable', function (Y, NAME) {
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* eslint-disable no-unused-vars */

/**
* Grader Report Functionality.
Expand Down Expand Up @@ -155,6 +156,7 @@ Y.namespace('M.gradereport_grader').init = function(config) {
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global SELECTORS */

/**
* @module moodle-gradereport_grader-gradereporttable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ YUI.add('moodle-gradereport_grader-gradereporttable', function (Y, NAME) {
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* eslint-disable no-unused-vars */

/**
* Grader Report Functionality.
Expand Down Expand Up @@ -155,6 +156,7 @@ Y.namespace('M.gradereport_grader').init = function(config) {
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global SELECTORS */

/**
* @module moodle-gradereport_grader-gradereporttable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global SELECTORS */

/**
* @module moodle-gradereport_grader-gradereporttable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* eslint-disable no-unused-vars */

/**
* Grader Report Functionality.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ YUI.add('moodle-editor_atto-editor', function (Y, NAME) {
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* eslint-disable no-unused-vars */

/**
* The Atto WYSIWG pluggable editor, written for Moodle.
Expand Down Expand Up @@ -735,6 +736,8 @@ Y.Base.mix(Y.M.editor_atto.Editor, [EditorTextArea]);
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global NOTIFY_WARNING, NOTIFY_INFO */
/* eslint-disable no-unused-vars */

/**
* A autosave function for the Atto editor.
Expand Down Expand Up @@ -1250,6 +1253,7 @@ Y.Base.mix(Y.M.editor_atto.Editor, [EditorAutosaveIo]);
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global LOGNAME */

/**
* @module moodle-editor_atto-editor
Expand Down Expand Up @@ -1875,6 +1879,7 @@ Y.Base.mix(Y.M.editor_atto.Editor, [EditorToolbar]);
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global LOGNAME */

/**
* @module moodle-editor_atto-editor
Expand Down Expand Up @@ -2083,6 +2088,7 @@ Y.Base.mix(Y.M.editor_atto.Editor, [EditorToolbarNav]);
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global rangy */

/**
* @module moodle-editor_atto-editor
Expand Down Expand Up @@ -2503,6 +2509,7 @@ Y.Base.mix(Y.M.editor_atto.Editor, [EditorSelection]);
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global rangy */

/**
* @module moodle-editor_atto-editor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ YUI.add('moodle-editor_atto-editor', function (Y, NAME) {
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* eslint-disable no-unused-vars */

/**
* The Atto WYSIWG pluggable editor, written for Moodle.
Expand Down Expand Up @@ -730,6 +731,8 @@ Y.Base.mix(Y.M.editor_atto.Editor, [EditorTextArea]);
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global NOTIFY_WARNING, NOTIFY_INFO */
/* eslint-disable no-unused-vars */

/**
* A autosave function for the Atto editor.
Expand Down Expand Up @@ -1239,6 +1242,7 @@ Y.Base.mix(Y.M.editor_atto.Editor, [EditorAutosaveIo]);
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global LOGNAME */

/**
* @module moodle-editor_atto-editor
Expand Down Expand Up @@ -1863,6 +1867,7 @@ Y.Base.mix(Y.M.editor_atto.Editor, [EditorToolbar]);
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global LOGNAME */

/**
* @module moodle-editor_atto-editor
Expand Down Expand Up @@ -2069,6 +2074,7 @@ Y.Base.mix(Y.M.editor_atto.Editor, [EditorToolbarNav]);
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global rangy */

/**
* @module moodle-editor_atto-editor
Expand Down Expand Up @@ -2489,6 +2495,7 @@ Y.Base.mix(Y.M.editor_atto.Editor, [EditorSelection]);
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/* global rangy */

/**
* @module moodle-editor_atto-editor
Expand Down
Loading

0 comments on commit ad3f8cd

Please sign in to comment.