One of the benefits of an IDE is that ... it's integrated. Unlike a CLI tool that has no choice but to run on an entire file (unless it maintains some cache and can do diffing, but that's complex), an IDE knows precisely what you've edited (even without saving to disk), so that it can run linters/formatters on local scopes without needing to parse everything again.
Now that's theoretical. Whether or not real IDEs do that can vary. One of the difficulties here is that you need to be able to parse subsections of a file of code, and modify the existing AST (the one generated from before your edit) to change its nodes that correspond to the area you edited. That might be tricky, so I image a lot of IDEs would have linters/formatters that parse the entire file, every time, and then just apply changes only to the area you selected.