{"id":15015728,"url":"https://github.com/emberjs/ember-classic-decorator","last_synced_at":"2025-05-05T18:46:20.078Z","repository":{"id":42879167,"uuid":"192813396","full_name":"emberjs/ember-classic-decorator","owner":"emberjs","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-21T17:43:46.000Z","size":1577,"stargazers_count":12,"open_issues_count":23,"forks_count":22,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-29T14:23:46.241Z","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/emberjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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}},"created_at":"2019-06-19T22:41:39.000Z","updated_at":"2025-03-21T17:43:24.000Z","dependencies_parsed_at":"2024-02-23T06:45:56.006Z","dependency_job_id":null,"html_url":"https://github.com/emberjs/ember-classic-decorator","commit_stats":{"total_commits":63,"total_committers":14,"mean_commits":4.5,"dds":"0.47619047619047616","last_synced_commit":"e39496d6a4c7c915fac33e00dfc22e9b51e060d8"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emberjs%2Fember-classic-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emberjs%2Fember-classic-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emberjs%2Fember-classic-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emberjs%2Fember-classic-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emberjs","download_url":"https://codeload.github.com/emberjs/ember-classic-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252270026,"owners_count":21721393,"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","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":"2024-09-24T19:47:50.973Z","updated_at":"2025-05-05T18:46:20.072Z","avatar_url":"https://github.com/emberjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!NOTE]  \n\u003e This library isn't needed. It can safely be removed from your projects with no change to runtime or buildtime behaviors.\n\n\u003e [!CAUTION]\n\u003e This library should be removed if you plan on switching to Vite. (Vite supports ember-source 3.28+) \n\n# ember-classic-decorator\n\nThis addon provides a dev-time only class decorator, `@classic`. This decorator\ngets removed from production builds, and is entirely for the purpose of helping\nyou navigate the upgrade from Ember's _classic class_ system to native classes\nin Ember Octane!\n\n\n## Installation\n\nFirst, install the addon:\n\n```\nember install ember-classic-decorator\n```\n\nYou should also ensure you are using the latest version of the [Ember eslint\nplugin](https://github.com/ember-cli/eslint-plugin-ember) and enable the related\neslint rules to gain the full benefits of the decorator:\n\n```js\n// .eslintrc.js\n\n  // ...\n  rules: {\n    'ember/classic-decorator-hooks': 'error',\n    'ember/classic-decorator-no-classic-methods': 'error'\n  },\n  // ...\n```\n\n### Why do I need this decorator?\n\nWhile you can now use native class syntax to extend from any Ember base class,\nthere are still a few differences between classic classes and native classes\nthat can be a little tricky during the conversion:\n\n- `init` and `constructor` are two separate methods that are called at different\n  times. If you convert a class to native class syntax and change its\n  `init` function to `constructor`, then it will run before any of its parent\n  classes' `init` methods. This could leave you in an inconsistent state, and\n  cause subtle bugs.\n- Ember's classic class system uses many static class methods such as `create`,\n  `reopen`, and `reopenClass`, which do not have native class equivalents. Some\n  classes will need to be redesigned to account for this.\n- All Ember classes have a number of methods, like `get`, `set`,\n  `incrementProperty`, and `notifyPropertyChange`. In the future, most of these\n  methods will not be necessary, and will not exist on future base classes like\n  Glimmer components.\n- Speaking of Glimmer components - if you convert your application to native\n  classes, and then start converting each component to Glimmer components, it\n  could get confusing very quickly. Is this component class a Glimmer component,\n  or a classic component?\n\n`@classic` provides a hint to you, the developer, that this class uses classic\nAPIs and base classes, and still has some work to do before it can be marked as\nfully converted to Octane conventions.\n\n### What does it do?\n\nWhen installed, `@classic` will modify Ember classes to assert if certain APIs\nare used, and lint against other APIs being used, _unless_ a class is defined\nwith classic class syntax, or decorated with `@classic`.\n\nThe following APIs will throw an error if used in a non-classic class:\n\n* `reopen`\n* `reopenClass`\n\nThe following APIs will cause a _lint_ error if used in a non-classic class\n_definition_. Since we cannot know everywhere that the class is used, instances\nof the class may still use these methods and will not cause assertions or lint\nerrors:\n\n  - `get`\n  - `set`\n  - `getProperties`\n  - `setProperties`\n  - `getWithDefault`\n  - `incrementProperty`\n  - `decrementProperty`\n  - `toggleProperty`\n  - `addObserver`\n  - `removeObserver`\n  - `notifyPropertyChange`\n\nIn addition, `@classic` will prevent users from using `constructor` in\nsubclasses if the parent class has an `init` method, to prevent bugs caused by\ntiming issues.\n\n### Which classes must be marked as @classic?\n\nCertain classes must _always_ be marked as classic:\n\n- Classic components\n- Utility classes that extend directly from `EmberObject`\n\nThese must be marked as classic because their APIs are intrinsically tied to the\nclassic class model. To remove the `@classic` decorator from them, you can:\n\n- Convert classic components to Glimmer components\n- Rewrite utility classes so they do not extend from `EmberObject` at all, and\n  only use native class syntax.\n\nOther classes can be converted incrementally to remove classic APIs, including:\n\n- Routes\n- Services\n- Controllers\n- Class based helpers\n\n### How do I refactor and remove @classic?\n\nIn order to remove the classic decorator from a class, you must:\n\n- Remove usage of mixins from the class\n- Remove usage of static class methods on the class, such as `reopen` and\n  `reopenClass`\n- Remove usage of classic class methods within the class definition, including:\n  - `get`\n  - `set`\n  - `getProperties`\n  - `setProperties`\n  - `getWithDefault`\n  - `incrementProperty`\n  - `decrementProperty`\n  - `toggleProperty`\n  - `addObserver`\n  - `removeObserver`\n  - `notifyPropertyChange`\n\n## Compatibility\n\n- Ember.js v3.24 or above\n- Ember CLI v3.24 or above\n- Node.js v12 or above\n\n## Usage\n\nApply the `@classic` decorator to any classes that should use classic APIs.\n\n```js\nimport EmberObject from '@ember/object';\nimport classic from 'ember-classic-decorator';\n\n@classic\nexport default class Foo extends EmberObject {}\n```\n\n## Contributing\n\nSee the [Contributing](CONTRIBUTING.md) guide for details.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femberjs%2Fember-classic-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femberjs%2Fember-classic-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femberjs%2Fember-classic-decorator/lists"}