nvim-lint icon indicating copy to clipboard operation
nvim-lint copied to clipboard

Add oxlint, the faster eslint alternative

Open msiirodrigo2670 opened this issue 1 year ago • 5 comments

OXC Linter Documentation

Features

  • 50 - 100 times faster than ESLint, and scales with the number of CPU cores (benchmark).
  • Over 200 rules with a growing list from eslint, typescript, eslint-plugin-react, eslint-plugin-jest, eslint-plugin-unicorn, and eslint-plugin-jsx-a11y.
  • Supports .eslintignore.
  • Supports ESLint comment disabling.
  • Lint <script> content of .vue, .astro, .svelte files by default.

msiirodrigo2670 avatar Feb 08 '24 01:02 msiirodrigo2670

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

fbuchlak avatar Feb 16 '24 09:02 fbuchlak

Happy to contribute toward this when the time comes.

andrew-t-james-core avatar Feb 29 '24 17:02 andrew-t-james-core

The time has come!

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

catgoose avatar Apr 22 '24 14:04 catgoose

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,
  },
}

jellydn avatar May 13 '24 04:05 jellydn

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:

catgoose avatar May 13 '24 11:05 catgoose