Skip to content

Commit

Permalink
feature: Enforced stylistic choices (only allow the declare keyword) …
Browse files Browse the repository at this point in the history
…for TS files
  • Loading branch information
ijlee2 committed Apr 23, 2024
1 parent 0feda91 commit 45d5f28
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/utils/steps/update-project/update-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ function updateServiceDecorators(
}

const decorator = node.value.decorators[0];
let isMatch = false;

switch (decorator.expression.type) {
case 'CallExpression': {
if (decorator.expression.callee.name === data.localName) {
decorator.expression.callee.name = 'service';
isMatch = true;
}

break;
Expand All @@ -115,12 +117,25 @@ function updateServiceDecorators(
case 'Identifier': {
if (decorator.expression.name === data.localName) {
decorator.expression.name = 'service';
isMatch = true;
}

break;
}
}

if (!isMatch || !data.isTypeScript) {
return false;
}

// Stylistic choices
if (!decorator.trailingComments) {
node.value.accessibility = null;
node.value.declare = true;
node.value.definite = null;
node.value.readonly = null;
}

return false;
},
});
Expand Down

0 comments on commit 45d5f28

Please sign in to comment.