ember-codemod-remove-inject-as-service 3.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,7 +13,7 @@ function updateImportStatement(file) {
|
|
|
13
13
|
if (source.type !== 'StringLiteral') {
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
|
-
if (source.value !== '@ember/service' ||
|
|
16
|
+
if (source.value !== '@ember/service' || specifiers === undefined) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
path.node.specifiers = specifiers.map((specifier) => {
|
|
@@ -57,7 +57,7 @@ function updateServiceDecorators(file, data) {
|
|
|
57
57
|
visitClassProperty(path) {
|
|
58
58
|
// @ts-expect-error: Incorrect type
|
|
59
59
|
const decorators = path.node.decorators;
|
|
60
|
-
if (
|
|
60
|
+
if (decorators === undefined || decorators.length !== 1) {
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
63
|
const decorator = decorators[0];
|
|
@@ -65,14 +65,16 @@ function updateServiceDecorators(file, data) {
|
|
|
65
65
|
switch (decorator.expression.type) {
|
|
66
66
|
case 'CallExpression': {
|
|
67
67
|
if (decorator.expression.callee.type === 'Identifier' &&
|
|
68
|
-
decorator.expression.callee.name === data.localName
|
|
68
|
+
decorator.expression.callee.name === data.localName &&
|
|
69
|
+
path.node.key.type === 'Identifier') {
|
|
69
70
|
decorator.expression.callee.name = 'service';
|
|
70
71
|
isMatch = true;
|
|
71
72
|
}
|
|
72
73
|
break;
|
|
73
74
|
}
|
|
74
75
|
case 'Identifier': {
|
|
75
|
-
if (decorator.expression.name === data.localName
|
|
76
|
+
if (decorator.expression.name === data.localName &&
|
|
77
|
+
path.node.key.type === 'Identifier') {
|
|
76
78
|
decorator.expression.name = 'service';
|
|
77
79
|
isMatch = true;
|
|
78
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-remove-inject-as-service",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "Codemod to remove `inject as service`",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"author": "Isaac J. Lee",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"main": "dist/src/index.js",
|
|
18
|
-
"bin": "dist/bin/ember-codemod-remove-inject-as-service.js",
|
|
19
18
|
"files": [
|
|
20
19
|
"dist"
|
|
21
20
|
],
|
|
@@ -56,5 +55,8 @@
|
|
|
56
55
|
"release:prepare": "changeset version",
|
|
57
56
|
"release:publish": "pnpm build && changeset publish",
|
|
58
57
|
"test": "sh build.sh --test && mt dist-for-testing --quiet"
|
|
58
|
+
},
|
|
59
|
+
"bin": {
|
|
60
|
+
"ember-codemod-remove-inject-as-service": "dist/bin/ember-codemod-remove-inject-as-service.js"
|
|
59
61
|
}
|
|
60
62
|
}
|