Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

refactor: transform to native classes via codemod #716

Merged
merged 4 commits into from
Nov 21, 2022

Conversation

derrabauke
Copy link
Contributor

Contents:

  • 388ee9d refactor(ember-tracked-properties-codemod): transform all classes
  • 10fcd48 refactor(ember-native-class-codemod): components
  • 39218cb refactor(ember-native-class-codemod): services
  • bfa5eaa refactor(no-get-with-defaults-codemod): replace getWithDefaults

The contents of this PR start at bfa5eaa
Commits before belong to #715


Info

6th PR of this series #710.
Only merge when #715 is merged and this PR got rebased!


@derrabauke derrabauke added the maintenance Code maintenance label Oct 27, 2022
@derrabauke derrabauke self-assigned this Oct 27, 2022
@derrabauke derrabauke changed the base branch from master to ember-octane October 27, 2022 13:32
Copy link
Member

@Yelinz Yelinz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some stylistic things, no need to change as long as it works

@@ -144,15 +149,17 @@ export default Component.extend({
);

yield this["on-save"](attendance);
}).drop(),
}).drop())
save;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored tasks look really weird

Comment on lines +17 to +20
return (get(this, "on-enter-viewport") ?? (() => {}))();
}

return this.getWithDefault("on-exit-viewport", () => {})();
return (get(this, "on-exit-viewport") ?? (() => {}))();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also very weird

Comment on lines +16 to +22
@(computed("current").readOnly())
get direction() {
return getDirection(this.current);
}).readOnly(),
}

active: computed("current", function() {
@(computed("current").readOnly())
get active() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the computed with readonly?

Comment on lines +22 to +25
name = "duration";
@tracked min = MIN_SAFE_INTEGER;
max = MAX_SAFE_INTEGER;
maxlength = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 1 tracked?

@@ -87,38 +74,38 @@ export default Component.extend({
* @property {Number} precision
* @public
*/
precision: 15,
@tracked precision = 15;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why only this property is tracked?

Comment on lines +8 to 10
"on-never"() {}
"on-later"() {}
"on-start"() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are some wild function names...

@@ -41,7 +44,7 @@ export default Service.extend({
* @return {Object} An object with the parsed metadata
* @public
*/
fetchSingleRecordMetadata: task(function*(type, id) {
@(task(function* (type, id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick refactor to restartableTask

const duration = moment.duration(
moment().diff(this.get("activity.from"))
);
@task(function* () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move function out of decorator


/**
* Whether it is the currently selected day
*
* @property {Boolean} active
* @public
*/
active: false,
active = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for tracked?

@derrabauke
Copy link
Contributor Author

Just some stylistic things, no need to change as long as it works

Thanks for the feedback! Will incorporate this after the automated codemods are done!

@derrabauke derrabauke merged commit d18a1a8 into adfinis:ember-octane Nov 21, 2022
@derrabauke derrabauke deleted the octane-pr-5 branch November 21, 2022 16:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
maintenance Code maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants