-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ember-codemods/suchita/readOnlyComputed
Add support for readOnly computed property conversion
- Loading branch information
Showing
7 changed files
with
210 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
transforms/tracked-properties/__testfixtures__/read-only-computed-decorators.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Component from '@ember/component'; | ||
import { computed, get } from '@ember/object'; | ||
import { alias } from '@ember/object/computed'; | ||
|
||
export default class Foo extends Component { | ||
bar; | ||
// baz class property | ||
baz = 'barBaz'; | ||
|
||
@alias('model.isFoo') | ||
isFoo; | ||
|
||
@computed('baz', 'bar') | ||
get barBazInfo() { | ||
return `Bar: ${get(this, 'bar')}, Baz: ${get(this, 'baz')}`; | ||
} | ||
|
||
@(computed('bar', 'isFoo').readOnly()) | ||
get barInfo() { | ||
return get(this, 'isFoo') ? `Name: ${get(this, 'bar')}` : 'Bar'; | ||
} | ||
|
||
// This should not remove the 'blah' decorator since its not a computed property. | ||
@blah('bar') | ||
get barData() { | ||
return get(this, 'bar'); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
transforms/tracked-properties/__testfixtures__/read-only-computed-decorators.output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { tracked } from '@glimmer/tracking'; | ||
import Component from '@ember/component'; | ||
import { computed, get } from '@ember/object'; | ||
import { alias } from '@ember/object/computed'; | ||
|
||
export default class Foo extends Component { | ||
@tracked bar; | ||
// baz class property | ||
@tracked baz = 'barBaz'; | ||
|
||
@alias('model.isFoo') | ||
isFoo; | ||
|
||
get barBazInfo() { | ||
return `Bar: ${get(this, 'bar')}, Baz: ${get(this, 'baz')}`; | ||
} | ||
|
||
@(computed('isFoo').readOnly()) | ||
get barInfo() { | ||
return get(this, 'isFoo') ? `Name: ${get(this, 'bar')}` : 'Bar'; | ||
} | ||
|
||
// This should not remove the 'blah' decorator since its not a computed property. | ||
@blah('bar') | ||
get barData() { | ||
return get(this, 'bar'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters