From 58c28cb158c31b733837f8f185c686db75f801f2 Mon Sep 17 00:00:00 2001 From: Vitaly Kramskikh Date: Thu, 14 Jul 2016 18:07:36 +0300 Subject: [PATCH] Enforce ES2015 syntax The whole project is going to use ES2015, so it's important to enforce usage of the new syntax to the project code homogeneous. This commit enforces usage of arrow functions where possible, let/const instead of var and rest/spread operator instead of arguments and call/apply. Change-Id: I2fd33400d7d4a3ed23363ceaaf0c2d2f1bd55c47 --- .eslintrc | 21 +++++++++++++++++++++ test/unit/indexTest.js | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index aaeb295..5891fe4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,3 +3,24 @@ extends: openstack parserOptions: ecmaVersion: 6 sourceType: module + +rules: + # disallow unnecessary .call() and .apply() + # http://eslint.org/docs/rules/no-useless-call + no-useless-call: 2 + + # require let or const instead of var + # http://eslint.org/docs/rules/no-var + no-var: 2 + + # suggest using arrow functions as callbacks + # http://eslint.org/docs/rules/prefer-arrow-callback + prefer-arrow-callback: 2 + + # suggest using the spread operator instead of .apply(). + # http://eslint.org/docs/rules/prefer-spread + prefer-spread: 2 + + # suggest using the rest parameters instead of arguments + # http://eslint.org/docs/rules/prefer-rest-params + prefer-rest-params: 2 diff --git a/test/unit/indexTest.js b/test/unit/indexTest.js index f4f8d01..1b0edf2 100644 --- a/test/unit/indexTest.js +++ b/test/unit/indexTest.js @@ -2,7 +2,7 @@ import Test from "../../src/index.js"; describe("Simple test", () => { it("should export a class", () => { - var t = new Test(); + let t = new Test(); expect(t).toBeDefined(); }); });