nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ember-cli/eslint-plugin-ember
Pull request #1615 (2022-10-07 14:26:12)

Add `objectAt` autofixer for `no-array-prototype-extensions rule`
## Summary
Added auto-fixer for `no-array-prototype-extensions` which fixes the `objectAt` usage.

## Description
Recently, the proposal to deprecate array prototype extensions has been approved and got merged. The plan is to add autoFixers to replace ember array prototype extensions with the native array methods. In this PR, an auto fixer has been added which will fix the usage of `objectAt` method.

## Testing
Modified test case to check if the right output is generated after the fix.



Patch:
diff --git a/lib/rules/no-array-prototype-extensions.js b/lib/rules/no-array-prototype-extensions.js
index d68f4beb..3c190d27 100644
--- a/lib/rules/no-array-prototype-extensions.js
+++ b/lib/rules/no-array-prototype-extensions.js
@@ -247,6 +247,23 @@ function applyFix(callExpressionNode, fixer, context, options = {}) {
 
       return fixes;
     }
+    case 'objectAt': {
+      const calleeObj = callExpressionNode.callee.object;
+      const callArgs = callExpressionNode.arguments;
+      const sourceCode = context.getSourceCode();
+
+      if (callArgs.length === 1) {
+        return [
+          fixer.insertTextBefore(
+            callExpressionNode,
+            `${sourceCode.getText(calleeObj)}[${sourceCode.getText(callArgs[0])}]`
+          ),
+          fixer.remove(callExpressionNode),
+        ];
+      }
+
+      return [];
+    }
     default: {
       return [];
     }


Test patch:
diff --git a/tests/lib/rules/no-array-prototype-extensions.js b/tests/lib/rules/no-array-prototype-extensions.js
index defab019..74625e01 100644
--- a/tests/lib/rules/no-array-prototype-extensions.js
+++ b/tests/lib/rules/no-array-prototype-extensions.js
@@ -486,10 +486,27 @@ import { get as g } from 'dummy';
       errors: [{ messageId: 'main', type: 'CallExpression' }],
     },
     {
+      // When unexpected number of arguments are passed, auto-fixer will not run
       code: 'something.objectAt()',
       output: null,
       errors: [{ messageId: 'main', type: 'CallExpression' }],
     },
+    {
+      // When unexpected number of arguments are passed, auto-fixer will not run
+      code: 'something.objectAt(1, 2)',
+      output: null,
+      errors: [{ messageId: 'main', type: 'CallExpression' }],
+    },
+    {
+      code: 'something.objectAt(1)',
+      output: 'something[1]',
+      errors: [{ messageId: 'main', type: 'CallExpression' }],
+    },
+    {
+      code: 'something.somethingElse.objectAt(1)',
+      output: 'something.somethingElse[1]',
+      errors: [{ messageId: 'main', type: 'CallExpression' }],
+    },
     {
       code: 'something.objectsAt()',
       output: null,
Repository: ember-cli/eslint-plugin-ember
Pull request #1616 (2022-10-07 15:08:44)

Add `toArray` autofixer for `no-array-prototype-extensions` rule
## Summary
Added auto-fixer for `no-array-prototype-extensions` which fixes the `toArray` usage.

## Description
Recently, the proposal to deprecate array prototype extensions has been approved and got merged. The plan is to add autoFixers to replace ember array prototype extensions with the native array methods. In this PR, an auto fixer has been added which will fix the usage of `toArray` method.

## Testing
Modified test case to check if the right output is generated after the fix.


tgvrssanthosh: @bmish Can you help review this PR as well? Thank you!

Patch:
diff --git a/lib/rules/no-array-prototype-extensions.js b/lib/rules/no-array-prototype-extensions.js
index 3c190d27..f9b19764 100644
--- a/lib/rules/no-array-prototype-extensions.js
+++ b/lib/rules/no-array-prototype-extensions.js
@@ -264,6 +264,20 @@ function applyFix(callExpressionNode, fixer, context, options = {}) {
 
       return [];
     }
+    case 'toArray': {
+      const calleeObj = callExpressionNode.callee.object;
+      const callArgs = callExpressionNode.arguments;
+      const sourceCode = context.getSourceCode();
+
+      if (callArgs.length === 0) {
+        return [
+          fixer.insertTextBefore(callExpressionNode, `[...${sourceCode.getText(calleeObj)}]`),
+          fixer.remove(callExpressionNode),
+        ];
+      }
+
+      return [];
+    }
     default: {
       return [];
     }


Test patch:
diff --git a/tests/lib/rules/no-array-prototype-extensions.js b/tests/lib/rules/no-array-prototype-extensions.js
index 74625e01..6acfa612 100644
--- a/tests/lib/rules/no-array-prototype-extensions.js
+++ b/tests/lib/rules/no-array-prototype-extensions.js
@@ -533,10 +533,21 @@ import { get as g } from 'dummy';
       errors: [{ messageId: 'main', type: 'CallExpression' }],
     },
     {
-      code: 'something.toArray()',
+      // When unexpected number of params are passed, we will skip auto-fixing
+      code: 'something.toArray(1)',
       output: null,
       errors: [{ messageId: 'main', type: 'CallExpression' }],
     },
