lsdsjy / prettier-plugin-stylus

Prettier plugin for Stylus.
17 stars 2 forks source link

Doesn't respect `prettier-ignore` #3

Open JounQin opened 2 years ago

JounQin commented 2 years ago
// prettier-ignore
shadow(offset-x, args...)
  box-shadow offset-x args
  margin-top offset-x
JounQin commented 2 years ago

Besides, how to comment without a new line?

lsdsjy commented 2 years ago

Besides, how to comment without a new line?

I think currently inline comment at the end of line is supported, see https://github.com/lsdsjy/prettier-plugin-stylus/blob/main/tests/comment/comment.styl#L2 for an example.

JounQin commented 2 years ago

@lsdsjy

shadow(offset-x, args...) // prettier-ignore
  box-shadow offset-x args
  margin-top offset-x

results

$ stylelint . --cache -f verbose
undefined
error Command failed with exit code 1
shadow(offset-x, args...) { // prettier-ignore
  box-shadow offset-x args
  margin-top offset-x
}

results:

tests/test.styl
 7:1   ✖  Expected 'pythonic' (i.e. indentation-based)  stylus/pythonic  
 7:15  ✖  Replace "...)·{" with ")⏎·"                   prettier/prettier
 9:10  ✖  Delete "⏎}"                                   prettier/prettier

1 source checked
 /Users/JounQin/Workspaces/GitHub/configs/tests/test.styl

3 problems found
 severity level "error": 3
  stylus/pythonic: 1
  prettier/prettier: 2
lsdsjy commented 2 years ago

I think we should come up with a specification of prettier-ignore comments first. Prettier says A JavaScript comment of // prettier-ignore will exclude the next node in the abstract syntax tree from formatting., while it says nothing in the CSS section. If we follow the same definition for JavaScript, then your example is fine because it just ignores the box-shadow ... declaration. (I tried Prettier playground for CSS and it seems to follow the same definition.) If we agree to follow the same definition as described above, I will try to implement it.

JounQin commented 2 years ago

@lsdsjy I think you're right here, // prettier-ignore is for next node, not inline comment.

So there is never comment without new line.