getsentry / sentry-docs

Sentry's documentation (and tools to build it)
https://docs.sentry.io
Other
332 stars 1.46k forks source link

Lint Code Samples #3536

Closed PeloWriter closed 4 months ago

PeloWriter commented 3 years ago

We should lint code samples to ensure that they are valid.

BYK commented 3 years ago

Brain dump:

  1. We either need to extract all fenced & tagged code pieces from MDX files (https://mdxjs.com/advanced/api) and then feed these to individual linters (https://github.com/github/super-linter/)
  2. Or we need to pull these out into individual files and add https://github.com/github/super-linter/ to the project.

The first solution seems harder to implement but the second solution seems like it is going to make the docs repo and examples harder to maintain.

@bruno-garcia @HazAT any thoughts on this?

bruno-garcia commented 3 years ago

I'm afraid many of the snippets wouldn't compile on their own. They'd need some sort of context: Be put inside the Android's Activity class, or be inside a Global.asax.cs file (for ASP.NET, Windows only) with all the references available, etc.

But perhaps it would be good enough for most cases, and still worth the effort. In that case some sort of opt-out list where we can mark which snippets shouldn't be alerted on might be worth taking into account.

BYK commented 3 years ago

Our aim is not to get them to compile but at least verify that they can be copy/pasted and are syntactically correct. If we can do more, that's awesome but this is a very low bar: code that is valid. 😀

PeloWriter commented 3 years ago

And, we could section this out, so linting starts with specified SDKs. We can roll it out to other SDKs as makes sense.