Skip to content

lint: Wrap array/objects from JSX in one line if possible #1494

@WaDadidou

Description

@WaDadidou

In our front, a lot of arrays and objects declarations could be wrapped on one line, but are extended on many lines.
It increases the number of lines in files
(Even if I think it's more readable (And big blocks can be wrapped/collapsed by click in IDEs), I understand the need).

This
Image
Could be this
Image

Formatting can be done using IDE parameters, but we want to be objective and format the code automatically.
So, maybe a lint rule can do the job

Here: https://github.com/TERITORI/teritori-dapp/blob/main/.eslintrc.js#L93-L98
I propose to add these two rules:

"array-bracket-newline": ["error", "consistent"],
"object-curly-newline": ["error", "never"]

(Not fully tested, not tested in CI)

Then, the code is formatted automatically in CI, using our config https://github.com/TERITORI/teritori-dapp/blob/main/.github/workflows/js.yml#L25
Or manually, using our scripts: https://github.com/TERITORI/teritori-dapp/blob/main/package.json#L12-L13

==> Should we make a PR that format the tens of files after manually triggering a yarn lint-fix? Or should we make a PR that just add these rules ?


Cf this comment on a PR: #1477 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requestedrefacto

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions