New Octane Rule: `no-component-lifecycle-hooks`
See original GitHub issuePulled from https://github.com/ember-cli/eslint-plugin-ember/issues/533 which proposes a new set of rules for Octane related best practices
Disallow “Classic” Ember Component lifecycle hooks. Prefer using @ember/render-modifiers
or custom functional modifiers.
List of Component lifecycle hooks pulled from here
// ### Good
export default class MyComponent extends Component {
init() { ... }
willDestroy() { ... }
}
export default Component.extend({
init() { ... }
willDestroy() { ... }
});
// ### Bad
export default class MyComponent extends Component {
didDestroyElement() {}
didInsertElement() {}
didReceiveAttrs() {}
didRender() {}
didUpdate() {}
didUpdateAttrs() {}
willClearRender() {}
willDestroyElement() {}
willRender() {}
}
export default Component.extend({
didDestroyElement() {},
didInsertElement() {},
didReceiveAttrs() {},
didRender() {},
didUpdate() {},
didUpdateAttrs() {},
willClearRender() {},
willDestroyElement() {},
willRender() {},
});
If anyone would like to implement this please comment that you’ll take it and work away.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Glimmer Components - Octane Upgrade Guide - Ember Guides
Lifecycle and Properties ... These components have 2 lifecycle hooks: ... These can be used to setup the class and tear it down,...
Read more >eslint-plugin-ember - npm
An ESLint plugin that provides a set of rules for Ember applications ... no-component-lifecycle-hooks, disallow usage of "classic" ember ...
Read more >eslint-plugin-ember/README.md - UNPKG
Note that new rules should not immediately be added to the [recommended](./lib/recommended-rules.js) configuration, as we only consider such breaking changes ...
Read more >Yehuda Katz on Twitter: "I don't think Ember Octane really got ...
Heterodox view: components are not the primary unit of composition in front ... we call modifiers) to abstract over DOM lifecycle; they work...
Read more >The 8 Most Common Mistakes That Ember.js Developers Make
Routes in Ember have a handful of lifecycle hooks to define ... In the case of non-component templates, that context is the current...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d like to tackle this 🙂
@jbandura yes, that was the intention. the new way of doing the same thing via modifiers works for ember components too, so IMHO we should warn about the life cycle hooks for those too