get-alex / alex

Catch insensitive, inconsiderate writing
https://alexjs.com
MIT License
4.8k stars 207 forks source link

Resolve newly uncovered TypeScript violations, add alternate config flag, and add test for allow patterns #337

Closed DAcodedBEAT closed 1 year ago

DAcodedBEAT commented 1 year ago

Context: I am a new user of alex and I tried to set allow patterns in my .alexrc, to allow the use of "host name" in my personal application's documentation. Since only providing the word "host" or "host name" in the alexrc was not working, I had to pull back the curtain and see what was going wrong in the codebase.

  1. When trying to use this application, I realized the main branch was currently experiencing some TypeScript violations, which was remediated in the first commit.

  2. Once this was resolved, I tried to use common UNIX cli verbosity flags (-v, -vv, -vvv), to only realize that -v is currently used as an alias to --version. I shifted the alias to -V in the second commit, in the event that maintainers of this application/library want to add verbose output in the future.

  3. Finally, as an attempt to check that my alexrc changes are being picked up, I added a flag to override which configuration file is used in the third commit by providing a --alexrc flag and providing a filesystem path to it. This addition also included additional unit tests for this new feature, as well as testing for the allow flag in alexrc which seemingly isn't present in ./test/fixtures.

Writing the unit test is what finally caused me to realize that the value in the alexrc should be host-hostess - Is there a mechanism to look up specific rules and what would trigger them?

DAcodedBEAT commented 1 year ago

Hello @wooorm! 👋

May I get a code review on this change? Thanks in advance!

wooorm commented 1 year ago

Hi there! :wave:

It’s generally recommend in open source on GitHub to split different things into different PRs.

I’ve just done the minimally-needed type changes here: https://github.com/get-alex/alex/commit/ca69a1971e6f3439db7d72bdb5792ff64fdd008b.

The casing of -v is intentional. It is also rather common in the JavaScript world. Even if it wasn’t, switching to -V is a breaking change, which I am not interested in.

Another recommendation for OSS: it’s often a good idea to first ask before you spend time building things: https://github.com/get-alex/.github/blob/main/contributing.md#submitting-a-pull-request.

I’m generally open to introducing support for a new CLI flag, that allows to specify a path. However, this flag you show does not solve your problem. You ask about different things. Your question seems to be at the start and end:

Is there a mechanism to look up specific rules and what would trigger them?

There is no such mechanism currently. There are tens of thousands of things that will be emitted. Many of them nasty words. For more on what is checked by alex, see the readme https://github.com/get-alex/alex#checks, and particularly the two projects alex uses and links to.

I tried to set allow patterns in my .alexrc, to allow the use of "host name"

alex will print something like this for you:

example.md
  1:15-1:18  warning  bla  xxx  retext-equality

⚠ 1 warning

If you think bla is fine, then you can allow it by using the identifier xxx.