unsplash / intlc

Compile ICU messages into code. Supports TypeScript and JSX. No runtime.
MIT License
56 stars 3 forks source link

Add linting/warnings #117

Closed samhh closed 2 years ago

samhh commented 2 years ago

This could lint against:

* I feel like this should be configurable, but that's probably overkill for now.

Notably these should be warnings, not errors. As such they need to be expressed via stdout, meaning we may want to start writing to files directly. Relevant: #1, #25

OliverJAsh commented 2 years ago
  • Advanced usages that may confuse translators e.g. more than one select/plural/etc in a message *

Note that in most cases these advanced usages only start to appear after we flatten—so we would want to lint the flattened output?

samhh commented 2 years ago

Note that in most cases these advanced usages only start to appear after we flatten—so we would want to lint the flattened output?

If we lint against {x, select, foo {}} {y, select, bar {}} in the knowledge that with flattening it becomes nested then that accomplishes the same thing.

samhh commented 2 years ago

TIL that > redirects stdout but not stderr, so printing to stdout doesn't block this ticket. We just need to print lint warnings to stderr. (What about the exit code?)

#!/bin/sh

echo stdout!
echo stderr... >&2
$ ./script.sh > out.txt
stderr...
$ cat out.txt
stdout!

Alternatively we could add a distinct lint subcommand. That'll be a bit slower as it means parsing everything again, however that does strike me as potentially the cleanest approach.

samhh commented 2 years ago

This can either be a subcommand in the preexisting binary or a new binary - it doesn't make much difference in code as everything that matters is in the shared library.

I'm tempted to say that it should be a new binary given how opinionated towards our own needs it'll be. Current rule plans and whether they're not too specific to our needs:

samhh commented 2 years ago

We now have an internal linter covering the nested/complexity rule as of #123. #128 will cover Unicode. Number skeletons can wait until the outcome of #112. Issues raised for a non-internal linter and rules with #135 and #136.