Lint
manifest.jsonfiles.
var lint = require( '@stdlib/_tools/lint/manifest-json' );Asynchronously lints manifest.json files.
lint( done );
function done( error, errs ) {
if ( error ) {
throw error;
}
if ( errs ) {
console.dir( errs );
} else {
console.log( 'Success!' );
}
}The function accepts the following options:
- dir: root directory from which to search for manifest.json files. May be either an absolute file path or a path relative to the current working directory. Default: current working directory.
- pattern: glob pattern used to find manifest.json files. Default:
'**/@stdlib/**/manifest.json'(note: pattern must end withmanifest.json). - ignore: list of glob patterns used to exclude matches.
To search from an alternative directory, set the dir option.
var opts = {
'dir': '/foo/bar/baz'
};
lint( opts, done );
function done( error, errs ) {
if ( error ) {
throw error;
}
if ( errs ) {
console.dir( errs );
} else {
console.log( 'Success!' );
}
}To provide an alternative include filter, set the pattern option.
var opts = {
'pattern': '**/@stdlib/math/**/manifest.json'
};
lint( opts, done );
function done( error, errs ) {
if ( error ) {
throw error;
}
if ( errs ) {
console.dir( errs );
} else {
console.log( 'Success!' );
}
}To exclude matches, set the ignore option.
var opts = {
'ignore': [
'node_modules/**',
'build/**',
'reports/**'
]
};
lint( opts, done );
function done( error, errs ) {
if ( error ) {
throw error;
}
if ( errs ) {
console.dir( errs );
} else {
console.log( 'Success!' );
}
}Synchronously lints manifest.json files.
var errs = lint.sync();
if ( errs ) {
console.dir( errs );
} else {
console.log( 'Success!' );
}The function accepts the same options as lint() above.
var lint = require( '@stdlib/_tools/lint/manifest-json' );
lint( done );
function done( error, errs ) {
if ( error ) {
throw error;
}
if ( errs ) {
console.dir( errs );
} else {
console.log( 'Success!' );
}
}Usage: lint-manifest-json [options] [dir]
Options:
-h, --help Print this message.
-V, --version Print the package version.
--pattern pattern Inclusion glob pattern.
--ignore pattern Exclusion glob pattern.
--format format Output format: ndjson, pretty.
--split sep Separator used to split stdin data. Default: /\\r?\\n/.
-
If part of a standard stream pipeline, results are written to
stdoutas newline-delimited JSON (NDJSON). Otherwise, results are pretty printed by default. -
If not provided a
dirargument, the current working directory is the search directory. -
To provide multiple exclusion glob patterns, set multiple
--ignoreoption arguments.$ lint-manifest-json --ignore=node_modules/** --ignore=build/** --ignore=reports/**
-
If the split separator is a regular expression, ensure that the
splitoption is properly escaped.# Not escaped... $ <stdout> | lint-manifest-json --split /\r?\n/ # Escaped... $ <stdout> | lint-manifest-json --split /\\r?\\n/
-
If provided a list of filenames via
stdin, each filename is resolved relative to the current working directory. To specify an alternative directory, provide adirargument.
$ lint-manifest-json
/path/to/manifest.json
message: should have required property 'confs'
field: .
data: {"options":{},"fields":[]}
1 errorsTo output results as newline-delimited JSON (NDJSON),
$ lint-manifest-json --format ndjson
{"file":"...","errors":[...]}
{"file":"...","errors":[...]}
...To use as a part of a standard stream pipeline,
$ echo -n $'./manifest.json' | lint-manifest-json
...