Fork me on GitHub
#clj-kondo
<
2022-08-30
>
ericdallo17:08:18

In a hook's code, do I have a way to know the filename being linted?

borkdude17:08:42

everything a hook can know is passed in the map as the argument

borkdude17:08:51

if the filename isn't in there yet, we could add it

borkdude17:08:06

why do you need the filename though?

ericdallo17:08:41

nice, at Nubank we had some crashes in prod related to use schema.core/with-fn-validation in a production code 😅 , so we are thinking on add a custom lint for that function to check if the filename contains a src (usually, at least for our services, production code)

ericdallo17:08:09

and emit a warning/error to avoid that code go to prod

borkdude17:08:17

so you would like to discourage with-fn-validation within certain namespaces?

ericdallo17:08:47

not namespaces, because we can't know only by a ns if that's is from test source-path

ericdallo17:08:01

I think we would need the filename or file uri

ericdallo17:08:29

Damm, didn't know about this one, sounds perfect

ericdallo17:08:33

will take a look, thank you very much

ericdallo17:08:55

Actually, we do use it on tests, using that would make the warn for tests as well right? :/

borkdude17:08:16

yes, but you can make an ns-group for your tests (e.g. all namespaces ending with -test ) and then undo it for the tests

ericdallo17:08:28

got it, sounds good

ericdallo17:08:32

will test it, thanks!

ericdallo17:08:24

the ns-group :pattern is a pattern for the ns right? I think that won't work since we can't know if a ns is a test, for example test/my_service/foo/my_feature.clj (`(ns my-service.foo.my-feature)`)

borkdude17:08:44

it's a common convention to name test nses foo_test.clj

borkdude17:08:58

but maybe could also enable a regex based on the file. gotta go now

ericdallo17:08:20

yeah I know, but we have some integration legacy tests not using that convention, I think it'd be convenient to have a file-pattern optional, WDYT?

ericdallo13:09:33

@U04V15CAJ WDYT? would you accept a issue about it? I can try to find some time to implement the file-pattern support if you want

borkdude13:09:15

issue welcome, + PR

👍 1