adamzapasnik / prettier-plugin-erb

Prettier ERB plugin
MIT License
103 stars 26 forks source link

Multiline-comment lines containing a colon are indented with each formatter run #32

Open Wowu opened 3 years ago

Wowu commented 3 years ago

Given a file:

<%#
Multiline comment
test: test
%>

This is the file content after running prettier for the first time:

<%#
  Multiline comment
    test: test
%>

This is the content after running prettier for the second time:

<%#
  Multiline comment
      test: test
%>

And it goes on, indenting this line with each run 😄

.prettierrc.yml:

printWidth: 100
plugins:
  - "@prettier/plugin-ruby"
  - prettier-plugin-erb

package.json:

...
"devDependencies": {
    "@prettier/plugin-ruby": "^1.5.5",
    "prettier": "2.2.1",
    "prettier-plugin-erb": "git+https://github.com/adamzapasnik/prettier-plugin-erb.git#6374074005"
  },
...

(latest master branch, as of creating this issue)


Other example, from kaminari gem:

<%# Link to the "Previous" page
  - available local variables
    url:           url to the previous page
    current_page:  a page object for the currently displayed page
    total_pages:   total number of pages
    per_page:      number of items to fetch per page
    remote:        data-remote
-%>

After formatting:

<%#
  Link to the "Previous" page
    - available local variables
      url:           url to the previous page
      current_page:  a page object for the currently displayed page
      total_pages:   total number of pages
      per_page:      number of items to fetch per page
      remote:        data-remote
-%>

After formatting again:

<%#
  Link to the "Previous" page
      - available local variables
        url:           url to the previous page
        current_page:  a page object for the currently displayed page
        total_pages:   total number of pages
        per_page:      number of items to fetch per page
        remote:        data-remote
-%>
adamzapasnik commented 3 years ago

Hey @Wowu :wave: Good catch :stuck_out_tongue_winking_eye: Working on a fix

adamzapasnik commented 3 years ago

should be fixed in a newly released v0.2.0