Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't respect prettier-ignore #3

Open
JounQin opened this issue Jul 1, 2022 · 5 comments
Open

Doesn't respect prettier-ignore #3

JounQin opened this issue Jul 1, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@JounQin
Copy link

JounQin commented Jul 1, 2022

// prettier-ignore
shadow(offset-x, args...)
  box-shadow offset-x args
  margin-top offset-x
@JounQin
Copy link
Author

JounQin commented Jul 1, 2022

Besides, how to comment without a new line?

@lsdsjy lsdsjy added the bug Something isn't working label Jul 1, 2022
@lsdsjy
Copy link
Owner

lsdsjy commented Jul 1, 2022

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
Copy link
Author

JounQin commented Jul 1, 2022

@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 lsdsjy added enhancement New feature or request and removed bug Something isn't working labels Jul 2, 2022
@lsdsjy
Copy link
Owner

lsdsjy commented Jul 30, 2022

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
Copy link
Author

JounQin commented Jul 30, 2022

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

So there is never comment without new line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants