nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ember-cli/eslint-plugin-ember
Pull request #1871 (2023-05-21 17:26:04)

Avoid further decorator detection crashes in `no-restricted-service-injections` rule

Follow-up to:
* #1869


Patch:
diff --git a/lib/rules/no-restricted-service-injections.js b/lib/rules/no-restricted-service-injections.js
index e9d83b77..b2ec4224 100644
--- a/lib/rules/no-restricted-service-injections.js
+++ b/lib/rules/no-restricted-service-injections.js
@@ -103,7 +103,13 @@ module.exports = {
       // Find the service decorator.
       const serviceDecorator =
         decoratorUtils.findDecorator(node, 'service') ||
-        decoratorUtils.findDecorator(node, 'inject');
+        decoratorUtils.findDecorator(node, 'inject') ||
+        decoratorUtils.findDecorator(node, 'Ember.inject.service');
+
+      if (!serviceDecorator) {
+        // TODO: emberUtils.isInjectedServiceProp() must have detected an injection that findDecorator() didn't.
+        return;
+      }
 
       // Get the service name either from the string argument or from the property name.
       const serviceName =


Test patch:
diff --git a/tests/lib/rules/no-restricted-service-injections.js b/tests/lib/rules/no-restricted-service-injections.js
index 226843ca..05b6dbe0 100644
--- a/tests/lib/rules/no-restricted-service-injections.js
+++ b/tests/lib/rules/no-restricted-service-injections.js
@@ -84,6 +84,13 @@ ruleTester.run('no-restricted-service-injections', rule, {
       code: `${SERVICE_IMPORT} Component.extend({ myService: service(SOME_VARIABLE) })`,
       options: [{ paths: ['app/components'], services: ['my-service'] }],
     },
+    {
+      // TODO: This should be invalid. With `inject.service` decorator.
+      filename: 'app/components/path.js',
+      code: `${INJECT_IMPORT} class MyComponent extends Component { @inject.service('myService') randomName }`,
+      output: null,
+      options: [{ paths: ['app/components'], services: ['my-service'] }],
+    },
   ],
   invalid: [
     {
@@ -156,7 +163,7 @@ ruleTester.run('no-restricted-service-injections', rule, {
       ],
     },
     {
-      // With decorator with camelized service name argument:
+      // With decorator with camelized service name argument (inject):
       filename: 'app/components/path.js',
       code: `${INJECT_IMPORT} class MyComponent extends Component { @inject('myService') randomName }`,
       output: null,
@@ -220,6 +227,19 @@ ruleTester.run('no-restricted-service-injections', rule, {
         },
       ],
     },
+    {
+      // With chained decorator
+      filename: 'app/components/path.js',
+      code: `${EMBER_IMPORT} class MyComponent extends Component { @Ember.inject.service('myService') randomName }`,
+      output: null,
+      options: [{ paths: ['app/components'], services: ['my-service'] }],
+      errors: [
+        {
+          message: DEFAULT_ERROR_MESSAGE,
+          // type could be ClassProperty (ESLint v7) or PropertyDefinition (ESLint v8)
+        },
+      ],
+    },
     {
       // With custom error message:
       filename: 'app/components/path.js',
Repository: ember-cli/eslint-plugin-ember
Pull request #2027 (2023-12-11 16:47:16)

Allow ember-data type registry imports in `use-ember-data-rfc-395-imports` rule
Addresses the issue raised by #1833, though we require the import to be directly from the registry module.

bmish: Can you target the v11 branch instead of master? Then I can release this as a bug fix to v11, as v12 on master is still WIP.

Patch:
diff --git a/docs/rules/use-ember-data-rfc-395-imports.md b/docs/rules/use-ember-data-rfc-395-imports.md
index 0d5cf148..dc13d55b 100644
--- a/docs/rules/use-ember-data-rfc-395-imports.md
+++ b/docs/rules/use-ember-data-rfc-395-imports.md
@@ -14,6 +14,8 @@ The goal of this rule is to ease the migration to the new @ember-data packages.
 
 ember-data has been split in multiple packages. For instance, its store is now released in "@ember-data/store" package. These packages have been released starting from ember-data version 3.11.
 
+For TypeScript users, imports from `ember-data/types/registries/*` are still allowed since there is currently no equivalent in the new packages.
+
 ## Examples
 
 Examples of **incorrect** code for this rule:
diff --git a/lib/rules/use-ember-data-rfc-395-imports.js b/lib/rules/use-ember-data-rfc-395-imports.js
index 21f795cb..a011b285 100644
--- a/lib/rules/use-ember-data-rfc-395-imports.js
+++ b/lib/rules/use-ember-data-rfc-395-imports.js
@@ -102,7 +102,11 @@ module.exports = {
           return;
         }
 
-        if (node.source.value === 'ember-data' || node.source.value.startsWith('ember-data/')) {
+        if (
+          node.source.value === 'ember-data' ||
+          (node.source.value.startsWith('ember-data/') &&
+            !node.source.value.startsWith('ember-data/types/registries/'))
+        ) {
           context.report({ node, message });
         }
       },


Test patch:
diff --git a/tests/lib/rules/use-ember-data-rfc-395-imports.js b/tests/lib/rules/use-ember-data-rfc-395-imports.js
index 15cf50d5..a0208aea 100644
--- a/tests/lib/rules/use-ember-data-rfc-395-imports.js
+++ b/tests/lib/rules/use-ember-data-rfc-395-imports.js
@@ -40,6 +40,10 @@ ruleTester.run('use-ember-data-rfc-395-imports', rule, {
        name: SomethingRandom.DS('string')
      });
     `,
+    "import AdapterRegistry from 'ember-data/types/registries/adapter';",
+    "import ModelRegistry from 'ember-data/types/registries/model';",
+    "import SerializerRegistry from 'ember-data/types/registries/serializer';",
+    "import TransformRegistry from 'ember-data/types/registries/transform';",
   ],
 
   invalid: [
Repository: ember-cli/eslint-plugin-ember
Pull request #2147 (2024-05-17 15:37:48)

fix isTestFile
We forgot to update this when we added gjs/gts support, so all the test-specific lints on gjs/gts files might be accidentally turned off right now (prior to this fix).

Fixes: https://github.com/ember-cli/eslint-plugin-ember/issues/2146


Patch:
diff --git a/lib/utils/ember.js b/lib/utils/ember.js
index cbc1249a..9aff9841 100644
--- a/lib/utils/ember.js
+++ b/lib/utils/ember.js
@@ -175,8 +175,10 @@ function isModuleByFilePath(filePath, module) {
   );
 }
 
+const validFileExtensions = ['js', 'ts', 'gjs', 'gts'];
+
 function isTestFile(fileName) {
-  return fileName.endsWith('-test.js') || fileName.endsWith('-test.ts');
+  return validFileExtensions.some((ext) => fileName.endsWith(`-test.${ext}`));
 }
 
 function isMirageDirectory(fileName) {


Test patch:
diff --git a/tests/lib/utils/ember-test.js b/tests/lib/utils/ember-test.js
index a9639215..a44a0c14 100644
--- a/tests/lib/utils/ember-test.js
+++ b/tests/lib/utils/ember-test.js
@@ -139,6 +139,8 @@ describe('isTestFile', () => {
   it('detects test files', () => {
     expect(emberUtils.isTestFile('some-test.js')).toBeTruthy();
     expect(emberUtils.isTestFile('some-test.ts')).toBeTruthy();
+    expect(emberUtils.isTestFile('some-test.gjs')).toBeTruthy();
+    expect(emberUtils.isTestFile('some-test.gts')).toBeTruthy();
   });
 
   it('does not detect other files', () => {
Repository: ember-cli/eslint-plugin-ember
Pull request #2162 (2024-09-18 15:43:47)

Allow imports from `ember-data/store`
This adjusts the `use-ember-data-rfc-395` rule so imports from `ember-data/store` are allowed.

It is a valid import according to the deprecation guides: https://deprecations.emberjs.com/id/ember-data-deprecate-legacy-imports/

Closes https://github.com/ember-cli/eslint-plugin-ember/issues/2156


Patch:
diff --git a/lib/rules/use-ember-data-rfc-395-imports.js b/lib/rules/use-ember-data-rfc-395-imports.js
index a011b285..82e42e4c 100644
--- a/lib/rules/use-ember-data-rfc-395-imports.js
+++ b/lib/rules/use-ember-data-rfc-395-imports.js
@@ -96,6 +96,11 @@ module.exports = {
        * into `import { attr } from "@ember-data/attr"`
        */
       ImportDeclaration(node) {
+        // 'ember-data/store' is a valid import again: https://deprecations.emberjs.com/id/ember-data-deprecate-legacy-imports/
+        if (node.source.value === 'ember-data/store') {
+          return;
+        }
+
         if (node.source.value in OLD_DATA_IMPORTS) {
           const fix = buildFix(node, OLD_DATA_IMPORTS);
           context.report({ node, message, fix });


Test patch:
diff --git a/tests/lib/rules/use-ember-data-rfc-395-imports.js b/tests/lib/rules/use-ember-data-rfc-395-imports.js
index 16e21f92..ab55f5b1 100644
--- a/tests/lib/rules/use-ember-data-rfc-395-imports.js
+++ b/tests/lib/rules/use-ember-data-rfc-395-imports.js
@@ -44,6 +44,7 @@ ruleTester.run('use-ember-data-rfc-395-imports', rule, {
     "import ModelRegistry from 'ember-data/types/registries/model';",
     "import SerializerRegistry from 'ember-data/types/registries/serializer';",
     "import TransformRegistry from 'ember-data/types/registries/transform';",
+    "import Store from 'ember-data/store';",
   ],
 
   invalid: [