nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: yannickcr/eslint-plugin-react
Pull request #1298 (2017-07-13 04:37:32)

Fix crash in jsx-no-target-blank
`{...spreadProps}` was not working correctly in case there was an external url. Added test case + fix + a small code refactor.

Should fix https://github.com/yannickcr/eslint-plugin-react/issues/1296


Patch:
diff --git a/lib/rules/jsx-no-target-blank.js b/lib/rules/jsx-no-target-blank.js
index 551d640c..a1a7deac 100644
--- a/lib/rules/jsx-no-target-blank.js
+++ b/lib/rules/jsx-no-target-blank.js
@@ -15,7 +15,7 @@ function isTargetBlank(attr) {
 }
 
 function hasExternalLink(element) {
-  return element.attributes.find(function (attr) {
+  return element.attributes.some(function (attr) {
     return attr.name &&
       attr.name.name === 'href' &&
       attr.value.type === 'Literal' &&
@@ -25,7 +25,7 @@ function hasExternalLink(element) {
 
 function hasSecureRel(element) {
   return element.attributes.find(function (attr) {
-    if (attr.name.name === 'rel') {
+    if (attr.type === 'JSXAttribute' && attr.name.name === 'rel') {
       const tags = attr.value && attr.value.type === 'Literal' && attr.value.value.toLowerCase().split(' ');
       return tags && (tags.indexOf('noopener') >= 0 && tags.indexOf('noreferrer') >= 0);
     }


Test patch:
diff --git a/tests/lib/rules/jsx-no-target-blank.js b/tests/lib/rules/jsx-no-target-blank.js
index ecd2c6d6..a0c756cb 100644
--- a/tests/lib/rules/jsx-no-target-blank.js
+++ b/tests/lib/rules/jsx-no-target-blank.js
@@ -31,6 +31,7 @@ ruleTester.run('jsx-no-target-blank', rule, {
     {code: '<a randomTag></a>'},
     {code: '<a href="foobar" target="_blank" rel="noopener noreferrer"></a>'},
     {code: '<a target="_blank" {...spreadProps} rel="noopener noreferrer"></a>'},
+    {code: '<a {...spreadProps} target="_blank" rel="noopener noreferrer" href="http://example.com">s</a>'},
     {code: '<a target="_blank" rel="noopener noreferrer" {...spreadProps}></a>'},
     {code: '<p target="_blank"></p>'},
     {code: '<a href="foobar" target="_BLANK" rel="NOOPENER noreferrer"></a>'},
Repository: yannickcr/eslint-plugin-react
Pull request #1365 (2017-08-13 20:29:05)

[prop types] fix an assignment to prop
fixes issue #1288 


Patch:
diff --git a/lib/rules/prop-types.js b/lib/rules/prop-types.js
index 32b83ed6..6f2a610b 100644
--- a/lib/rules/prop-types.js
+++ b/lib/rules/prop-types.js
@@ -116,6 +116,20 @@ module.exports = {
       return false;
     }
 
+    /**
+    * Checks if a prop is being assigned a value props.bar = 'bar'
+    * @param {ASTNode} node The AST node being checked.
+    * @returns {Boolean}
+    */
+
+    function isAssignmentToProp(node) {
+      return (
+        node.parent &&
+        node.parent.type === 'AssignmentExpression' &&
+        node.parent.left === node
+      );
+    }
+
     /**
      * Checks if we are using a prop
      * @param {ASTNode} node The AST node being checked.
@@ -126,7 +140,7 @@ module.exports = {
         (utils.getParentES6Component() || utils.getParentES5Component()) &&
         node.object.type === 'ThisExpression' && node.property.name === 'props'
       );
-      const isStatelessFunctionUsage = node.object.name === 'props';
+      const isStatelessFunctionUsage = node.object.name === 'props' && !isAssignmentToProp(node);
       const isNextPropsUsage = node.object.name === 'nextProps' && inComponentWillReceiveProps();
       return isClassUsage || isStatelessFunctionUsage || isNextPropsUsage;
     }


Test patch:
diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js
index bc6ec6fe..660caa5e 100644
--- a/tests/lib/rules/prop-types.js
+++ b/tests/lib/rules/prop-types.js
@@ -1557,7 +1557,18 @@ ruleTester.run('prop-types', rule, {
         '}'
       ].join('\n'),
       parser: 'babel-eslint'
-    }
+    },
+    // issue #1288
+    `function Foo() {
+      const props = {}
+      props.bar = 'bar'
+      return <div {...props} />
+    }`,
+    // issue #1288
+    `function Foo(props) {
+      props.bar = 'bar';
+      return <div {...props} />;
+    }`
   ],
 
   invalid: [
Repository: yannickcr/eslint-plugin-react
Pull request #1380 (2017-08-17 02:38:04)

require-default-props - fixing an edge case where linting stops early
This is to fix an edge case where linting stops when it finds a component without props.  Instead it should move on to the next component in the file.

jseminck: Nice find! 

The fix looks good to me. I added a few comments about the tests.

Patch:
diff --git a/lib/rules/require-default-props.js b/lib/rules/require-default-props.js
index 1d14b163..4d8cdf9e 100644
--- a/lib/rules/require-default-props.js
+++ b/lib/rules/require-default-props.js
@@ -578,7 +578,7 @@ module.exports = {
 
           // If no propTypes could be found, we don't report anything.
           if (!list[component].propTypes) {
-            return;
+            continue;
           }
 
           reportPropTypesWithoutDefault(


Test patch:
diff --git a/tests/lib/rules/require-default-props.js b/tests/lib/rules/require-default-props.js
index 07add862..7b50b780 100644
--- a/tests/lib/rules/require-default-props.js
+++ b/tests/lib/rules/require-default-props.js
@@ -1307,6 +1307,25 @@ ruleTester.run('require-default-props', rule, {
       }]
     },
 
+    // component with no declared props followed by a failing component
+    {
+      code: [
+        'var ComponentWithNoProps = ({ bar = "bar" }) => {',
+        '  return <div>Hello {this.props.foo}</div>;',
+        '}',
+        'var Greetings = ({ foo = "foo" }) => {',
+        '  return <div>Hello {this.props.foo}</div>;',
+        '}',
+        'Greetings.propTypes = {',
+        '  foo: PropTypes.string',
+        '};'
+      ].join('\n'),
+      errors: [{
+        message: 'propType "foo" is not required, but has no corresponding defaultProp declaration.',
+        line: 8,
+        column: 3
+      }]
+    },
     //
     // with Flow annotations
     {
Repository: yannickcr/eslint-plugin-react
Pull request #1530 (2017-11-10 23:56:51)

Deprecation check for React.DOM factories 
React.DOM factories were deprecated in 15.6.0 -> https://github.com/facebook/react/pull/8356


Patch:
diff --git a/docs/rules/no-deprecated.md b/docs/rules/no-deprecated.md
index 0296f7d7..77cf0ff7 100644
--- a/docs/rules/no-deprecated.md
+++ b/docs/rules/no-deprecated.md
@@ -23,6 +23,9 @@ const propTypes = {
   foo: PropTypes.bar,
 };
 
+//Any factories under React.DOM
+React.DOM.div();
+
 import React, { PropTypes } from 'react';
 ```
 
diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js
index 0504798c..73f1f6d2 100644
--- a/lib/rules/no-deprecated.js
+++ b/lib/rules/no-deprecated.js
@@ -68,7 +68,8 @@ module.exports = {
       // 15.5.0
       deprecated[`${pragma}.createClass`] = ['15.5.0', 'the npm module create-react-class'];
       deprecated[`${pragma}.PropTypes`] = ['15.5.0', 'the npm module prop-types'];
-
+      // 15.6.0
+      deprecated[`${pragma}.DOM`] = ['15.6.0', 'the npm module react-dom-factories'];
       return deprecated;
     }
 


Test patch:
diff --git a/tests/lib/rules/no-deprecated.js b/tests/lib/rules/no-deprecated.js
index f628ec7a..a360c752 100644
--- a/tests/lib/rules/no-deprecated.js
+++ b/tests/lib/rules/no-deprecated.js
@@ -174,5 +174,11 @@ ruleTester.run('no-deprecated', rule, {
     errors: [{
       message: 'ReactPerf.printDOM is deprecated since React 15.0.0, use ReactPerf.printOperations instead'
     }]
+  },
+  {
+    code: 'React.DOM.div',
+    errors: [{
+      message: 'React.DOM is deprecated since React 15.6.0, use the npm module react-dom-factories instead'
+    }]
   }]
 });
Repository: yannickcr/eslint-plugin-react
Pull request #1698 (2018-02-20 14:45:17)

Allow crossOrigin on audio elements
As audio elements also inherit from HTMLMediaElement and thus have the `crossOrigin` property

Also see:

Audio element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio
HTMLAudioElement: https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement
HTMLMediaElement crossOrigin: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/crossOrigin


Patch:
diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js
index f2ea0e1a..59704d96 100644
--- a/lib/rules/no-unknown-property.js
+++ b/lib/rules/no-unknown-property.js
@@ -26,7 +26,7 @@ const DOM_ATTRIBUTE_NAMES = {
 };
 
 const ATTRIBUTE_TAGS_MAP = {
-  crossOrigin: ['script', 'img', 'video', 'link']
+  crossOrigin: ['script', 'img', 'video', 'audio', 'link']
 };
 
 const SVGDOM_ATTRIBUTE_NAMES = {


Test patch:
diff --git a/tests/lib/rules/no-unknown-property.js b/tests/lib/rules/no-unknown-property.js
index 8fdc4f75..462e4ee5 100644
--- a/tests/lib/rules/no-unknown-property.js
+++ b/tests/lib/rules/no-unknown-property.js
@@ -42,7 +42,8 @@ ruleTester.run('no-unknown-property', rule, {
       code: '<div class="bar"></div>;',
       options: [{ignore: ['class']}]
     },
-    {code: '<script crossOrigin />'}
+    {code: '<script crossOrigin />'},
+    {code: '<audio crossOrigin />'}
   ],
   invalid: [{
     code: '<div class="bar"></div>;',
@@ -88,6 +89,6 @@ ruleTester.run('no-unknown-property', rule, {
     errors: [{message: 'Unknown property \'crossorigin\' found, use \'crossOrigin\' instead'}]
   }, {
     code: '<div crossOrigin />',
-    errors: [{message: 'Invalid property \'crossOrigin\' found on tag \'div\', but it is only allowed on: script, img, video, link'}]
+    errors: [{message: 'Invalid property \'crossOrigin\' found on tag \'div\', but it is only allowed on: script, img, video, audio, link'}]
   }]
 });
Repository: yannickcr/eslint-plugin-react
Pull request #1863 (2018-06-29 12:35:11)

Make attribute "charset" valid
The attribute `charset` was considered an error in favor of `charSet`, but both of them result in valid HTML because HTML is case-insensitive. In other words, these two lines will be interpreted in the same way:

```jsx
<meta charSet="utf-8" />
<meta charset="utf-8" />
```

They will render different HTML (exactly like this JSX suggests), but browsers won't care. If nothing else, `charset` should be the more "correct" form of this attribute because it doesn't suggest a dash (`fillOpacity` = `fill-opacity`, `charSet` ≠ `char-set`).

https://github.com/facebook/react/issues/11492#issuecomment-342953964


Patch:
diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js
index 59704d96..5d03286f 100644
--- a/lib/rules/no-unknown-property.js
+++ b/lib/rules/no-unknown-property.js
@@ -117,7 +117,7 @@ const SVGDOM_ATTRIBUTE_NAMES = {
 const DOM_PROPERTY_NAMES = [
   // Standard
   'acceptCharset', 'accessKey', 'allowFullScreen', 'allowTransparency', 'autoComplete', 'autoFocus', 'autoPlay',
-  'cellPadding', 'cellSpacing', 'charSet', 'classID', 'className', 'colSpan', 'contentEditable', 'contextMenu',
+  'cellPadding', 'cellSpacing', 'classID', 'className', 'colSpan', 'contentEditable', 'contextMenu',
   'dateTime', 'encType', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget',
   'frameBorder', 'hrefLang', 'htmlFor', 'httpEquiv', 'inputMode', 'keyParams', 'keyType', 'marginHeight', 'marginWidth',
   'maxLength', 'mediaGroup', 'minLength', 'noValidate', 'onAnimationEnd', 'onAnimationIteration', 'onAnimationStart',


Test patch:
diff --git a/tests/lib/rules/no-unknown-property.js b/tests/lib/rules/no-unknown-property.js
index 6bb38c07..ea94c867 100644
--- a/tests/lib/rules/no-unknown-property.js
+++ b/tests/lib/rules/no-unknown-property.js
@@ -30,6 +30,8 @@ ruleTester.run('no-unknown-property', rule, {
     {code: '<App class="bar" />;'},
     {code: '<App for="bar" />;'},
     {code: '<App accept-charset="bar" />;'},
+    {code: '<meta charset="utf-8" />;'},
+    {code: '<meta charSet="utf-8" />;'},
     {code: '<App http-equiv="bar" />;'},
     {code: '<App xlink:href="bar" />;'},
     {code: '<App clip-path="bar" />;'},
Repository: edvardchen/eslint-plugin-i18next
Pull request #21 (2020-06-07 21:34:30)

feat: allow ignoring lists of components
we needed this for an icon component that retrieves string literals. thought it might be useful.


Patch:
diff --git a/README.md b/README.md
index 3be4cf0..ab6a0a6 100644
--- a/README.md
+++ b/README.md
@@ -315,3 +315,14 @@ Examples of correct code for the `{ "ignoreProperty": ["foo"] }` option:
 /*eslint i18next/no-literal-string: ["error", { "ignoreProperty": ["foo"] }]*/
 const a = { foo: 'bar' };
 ```
+
+#### ignoreComponent
+
+The `ignoreComponent` option specifies exceptions not to check for string literals inside a list of named components. It includes `<Trans>` per default.
+
+Examples of correct code for the `{ "ignoreComponent": ["Icon"] }` option:
+
+```jsx
+/*eslint i18next/no-literal-string: ["error", { "ignoreComponent": ["Icon"] }]*/
+<Icon>arrow<Icon/>
+```
diff --git a/lib/rules/no-literal-string.js b/lib/rules/no-literal-string.js
index 0218efc..8c0b720 100644
--- a/lib/rules/no-literal-string.js
+++ b/lib/rules/no-literal-string.js
@@ -46,6 +46,12 @@ module.exports = {
               type: 'string'
             }
           },
+          ignoreComponent: {
+            type: 'array',
+            items: {
+              type: 'string'
+            }
+          },
           markupOnly: {
             type: 'boolean'
           }
@@ -114,6 +120,10 @@ module.exports = {
     }
 
     // Ignore the Trans component for react-i18next compatibility
+    let ignoredComponents = ['Trans'];
+    if (option && option.ignoreComponent)
+      ignoredComponents = ignoredComponents.concat(option.ignoreComponent);
+
     function hasValidElementName(node) {
       let currentNode = node;
       while (
@@ -122,7 +132,11 @@ module.exports = {
         currentNode.parent.openingElement &&
         currentNode.parent.openingElement.name
       ) {
-        if (currentNode.parent.openingElement.name.name === 'Trans') {
+        if (
+          ignoredComponents.includes(
+            currentNode.parent.openingElement.name.name
+          )
+        ) {
           return true;
         }
         currentNode = currentNode.parent;


Test patch:
diff --git a/tests/lib/rules/no-literal-string.js b/tests/lib/rules/no-literal-string.js
index e96e03b..797730f 100644
--- a/tests/lib/rules/no-literal-string.js
+++ b/tests/lib/rules/no-literal-string.js
@@ -95,6 +95,8 @@ ruleTester.run('no-literal-string', rule, {
     { code: '<DIV foo="bar" />', options: [{ ignoreAttribute: ['foo'] }] },
     { code: '<Trans>foo</Trans>' },
     { code: '<Trans><span>bar</span></Trans>' },
+    { code: '<Trans>foo</Trans>', options: [{ ignoreComponent: ['Icon'] }] },
+    { code: '<Icon>arrow</Icon>', options: [{ ignoreComponent: ['Icon'] }] },
     { code: 'a + "b"', options: [{ markupOnly: true }] },
     { code: '<div>{import("abc")}</div>', options: [{ markupOnly: true }] },
     {
Repository: edvardchen/eslint-plugin-i18next
Pull request #22 (2020-06-11 13:10:02)

feat: support multibyte characters
Support no literal string even when use multibyte characters.
Multibyte characters were contained ignore list.


Patch:
diff --git a/lib/rules/no-literal-string.js b/lib/rules/no-literal-string.js
index 0218efc..3ed673a 100644
--- a/lib/rules/no-literal-string.js
+++ b/lib/rules/no-literal-string.js
@@ -62,7 +62,7 @@ module.exports = {
       options: [option]
     } = context;
     const whitelists = [
-      /^[^A-Za-z]+$/, // ignore not-word string
+      /^[0-9!-/:-@[-`{-~]+$/, // ignore not-word string
       ...((option && option.ignore) || [])
     ].map(item => new RegExp(item));
 


Test patch:
diff --git a/tests/lib/rules/no-literal-string.js b/tests/lib/rules/no-literal-string.js
index e96e03b..7a68685 100644
--- a/tests/lib/rules/no-literal-string.js
+++ b/tests/lib/rules/no-literal-string.js
@@ -138,6 +138,7 @@ ruleTester.run('no-literal-string', rule, {
       options: [{ markupOnly: true }],
       errors
     },
+    { code: '<div>フー</div>', errors },
     { code: '<DIV foo="bar" />', errors },
     { code: '<DIV foo="bar" />', options: [{ markupOnly: true }], errors },
     { code: '<DIV foo={"bar"} />', options: [{ markupOnly: true }], errors },
Repository: dbader/node-datadog-metrics
Pull request #35 (2017-11-17 21:09:12)

update metric type `counter` to `count`; `counter` is deprecated
update metric type `counter` to `count` as `counter` is being deprecated.
https://help.datadoghq.com/hc/en-us/articles/206955236-Metric-types-in-Datadog
```
In the web app there are 3 metric types: GAUGE, RATE, COUNT (and COUNTER, now deprecated).
```

set histogram count to type `count` as well; more precise for the type.


Patch:
diff --git a/lib/metrics.js b/lib/metrics.js
index f7869bb..65debbe 100644
--- a/lib/metrics.js
+++ b/lib/metrics.js
@@ -96,7 +96,7 @@ Counter.prototype.addPoint = function(val, timestampInMillis) {
 };
 
 Counter.prototype.flush = function() {
-    return [this.serializeMetric(this.value, 'counter')];
+    return [this.serializeMetric(this.value, 'count')];
 };
 
 //
@@ -143,7 +143,7 @@ Histogram.prototype.flush = function() {
         this.serializeMetric(this.min, 'gauge', this.key + '.min'),
         this.serializeMetric(this.max, 'gauge', this.key + '.max'),
         this.serializeMetric(this.sum, 'gauge', this.key + '.sum'),
-        this.serializeMetric(this.count, 'gauge', this.key + '.count'),
+        this.serializeMetric(this.count, 'count', this.key + '.count'),
         this.serializeMetric(this.average(), 'gauge', this.key + '.avg')
     ];
 


Test patch:
diff --git a/test/metrics_tests.js b/test/metrics_tests.js
index f88f766..69541ed 100644
--- a/test/metrics_tests.js
+++ b/test/metrics_tests.js
@@ -78,7 +78,7 @@ describe('Counter', function() {
         f[0].should.have.deep.property('metric', 'the.key');
         f[0].should.have.deep.property('tags[0]', 'mytag');
         f[0].should.have.deep.property('host', 'myhost');
-        f[0].should.have.deep.property('type', 'counter');
+        f[0].should.have.deep.property('type', 'count');
         f[0].should.have.deep.property('points[0][0]', g.timestamp);
         f[0].should.have.deep.property('points[0][1]', 1);
     });
@@ -91,7 +91,7 @@ describe('Counter', function() {
         f[0].should.have.deep.property('metric', 'the.key');
         f[0].should.have.deep.property('tags[0]', 'mytag');
         f[0].should.have.deep.property('host', 'myhost');
-        f[0].should.have.deep.property('type', 'counter');
+        f[0].should.have.deep.property('type', 'count');
         f[0].should.have.deep.property('points[0][0]', 123);
         f[0].should.have.deep.property('points[0][1]', 1);
     });
Repository: dbader/node-datadog-metrics
Pull request #37 (2018-01-02 19:32:50)

Adds ability to pass an https agent for the datadog API


Patch:
diff --git a/lib/loggers.js b/lib/loggers.js
index 841052e..205a7f3 100644
--- a/lib/loggers.js
+++ b/lib/loggers.js
@@ -27,6 +27,7 @@ var Histogram = require('./metrics').Histogram;
 //     - appKey: DataDog APP key
 //     - host: Default host for all reported metrics
 //     - prefix: Default key prefix for all metrics
+//     - agent: a https agent, passed as dogapi's proxy_agent
 //     - flushIntervalSeconds:
 //
 // You can also use it to override (dependency-inject) the aggregator
@@ -37,7 +38,7 @@ var Histogram = require('./metrics').Histogram;
 //
 function BufferedMetricsLogger(opts) {
     this.aggregator = opts.aggregator || new Aggregator(opts.defaultTags);
-    this.reporter = opts.reporter || new DataDogReporter(opts.apiKey, opts.appKey);
+    this.reporter = opts.reporter || new DataDogReporter(opts.apiKey, opts.appKey, opts.agent);
     this.host = opts.host;
     this.prefix = opts.prefix || '';
     this.flushIntervalSeconds = opts.flushIntervalSeconds;
diff --git a/lib/reporters.js b/lib/reporters.js
index 4b8bafd..6b74320 100644
--- a/lib/reporters.js
+++ b/lib/reporters.js
@@ -21,7 +21,7 @@ NullReporter.prototype.report = function(series, onSuccess, onError) {
 // DataDogReporter
 //
 
-function DataDogReporter(apiKey, appKey) {
+function DataDogReporter(apiKey, appKey, agent) {
     apiKey = apiKey || process.env.DATADOG_API_KEY;
     appKey = appKey || process.env.DATADOG_APP_KEY;
 
@@ -30,7 +30,7 @@ function DataDogReporter(apiKey, appKey) {
     }
 
     // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
-    dogapi.initialize({api_key: apiKey, app_key: appKey});
+    dogapi.initialize({api_key: apiKey, app_key: appKey, proxy_agent: agent });
     // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
 }
 


Test patch:
diff --git a/test/loggers_tests.js b/test/loggers_tests.js
index 4e028df..6943ba6 100644
--- a/test/loggers_tests.js
+++ b/test/loggers_tests.js
@@ -6,7 +6,8 @@ var chai = require('chai');
 chai.use(require('chai-string'));
 
 var should = chai.should();
-
+var https = require('https');
+var dogapi = require('dogapi');
 var loggers = require('../lib/loggers');
 var reporters = require('../lib/reporters');
 var BufferedMetricsLogger = loggers.BufferedMetricsLogger;
@@ -103,4 +104,15 @@ describe('BufferedMetricsLogger', function() {
         });
         l.aggregator.defaultTags.should.deep.equal(['one', 'two']);
     });
+
+    it('should allow setting the agent tags', function() {
+        var agent = new https.Agent({ keepAlive: true, keepAliveMsecs: 10 });
+        var l = new BufferedMetricsLogger({
+            reporter: new reporters.DataDogReporter('yolo', 'yolo', agent),
+        });
+        // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
+        dogapi.client.proxy_agent.keepAlive.should.equal(true);
+        dogapi.client.proxy_agent.keepAliveMsecs.should.equal(10);
+        // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
+    });
 });
Repository: dbader/node-datadog-metrics
Pull request #39 (2018-01-10 08:34:17)

don't increment count when value is 0
fix for https://github.com/dbader/node-datadog-metrics/issues/38


Patch:
diff --git a/lib/loggers.js b/lib/loggers.js
index 205a7f3..ab3d3e4 100644
--- a/lib/loggers.js
+++ b/lib/loggers.js
@@ -73,7 +73,11 @@ BufferedMetricsLogger.prototype.gauge = function(key, value, tags, timestampInMi
 };
 
 BufferedMetricsLogger.prototype.increment = function(key, value, tags, timestampInMillis) {
-    this.addPoint(Counter, key, value || 1, tags, timestampInMillis);
+    if (value === undefined || value === null) {
+        this.addPoint(Counter, key, 1, tags, timestampInMillis);
+    } else {
+        this.addPoint(Counter, key, value, tags, timestampInMillis);
+    }
 };
 
 BufferedMetricsLogger.prototype.histogram = function(key, value, tags, timestampInMillis) {


Test patch:
diff --git a/test/loggers_tests.js b/test/loggers_tests.js
index 6943ba6..4646f54 100644
--- a/test/loggers_tests.js
+++ b/test/loggers_tests.js
@@ -42,14 +42,30 @@ describe('BufferedMetricsLogger', function() {
         l.increment('test.counter');
 
         l.aggregator = {
-            addPoint: function(Type, key, value, tags, host, timestampInMillis) {
+            addPoint: function(Type, key, value, tags, host) {
                 key.should.equal('test.counter2');
+                value.should.equal(0);
+            }
+        };
+        l.increment('test.counter2', 0);
+
+        l.aggregator = {
+            addPoint: function(Type, key, value, tags, host) {
+                key.should.equal('test.counter3');
+                value.should.equal(1);
+            }
+        };
+        l.increment('test.counter3', null);
+
+        l.aggregator = {
+            addPoint: function(Type, key, value, tags, host, timestampInMillis) {
+                key.should.equal('test.counter4');
                 value.should.equal(23);
                 tags.should.eql(['z:z', 'a:a']);
                 timestampInMillis.should.equal(1234567890);
             }
         };
-        l.increment('test.counter2', 23, ['z:z', 'a:a'], 1234567890);
+        l.increment('test.counter4', 23, ['z:z', 'a:a'], 1234567890);
     });
 
     it('should have a histogram() metric', function() {