+    {
+      code: 'something.toArray()',
+      output: '[...something]',
+      errors: [{ messageId: 'main', type: 'CallExpression' }],
+    },
+    {
+      code: 'something.somethingElse.toArray()',
+      output: '[...something.somethingElse]',
+      errors: [{ messageId: 'main', type: 'CallExpression' }],
+    },
     {
       code: 'something.uniq()',
       output: null,
Repository: ember-cli/eslint-plugin-ember
Pull request #1620 (2022-10-10 14:09:33)

Add `uniq` autofixer for `no-array-prototype-extensions` rule
## Summary
Added auto-fixer for `no-array-prototype-extensions` which fixes `uniq`.

## Description
Recently, the proposal to deprecate array prototype extensions has been approved and got merged. The plan is to add autoFixers to replace ember array prototype extensions with the native array methods. In this PR, an auto fixer has been added which will replace the ember array method `uniq`

## Testing
Modified test case to check if the right output is generated after the fix.


tgvrssanthosh: @bmish Can you please review this PR as well?

Patch:
diff --git a/lib/rules/no-array-prototype-extensions.js b/lib/rules/no-array-prototype-extensions.js
index be50c9d9..a894dca5 100644
--- a/lib/rules/no-array-prototype-extensions.js
+++ b/lib/rules/no-array-prototype-extensions.js
@@ -282,6 +282,19 @@ function applyFix(callExpressionNode, fixer, context, options = {}) {
 
       return [];
     }
+    case 'uniq': {
+      if (callArgs.length === 0) {
+        return [
+          fixer.insertTextBefore(
+            callExpressionNode,
+            `[...new Set(${sourceCode.getText(calleeObj)})]`
+          ),
+          fixer.remove(callExpressionNode),
+        ];
+      }
+
+      return [];
+    }
     case 'without': {
       if (callArgs.length === 1) {
         const argText = sourceCode.getText(callArgs[0]);


Test patch:
diff --git a/tests/lib/rules/no-array-prototype-extensions.js b/tests/lib/rules/no-array-prototype-extensions.js
index 3ae2e582..4bae0854 100644
--- a/tests/lib/rules/no-array-prototype-extensions.js
+++ b/tests/lib/rules/no-array-prototype-extensions.js
@@ -587,6 +587,12 @@ import { get as g } from 'dummy';
     },
     {
       code: 'something.uniq()',
+      output: '[...new Set(something)]',
+      errors: [{ messageId: 'main', type: 'CallExpression' }],
+    },
+    {
+      // When unexpected number of params are passed, we will skip auto-fixing
+      code: 'something.uniq(1)',
       output: null,
       errors: [{ messageId: 'main', type: 'CallExpression' }],
     },
Repository: ember-cli/eslint-plugin-ember
Pull request #1629 (2022-10-11 10:22:53)

Add `reject` to `filter` autofixer for no-array-prototype-extensions rule
## Summary
Added auto-fixer for `no-array-prototype-extensions` which replaces `reject` with `filter`.

## Description
Recently, the proposal to deprecate array prototype extensions has been approved and got merged. The plan is to add autoFixers to replace ember array prototype extensions with the native array methods. In this PR, an auto fixer has been added which will replace the ember array method `reject` with the native array method `filter`.

## Testing
Modified test case to check if the right output is generated after the fix.

tgvrssanthosh: @bmish Can you help review this PR?

Patch:
diff --git a/lib/rules/no-array-prototype-extensions.js b/lib/rules/no-array-prototype-extensions.js
index 711cf858..5dc4f2d0 100644
--- a/lib/rules/no-array-prototype-extensions.js
+++ b/lib/rules/no-array-prototype-extensions.js
@@ -309,6 +309,19 @@ function applyFix(callExpressionNode, fixer, context, options = {}) {
 
       return [];
     }
+    case 'reject': {
+      if (callArgs.length > 0 && callArgs.length < 3) {
+        return [
+          fixer.replaceText(calleeProp, 'filter'),
+          // TODO: Switch to `Reflect.apply` once Ember v3 LTS support ends: https://emberjs.com/releases/lts/
+          fixer.replaceText(
+            callArgs[0],
+            `function(...args) { return !(${sourceCode.getText(callArgs[0])}).apply(this, args); }`
+          ),
+        ];
+      }
+      return [];
+    }
     case 'rejectBy': {
       const fixes = [];
 


Test patch:
diff --git a/tests/lib/rules/no-array-prototype-extensions.js b/tests/lib/rules/no-array-prototype-extensions.js
index 22118d66..85c5525e 100644
--- a/tests/lib/rules/no-array-prototype-extensions.js
+++ b/tests/lib/rules/no-array-prototype-extensions.js
@@ -632,10 +632,25 @@ import { get as g } from 'dummy';
       errors: [{ messageId: 'main', type: 'CallExpression' }],
     },
     {
+      // When unexpected number of arguments are passed, auto-fixer will not run
       code: 'something.reject()',
       output: null,
       errors: [{ messageId: 'main', type: 'CallExpression' }],
     },
+    {
+      // Single argument is passed
+      code: 'something.reject(function(el) { return el.isFlagged; })',
+      output:
+        'something.filter(function(...args) { return !(function(el) { return el.isFlagged; }).apply(this, args); })',
+      errors: [{ messageId: 'main', type: 'CallExpression' }],
+    },
+    {
+      // Two arguments are passed
+      code: 'something.reject(function(el) { return el.isFlagged && this.isFlagged; }, {isFlagged: true})',
+      output:
+        'something.filter(function(...args) { return !(function(el) { return el.isFlagged && this.isFlagged; }).apply(this, args); }, {isFlagged: true})',
+      errors: [{ messageId: 'main', type: 'CallExpression' }],
+    },
     {
       // When unexpected number of arguments are passed, auto-fixer will not run
       code: 'something.rejectBy()',