tldr-pages / tldr-lint

:rotating_light: A linting tool to validate tldr pages
https://www.npmjs.com/package/tldr-lint
MIT License
36 stars 20 forks source link

Replace Generic Rules with EditorConfig #94

Closed SethFalco closed 3 years ago

SethFalco commented 3 years ago

Some rules are defined and implemented here that are generic and can be handled already by EditorConfig. We have an .editorconfig file defined in tldr-pages/tldr.

I think we can reduce the code surface by using something that enforces EditorConfig instead. This means less code to maintain, while having access to more rules.

Error Code Description Rule
TLDR009 Page should contain a newline at end of file insert_final_newline
TLDR010 Only Unix-style line endings allowed end_of_line
TLDR012 Page should contain no tabs indent_style

Solutions

Prettier

I think the best way would be to delegate some rules to Prettier. It documents that we can read an .editorconfig file which can use it to override rules. (More Info)

This would cover:

Prettier doesn't support the other properties that would help out yet, though:

GitHub Actions

This one would be out of scope for this repository, but we could just scrap those rules and use a GitHub Action.

setup-editorconfig-checker

setup-editorconfig-checker might be good, and it uses editorconfig-checker which is still maintained.

EditorConfig-Action

EditorConfig-Action wins by star count, but this just uses jedmao/eclint under the hood, which is an archived and unmaintained project.

EditorConfig JavaScript Core

Alternatively, we could use EditorConfig JavaScript Core to parse the .editorconfig file, and apply the rule from there instead. That would defeat the point, as we'd still have to implement ourselves anyway, though. 🤔

marchersimon commented 3 years ago

I'm not sure if breaking up the rules to multiple services would make it easier. I feel like this can get confusing. Also, what about using tldr-lint offline? There I don't have GitHub Actions or Prettier?

marchersimon commented 3 years ago

(Also, pinging some maintainers, since they don't watch this repo: @sbrl @navarroaxel @CleanMachine1)

SethFalco commented 3 years ago

Ahh, I didn't consider offline use. 🤔 I don't think the Prettier comment applies, as this project is in JavaScript, so it can just depend on Prettier.

As for GitHub actions, fair enough, that wouldn't work.

owenvoke commented 3 years ago

I'd have to agree with @marchersimon, I think having the offline capability as well as it being part of a centralised tool makes more sense.

Although, I still think that in future it would be nice to possibly rewrite the tldr-lint tool to a different lexer, etc.

MasterOdin commented 3 years ago

Given that this repo is very stable and doesn't change very often, I think replacing the built-in parse rules with a third party dependency would raise maintainer workload as we'd now have to keep track of yet another dependency and its new versions. The code that would be removed would also be the smallest, simplest rules that it wouldn't really give all that much less code to maintain.

SethFalco commented 3 years ago

Fair enough, I'll concede to that. I'll actually close this issue already. Looking back at my original issue and after hearing feedback, I agree it's not worthwhile.