Lint

Lint stdlib namespace aliases.

Usage

var lint = require( '@stdlib/_tools/lint/namespace-aliases' );

lint( [options,] clbk )

Asynchronously lints stdlib namespace aliases to ensure that each namespace alias for a package matches the package's global alias.

lint( onLint );

function onLint( error, errs ) {
    if ( error ) {
        throw error;
    }
    if ( errs.length ) {
        console.error( JSON.stringify( errs ) );
    } else {
        console.error( 'No detected errors.' );
    }
}

The function accepts the following options:

  • dir: root directory from which to search for namespace to lint. May be either an absolute file path or a path relative to the stdlib/lib/node_modules/ directory. Default: /path/to/stdlib/lib/node_modules/.

Each lint error is represented by an object having the following fields:

  • namespace: namespace identifier.
  • pkg: package identifier.
  • expected: expected alias.
  • actual: actual alias.

To lint starting from a descendant directory, set the dir option.

var opts = {
    'dir': './@stdlib/math/base'
};

lint( opts, onLint );

function onLint( error, errs ) {
    if ( error ) {
        throw error;
    }
    if ( errs.length ) {
        console.error( JSON.stringify( errs ) );
    } else {
        console.error( 'No detected errors.' );
    }
}

lint.sync( [options] )

Synchronously lints stdlib namespace aliases to ensure that each namespace alias for a package matches the package's global alias.

var errs = lint.sync();
if ( errs.length ) {
    console.error( JSON.stringify( errs ) );
} else {
    console.error( 'No detected errors.' );
}

The function accepts the same options as lint() above.

Notes

  • The function only lints namespaces under the @stdlib scope.

Examples

var lint = require( '@stdlib/_tools/lint/namespace-aliases' );

var opts = {
    'dir': './'
};

lint( opts, onLint );

function onLint( error, errors ) {
    if ( error ) {
        throw error;
    }
    if ( errors.length ) {
        console.error( JSON.stringify( errors ) );
    } else {
        console.error( 'No detected errors.' );
    }
}

CLI

Usage

Usage: stdlib-lint-namespace-aliases [options] [<dir>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --pattern pattern     Pattern to match files for linting.
         --ignore pattern      Exclusion glob pattern.

Notes

  • If not provided a dir argument, the search directory is the current working directory.

Examples

$ stdlib-lint-namespace-aliases