mattlqx / pre-commit-search-and-replace

Plugin for pre-commit for arbitrary search and replace on committed files.
MIT License
12 stars 6 forks source link

Skip lines that include `no-search-replace` #13

Closed namurphy closed 7 months ago

namurphy commented 7 months ago

Currently, there isn't a way to skip searches-and-replaces only on a single line.

One practice used by many tools is to end a line with a comment that indicates that a particular linter or formatter rule should be skipped. One possibility would be to implement something like this for pre-commit search and replace. In particular, searches-and-replaces could be skipped if the line contains a phrase like no-search-replace. An example usage would be:

x = this_line_matches_a_pattern()  # no-search-replace

This capability would fit well with programming languages that allow in-line comments, though it wouldn't handle certain markup languages like reStructuredText.

Also, thank you for creating a great tool! I use it frequently!

mattlqx commented 7 months ago

Added in v1.1.0. Thanks for the suggestion.