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.

Rule proposition: order-in-components

See original GitHub issue

As I mentioned in #10, I think that creating separate issue for each rule proposition has many benefits, so this is my first proposition:

Rule name: order-in-components Description: Keep order of properties in components according to https://docs.gitlab.com/ce/development/fe_guide/style_guide_js.html#ordering

Gitlab’s style guide lists all properties, I would however consider grouping lifecycle hooks in order to make it simpler, like so:

  • name
  • props
  • mixins
  • data
  • components
  • computedProps
  • methods
  • lifecycle hooks

Introducing order rule we can make sure that every component is written in exactly the same way, which would make it more readable and consistent across codebase.

This rule should be configurable, so that anyone can amend proposed order in .eslintrc.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

15reactions
yyx990803commented, Jun 5, 2017

I personally prefer having all assets at top of the component (like dependencies), and then group all state-related options (props, data, computed), hence:

  • name
  • assets (mixins, components, directives, filters)
  • props
  • data
  • computed
  • methods
  • lifecycle hooks
  • render (if used)
6reactions
yyx990803commented, Jun 16, 2017

Looks good - tweaked a bit more:

  • Options / Misc (name, delimiters, functional, model)
  • Options / Assets (components, directives, filters)
  • Options / Composition (parent, mixins, extends, provide, inject)
  • el / template
  • props
  • propsData
  • data
  • computed
  • watch
  • lifecycle hooks
  • methods
  • render
  • renderError

The main thing is I moved template up alongside el, and moved methods to be after lifecycle hooks.

It’s interesting because putting render last is kind of a convention from React land, but I’m much more used to seeing templates earlier to get a visual understanding of a component.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Robert's Rules of Order
Robert's Rules of Order is the standard for facilitating discussions and group decision-making. Copies of the rules are available at most bookstores.
Read more >
on some asymptotically nonparametric competitors of ... - jstor
Summary. In a previous paper [2] the author investigated some alternative estimates of shift in the p-variate one-sample problem. This paper examines the....
Read more >
Category: Vuejs - Full Stack Programmer
Vuejs: Rule proposition of order-in-components ... It's important to keep one standard way of ordering properties in vue components, that will… Posted in ......
Read more >
What's on the ballot? Here's a look at California's 2022 ...
Proposition 31 is a referendum on a law passed by the Legislature in 2020 to ban the sale of many flavored tobacco products...
Read more >
International Journal of Plasticity - COMOD
ick (1966) law adapted to orthotropic material and isotropic hardening, ... mials of the third order in components of the stress, while the...
Read more >

github_iconTop Related Medium Post

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