MrLeebo / prisma-ast

Abstract Syntax Tree for parsing schema.prisma files
MIT License
142 stars 18 forks source link

Add `parser` option to `getSchema` #26

Closed maxh closed 11 months ago

maxh commented 11 months ago

I finally got around to hacking on using location data in prisma-lint!

https://github.com/loop-payments/prisma-lint/pull/84

Everything works great when testing in the prisma-lint repository, but I didn't get location data when running the linter on a schema in a different repository (backend) that uses prisma-lint. I think this is because prisma-ast was looking for a config file in backend.

I wasn't sure how to get the location node configuration for prisma-ast to be set by prisma-lint without requiring backend to also have to configure prisma-ast, which felt like too much to ask for users of prisma-lint.

This PR allows prisma-lint to request location information on demand from prisma-ast, regardless of the config.

I recommend reviewing with the hide whitespace option enabled:

image
maxh commented 11 months ago

Thanks for the feedback. I've iterated in that direction -- let me know what you think.

UPDATE:

I confirmed this approach works from prisma-lint side: https://github.com/loop-payments/prisma-lint/pull/239/files

MrLeebo commented 11 months ago

@maxh this feature should be available via prisma-ast v0.8.0