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

Option to permit different indentations inside and outside multiline strings #505

Open
tchwpkgorg opened this issue Apr 28, 2024 · 3 comments

Comments

@tchwpkgorg
Copy link

tchwpkgorg commented Apr 28, 2024

I have a bash script which has multiline variables, which begin lines with spaces:

#!/bin/bash

RULES="rules:
  - when: manual  # <-----  two spaces at the beginning of the line
    allow_failure: true"  # <-----  four spaces at the beginning of the line

My .editorconfig assumes tabs:

[shell]
indent_style = tab
indent_size = 4

[*.sh]
indent_style = tab
indent_size = 4

When I run it against editorconfig, I get an error, like:

	4: Wrong indentation type(spaces instead of tabs)
	5: Wrong indentation type(spaces instead of tabs)

Is there a rule to make editorconfig ignore the contents of bash variables?

@tchwpkgorg tchwpkgorg added the bug label Apr 28, 2024
@cxw42
Copy link
Member

cxw42 commented Apr 28, 2024

Thanks for reporting! Could you please post the steps you used to get the above output? I think the answer probably depends on exactly which tools you are using.

@cxw42 cxw42 added question and removed bug labels Apr 28, 2024
@cxw42 cxw42 changed the title editorconfig forces tabs in multiline variables Option to permit different indentations inside and outside multiline strings Apr 28, 2024
@tchwpkgorg
Copy link
Author

Not exactly sure! My editorconfig is running as a part of megalinter, which reports it as editorconfig issue.

@cxw42
Copy link
Member

cxw42 commented Apr 29, 2024

I've never heard of megalinter --- is it this? https://github.com/oxsecurity/megalinter/blob/main/megalinter/descriptors/editorconfig.megalinter-descriptor.yml

Your request is reasonable, but I don't know a way to support it. EditorConfig only stores one set of conventions per file, and doesn't know anything about blocks within files. I have noted this issue in the wider discussion at #415 (comment).

Edit As of right now, the checker would have to implement a custom property supporting this behaviour.

(note: the above link for megalinter appears to delegate to https://github.com/editorconfig-checker/editorconfig-checker/blob/main/pkg/validation/validation.go, which uses the golang core.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants