Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
294 changes: 294 additions & 0 deletions lib/node_modules/@stdlib/_tools/lint/manifest-json/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
<!--

@license Apache-2.0

Copyright (c) 2026 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# Lint

> Lint `manifest.json` files.

<section class="usage">

## Usage

```javascript
var lint = require( '@stdlib/_tools/lint/manifest-json' );
```

#### lint( \[options,] clbk )

Asynchronously lints `manifest.json` files.

```javascript
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 with `manifest.json`).
- **ignore**: list of glob patterns used to exclude matches.

To search from an alternative directory, set the `dir` option.

```javascript
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.

```javascript
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.

```javascript
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!' );
}
}
```

#### lint.sync( \[options] )

Synchronously lints `manifest.json` files.

```javascript
var errs = lint.sync();
if ( errs ) {
console.dir( errs );
} else {
console.log( 'Success!' );
}
```

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

</section>

<!-- /.usage -->

<section class="notes">

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
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!' );
}
}
```

</section>

<!-- /.examples -->

* * *

<section class="cli">

## CLI

<section class="usage">

### Usage

```text
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/.
```

</section>

<!-- /.usage -->

<section class="notes">

### Notes

- If part of a [standard stream][standard-stream] pipeline, results are written to `stdout` as newline-delimited JSON ([NDJSON][ndjson]). Otherwise, results are pretty printed by default.

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

- To provide multiple exclusion glob patterns, set multiple `--ignore` option arguments.

```bash
$ lint-manifest-json --ignore=node_modules/** --ignore=build/** --ignore=reports/**
```

- If the split separator is a [regular expression][regexp], ensure that the `split` option is properly **escaped**.

```bash
# 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 a `dir` argument.

</section>

<!-- /.notes -->

<section class="examples">

### Examples

```bash
$ lint-manifest-json

/path/to/manifest.json

message: should have required property 'confs'
field: .
data: {"options":{},"fields":[]}

1 errors
```

To output results as newline-delimited JSON ([NDJSON][ndjson]),

```bash
$ lint-manifest-json --format ndjson
{"file":"...","errors":[...]}
{"file":"...","errors":[...]}
...
```

To use as a part of a [standard stream][standard-stream] pipeline,

```bash
$ echo -n $'./manifest.json' | lint-manifest-json
...
```

</section>

<!-- /.examples -->

</section>

<!-- /.cli -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[ndjson]: http://ndjson.org/

[regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

[standard-stream]: https://en.wikipedia.org/wiki/Pipeline_%28Unix%29

</section>

<!-- /.links -->
Loading
Loading