Skip to content
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

How to run with custom rules? #8

Closed
p1tt1 opened this issue Feb 28, 2024 · 6 comments
Closed

How to run with custom rules? #8

p1tt1 opened this issue Feb 28, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@p1tt1
Copy link

p1tt1 commented Feb 28, 2024

I ask what is the best way to start splint with inflow defined rules?

Is it possible to fork without splint?

@NoahTheDuke
Copy link
Owner

What do you mean, "inflow defined rules"? If you mean custom rules, then there's a small amount of work, which I hope to smooth soon.

First, define the rules in some namespace (dev.rules for example). Next, add it to your .splint.edn file: p1tt1/special-rule {:enabled true}. Then call clojure -M:splint -e '(require 'dev.rules)'. This will load the file and then execute the splint runner as normal, including your rule.

I am not entirely sure if you can do this with the bbin version, I haven't tried yet.

Let me know if you need help.

@p1tt1
Copy link
Author

p1tt1 commented Mar 4, 2024

Oh sry, I mean "custom" rules.

Thanks for the quick answer!.
-e "(require 'dev.rules)" is sadly an unknown operation:

❯ clj -M:splint -e "(require 'dev.rules)"
splint errors:
Unknown option: "-e"

@NoahTheDuke
Copy link
Owner

Ah damn, I thought that would work. Let me see if I can whip something up to help you out.

@NoahTheDuke
Copy link
Owner

NoahTheDuke commented Mar 4, 2024

Ah, I missed the crucial final bit. There are two ways to handle it.

  1. You add the -e call directly to the :main-opts in your alias: :splint {:extra-paths ["<PATH TO DEV RULES>"] :extra-deps {io.github.noahtheduke/splint {:mvn/version "1.10.1"}} :main-opts ["-e" "(require 'dev.rules)" "-m" "noahtheduke.splint"]}.

  2. Instead of specifying a :main-opts in the alias, you write the main arg -m noahtheduke.splint explicitly. Your :splint alias is: :splint {:extra-paths ["<PATH TO DEV RULES>"] :extra-deps {io.github.noahtheduke/splint {:mvn/version "1.10.1"}}} and the invocation is clojure -M:splint -e "(require 'dev.rules)" -m noahtheduke.splint.

I'll update the docs while I consider how best to handle this automatically.

@NoahTheDuke NoahTheDuke added enhancement New feature or request question Further information is requested labels Apr 30, 2024
@NoahTheDuke
Copy link
Owner

Okay, having thought about this for a little while, I have a solution in mind. I'd like your feedback before I begin implementation.

There will be a new command-line flag -r / --require as well as a require top-level entry in .splint.edn. This must be a vector of files. All of the provided .clj files will be loaded with clojure.core/load-file (and therefore the paths must be relative to the calling site) before running the primary linting step.

This shouldn't be too hard to implement, so please let me know if that would suit your needs.

@NoahTheDuke NoahTheDuke self-assigned this Apr 30, 2024
NoahTheDuke added a commit that referenced this issue May 1, 2024
@NoahTheDuke
Copy link
Owner

I decided to implement it as described. Will be released shortly. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants