Skip to content

Commit 8011c7f

Browse files
committed
Cleanup
1 parent c085939 commit 8011c7f

3 files changed

Lines changed: 24 additions & 20 deletions

File tree

packages/@ember/engine/lib/strict-resolver.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
import type { Factory, Resolver } from '@ember/owner';
1+
import type { Factory, Resolver } from '@ember/-internals/owner';
2+
3+
const KNOWN_EASY_PLURALS = new Set([
4+
'adapter',
5+
'component',
6+
'controller',
7+
'model',
8+
'modifier',
9+
'route',
10+
'serializer',
11+
'template',
12+
]);
213

314
export class StrictResolver implements Resolver {
415
// Ember's router uses this flag to decide whether to auto-generate
@@ -8,16 +19,6 @@ export class StrictResolver implements Resolver {
819
moduleBasedResolver = true;
920

1021
#modules = new Map<string, unknown>();
11-
#plurals = new Map<string, string>([
12-
['component', 'components'],
13-
['config', 'config'],
14-
['controller', 'controllers'],
15-
['helper', 'helpers'],
16-
['model', 'models'],
17-
['modifier', 'modifiers'],
18-
['route', 'routes'],
19-
['template', 'templates'],
20-
]);
2122
original: any;
2223

2324
constructor(modules: Record<string, unknown>) {
@@ -34,12 +35,12 @@ export class StrictResolver implements Resolver {
3435
return moduleName.replace(fileExtension, '').replace(leadingDotSlash, '');
3536
}
3637

37-
/**
38-
* We only support plurals for the well known things (for historical reasons)
39-
* (see the hard-coded map of plurals in #plurals)
40-
*/
41-
#plural(s: string) {
42-
return this.#plurals.get(s) ?? s;
38+
#plural(word: string) {
39+
if (KNOWN_EASY_PLURALS.has(word)) {
40+
return word + 's';
41+
}
42+
43+
return word;
4344
}
4445

4546
resolve(fullName: string): Factory<object> | object | undefined {

packages/@ember/engine/tests/resolver/basic-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { module, test } from 'qunit';
21
import { StrictResolver } from '@ember/engine/lib/strict-resolver';
32

3+
import * as QUnit from 'qunit';
4+
const { module, test } = QUnit;
5+
46
module('StrictResolver', function (hooks) {
57
let resolver;
68
let modules;
@@ -21,7 +23,6 @@ module('StrictResolver', function (hooks) {
2123
{ fullName: 'component:my-widget', key: './components/my-widget' },
2224
{ fullName: 'modifier:auto-focus', key: './modifiers/auto-focus' },
2325
{ fullName: 'template:application', key: './templates/application' },
24-
{ fullName: 'view:queue-list', key: './views/queue-list' },
2526
{ fullName: 'route:index', key: './routes/index' },
2627
{ fullName: 'controller:application', key: './controllers/application' },
2728
];

packages/@ember/engine/tests/resolver/registry_test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { module, test } from 'qunit';
1+
import * as QUnit from 'qunit';
22
import Application from '@ember/application';
33
import Service from '@ember/service';
44
import { run } from '@ember/runloop';
55
import type ApplicationInstance from '@ember/application/instance';
66

7+
const { module, test } = QUnit;
8+
79
module('strict-resolver | Application with modules', function (hooks) {
810
let app: Application | undefined;
911
let instance: ApplicationInstance | undefined;

0 commit comments

Comments
 (0)