Fix eslint formatting via lspconfig keymap/function `vim.lsp.buf.format`?

Hello everyone.

Unfortunately, I cannot quite figure out how to use eslint for formatting via lspconfig keymap, like for example: vim.keymap.set("n", "<Leader>F", function() vim.lsp.buf.format({ async = true }) end, opts)

I read and searched through quite some threads on GitHub, Reddit, and this Discourse, … and it seems that using eslint this way simply does not work; or is there any convenient way on how to make eslint format my file, i.e. fix eslint (format) errors via this keybinding?

NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3

Find my lspconfig.lua file below:

return {
  "neovim/nvim-lspconfig",

  dependencies = {
    { "folke/neodev.nvim", config = true },
    { "williamboman/mason.nvim", config = true },
    { "williamboman/mason-lspconfig.nvim", config = true },
  },

  config = function()
    -- local capabilities = vim.lsp.protocol.make_client_capabilities()

    local on_attach = function(_, bufnr)
      local opts = { noremap = true, silent = true, buffer = bufnr }
      -- […]
      vim.keymap.set("n", "<Leader>F", function() vim.lsp.buf.format({ async = true }) end, opts)
    end

    local servers = {
      -- […]
      eslint = {},
      -- […]
      stylelint_lsp = {
        settings = {
          stylelintplus = {
            autoFixOnFormat = true,
          },
        },
      },
      sumneko_lua = {
        settings = {
          Lua = {
            workspace = {
              checkThirdParty = false,
            },
            telemetry = {
              enable = false,
            },
          },
        },
      },
    }

    require("mason-lspconfig").setup({
      ensure_installed = vim.tbl_keys(servers),
    })

    require("mason-lspconfig").setup_handlers({
      function(server_name)
        require("lspconfig")[server_name].setup({
          -- capabilities = capabilities,
          on_attach = on_attach,
          settings = servers[server_name].settings,
        })
      end
    })
  end
}

Thank you very much.

It seems I can use null-ls to configure eslint formatting via:

return {
  "jose-elias-alvarez/null-ls.nvim",

  config = function()
    require("null-ls").setup({
      sources = {
        require("null-ls").builtins.formatting.eslint,
      },
    })

  end
}

… but I’m not sure if using null-ls just for enabling eslint formattting is a clever approach to this issue.