{"id":25157539,"url":"https://github.com/ota-insight/ember-computed-macro-codemod","last_synced_at":"2025-10-25T11:05:05.726Z","repository":{"id":154476786,"uuid":"629527902","full_name":"OTA-Insight/ember-computed-macro-codemod","owner":"OTA-Insight","description":"A codemod for converting Ember computed property macros (a.k.a. shorthands) to native getters in class syntax","archived":false,"fork":false,"pushed_at":"2023-05-15T07:45:32.000Z","size":1452,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-03T02:51:30.866Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OTA-Insight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-18T13:49:11.000Z","updated_at":"2023-08-01T11:18:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"e60e61ba-9a0c-46ff-b526-00df59f842b9","html_url":"https://github.com/OTA-Insight/ember-computed-macro-codemod","commit_stats":{"total_commits":24,"total_committers":3,"mean_commits":8.0,"dds":0.08333333333333337,"last_synced_commit":"7c3e6d3e2e95c15144789217e7b00778ac670166"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/OTA-Insight/ember-computed-macro-codemod","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OTA-Insight%2Fember-computed-macro-codemod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OTA-Insight%2Fember-computed-macro-codemod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OTA-Insight%2Fember-computed-macro-codemod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OTA-Insight%2Fember-computed-macro-codemod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OTA-Insight","download_url":"https://codeload.github.com/OTA-Insight/ember-computed-macro-codemod/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OTA-Insight%2Fember-computed-macro-codemod/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280943394,"owners_count":26417747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-09T01:24:00.870Z","updated_at":"2025-10-25T11:05:05.691Z","avatar_url":"https://github.com/OTA-Insight.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-computed-macro-codemod\n\n\nA codemod for converting Ember computed property macros (a.k.a. shorthands) to native getters in class syntax.\n\n## Updating your codebase\n\nThe recommended Ember ESLint config [discourages computed property macros](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-computed-properties-in-native-classes.md) for class based syntax. Instead, it recommends to use auto tracking and native getters. This codemod converts a subset (see support matrix) of all computed property macros to native getters.\n\nSee also:\n- This codemod only runs on JavaScript Class syntax. If you haven't already, use the [ember-native-class](https://github.com/ember-codemods/ember-native-class-codemod) codemod to transform object syntax to class syntax.\n- The [ember-tracked-properties](https://github.com/ember-codemods/ember-tracked-properties-codemod) codemod will further help you migrate from `@computed` to tracked properties.\n\n## Usage\n\n```\nnpx @ota-insight/ember-computed-macro-codemod path/of/files/ or/some**/*glob.js\n```\n\n\u003e **Warning**\n\u003e As with most codemods, changes are made in place, meaning it will overwrite existing files. Make sure to run this codemod on a codebase that has been checked into version control to avoid losing progress.\n\nThe codemod accepts the following options:\n\n|        Option         |  Value  |             Default             |                                                                     Details                                                                      |\n| --------------------- | ------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `--macros`      | string | `alias,and,equal,gt,gte,lt,lte,or,readOnly`                          | Filter which computed macros should be transformed. By default, all supported ones are transformed.                                                                              |\n| `--add-computed-decorator`      | boolean | `false`                          | Add the `@computed` decorator to the native getter for full compatibility. Skipping this has sublte side effects which could cause issues.\u003csup\u003e1\u003c/sup\u003e                                                                             |\n\n\u003csmall\u003e1. Computed property macros are computed properties, thus only recompute once the dependency keys are updated. If you want to keep this behaviour, the `@cached` decorator should be added. This should however be used with caution, and is usually something you don't want. ([see docs](https://api.emberjs.com/ember/release/functions/@glimmer%2Ftracking/cached)) Alternatively, you can opt to readd the `@computed` decorator to keep compatible behaviour in case where not all dependencies are auto tracked yet.\u003c/small\u003e\n\n## Basic example\n\nGiven the following input file:\n\n```js\nimport { readOnly } from '@ember/object/computed';\n\nclass Foo {\n  @readOnly('foo.bar') bar;\n}\n```\n\nThe codemod will rewrite this to use native getters:\n\n```js\nclass Foo {\n  get bar() {\n    return this.foo?.bar;\n  }\n}\n```\n\nFor a complete list of example transforms, see the [computed-macro](transforms/computed-macro/README.md) transform description.\n\n## Support matrix\n\n| Computed property macro   | Supported |\n|------------------|-----------|\n| alias            | ✅         |\n| and              | ✅         |\n| bool             | ❌         |\n| collect          | ❌         |\n| deprecatingAlias | ❌         |\n| empty            | ❌         |\n| equal            | ✅         |\n| expandProperties | ❌         |\n| filter           | ❌         |\n| filterBy         | ❌         |\n| gt               | ✅         |\n| gte              | ✅         |\n| intersect        | ❌         |\n| lt               | ✅         |\n| lte              | ✅         |\n| map              | ❌         |\n| mapBy            | ❌         |\n| match            | ❌         |\n| max              | ❌         |\n| min              | ❌         |\n| not              | ❌         |\n| notEmpty         | ❌         |\n| oneWay           | ❌         |\n| or               | ✅         |\n| readOnly         | ✅         |\n| reads            | ❌         |\n| setDiff          | ❌         |\n| sort             | ❌         |\n| sum              | ❌         |\n| union            | ❌         |\n| uniq             | ❌         |\n| uniqBy           | ❌         |\n\n### Known limitations\n\n- Computed property macros with complex dependent keys are not supported (`@each`, `.{}`, `.[]`).\n- Doesn't handle invalid usages of marcos, e.g. using `and`, `or` with only one argument.\n- Expects you import computed macros from `@ember/object/computed`, instead of e.g. using `@computed.readOnly()`.\n\n\n## Transforms\n\n\u003c!--TRANSFORMS_START--\u003e\n* [computed-macro](transforms/computed-macro/README.md)\n\u003c!--TRANSFORMS_END--\u003e\n\n## Contributing\n\n### Installation\n\n* clone the repo\n* change into the repo directory\n* `yarn`\n\n### Running tests\n\n* `yarn test`\n\n### Update Documentation\n\n* `yarn update-docs`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fota-insight%2Fember-computed-macro-codemod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fota-insight%2Fember-computed-macro-codemod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fota-insight%2Fember-computed-macro-codemod/lists"}