Skip to content

Fix ignore behavior for --stdin-filepath#495

Merged
JohnnyMorganz merged 1 commit intoJohnnyMorganz:masterfrom
MunifTanjim:fix-ignore-for-stdin-filepath
Jul 21, 2022
Merged

Fix ignore behavior for --stdin-filepath#495
JohnnyMorganz merged 1 commit intoJohnnyMorganz:masterfrom
MunifTanjim:fix-ignore-for-stdin-filepath

Conversation

@MunifTanjim
Copy link
Copy Markdown
Contributor

Current Behavior

When the .styluaignore file contains:

**/ignored_*

And stylua is run like this:

cat /home/user/lua-project/ignored_file.lua | stylua --search-parent-directories --stdin-filepath /home/user/lua-project/ignored_file.lua -

StyLua still formats the code.

Expected Behavior

When --stdin-filepath is provided, it should respect the .styluaignore rules even if the code is read from stdin.

For reference, Prettier respects the ignore file when --stdin-filepath is provided.

Usecase

Editor plugins depend on this behavior. For example, null-ls.vim is broken for stylua because of this bug... even if a file is ignored in .styluaignore, the file is unexpectedly formatted on save.

Copy link
Copy Markdown
Owner

@JohnnyMorganz JohnnyMorganz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this! And sorry for the delay in reviewing, I seem to have missed the notification about your PR.

Could you please update the CHANGELOG aswell?

Comment thread src/cli/main.rs
Comment thread src/cli/main.rs Outdated
Comment thread src/cli/main.rs Outdated
Comment thread src/cli/config.rs Outdated
Comment thread src/cli/main.rs Outdated
@MunifTanjim MunifTanjim force-pushed the fix-ignore-for-stdin-filepath branch 2 times, most recently from 0745ff2 to 31f4343 Compare July 21, 2022 04:04
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 21, 2022

Codecov Report

Merging #495 (c7abd06) into master (fe8c8e3) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #495   +/-   ##
=======================================
  Coverage   97.66%   97.66%           
=======================================
  Files          14       14           
  Lines        5346     5346           
=======================================
  Hits         5221     5221           
  Misses        125      125           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe8c8e3...c7abd06. Read the comment docs.

@MunifTanjim MunifTanjim force-pushed the fix-ignore-for-stdin-filepath branch 2 times, most recently from d862981 to cc15dad Compare July 21, 2022 12:16
Comment thread src/cli/main.rs Outdated
@MunifTanjim MunifTanjim force-pushed the fix-ignore-for-stdin-filepath branch 2 times, most recently from 11a817b to d394e5f Compare July 21, 2022 12:48
Comment thread src/cli/main.rs Outdated
@MunifTanjim MunifTanjim force-pushed the fix-ignore-for-stdin-filepath branch from d394e5f to c7abd06 Compare July 21, 2022 12:54
Copy link
Copy Markdown
Owner

@JohnnyMorganz JohnnyMorganz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants