nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: yagoferrer/map-tools
Pull request #230 (2015-04-13 19:05:36)

Expose a method to delete/clear all Markers from the Map #229


Patch:
diff --git a/README.md b/README.md
index 5225007..b1134fd 100644
--- a/README.md
+++ b/README.md
@@ -169,6 +169,19 @@ map.updateMarker(<marker>, {visible: false})
 
 You can also use `lat` and `lng` to change the position of the Marker and many other options.
 
+#### Remove Marker
+Allows you to delete one or multiple Markers.
+
+```javascript
+map.removeMarker([markerInstance, markerInstance]);
+```
+
+#### Remove All Markers
+Call the method with no parameters and that will delete all the Markers in the Map.
+```javascript
+map.removeMarker()
+```
+
 
 #### Animate Markers
 Make your marker bounce `move: 'bounce'` or drop `move: 'drop'`
diff --git a/lib/map-tools/removeMarker.js b/lib/map-tools/removeMarker.js
index a48ac22..e10b152 100644
--- a/lib/map-tools/removeMarker.js
+++ b/lib/map-tools/removeMarker.js
@@ -3,8 +3,22 @@ module.exports = function(global, that) {
 
   var findMarker = require('map-tools/findMarker')(global, that);
 
+  function removeBulk(args) {
+    var marker, x;
+    for (x in args) {
+      if (args.hasOwnProperty(x)) {
+        marker = args[x];
+        remove(findMarker(marker));
+      }
+    }
+  }
+
   function removeMarker(args) {
 
+    if (typeof args === 'undefined') {
+      removeBulk(that.markers.all);
+    }
+
     var type = Object.prototype.toString.call(args);
 
     if (type === '[object Object]') {
@@ -12,13 +26,7 @@ module.exports = function(global, that) {
     }
 
     if (type === '[object Array]') {
-      var marker, x;
-      for (x in args) {
-        if (args.hasOwnProperty(x)) {
-          marker = args[x];
-          remove(findMarker(marker));
-        }
-      }
+      removeBulk(args);
     }
   }
 


Test patch:
diff --git a/test/functional/removeMarker.Spec.js b/test/functional/removeMarker.Spec.js
index beb98bf..a716052 100644
--- a/test/functional/removeMarker.Spec.js
+++ b/test/functional/removeMarker.Spec.js
@@ -42,4 +42,28 @@ describe('when calling removeMarker()', function () {
 
   });
 
+
+  it('should remove all the Markers from the Map', function() {
+
+    var map = new mapTools({async: false, id: 'mymap', lat: 41.3833, lng: 2.1833});
+
+    var markers = [{
+      lat: 41.3833,
+      lng: 2.1833,
+      title: 'Barcelona'
+    }, {
+      lat: 41.4489,
+      lng: 2.2461,
+      title: 'Badalona'
+    }];
+
+    var result = map.addMarker(markers);
+
+    map.removeMarker();
+
+    expect(result[0].map).to.equal(null);
+    expect(result[1].map).to.equal(null);
+
+  });
+
 });
Repository: yagoferrer/map-tools
Pull request #274 (2015-04-30 21:10:26)

Toro/268 blocked w multi tag search


Patch:
diff --git a/lib/map-tools/filter.js b/lib/map-tools/filter.js
index 0d33779..c7fefb9 100644
--- a/lib/map-tools/filter.js
+++ b/lib/map-tools/filter.js
@@ -9,6 +9,8 @@ module.exports = function(global, that, type) {
     DESC: 'bottom'
   };
 
