MDL-57139 eslint: enable eslint-plugin-promise rules
authorDan Poltawski <dan@moodle.com>
Fri, 16 Dec 2016 10:13:25 +0000 (10:13 +0000)
committerDan Poltawski <dan@moodle.com>
Thu, 1 Jun 2017 09:27:58 +0000 (10:27 +0100)
For promise best practices

.eslintrc
npm-shrinkwrap.json
package.json

index 3514759..c50d2bb 100644 (file)
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,4 +1,7 @@
 {
+  'plugins': [
+    'promise',
+  ],
   'env': {
     'browser': true,
     'amd': true
     'unicode-bom': 'error',
     'wrap-regex': 'off',
 
+    // === Promises ===
+    'promise/always-return': 'warn',
+    'promise/no-return-wrap': 'warn',
+    'promise/param-names': 'warn',
+    'promise/catch-or-return': ['warn', {terminationMethod: ['catch', 'fail']}],
+    'promise/no-native': 'warn',
+    'promise/no-promise-in-callback': 'warn',
+    'promise/no-callback-in-promise': 'warn',
+    'promise/avoid-new': 'warn',
+
     // === Deprecations ===
     "no-restricted-properties": ['warn', {
         'object': 'M',
         'property': 'str',
         'message': 'Use AMD module "core/str" or M.util.get_string()'
     }],
+
   }
 }
index 3792266..19a7c66 100644 (file)
       "integrity": "sha1-f6qEWZ4P6kIvBLwy20kFQFGj8Ro=",
       "dev": true
     },
+    "eslint-plugin-promise": {
+      "version": "3.5.0",
+      "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.5.0.tgz",
+      "integrity": "sha1-ePu2/+BHIBYnVp6FpsU3OvKmj8o=",
+      "dev": true
+    },
     "espree": {
       "version": "3.4.3",
       "resolved": "https://registry.npmjs.org/espree/-/espree-3.4.3.tgz",
index 2a7d142..0ee1295 100644 (file)
@@ -5,6 +5,7 @@
   "devDependencies": {
     "async": "1.5.2",
     "eslint": "3.7.1",
+    "eslint-plugin-promise": "3.5.0",
     "gherkin-lint": "1.1.3",
     "grunt": "1.0.1",
     "grunt-contrib-less": "1.3.0",