ThisIsManta / stylus-supremacy

A Node.js script that helps formatting Stylus files.
https://thisismanta.github.io/stylus-supremacy
MIT License
88 stars 9 forks source link

Format or ignore the mixins `named parameters` #26

Closed zoxon closed 6 years ago

zoxon commented 6 years ago

Hello, thank you for the wonderful tool. I have a question about named mixin parameters.

Example: This code is

font-face(
    family: "Noto Sans",
    file-name: "regular",
    base-path: "../fonts/noto/sans",
    formats: eot woff2 woff truetype
)

.button_style_solid.button_color_gray
    button-style(
        color: $gray-6,
        background-color: $gray-2,
        background-color-hover: $gray-3
    )

formatted to this

font-face(family: 'Noto Sans', file-name: 'regular', base-path: '../fonts/noto/sans', formats: eot woff2 woff truetype)
.button_style_solid.button_color_gray
  button-style(color: $gray-6, background-color: $gray-2, background-color-hover: $gray-3)

How can I disable formatting or better format more pretty (readable) like now?

ThisIsManta commented 6 years ago

Thank you for your opinion.

I agreed that it was hard to read when they were in the same line. Spare me sometime to find a solution for all.

zoxon commented 6 years ago

IMHO. The first thing to do is to disable formatting wiht inline comments, like in eslint. https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments This will solve a lot of problems in the future

ThisIsManta commented 6 years ago

Here's my solution:

If the original function call is written in a single line, for example mixin(arg1: val1, arg2, val2), then the formatted content will be in a single line mixin(arg1: val1, arg2, val2).

If the original function call has one or more arguments written in a different line, for example

mixin(arg1: val1,
  arg2: val2)

then the formatted content will be distributed in different line

mixin(
  arg1: val1,
  arg2: val2
)

This out-of-the-box solution has been implemented in version version 2.10.0, which is available now. You don't have to config anything to get this work.

Personally, I don't like the way ESLint allow us to make an exception to some rules/files. I'd rather make a patch to fix a real issue.

Cheers!

zoxon commented 6 years ago

Thank You for the quick feedback