+  var tags = [];
+
   // cf has it's own state, for each dimension
   // before each new filtering we need to clear this state
   function clearAll(dimensionSet){
@@ -42,11 +44,11 @@ module.exports = function(global, that, type) {
       function fetchByTag(query){
         for (var i in query) {
           var tag = query[i];
-          var res= that[type].tags[tag]
+          var nextTag = query[parseInt(i)+parseInt(1)];
+          var res; // store first set of markers to compare
 
           try{
-            var nextTag = query[i+1];
-            res = getCommonObject(res,that[type].tags[nextTag])
+            res = getCommonObject(that[type].tags[tag],that[type].tags[nextTag])
           } catch(e){
             // end of the array
           }
@@ -54,8 +56,10 @@ module.exports = function(global, that, type) {
         }
         return res;
       }
-
       function getCommonObject(list1, list2){
+        if(list1 === undefined || list2 === undefined){
+          return error("one of the marker lists you are trying to compare is undefined");
+        }
         var result = {};
         for (var uid in list1){
           var match =  list2[uid];
@@ -65,8 +69,8 @@ module.exports = function(global, that, type) {
         }
         return result;
       }
+       return utils.toArray(fetchByTag(query));
 
-      return utils.toArray(fetchByTag(query));
     }
   }
 


Test patch:
diff --git a/test/functional/tags.Spec.js b/test/functional/tags.Spec.js
index add7b74..dda3df7 100644
--- a/test/functional/tags.Spec.js
+++ b/test/functional/tags.Spec.js
@@ -80,7 +80,7 @@ describe('Given the Tag Feature', function () {
         lat: 42,
         lng: 1,
         title: 'Barcelona',
-        tags: 'tag1'
+        tags: ['tag1', 'tag2', 'tag3']
       },
 
         {
@@ -101,18 +101,20 @@ describe('Given the Tag Feature', function () {
           lat: 42,
           lng: 3,
           title: 'Sevilla',
-          tags: 'tag2'
+          tags: ['tag2']
         }
       ]);
 
       var result1 = map.findMarker({tags: ['tag1', 'tag2']});
-      expect(result1[0].title).to.eql('Andorra');
-
-      var result2 = map.findMarker({tags: ['tag1', 'tag2', 'tag3']});
-      expect(result2[0].title).to.eql('Zaragoza');
-
-      var result3 = map.findMarker({tags: 'tag1'});
-      expect(result3.length).to.eql(3);
+      expect(result1[0].title).to.eql('Barcelona');
+      expect(result1[1].title).to.eql('Andorra');
+      expect(result1[2].title).to.eql('Zaragoza');
+      expect(result1.length).to.eql(3);
+
+      var result2 = map.findMarker({tags: ['tag2', 'tag3']});
+      expect(result2[0].title).to.eql('Barcelona');
+      expect(result2[1].title).to.eql('Zaragoza');
+      expect(result2.length).to.eql(2);
 
     });
Repository: yannickcr/eslint-plugin-react
Pull request #42 (2015-03-30 03:17:56)

Handle spread in jsx-sort-props


Patch:
diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js
index ea7aa938..408321b6 100755
--- a/lib/rules/jsx-sort-props.js
+++ b/lib/rules/jsx-sort-props.js
@@ -15,7 +15,11 @@ module.exports = function(context) {
 
   return {
     JSXOpeningElement: function(node) {
-      node.attributes.reduce(function(memo, decl) {
+      var attributes = node.attributes.filter(function(decl) {
+        return decl.type === 'JSXAttribute';
+      });
+
+      attributes.reduce(function(memo, decl) {
         var lastPropName = memo.name.name;
         var currenPropName = decl.name.name;
 
@@ -30,7 +34,7 @@ module.exports = function(context) {
         }
 
         return decl;
-      }, node.attributes[0]);
+      }, attributes[0]);
     }
   };
 };


Test patch:
diff --git a/tests/lib/rules/jsx-sort-props.js b/tests/lib/rules/jsx-sort-props.js
index 69ff0b41..bcc30ed3 100755
--- a/tests/lib/rules/jsx-sort-props.js
+++ b/tests/lib/rules/jsx-sort-props.js
@@ -32,8 +32,11 @@ var features = {
 eslintTester.addRuleTest('lib/rules/jsx-sort-props', {
   valid: [
     {code: '<App />;', ecmaFeatures: features},
+    {code: '<App {...this.props} />;', ecmaFeatures: features},
     {code: '<App a b c />;', ecmaFeatures: features},
+    {code: '<App {...this.props} a b c />;', ecmaFeatures: features},
     {code: '<App a="c" b="b" c="a" />;', ecmaFeatures: features},
+    {code: '<App {...this.props} a="c" b="b" c="a" />;', ecmaFeatures: features},
     {code: '<App A a />;', ecmaFeatures: features},
     {code: '<App a A />;', args: ignoreCaseArgs, ecmaFeatures: features},
     {code: '<App a B c />;', args: ignoreCaseArgs, ecmaFeatures: features},
@@ -41,9 +44,11 @@ eslintTester.addRuleTest('lib/rules/jsx-sort-props', {
   ],
   invalid: [
     {code: '<App b a />;', errors: [expectedError], ecmaFeatures: features},
+    {code: '<App {...this.props} b a />;', errors: [expectedError], ecmaFeatures: features},
     {code: '<App a A />;', errors: [expectedError], ecmaFeatures: features},
     {code: '<App B a />;', args: ignoreCaseArgs, errors: [expectedError], ecmaFeatures: features},
     {code: '<App B A c />;', args: ignoreCaseArgs, errors: [expectedError], ecmaFeatures: features},
-    {code: '<App c="a" a="c" b="b" />;', errors: 2, ecmaFeatures: features}
+    {code: '<App c="a" a="c" b="b" />;', errors: 2, ecmaFeatures: features},
+    {code: '<App {...this.props} c="a" a="c" b="b" />;', errors: 2, ecmaFeatures: features}
   ]
 });
Repository: yannickcr/eslint-plugin-react
Pull request #69 (2015-04-17 18:13:08)

Only mark component types as used, not prop names.
Previously, all JSX identifiers were marked as "used", even for prop names. This is an issue in cases where component props happened by chance to have the same name as a local variable, like this:

        var App;
        var foo;
        React.render(<App foo="bar"/>);

Here, the "foo" prop prevents the `foo` variable from being marked as unused and ESLint gives no warnings for the `no-unused-vars` rule, even though `foo` is not actually referenced anywhere.

This change updates the `jsx-uses-vars` rule to only mark variables as used if they occur in a `JSXOpeningElement` node (thus excluding prop names, as they exist in `JSXAttribute` nodes instead).


Patch:
diff --git a/lib/rules/jsx-uses-vars.js b/lib/rules/jsx-uses-vars.js
index 174f64cc..5e666830 100755
--- a/lib/rules/jsx-uses-vars.js
+++ b/lib/rules/jsx-uses-vars.js
@@ -20,8 +20,8 @@ module.exports = function(context) {
       variableUtil.markVariableAsUsed(context, node.expression.name);
     },
 
-    JSXIdentifier: function(node) {
-      variableUtil.markVariableAsUsed(context, node.name);
+    JSXOpeningElement: function(node) {
+      variableUtil.markVariableAsUsed(context, node.name.name);
     }
 
   };


Test patch:
diff --git a/tests/lib/rules/jsx-uses-vars.js b/tests/lib/rules/jsx-uses-vars.js
index 24317b2d..f059f35b 100644
--- a/tests/lib/rules/jsx-uses-vars.js
+++ b/tests/lib/rules/jsx-uses-vars.js
@@ -65,7 +65,18 @@ eslintTester.addRuleTest('node_modules/eslint/lib/rules/no-unused-vars', {
   invalid: [
     {
       code: '/*eslint jsx-uses-vars:1*/ var App;',
-      errors: [{message: 'App is defined but never used'}], ecmaFeatures: {jsx: true}
+      errors: [{message: 'App is defined but never used'}],
+      ecmaFeatures: {jsx: true}
+    }, {
+      code: '\
+        /*eslint jsx-uses-vars:1*/\
+        var App;\
+        var unused;\
+        React.render(<App unused=""/>);',
+      errors: [{message: 'unused is defined but never used'}],
+      ecmaFeatures: {
+        jsx: true
+      }
     }
   ]
 });