Skip to content

Commit 01b5769

Browse files
committed
feat(pack): add eslint
1 parent 567643e commit 01b5769

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ESLint
2+
3+
[ESLint](https://eslint.org/) ESLint is a tool for identifying and reporting on
4+
patterns found in ECMAScript/JavaScript code, with the goal of making code more
5+
consistent and avoiding bugs.
6+
7+
ESLint is completely pluggable. Every single rule is a plugin and you can add
8+
more at runtime. You can also add community plugins, configurations, and
9+
parsers to extend the functionality of ESLint.
10+
11+
## Prerequisites
12+
13+
To use ESLint, you must have [Node.js](https://nodejs.org/en/) (^18.18.0, ^20.9.0, or >=21.1.0) installed
14+
and built with SSL support. (If you are using an official Node.js distribution, SSL is always built in.)
15+
16+
## How do I disable Eslint format on save?
17+
18+
To opt out of the Eslint format on save behaviour, you can disable the autocmd setup with the pack with this:
19+
20+
```lua
21+
return {
22+
"AstroNvim/astrolsp",
23+
optional = true,
24+
opts = {
25+
autocmds = {
26+
eslint_fix_on_save = false,
27+
},
28+
},
29+
}
30+
```
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
return {
2+
{
3+
"AstroNvim/astrolsp",
4+
optional = true,
5+
---@type AstroLSPOpts
6+
opts = {
7+
autocmds = {
8+
eslint_fix_on_save = {
9+
cond = function(client) return client.name == "eslint" and vim.fn.exists ":EslintFixAll" > 0 end,
10+
{
11+
event = "BufWritePost",
12+
desc = "Fix all eslint errors",
13+
callback = function(args)
14+
if vim.F.if_nil(vim.b[args.buf].autoformat, vim.g.autoformat, true) then vim.cmd.EslintFixAll() end
15+
end,
16+
},
17+
},
18+
},
19+
},
20+
},
21+
{
22+
"williamboman/mason-lspconfig.nvim",
23+
optional = true,
24+
opts = function(_, opts)
25+
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed or {}, { "eslint" })
26+
end,
27+
},
28+
{
29+
"WhoIsSethDaniel/mason-tool-installer.nvim",
30+
optional = true,
31+
opts = function(_, opts)
32+
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed or {}, { "eslint-lsp" })
33+
end,
34+
},
35+
{
36+
"echasnovski/mini.icons",
37+
optional = true,
38+
opts = function(_, opts)
39+
if not opts.file then opts.file = {} end
40+
opts.file[".eslintrc.js"] = { glyph = "󰱺", hl = "MiniIconsYellow" }
41+
opts.file["eslint.config.js"] = { glyph = "󰱺", hl = "MiniIconsYellow" }
42+
end,
43+
},
44+
}

0 commit comments

Comments
 (0)