-
-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add invalid-fn-name linter #2211
Conversation
Fixes clj-kondo#2159 paritially
I noticed that the |
Merged master back in so it's easier to see it can be merged. Also updated the error message to be a bit more accurate. I think the only question that needs answering before it can be merged is if it's ok to set the default config for this to be |
Hey @tomdl89 ! I appreciate the effort, but I think the PR fixes more than one issue and partially fixes the main issue it was written for? If this PR is only for checking that the name of a |
Hey @borkdude yes the PR definitely has some scope creep, no doubt. But I'm fairly sure it isn't otherwise over-engineered. The only bit of code that checks for invalid fns directly is The rest of the code is expanding function reader literals (i.e. That, and tests to support the above work. Some project prefer separate PRs, but I felt that it was connected enough to warrant one PR. Let me know what you'd like and I'll get on it :) |
Yes, let's split it up into tinier issues. With the expanding of fn literals, please give a test case that would otherwise fail with the current order. |
Ah, cool. I just extracted mine too. Lemme compare the approaches... |
So, your version is arguably a bit neater, but it does miss things like this: (fn {:foo :bar} [x] (+ x 42)) which mine catches, because it explicitly says the first arg has to be a symbol, arg vec or fn arity: ({:file "<stdin>",
:row 1,
:col 1,
:level :error,
:message "First arg of fn should be a symbol, params vector or arity clause"}) otherwise, good catch on needing to lint it for fns and defns. I'll add that. |
I'll close this to reduce clutter. Can spin out the threading-macro-related functionality in a later PR. |
Fixes #2159 paritially
Please answer the following questions and leave the below in as part of your PR.
[✓] I have read the developer documentation.
[✓] This PR corresponds to an issue with a clear problem statement.
New linter idea: threaded-fn-form #2159
[✓] This PR contains a test to prevent against future regressions
[✓] I have updated the CHANGELOG.md file with a description of the addressed issue.
This, effectively supersedes #2160, although as noted in the test file, there is still room for a linter which catches bound vars threaded into fn name position.