Sublime Forum

Package or command to apply auto linting

#1

I can use ruff or black from the command line to automatically fix linting issues with my files. Is there a package or a commando to do this within ST?

0 Likes

#2

https://packagecontrol.io/packages/python-black

1 Like

#3

And https://packagecontrol.io/packages/SublimeLinter-contrib-ruff or the LSP version https://packagecontrol.io/packages/LSP-ruff

1 Like

#4

Thank you both! I tested python-black and it does what I need. I also attempted to use LSP-ruff but I can not get it to work. I mean, it shows the lint messages but how do I make it apply the fixes on command and/or on save? I added:

  // Only "source.*" actions are supported.
  "lsp_code_actions_on_save": {
    "source.fixAll.ruff": true,
  },

to LPS.sublime-settings but nothing happens an save. I know that ruff is working because I can use the command line to invike it as $ ruff format file.py and it does apply the changes.

0 Likes

#5

Got it. I was missing the "lsp_format_on_save": true

0 Likes