Repository: ember-cli/eslint-plugin-ember
Pull request #2029 (2023-12-12 23:52:29)

Changes from v11.12.0
This pulls in changes that were implemented in [v11.12.0](https://github.com/ember-cli/eslint-plugin-ember/releases/tag/v11.12.0) from the v11 branch (for backporting) to master where we are actively developing v12 (in alpha). 

* [#2020](https://github.com/ember-cli/eslint-plugin-ember/pull/2020) Support ESLint flat config ([@bmish](https://github.com/bmish))
   * Note: I had to create flat config versions of the new configs in v12
* [#2027](https://github.com/ember-cli/eslint-plugin-ember/pull/2027) Allow ember-data type registry imports in `use-ember-data-rfc-395-imports` rule ([@wagenet](https://github.com/wagenet))



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3d0555c3..f323271e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,50 +1,3 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 ## v12.0.0-alpha.2 (2023-11-10)
 
 #### :bug: Bug Fix
@@ -102,6 +55,19 @@
 - Patrick Pircher ([@patricklx](https://github.com/patricklx))
 
 
+## v11.12.0 (2023-12-12)
+
+#### :rocket: Enhancement
+* [#2020](https://github.com/ember-cli/eslint-plugin-ember/pull/2020) Support ESLint flat config ([@bmish](https://github.com/bmish))
+
+#### :bug: Bug Fix
+* [#2027](https://github.com/ember-cli/eslint-plugin-ember/pull/2027) Allow ember-data type registry imports in `use-ember-data-rfc-395-imports` rule ([@wagenet](https://github.com/wagenet))
+
+#### Committers: 2
+- Bryan Mishkin ([@bmish](https://github.com/bmish))
+- Peter Wagenet ([@wagenet](https://github.com/wagenet))
+
+
 ## v11.11.1 (2023-08-22)
 
 #### :bug: Bug Fix
diff --git a/README.md b/README.md
index 9b9c7b93..1222fbf5 100644
--- a/README.md
+++ b/README.md
@@ -25,10 +25,21 @@ Or
 npm install --save-dev eslint-plugin-ember
 ```
 
-### 2. Modify your `.eslintrc.js`
+### 2. Update your config
 
 ```js
-// .eslintrc.js
+// eslint.config.js (flat config)
+const eslintPluginEmberRecommended = require('eslint-plugin-ember/configs/recommended');
+
+module.exports = [
+  ...eslintPluginEmberRecommended,
+];
+```
+
+or
+
+```js
+// .eslintrc.js (legacy config)
 module.exports = {
   plugins: ['ember'],
   extends: [
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/config-legacy/base.js b/lib/config-legacy/base.js
new file mode 100644
index 00000000..bb58ec1e
--- /dev/null
+++ b/lib/config-legacy/base.js
@@ -0,0 +1,27 @@
+module.exports = {
+  root: true,
+
+  parserOptions: {
+    ecmaVersion: 2022,
+    sourceType: 'module',
+  },
+
+  env: {
+    browser: true,
+    es2022: true,
+  },
+
+  plugins: ['ember'],
+
+  overrides: [
+    /**
+     * We don't want to *always* have the preprocessor active,
+     * it's only relevant on gjs and gts files to detect if eslint config is correctly setup for this files.
+     */
+    {
+      files: ['**/*.{gts,gjs}'],
+      parser: 'eslint-plugin-ember/gjs-gts-parser',
+      processor: 'ember/<noop>',
+    },
+  ],
+};
diff --git a/lib/config-legacy/recommended-gjs.js b/lib/config-legacy/recommended-gjs.js
new file mode 100644
index 00000000..924c05ff
--- /dev/null
+++ b/lib/config-legacy/recommended-gjs.js
@@ -0,0 +1,7 @@
+const base = require('./base');
+const gjsRules = require('../recommended-rules-gjs');
+
+module.exports = {
+  ...base,
+  rules: gjsRules,
+};
diff --git a/lib/config-legacy/recommended-gts.js b/lib/config-legacy/recommended-gts.js
new file mode 100644
index 00000000..c29d094d
--- /dev/null
+++ b/lib/config-legacy/recommended-gts.js
@@ -0,0 +1,7 @@
+const base = require('./base');
+const gtsRules = require('../recommended-rules-gts');
+
+module.exports = {
+  ...base,
+  rules: gtsRules,
+};
diff --git a/lib/config-legacy/recommended.js b/lib/config-legacy/recommended.js
new file mode 100644
index 00000000..7f83b571
--- /dev/null
+++ b/lib/config-legacy/recommended.js
@@ -0,0 +1,7 @@
+const base = require('./base');
+const rules = require('../recommended-rules');
+
+module.exports = {
+  ...base,
+  rules,
+};
diff --git a/lib/config/base.js b/lib/config/base.js
index bb58ec1e..e4c04d43 100644
--- a/lib/config/base.js
+++ b/lib/config/base.js
@@ -1,27 +1,17 @@
-module.exports = {
-  root: true,
+const plugin = require('../index');
 
-  parserOptions: {
-    ecmaVersion: 2022,
-    sourceType: 'module',
+module.exports = [
+  {
+    plugins: { ember: plugin },
   },
 
-  env: {
-    browser: true,
-    es2022: true,
+  /**
+   * We don't want to *always* have the preprocessor active,
+   * it's only relevant on gjs and gts files to detect if eslint config is correctly setup for this files.
+   */
+  {
+    files: ['**/*.{gts,gjs}'],
+    parser: 'eslint-plugin-ember/gjs-gts-parser',
+    processor: 'ember/<noop>',
   },
-
-  plugins: ['ember'],
-
-  overrides: [
-    /**
-     * We don't want to *always* have the preprocessor active,
-     * it's only relevant on gjs and gts files to detect if eslint config is correctly setup for this files.
-     */
-    {
-      files: ['**/*.{gts,gjs}'],
-      parser: 'eslint-plugin-ember/gjs-gts-parser',
-      processor: 'ember/<noop>',
-    },
-  ],
-};
+];
diff --git a/lib/config/recommended-gjs.js b/lib/config/recommended-gjs.js
index 924c05ff..f47466d2 100644
--- a/lib/config/recommended-gjs.js
+++ b/lib/config/recommended-gjs.js
@@ -1,7 +1,4 @@
 const base = require('./base');
 const gjsRules = require('../recommended-rules-gjs');
 
-module.exports = {
-  ...base,
-  rules: gjsRules,
-};
+module.exports = [...base, { rules: gjsRules }];
diff --git a/lib/config/recommended-gts.js b/lib/config/recommended-gts.js
index c29d094d..d35deb42 100644
--- a/lib/config/recommended-gts.js
+++ b/lib/config/recommended-gts.js
@@ -1,7 +1,4 @@
 const base = require('./base');
 const gtsRules = require('../recommended-rules-gts');
 
-module.exports = {
-  ...base,
-  rules: gtsRules,
-};
+module.exports = [...base, { rules: gtsRules }];
diff --git a/lib/config/recommended.js b/lib/config/recommended.js
index 7f83b571..ae7d5718 100644
--- a/lib/config/recommended.js
+++ b/lib/config/recommended.js
@@ -1,7 +1,4 @@
 const base = require('./base');
 const rules = require('../recommended-rules');
 
-module.exports = {
-  ...base,
-  rules,
-};
+module.exports = [...base, { rules }];
diff --git a/lib/index.js b/lib/index.js
index 6aafc671..4cfff509 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -2,10 +2,15 @@
 
 const requireIndex = require('requireindex');
 const noop = require('./preprocessors/noop');
+const pkg = require('../package.json'); // eslint-disable-line import/extensions
 
 module.exports = {
+  meta: {
+    name: pkg.name,
+    version: pkg.version,
+  },
   rules: requireIndex(`${__dirname}/rules`),
-  configs: requireIndex(`${__dirname}/config`),
+  configs: requireIndex(`${__dirname}/config-legacy`),
   utils: {
     ember: require('./utils/ember'),
   },
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 });
         }
       },
diff --git a/package.json b/package.json
index 11051cb0..f5b26f2c 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,7 @@
   "license": "MIT",
   "exports": {
     ".": "./lib/index.js",
+    "./configs/*": "./lib/config/*.js",
     "./gjs-gts-parser": "./lib/parsers/gjs-gts-parser.js"
   },
   "main": "./lib/index.js",


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 aa7c1212..16e21f92 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: [
diff --git a/tests/plugin-exports.js b/tests/plugin-exports.js
index 88f6c5b3..bc41e2e2 100644
--- a/tests/plugin-exports.js
+++ b/tests/plugin-exports.js
@@ -2,10 +2,10 @@
 
 const plugin = require('../lib');
 const ember = require('../lib/utils/ember');
-const base = require('../lib/config/base');
-const recommended = require('../lib/config/recommended');
-const recommendedGjs = require('../lib/config/recommended-gjs');
-const recommendedGts = require('../lib/config/recommended-gts');
+const base = require('../lib/config-legacy/base');
+const recommended = require('../lib/config-legacy/recommended');
+const recommendedGjs = require('../lib/config-legacy/recommended-gjs');
+const recommendedGts = require('../lib/config-legacy/recommended-gts');
 
 describe('plugin exports', () => {
   describe('utils', () => {