lint-paths

Checks that paths correspond to a desired pattern

Usage no npm install needed!

<script type="module">
  import lintPaths from 'https://cdn.skypack.dev/lint-paths';
</script>

README

lint-paths

Checks that paths correspond to a desired pattern.

Install

As a command line tool:

npm install -g lint-paths

Or as development tool:

npm install --save-dev lint-paths

Command line usage

lint-paths [options] root[, root]

Options

  • -h, --help: display a help message,
  • -p, --pattern: the expected pattern of the paths, ^[^A-Z]*$ by default,
  • -i, --ignore: a valid RegExp pattern to ignore, this options can be repeated multiple times.

Examples

$ lint-paths .
$ lint-paths -p "^[a-z]*\quot; .
$ lint-paths -p "^[a-z]*\quot; -i bin .
$ lint-paths -p "^[a-z]*\quot; --ignore=bin -i "\\.jsonquot; .
$ lint-paths --pattern "^[a-z]*\quot; src lib

API usage

Syntax

lintPaths(options)

Parameter

  • options: an object containing:
    • roots (array): the array of folder to scan,
    • pattern (RegExp): the expected pattern of the paths,
    • ignore (array): the array of valid RegExp patterns to ignore.

Return value

Return the array of errors. If there are none, the array is empty.

Example

const lintPaths = require('lint-paths');

const options = {
  roots: [ src, lib ],
  pattern: /^[^0-9]*$/,
  ignore: [ 'node_modules' ]
};

console.log(lintPaths(options));

License

MIT