MDL-54944 eslint: Add rules from Policy decision
Also bump eslint to v2.13.1 and make the version explicit in package.json
This commit is contained in:
@@ -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',
|
||||
|
||||
+7
-2
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Generated
+39
-34
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"acorn": {
|
||||
"version": "3.2.0",
|
||||
"from": "acorn@>=3.1.0 <4.0.0",
|
||||
"from": "acorn@>=3.2.0 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-3.2.0.tgz"
|
||||
},
|
||||
"acorn-jsx": {
|
||||
@@ -59,14 +59,14 @@
|
||||
}
|
||||
},
|
||||
"array-union": {
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"from": "array-union@>=1.0.1 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.1.tgz"
|
||||
"resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz"
|
||||
},
|
||||
"array-uniq": {
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"from": "array-uniq@>=1.0.1 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz"
|
||||
"resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz"
|
||||
},
|
||||
"arrify": {
|
||||
"version": "1.0.1",
|
||||
@@ -116,9 +116,9 @@
|
||||
}
|
||||
},
|
||||
"bluebird": {
|
||||
"version": "3.4.0",
|
||||
"version": "3.4.1",
|
||||
"from": "bluebird@>=3.1.1 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.0.tgz"
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.1.tgz"
|
||||
},
|
||||
"boom": {
|
||||
"version": "2.10.1",
|
||||
@@ -239,7 +239,7 @@
|
||||
},
|
||||
"concat-stream": {
|
||||
"version": "1.5.1",
|
||||
"from": "concat-stream@>=1.4.1 <2.0.0",
|
||||
"from": "concat-stream@>=1.4.6 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.1.tgz",
|
||||
"dependencies": {
|
||||
"readable-stream": {
|
||||
@@ -332,9 +332,9 @@
|
||||
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz"
|
||||
},
|
||||
"del": {
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"from": "del@>=2.0.2 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/del/-/del-2.2.0.tgz"
|
||||
"resolved": "https://registry.npmjs.org/del/-/del-2.2.1.tgz"
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
@@ -470,9 +470,9 @@
|
||||
}
|
||||
},
|
||||
"eslint": {
|
||||
"version": "2.12.0",
|
||||
"from": "eslint@>=2.0.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-2.12.0.tgz",
|
||||
"version": "2.13.1",
|
||||
"from": "eslint@2.13.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-2.13.1.tgz",
|
||||
"dependencies": {
|
||||
"ansi-styles": {
|
||||
"version": "2.2.1",
|
||||
@@ -505,9 +505,9 @@
|
||||
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz"
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.0.3",
|
||||
"version": "7.0.5",
|
||||
"from": "glob@>=7.0.3 <8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.0.3.tgz"
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.0.5.tgz"
|
||||
},
|
||||
"js-yaml": {
|
||||
"version": "3.6.1",
|
||||
@@ -520,9 +520,9 @@
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz"
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.0",
|
||||
"from": "[email protected].0",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.0.tgz"
|
||||
"version": "3.0.2",
|
||||
"from": "minimatch@^3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.2.tgz"
|
||||
},
|
||||
"progress": {
|
||||
"version": "1.1.8",
|
||||
@@ -537,9 +537,9 @@
|
||||
}
|
||||
},
|
||||
"espree": {
|
||||
"version": "3.1.4",
|
||||
"from": "[email protected].4",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-3.1.4.tgz"
|
||||
"version": "3.1.6",
|
||||
"from": "espree@>=3.1.6 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-3.1.6.tgz"
|
||||
},
|
||||
"esprima": {
|
||||
"version": "1.0.4",
|
||||
@@ -679,6 +679,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"from": "fs.realpath@>=1.0.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
|
||||
},
|
||||
"gaze": {
|
||||
"version": "0.5.2",
|
||||
"from": "gaze@>=0.5.1 <0.6.0",
|
||||
@@ -793,19 +798,19 @@
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-9.8.0.tgz"
|
||||
},
|
||||
"globby": {
|
||||
"version": "4.1.0",
|
||||
"from": "globby@>=4.0.0 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-4.1.0.tgz",
|
||||
"version": "5.0.0",
|
||||
"from": "globby@>=5.0.0 <6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz",
|
||||
"dependencies": {
|
||||
"glob": {
|
||||
"version": "6.0.4",
|
||||
"from": "glob@>=6.0.1 <7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz"
|
||||
"version": "7.0.5",
|
||||
"from": "glob@^7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.0.5.tgz"
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.0",
|
||||
"from": "minimatch@>=2.0.0 <3.0.0||>=3.0.0 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.0.tgz"
|
||||
"version": "3.0.2",
|
||||
"from": "minimatch@>=3.0.2 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.2.tgz"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1013,9 +1018,9 @@
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.11.tgz"
|
||||
},
|
||||
"ignore": {
|
||||
"version": "3.1.2",
|
||||
"version": "3.1.3",
|
||||
"from": "ignore@>=3.1.2 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-3.1.2.tgz"
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-3.1.3.tgz"
|
||||
},
|
||||
"image-size": {
|
||||
"version": "0.3.5",
|
||||
@@ -1039,7 +1044,7 @@
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.1",
|
||||
"from": "inherits@>=2.0.0 <3.0.0",
|
||||
"from": "inherits@>=2.0.1 <2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
|
||||
},
|
||||
"inquirer": {
|
||||
@@ -1765,7 +1770,7 @@
|
||||
},
|
||||
"strip-json-comments": {
|
||||
"version": "1.0.4",
|
||||
"from": "strip-json-comments@>=1.0.0 <1.1.0",
|
||||
"from": "strip-json-comments@>=1.0.1 <1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz"
|
||||
},
|
||||
"supports-color": {
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user