Skip to content

Frontend code style  #11

@susnux

Description

@susnux

Prologue

For backend development we are using the PHP CS fixer with our code style for PHP.

Problem

For frontend code we have no established code style. Currently some apps and some libraries are using our eslint-config which currently (as of 2024) also includes some stylistic rules from the standardjs project.
Also our stylelint configuration includes some stylistic rules.

As we mostly use Vue we tried to follow some of the Vue styleguide rules, but we do not enforce them all.

But in general both ESLint and Stylelint decided or followed the "mindset" to separate linters (for code quality and issues) and formatters (for code style). This means e.g. with current Stylelint there are no stylelistic rules anymore and ESLint with v9 also deprecated and removed a lot of stylistic rules.

Proposal

  1. Adjust our rules to match closer with the Vue styleguide, for the reasons mentioned on the rules.
  2. We should join ESLint and Stylelint and use them only for linting, meaning for rules that prevent issues and bugs.
    For stylistic rules, speaking so the code style, we should use a formatter.

I propose to use the very well known Prettier.
From my point of view it creates a good code style especially it creates code that is easier to review (diff).
It does not let much room for discussion about what to configure, this is a benefit and a negative point however you want to see it.

An example configuration can be found here: Prettier config
It is built with current (v8) ESLint rules in mind to reduce the diff when applying the new config.

Alternative

There are also ways to bring back stylistic rules to ESLint and stylelint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions