Skip to content

Commit

Permalink
Changes from v11.12.0 (#2029)
Browse files Browse the repository at this point in the history
* Support ESLint flat config (#2020)

* Allow ember-data type registry imports in `use-ember-data-rfc-395-imports` rule (#2027)

* Allow ember-data type registry imports

* fix lint

---------

Co-authored-by: Bryan Mishkin <[email protected]>

* fix lint

* Release 11.12.0

* fix merge mistakes

---------

Co-authored-by: Peter Wagenet <[email protected]>
  • Loading branch information
bmish and wagenet authored Dec 12, 2023
1 parent 49f2690 commit b567165
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 90 deletions.
60 changes: 13 additions & 47 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,3 @@















































## v12.0.0-alpha.2 (2023-11-10)

#### :bug: Bug Fix
Expand Down Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/use-ember-data-rfc-395-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
27 changes: 27 additions & 0 deletions lib/config-legacy/base.js
Original file line number Diff line number Diff line change
@@ -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>',
},
],
};
7 changes: 7 additions & 0 deletions lib/config-legacy/recommended-gjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const base = require('./base');
const gjsRules = require('../recommended-rules-gjs');

module.exports = {
...base,
rules: gjsRules,
};
7 changes: 7 additions & 0 deletions lib/config-legacy/recommended-gts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const base = require('./base');
const gtsRules = require('../recommended-rules-gts');

module.exports = {
...base,
rules: gtsRules,
};
7 changes: 7 additions & 0 deletions lib/config-legacy/recommended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const base = require('./base');
const rules = require('../recommended-rules');

module.exports = {
...base,
rules,
};
36 changes: 13 additions & 23 deletions lib/config/base.js
Original file line number Diff line number Diff line change
@@ -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>',
},
],
};
];
5 changes: 1 addition & 4 deletions lib/config/recommended-gjs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const base = require('./base');
const gjsRules = require('../recommended-rules-gjs');

module.exports = {
...base,
rules: gjsRules,
};
module.exports = [...base, { rules: gjsRules }];
5 changes: 1 addition & 4 deletions lib/config/recommended-gts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const base = require('./base');
const gtsRules = require('../recommended-rules-gts');

module.exports = {
...base,
rules: gtsRules,
};
module.exports = [...base, { rules: gtsRules }];
5 changes: 1 addition & 4 deletions lib/config/recommended.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const base = require('./base');
const rules = require('../recommended-rules');

module.exports = {
...base,
rules,
};
module.exports = [...base, { rules }];
7 changes: 6 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
},
Expand Down
6 changes: 5 additions & 1 deletion lib/rules/use-ember-data-rfc-395-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/use-ember-data-rfc-395-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
8 changes: 4 additions & 4 deletions tests/plugin-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit b567165

Please sign in to comment.