alan-if / alan-docs

Alan IF Documentation Project

Home Page:https://git.io/alan-docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Find EClint Alternative

tajmone opened this issue · comments

We really need to find an alternative tool to EClint to validate code styles consistency of the repo's code, for the following reasons:

  1. ECLint development has been officially dead for over two years, and it will soon stop working due to deprecated dependencies or incompatibility with new Node.js versions.
  2. It's quite buggy.
  3. It forces us to distort optimal EditorConifg setting to accommodate validation rules (e.g. set indentation to 1 space instead of two, to allow custom alignments).
  4. It doesn't validate correctly ISO-8859-1 files, which are plentiful in this project.
  5. It's a Node.js app, with all the downsides that come with it (unsafety, outdated dependencies hell, etc.).

Of the above, point 3 is particularly relevant, for it would be ideal to find a code validation tool that uses its own settings file instead of the .editorconfig settings, so that we could decouple it from the EditorConifg rules, which don't always match the validation criteria.

@thoni56, any ideas if there are any code validation tools in the wild that meet these criteria? Possibly, in standalone binary format.

Prettier

This is an alternative tool to EditorConfig, worth looking into it:

The overall philosophy is quite different. It seems to work with a set of predefined languages, but it's also extensible.

This is not just and editor/IDE setter, it's an actual code linter. But it can also be used just for code styles validation (--check option).

Need to look into it with more time at hand...

NOTE — Also a Node.js app! 😭

More Validator Tools

I've come across some new EditorConfig validators (didn't yet test all of them):

eslint-plugin-editorconfig

Seems to be able to check for code consistency and even enforce it as a linter.

editorconfig-checker

This is an interesting tool (written in Go but also available via NPM) which I've following for over a year:

The problem is that it's not yet production ready, due to some bugs. Last time I tested it (April 2012) I found a Windows bug which won't allow us to use it right now — see: editorconfig-checker/editorconfig-checker#164

Also, it doesn't yet support encoding validation, which is a pity (at least UTF-8 validation would be nice).

But I'm confident that within less than a year this tool will be stable and usable. Since it's written in Go, you can download pre-compiled binaries, without having to use NPM and Node.js, which is an added bonus.

Another thing that I like about this tool is that it allows overriding some of the settings in .editorconfig and even introduces new settings especially for validation tasks — but I haven't used it as much as EClint, so I'm speaking from first impressions.

There's also a GitHub Action to validate project using this tools:

Editorconfig-Checker Bug Fixed, But not NPM Package

The bug mentioned in editorconfig-checker/editorconfig-checker#164, which fails the build under Windows when no EOL type is specified, seems to have been fixed in October 13, 2021, with PR editorconfig-checker/editorconfig-checker#184, but the fix is not yet available in the current NPM tool.

The fix is mentioned in release 2.4.0 of the Go binary.

The NPM package is lagging behind the latest wrapper, it's still using core v2.3.5:

$ ec -version
2.3.5

So, until the NPM package is update to use core v2.4.0 we won't be able to use the tool in our repositories.

Editorconfig-Checker NPM Package: Can We Trust It?

The editorconfig-checker bug-fix was released in 2021-10, but six months have elapsed since and the NPM package hasn't been updated accordingly. Doesn't seem like the NPM package can be relied upon — it doesn't look to be actively maintained at all.

EClint can't be relied upon either, since it's buggy and no longer maintained.

What are the viable alternatives then?

Create a Ruby Gem for Editorconfig-Checker?

All I can think of is attempting to create a Ruby gem that downloads the latest Editorconfig-Checker precompiled binary and wraps it around a useful command for validating repositories. But the we would have to maintain the Gem.

Other than that, we could ask end users to download the Editorconfig-Checker binaries — maybe there's Chocolatey Package for this? but a Ruby gem would be better since it would ensure the binaries are updated (at least whenever we discover a bug or there's a new feature we need), also we could provide some custom options via Ruby to filter results for Git specific needs — e.g. excluding from the validation (or report) any files ignored by Git, or to focus-on/filter only the files affected by a specific commit (for PRs validation).