# NOT RUN {
dropping <- specify_transformers_drop(
spaces = c(remove_space_after_excl = "'!'")
)
style_guide <- create_style_guide(
space = list(remove_space_after_excl = styler:::remove_space_after_excl),
transformers_drop = dropping
)
# transformers_drop() will remove the transformer when the code does not
# contain an exclamation mark
style_guide_with_some_transformers_dropped <- styler:::transformers_drop(
"x <- 3;2", style_guide
)
setdiff(
names(style_guide$space),
names(style_guide_with_some_transformers_dropped)
)
# note that dropping all transformers of a scope means that this scope
# has an empty named list for this scope
style_guide_with_some_transformers_dropped$space
# this is not the same as if this scope was never specified.
tidyverse_style(scope = "none")$space
# Hence, styler should check for length 0 to decide if a scope is present or
# not, not via `is.null()` and we can use the `is.null()` check to see if
# this scope was initially required by the user.
# }
Run the code above in your browser using DataLab