question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Octane Rule: `no-component-lifecycle-hooks`

See original GitHub issue

Pulled 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:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jbanduracommented, Oct 21, 2019

I’d like to tackle this 🙂

1reaction
Turbo87commented, Oct 27, 2019

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found