You can use this package to validate that the filenames in your git repository meet your validation rules.
Current validation rules are camelCase
, PascalCase
, and ignore
.
yarn global add @hollowverse/validate-filenames
Go to a git-managed repo and run:
validate-filenames --config ./path/to/configFile.js
When you do that, the tool will retrieve a list of all the filenames under git control and will validate them based on the rules that you have in your config file.
The config file can be any file that exports a JavaScript module with the format you see below.
configFile.js:
module.exports = {
rules: [
{
validation: 'camelCase',
patterns: ['**/*'],
},
{
validation: 'ignore',
patterns: [
'README.md',
'Dockerfile',
'LICENSE.md',
'customTypings/*',
'typings/*',
],
},
],
};
Notice that rules
is an array. Each item in the array is an object with two
properties: validation
and patterns
.
validation
can be one of three values: camelCase
, PascalCase
, or ignore
.
patterns
is an array of
glob patterns that tells
validate-filenames
that the validation rule applies to files that fall within
this glob pattern.
The order of the rules matter. The last rule wins. This allows us to have general rules and override those general rules with specific rules for specific paths. In the example above, we're saying all filenames within our repo should be camelCased except for certain files which should be ignored.