Extracted from #471
Currently if a user does
then <file>.R is unconditionally formatted, full stop, regardless of exclude and default-exclude.
This means that air format renv/activate.R would try to format renv/activate.R, even though it is part of default-exclude and should never be formatted. Similar results with any user provided excludes.
I think this is wrong!
In particular, it makes it more difficult for tools such as pre-commit and RStudio to invoke air. Those tools have no way of knowing what excludes or default-excludes are, so when a user edits or saves renv/activate.R, both of them are very likely to just call:
air format renv/activate.R
This was a problem for ruff as well, so much so that they added a special --force-exclude option that they use in their default pre-commit hook:
https://github.com/astral-sh/ruff-pre-commit/blob/1629a02ed57c23345951c75547bfe5fb73970fd3/.pre-commit-hooks.yaml#L15
For them, --force-exclude means "Respect excludes even for files provided directly on the command line".
I'd like to make the argument that we should just always respect exclude and default-exclude for files provided directly on the command line.
It seems very unlikely that a user would really want to ever run air format renv/activate.R, but there is a real problem with the fact that pre-commit (and eventually RStudio when it uses stdin) do this right now and will change these files. So I'd advocate for the safer default.
Extracted from #471
Currently if a user does
then
<file>.Ris unconditionally formatted, full stop, regardless ofexcludeanddefault-exclude.This means that
air format renv/activate.Rwould try to formatrenv/activate.R, even though it is part ofdefault-excludeand should never be formatted. Similar results with any user providedexcludes.I think this is wrong!
In particular, it makes it more difficult for tools such as pre-commit and RStudio to invoke air. Those tools have no way of knowing what
excludes ordefault-excludes are, so when a user edits or savesrenv/activate.R, both of them are very likely to just call:This was a problem for ruff as well, so much so that they added a special
--force-excludeoption that they use in their default pre-commit hook:https://github.com/astral-sh/ruff-pre-commit/blob/1629a02ed57c23345951c75547bfe5fb73970fd3/.pre-commit-hooks.yaml#L15
For them,
--force-excludemeans "Respectexcludes even for files provided directly on the command line".I'd like to make the argument that we should just always respect
excludeanddefault-excludefor files provided directly on the command line.It seems very unlikely that a user would really want to ever run
air format renv/activate.R, but there is a real problem with the fact that pre-commit (and eventually RStudio when it uses stdin) do this right now and will change these files. So I'd advocate for the safer default.