Permalink
Browse files

MDL-54944 eslint: Add rules from Policy decision

Also bump eslint to v2.13.1 and make the version explicit in
package.json
  • Loading branch information...
danpoltawski committed Jun 28, 2016
1 parent 5a1728d commit 037de719966aaf8de9e2dbffb2121e407eb4bb40
Showing with 82 additions and 59 deletions.
  1. +31 −23 .eslintrc
  2. +7 −2 Gruntfile.js
  3. +2 −0 admin/tool/lp/amd/src/tree.js
  4. +2 −0 lib/amd/src/tree.js
  5. +39 −34 npm-shrinkwrap.json
  6. +1 −0 package.json
View
@@ -9,10 +9,10 @@
},
'rules': {
// See http://eslint.org/docs/rules/ for all rules and explanations of all
// rules. Commented out rules with 'DEFINE POLICY' are rules Dan P has flagged
// for discussion and possible enable soon.
// rules.
// === Possible Errors ===
// DEFINE POLICY: 'comma-dangle': ['off', 'always'],
'comma-dangle': 'off',
'no-cond-assign': 'error',
'no-console': 'error',
'no-constant-condition': 'error',
@@ -21,7 +21,7 @@
'no-dupe-args': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
// Disabled for YUI rollups, enabled by grunt for AMD: 'no-empty': 'error',
'no-empty': 'warn',
'no-empty-character-class': 'error',
'no-ex-assign': 'error',
'no-extra-boolean-cast': 'error',
@@ -45,18 +45,25 @@
// === Best Practices ===
// (these mostly match our jshint config)
'array-callback-return': 'warn',
'block-scoped-var': 'warn',
'complexity': 'warn',
'consistent-return': 'warn',
'curly': 'error',
'dot-notation': 'warn',
'no-alert': 'warn',
'no-caller': 'error',
'no-case-declarations': 'error',
'no-div-regex': 'error',
'no-empty-pattern': 'error',
'no-empty-function': 'warn',
//DEFINE POLICY: 'no-eq-null': 'warn',
'no-eq-null': 'error',
'no-eval': 'error',
//DEFINE POLICY: 'no-extra-bind': 'warn',
'no-extend-native': 'error',
'no-extra-bind': 'warn',
'no-fallthrough': 'error',
//DEFINE POLICY: 'no-implicit-globals': 'warn',
'no-floating-decimal': 'warn',
// Disabled for YUI rollups, enabled by grunt for AMD: 'no-implicit-globals': 'warn',
'no-implied-eval': 'error',
'no-invalid-this': 'error',
'no-iterator': 'error',
@@ -67,26 +74,28 @@
'no-native-reassign': 'warn',
'no-new-func': 'error',
'no-new-wrappers': 'error',
// DEFINE POLICY: no-octal: "error"
// DEFINE POLICY: no-octal-escape: "error"
'no-octal': 'error',
'no-octal-escape': 'error',
'no-proto': 'error',
'no-redeclare': 'warn',
'no-return-assign': 'error',
'no-script-url': 'error',
'no-self-assign': 'error',
'no-self-compare': 'error',
'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-labels': 'error',
//DEFINE POLICY: 'no-useless-call': 'error',
'no-useless-call': 'warn',
'no-useless-escape': 'warn',
//DEFINE POLICY: 'no-with': 'error',
'no-with': 'error',
'wrap-iife': ['error', 'any'],
// === Variables ===
'no-delete-var': 'error',
// Disabled for YUI rollups, enabled by grunt for AMD: 'no-undef': 'off',
//DEFINE POLICY: 'no-undef-init': 'error',
'no-undef-init': 'error',
// Disabled for YUI rollups, enabled by grunt for AMD: 'no-unused-vars': 'error',
// === Stylistic Issues ===
@@ -109,17 +118,16 @@
'lines-around-comment': 'off',
'max-len': ['error', 132],
'max-lines': 'off',
// DEFINE POLICY: turn on some of these max values?
'max-depth': 'off',
'max-nested-callbacks': 'off',
'max-depth': 'warn',
'max-nested-callbacks': ['warn', 5],
'max-params': 'off',
'max-statements': 'off',
'max-statements-per-line': 'off',
'max-statements-per-line': ['warn', { max: 2 }],
'new-cap': ['warn', { 'properties': false }],
'new-parens': 'warn',
'newline-after-var': 'off',
'newline-before-return': 'off',
// REVIST POLICY: 'newline-per-chained-call': 'warn',
'newline-per-chained-call': 'off',
'no-array-constructor': 'off',
'no-bitwise': 'error',
'no-continue': 'off',
@@ -136,17 +144,17 @@
'no-ternary': 'off',
'no-trailing-spaces': 'error',
'no-underscore-dangle': 'off',
// DEFINE POLICY: 'no-unneeded-ternary': 'off',
'no-unneeded-ternary': 'off',
'no-whitespace-before-property': 'warn',
// DEFINE POLICY: 'object-curly-newline': 'off,
// DEFINE POLICY: 'object-curly-spacing': 'off',
// DEFINE POLICY: 'object-property-newline': 'off',
'object-curly-newline': 'off',
'object-curly-spacing': 'warn',
'object-property-newline': 'off',
'one-var': 'off',
// DEFINE POLICY: 'one-var-declaration-per-line': 'off',
'one-var-declaration-per-line': ['warn', 'initializations'],
'operator-assignment': 'off',
'operator-linebreak': 'off',
'padded-blocks': 'off',
// DEFINE POLICY: 'quote-props': 'off',
'quote-props': ['warn', 'as-needed', {'unnecessary': false, 'keywords': true, 'numbers': true}],
'quotes': 'off',
'require-jsdoc': 'warn',
'semi': 'error',
View
@@ -104,13 +104,18 @@ module.exports = function(grunt) {
eslint: {
// 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') },
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-empty': 'error', 'no-unused-expressions': 'error'}
rules: {
'no-undef': 'error',
'no-unused-vars': 'error',
'no-unused-expressions': 'error',
'no-implicit-globals': 'error'
}
}
},
// Check YUI module source files.
@@ -274,6 +274,8 @@ define(['jquery', 'core/url', 'core/log'], function($, url, log) {
* @param {Event} e The event.
* @return {Boolean}
*/
// This function should be simplified. In the meantime..
// eslint-disable-next-line complexity
Tree.prototype.handleKeyDown = function(item, e) {
var currentIndex = this.visibleItems.index(item);
var newItem = null;
View
@@ -343,6 +343,8 @@ define(['jquery'], function($) {
* @param {Event} e The event.
* @return {Boolean}
*/
// This function should be simplified. In the meantime..
// eslint-disable-next-line complexity
Tree.prototype.handleKeyDown = function(item, e) {
var currentIndex = this.getVisibleItems().index(item);
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -4,6 +4,7 @@
"description": "Moodle",
"devDependencies": {
"async": "^1.5.2",
"eslint": "^2.13.1",
"grunt": "0.4.5",
"grunt-contrib-less": "1.1.0",
"grunt-contrib-uglify": "0.11.0",

0 comments on commit 037de71

Please sign in to comment.