File and folder convention checker written in rust
The distribution is now available on crates.io. You can install via cargo
.
$ cargo install ficon
Or you can run through docker
$ docker run -v "$PWD":/app ibosz/ficon
It will pull the ficon image from dockerhub
and mount your current working directory to docker container to run ficon
.
More options are coming. Contributions are welcome :)
First you need to create Ficon.toml
in the directory that you want to verify convention.
For basic usage, you can just have this configuration:
[default]
convention = "any"
And run
$ ficon
Everything will be green since we haven't put in any constraint.
Everything in .gitignore
file will be ignored by default.
For more sophisticated example, this is copied from this project itself:
[default]
convention = "snake"
[[for_patterns]]
pattern = "*.toml"
convention = "pascal"
[[for_patterns]]
pattern = "*.md"
convention = "upper_snake"
[[for_patterns]]
pattern = "./LICENSE"
convention = "upper_snake"
[[for_patterns]]
pattern = "./Cargo.lock"
convention = "pascal"
You can specify default convention and convention for specific glob patterns using [[for_patterns]]
as you can see above.
We are using glob
crate to do glob matching, see more.
The higher [[for_pattern]]
position, the higher precedence it is, this behaviour might change in the next release.
There are 6 predefined convention, namely
any
: no constraintkebab
: kebab-casesnake
: snake_caseupper_snake
: UPPER_SNAKE_CASEpascal
: PascalCasecamel
: camelCase
But if you want to define your own convention, you can do so by using regex:
[[for_patterns]]
pattern = "**/__*__/"
convention = "/^__[a-z]+__$/"
This will match path like ./test/app/__mock__
for example.
Note that //
is required in order to use regex as convention.
The convention constraint only checks against file name or directory name, disregrading any extension,
for example, src/lib/app.rs
, ficon
only check if app
matches the constraint.
If the file has multiple extension eg. test/main/app.spec.ts
, again ficon
will only check app
.