Commit Graph

39 Commits

Author SHA1 Message Date
Michele Campeotto
515e40bd4c Fix unknown field false positive
When attempting to search through a require, analyzer.search-list was
returning nil instead of indeterminate if it could not find the file.

Fixes #89
2025-11-08 11:58:14 -06:00
Phil Hagelberg
2b2c31c577 Add legacy-multival/legacy-multival-case lint and fix.
As of Fennel 1.6.0, parens in destructuring is deprecated, and we want
to make it easy for people to convert to using table destructuring
instead since it's optimized to compile to the same thing.
2025-10-07 10:18:04 -07:00
XeroOl
5c0894d57d fix vararg issue in compiler environment 2025-08-29 15:41:07 -05:00
XeroOl
13b75260b2 fix initialization options ignoring symbol splitting 2025-08-22 19:03:53 -05:00
Rudolf Adamkovič
fe3fd3340d Add empty-do hint 2025-08-16 10:07:19 -07:00
XeroOl
bf3f353b8d fix issue with duplicate errors
fixes #75
2025-08-08 01:12:57 -05:00
XeroOl
a366e5996d rewrite diagnostics to support pull diagnostics 2025-08-07 22:57:07 -05:00
XeroOl
0828820097 completions no longer suggest invalid fields 2025-07-26 19:10:41 -05:00
XeroOl
319a2ddf10 better messages for not-enough-arguments and too-many-arguments 2025-07-18 13:23:10 -05:00
XeroOl
0817af9488 New nested-associative-operator lint
I want to also get like (if a (if b c)) at some point, but this lint
only covers the ones where flattening fixes it always.
2025-07-17 16:37:44 -05:00
XeroOl
8811454456 split mismatched-argument-count lint into not-enough-arguments and too-many-arguments 2025-07-15 22:56:20 -05:00
XeroOl
722a3a6089 make selflint now covers tests 2025-07-12 16:11:51 -05:00
XeroOl
d4c24b00f4 duplicate-table-keys lint 2025-07-12 16:11:36 -05:00
XeroOl
561f199505 hardcode in some argument counting exceptions 2025-07-11 23:39:01 -05:00
XeroOl
5143310b90 introduce mismatched-argument-count lint 2025-07-11 19:16:06 -05:00
XeroOl
772d59fff1 more changes to the linting system 2025-07-11 18:22:16 -05:00
XeroOl
6f946c76ea add lint that (let [] ...) should be (do ...) 2025-06-19 12:56:29 -05:00
Michele Campeotto
6325b9c6ff Fix operator with no arguments lint incorrect report.
Operator with no arguments check failed when the first argument to the
operator was falsy. We might want to have a new lint to check for
"always false/true" expressions but this report was incorrect and the
quickfix replaced incorrect code.
2025-03-24 08:31:23 -07:00
Michele Campeotto
7345d1bcd6 Update diagnostics to be spec compliant.
The spec says diagnostic.codeDescription should be an object with an URI
linking to information about the error, we were using it as a string
identifier for the diagnostic.

This was making Helix ignore all diagnostics from fennel-ls.

Changed diagnostic.code to be the string identifier, removed numeric
identifiers and codeDescription field.
2025-03-22 12:10:54 -07:00
Michele Campeotto
e504013663 Update unnecessary tset lint to handle any key nesting depth.
The unnecessary tset lint was assuming a single key, but it was
triggering for calls with multiple nested keys, causing the quickfix
action to drop all elements after the fourth argument, which was assumed
to be the value.

Now it's been updated to handle nested calls of any depth.
2025-03-22 12:03:57 -07:00
Phil Hagelberg
3eb016a369 Search for special forms in analyzer. 2025-03-15 12:26:15 -07:00
Phil Hagelberg
e5dc04764c Allow trailing underscores to bypass unused local warnings. 2025-01-05 12:40:25 -08:00
Phil Hagelberg
3979ab4c3c Strings beginning with digits can't be rewritten as syms.
Also fix a self-lint.
2025-01-05 12:39:10 -08:00
XeroOl
7f15f64e22 tset lint should only apply when rewriting as sym is valid 2024-12-28 15:50:44 -06:00
Phil Hagelberg
baf1065f0b Add assert-ok helper for linting tests.
Also factor out FAITH_TEST flag so you can use it to run an entire
module, not just individual tests.
2024-10-10 19:54:18 -05:00
Phil Hagelberg
b5dbeb28fe Add unnecessary-tset, unnecessary-do, and redundant-do lints.
"Redundant" means that it's a `do` in a context where there's already
an implicit `do`, as defined by fennel.syntax indicating body-form? is
true. Unnecessary means it only has one argument.
2024-10-10 19:50:16 -05:00
Phil Hagelberg
a27f42bfa4 Add match-should-case lint and fix action.
When a `match` call's patterns do not contain any symbols that reference
the outer scope, then there is no reason to use `match`; that call
should be replaced with `case`.

This allocates diagnostic code 308 to match-should-case.

In order to detect this, I had to add a loop over file.lexicals. This
is often a very large table, so it could adverse performance impact. I
believe it is necessary in order to distinguish between case vs match
since other means seem to only be applied after macroexpansion by
which time neither one exists.

I've updated docs/linting.md to mention the new loop and cleaned up a
few things in that file that were outdated.

I've added tests for the new lint to ensure it doesn't trigger when it
shouldn't.
2024-10-10 19:46:59 -05:00
XeroOl
3d1485060c fix "unknown module field" when accessing fields from doc objects with no known fields
this means stuff like `io.stderr:write` isn't a warning anymore
2024-07-15 17:48:11 -05:00
XeroOl
6801d0d3d9 unknown module field lint works on definitions 2024-07-07 23:54:17 -05:00
XeroOl
d309c80541 simplify tests. only one create-client function 2024-07-05 00:25:51 -05:00
XeroOl
8dc4f3d0f8 Rename language -> analyzer 2024-06-05 01:22:08 -05:00
XeroOl
c56ce89ccf λ now warns about unused arguments 2024-06-04 20:17:21 -05:00
XeroOl
e0067880d1 Unknown field lint only triggers at stack size 1
This is probably not a good commit message, but basically, if you
require a module foo, and then look for foo.bar.baz, it won't trigger,
but foo.bar will trigger it.
2024-05-29 22:38:55 -05:00
XeroOl
34e0bce092 Hover in hashfn 2024-05-12 15:32:43 -05:00
XeroOl
be44cda696 Unknown field errors in _G are suppressed 2024-05-12 12:26:24 -05:00
XeroOl
2d7c8b1ad7 Lints for doc fields, doc hovers on strings 2024-05-04 15:37:01 -05:00
XeroOl
311ce2645e fix fennel-ls#22
This is getting messy, but now the same sym can reference multiple
places. (. file references mysym) only holds the last one, but
(. file definitions <x> :referenced-by) could still hold older
references.
2024-04-07 23:18:14 -05:00
XeroOl
3bc530e11b in tests, separate compile error diagnostics from lints 2024-03-28 23:04:25 -05:00
XeroOl
b5750b1a8a rename diagnostic to lint 2024-03-28 23:01:20 -05:00