mfussenegger / nvim-lint

An asynchronous linter plugin for Neovim complementary to the built-in Language Server Protocol support.
GNU General Public License v3.0
1.94k stars 204 forks source link

Add oxlint, the faster eslint alternative #531

Closed msiirodrigo2670 closed 4 months ago

msiirodrigo2670 commented 7 months ago

OXC Linter Documentation

Features

fbuchlak commented 7 months ago

For easier implementation I'm waiting for 1462 with this.

andrew-t-james-core commented 7 months ago

Happy to contribute toward this when the time comes.

catgoose commented 5 months ago

The time has come!

https://github.com/oxc-project/oxc/issues/1462 has been merged.

jellydn commented 4 months ago

Here is how I set up with my neovim. Just leave here if anyone want to take a try.

return {
  {
    "mfussenegger/nvim-lint",
    opts = {
      linters_by_ft = {
        javascript = { "oxlint" },
        typescript = { "oxlint" },
        javascriptreact = { "oxlint" },
        typescriptreact = { "oxlint" },
      },
    },
    init = function()
      -- Register oxlint, based on `lua/lint/linters/jshint.lua`
      require("lint").linters.oxlint = {
        name = "oxlint",
        -- cargo install --features allocator --git https://github.com/oxc-project/oxc oxc_cli
        cmd = "oxlint", // NOTE: this is using oxlint bin from cargo
        stdin = false,
        args = { "--format", "unix" },
        stream = "stdout",
        ignore_exitcode = true,
        parser = require("lint.parser").from_errorformat("%f:%l:%c: %m", {
          source = "oxlint",
          severity = vim.diagnostic.severity.WARN,
        }),
      }
    end,
  },
}
catgoose commented 4 months ago

Here is how I set up with my neovim. Just leave here if anyone want to take a try.

return {
  {
    "mfussenegger/nvim-lint",
    opts = {
      linters_by_ft = {
        javascript = { "oxlint" },
        typescript = { "oxlint" },
        javascriptreact = { "oxlint" },
        typescriptreact = { "oxlint" },
      },
    },
    init = function()
      -- Register oxlint, based on `lua/lint/linters/jshint.lua`
      require("lint").linters.oxlint = {
        name = "oxlint",
        -- cargo install --features allocator --git https://github.com/oxc-project/oxc oxc_cli
        cmd = "oxlint", // NOTE: this is using oxlint bin from cargo
        stdin = false,
        args = { "--format", "unix" },
        stream = "stdout",
        ignore_exitcode = true,
        parser = require("lint.parser").from_errorformat("%f:%l:%c: %m", {
          source = "oxlint",
          severity = vim.diagnostic.severity.WARN,
        }),
      }
    end,
  },
}

What is interesting is if you try this in a vue SFC with the template tags before the script tags, oxlint is reporting the position of the warning offset from the top of the file in the template relative to where the setup tags start:

image

I guess this finally solves the debate of whether to put setup at the beginning or end of the file :rofl: