From d67ab88e21c5a1deaa4f47e1689c3e7222acf635 Mon Sep 17 00:00:00 2001 From: Michael Krotscheck Date: Fri, 28 Aug 2015 10:13:59 -0700 Subject: [PATCH] Added test for new rules This patch adds unit tests that ensure new rules - added by an eslint upgrade perhaps - are not missed. The patch also adds those rules that have already fallen through the cracks. Change-Id: Idf84af253995690bd7043813a8c891c96f443e0f --- .eslintrc | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ spec/index.js | 12 ++++++++ 2 files changed, 91 insertions(+) diff --git a/.eslintrc b/.eslintrc index 6976fba..08be54a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -171,6 +171,10 @@ rules: # http://eslint.org/docs/rules/valid-typeof valid-typeof: 2 + # Avoid code that looks like two expressions but is actually one + # http://eslint.org/docs/rules/no-unexpected-multiline + no-unexpected-multiline: 0 # TODO(krotscheck): Discuss & Activate + ############################################################################# # Best Practices ############################################################################# @@ -261,10 +265,18 @@ rules: # http://eslint.org/docs/rules/no-floating-decimal no-floating-decimal: 2 + # disallow the type conversions with shorter notations + # http://eslint.org/docs/rules/no-implicit-coercion + no-implicit-coercion: 0 # TODO(krotscheck): Discuss & Activate + # Disallow use of eval()-like methods # http://eslint.org/docs/rules/no-implied-eval no-implied-eval: 2 + # disallow this keywords outside of classes or class-like objects + # http://eslint.org/docs/rules/no-invalid-this + no-invalid-this: 0 # TODO(krotscheck): Discuss & Activate + # Disallow usage of __iterator__ property # http://eslint.org/docs/rules/no-iterator no-iterator: 2 @@ -357,6 +369,10 @@ rules: # http://eslint.org/docs/rules/no-unused-expressions no-unused-expressions: 2 + # disallow unnecessary .call() and .apply() + # http://eslint.org/docs/rules/no-useless-call + no-useless-call: 0 # TODO(krotscheck): Discuss & Activate + # Disallow use of void operator # http://eslint.org/docs/rules/no-void no-void: 2 @@ -408,6 +424,10 @@ rules: ############################################################################# # Variable declaration rules ############################################################################# + # enforce or disallow variable initializations at definition + # http://eslint.org/docs/rules/init-declarations + init-declarations: 0 # TODO(krotscheck): Discuss & Activate + # Disallow the catch clause parameter name being the same as a variable in # the outer scope # http://eslint.org/docs/rules/no-catch-shadow @@ -453,6 +473,10 @@ rules: # Node.js rules ############################################################################# + # enforce return after a callback + # http://eslint.org/docs/rules/callback-return + callback-return: 2 + # Enforces error handling in callbacks # http://eslint.org/docs/rules/handle-callback-err handle-callback-err: 2 @@ -486,6 +510,10 @@ rules: # Stylistic Changes ############################################################################# + # enforce spacing inside array brackets + # http://eslint.org/docs/rules/array-bracket-spacing + array-bracket-spacing: 0 # TODO(krotscheck): Discuss & Activate + # Enforce one true brace style # http://eslint.org/docs/rules/brace-style brace-style: 0 # TODO(krotscheck): Discuss & Activate @@ -504,6 +532,10 @@ rules: # http://eslint.org/docs/rules/comma-style comma-style: 2 + # require or disallow padding inside computed properties. + # http://eslint.org/docs/rules/computed-property-spacing + computed-property-spacing: 0 # TODO(krotscheck): Discuss & Activate + # Enforces consistent naming when capturing the current execution context # http://eslint.org/docs/rules/consistent-this consistent-this: @@ -522,6 +554,14 @@ rules: # http://eslint.org/docs/rules/func-style func-style: 0 + # this option enforces minimum and maximum identifier lengths (variable names, property names...) + # http://eslint.org/docs/rules/id-length + id-length: 0 # TODO(krotscheck): Discuss & Activate + + # require identifiers to match the provided regular expression + # http://eslint.org/docs/rules/id-match + id-match: 0 # TODO(krotscheck): Discuss & Activate + # This option sets a specific tab width for your code # http://eslint.org/docs/rules/indent indent: @@ -699,6 +739,10 @@ rules: - words: true nonwords: false + # require or disallow a space immediately following the // or /* in a comment + # http://eslint.org/docs/rules/spaced-comment + spaced-comment: 0 # TODO(krotscheck): Discuss & Activate + # require regex literals to be wrapped in parentheses # http://eslint.org/docs/rules/wrap-regex wrap-regex: 0 @@ -707,10 +751,34 @@ rules: ############################################################################# # ECMAScript 6 (All Off) ############################################################################# + # require parens in arrow function arguments + # http://eslint.org/docs/rules/arrow-parens + arrow-parens: 0 + + # require space before/after arrow function's arrow + # http://eslint.org/docs/rules/arrow-spacing + arrow-spacing: 0 + + # verify calls of super() in constructors + # http://eslint.org/docs/rules/constructor-super + constructor-super: 0 + # enforce the spacing around the * in generator functions # http://eslint.org/docs/rules/generator-star-spacing generator-star-spacing: 0 + # disallow modifying variables of class declarations + # http://eslint.org/docs/rules/no-class-assign + no-class-assign: 0 + + # disallow modifying variables that are declared using const + # http://eslint.org/docs/rules/no-const-assign + no-const-assign: 0 + + # disallow use of this/super before calling super() in constructors + # http://eslint.org/docs/rules/no-this-before-super + no-this-before-super: 0 + # require let or const instead of var # http://eslint.org/docs/rules/no-var no-var: 0 @@ -723,6 +791,17 @@ rules: # http://eslint.org/docs/rules/prefer-const prefer-const: 0 + # suggest using the spread operator instead of .apply(). + # http://eslint.org/docs/rules/prefer-spread + prefer-spread: 0 + + # suggest using Reflect methods where applicable + # http://eslint.org/docs/rules/prefer-reflect + prefer-reflect: 0 + + # disallow generator functions that do not have yield + # http://eslint.org/docs/rules/require-yield + require-yield: 0 ############################################################################# # Legacy diff --git a/spec/index.js b/spec/index.js index d1b5f79..b43115e 100644 --- a/spec/index.js +++ b/spec/index.js @@ -32,6 +32,18 @@ describe("Unit: eslint-config-openstack", function() { /*eslint-enable guard-for-in */ }); + it("should have an opinion on every eslint default rule.", function() { + var eslintDefaults = require('eslint/conf/eslint.json'); + var rules = require('../index').rules; + + /*eslint-disable guard-for-in */ + for (var ruleName in eslintDefaults.rules) { + expect(rules.hasOwnProperty(ruleName)) + .toBeTruthy("Rule " + ruleName + " must be defined."); + } + /*eslint-enable guard-for-in */ + }); + it("should only have opinions on rules that exist (no zombies).", function() { var eslintRules = require('eslint/conf/eslint.json').rules; var openstackRules = require('../index').rules;