Repository: brenolf/polyjuice (js)

Issue:
Add `requireCapitalizedConstructorsNew` rule
http://jscs.info/rule/requireCapitalizedConstructorsNew

Pull request description:
Resolves #51

Patch:
diff --git a/lib/dictionaries/jscs/requireCapitalizedConstructorsNew.js b/lib/dictionaries/jscs/requireCapitalizedConstructorsNew.js
new file mode 100644
index 0000000..45fe17b
--- /dev/null
+++ b/lib/dictionaries/jscs/requireCapitalizedConstructorsNew.js
@@ -0,0 +1,27 @@
+/**
+* @fileoverview Translation for `requireCapitalizedConstructorsNew` (JSCS) to ESLint
+* @author Breno Lima de Freitas <https://breno.io>
+* @copyright 2016 Breno Lima de Freitas. All rights reserved.
+* See LICENSE file in root directory for full license.
+*/
+
+'use strict'
+
+//------------------------------------------------------------------------------
+// Rule Translation Definition
+//------------------------------------------------------------------------------
+
+module.exports = {
+  name: 'new-cap',
+  truthy: function(__current__, value) {
+    if (value !== true) {
+      return [2, {
+        capIsNewExceptions: value.allExcept
+      }]
+    }
+
+    return [2, {
+      capIsNewExceptions: []
+    }]
+  }
+};


Test patch:
diff --git a/test/dictionaries/jscs/requireCapitalizedConstructorsNew.test.js b/test/dictionaries/jscs/requireCapitalizedConstructorsNew.test.js
new file mode 100644
index 0000000..343ce45
--- /dev/null
+++ b/test/dictionaries/jscs/requireCapitalizedConstructorsNew.test.js
@@ -0,0 +1,32 @@
+/**
+ * @fileoverview Tests for `requireCapitalizedConstructorsNew` (JSCS) translation
+ * @author Breno Lima de Freitas <https://breno.io>
+ * @copyright 2016 Breno Lima de Freitas. All rights reserved.
+ * See LICENSE file in root directory for full license.
+ */
+
+'use strict'
+
+//------------------------------------------------------------------------------
+// Requirements
+//------------------------------------------------------------------------------
+
+var lib = require('../../../lib/dictionaries/jscs/requireCapitalizedConstructorsNew.js')
+
+var getFn = caller(lib)
+
+describe('jscs#requireCapitalizedConstructorsNew', function() {
+  it('converts the rule correctly', function() {
+    var fn = getFn()
+
+    expect(fn(true)).to.eql([2, {
+      capIsNewExceptions: []
+    }])
+
+    expect(fn({
+      allExcept: ['A', 'B', 'C']
+    })).to.eql([2, {
+      capIsNewExceptions: ['A', 'B', 'C']
+    }])
+  })
+})