Repository: brenolf/polyjuice (js)

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

Pull request:
Resolves #43

Patch:
diff --git a/lib/dictionaries/jscs/disallowUnusedParams.js b/lib/dictionaries/jscs/disallowUnusedParams.js
index 35c0f42..ae97904 100644
--- a/lib/dictionaries/jscs/disallowUnusedParams.js
+++ b/lib/dictionaries/jscs/disallowUnusedParams.js
@@ -11,4 +11,18 @@
 // Rule Translation Definition
 //------------------------------------------------------------------------------
 
-module.exports = 'no-unused-vars';
+module.exports = {
+  name: 'no-unused-vars',
+  truthy: function(__current__) {
+    if (__current__) {
+      __current__[1].args = 'all'
+
+      return __current__
+    }
+
+    return [2, {
+      vars: 'local',
+      args: 'all'
+    }]
+  }
+}
diff --git a/lib/dictionaries/jscs/disallowUnusedVariables.js b/lib/dictionaries/jscs/disallowUnusedVariables.js
new file mode 100644
index 0000000..8a75381
--- /dev/null
+++ b/lib/dictionaries/jscs/disallowUnusedVariables.js
@@ -0,0 +1,28 @@
+/**
+* @fileoverview Translation for `disallowUnusedVariables` (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: 'no-unused-vars',
+  truthy: function(__current__) {
+    if (__current__) {
+      __current__[1].vars = 'all'
+
+      return __current__
+    }
+
+    return [2, {
+      vars: 'all',
+      args: 'none'
+    }]
+  }
+}


Test patch:
diff --git a/test/dictionaries/jscs/disallowUnusedParams.test.js b/test/dictionaries/jscs/disallowUnusedParams.test.js
new file mode 100644
index 0000000..b2c33b1
--- /dev/null
+++ b/test/dictionaries/jscs/disallowUnusedParams.test.js
@@ -0,0 +1,37 @@
+/**
+ * @fileoverview Tests for `disallowUnusedParams` (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/disallowUnusedParams.js')
+
+var getFn = caller(lib)
+
+describe('jscs#disallowUnusedParams', function() {
+  it('converts the rule correctly', function() {
+    var fn = getFn()
+
+    var fnBound = getFn([2, {
+      vars: 'xxx',
+      args: 'none'
+    }])
+
+    expect(fn()).to.eql([2, {
+      vars: 'local',
+      args: 'all'
+    }])
+
+    expect(fnBound()).to.eql([2, {
+      vars: 'xxx',
+      args: 'all'
+    }])
+  })
+})
diff --git a/test/dictionaries/jscs/disallowUnusedVariables.test.js b/test/dictionaries/jscs/disallowUnusedVariables.test.js
new file mode 100644
index 0000000..30f061d
--- /dev/null
+++ b/test/dictionaries/jscs/disallowUnusedVariables.test.js
@@ -0,0 +1,37 @@
+/**
+ * @fileoverview Tests for `disallowUnusedVariables` (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/disallowUnusedVariables.js')
+
+var getFn = caller(lib)
+
+describe('jscs#disallowUnusedVariables', function() {
+  it('converts the rule correctly', function() {
+    var fn = getFn()
+
+    var fnBound = getFn([2, {
+      vars: 'local',
+      args: 'xxx'
+    }])
+
+    expect(fn()).to.eql([2, {
+      vars: 'all',
+      args: 'none'
+    }])
+
+    expect(fnBound()).to.eql([2, {
+      vars: 'all',
+      args: 'xxx'
+    }])
+  })
+})