0.2.7 • Published 5 months ago

publint v0.2.7

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

This package contains a CLI and API to lint packages locally. The package to be linted must exist and be built locally for the lint to succeed. To test other npm packages, try https://publint.dev.

Usage

CLI

# Lint your library project
$ npx publint

# Lint a dependency
$ npx publint ./node_modules/some-lib

# Lint your project's dependencies based on package.json
$ npx publint deps

Use npx publint --help for more information.

API

import { publint } from 'publint'

const { messages } = await publint({
  /**
   * Path to your package that contains a package.json file.
   * Defaults to `process.cwd()` in node, `/` in browser.
   */
  pkgDir: './path/to/package',
  /**
   * A virtual file-system object that handles fs/path operations.
   * This field is required if you're using in the browser.
   */
  vfs: createCustomVfsObj(),
  /**
   * The level of messages to log (default: `'suggestion'`).
   * - `suggestion`: logs all messages
   * - `warning`: logs only `warning` and `error` messages
   * - `error`: logs only `error` messages
   */
  level: 'warning',
  /**
   * Report warnings as errors.
   */
  strict: true
})

console.log(messages)

Extra utilities are exported under publint/utils:

import { formatMessage } from 'publint/utils'
import fs from 'node:fs/promises'

const pkg = JSON.parse(
  await fs.readFile('./path/to/package/package.json', 'utf8')
)

for (const message of messages) {
  // Prints default message in Node.js. Always a no-op in browsers.
  // Useful for re-implementing the CLI in a programmatic way.
  console.log(formatMessage(message, pkg))
}

License

MIT

0.2.7

5 months ago

0.2.6

5 months ago

0.2.5

7 months ago

0.2.4

7 months ago

0.2.3

7 months ago

0.1.13

11 months ago

0.1.14

10 months ago

0.1.15

10 months ago

0.2.1

9 months ago

0.2.0

10 months ago

0.1.16

10 months ago

0.2.2

9 months ago

0.1.12

12 months ago

0.1.10

1 year ago

0.1.11

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.9

1 year ago

0.1.6

1 year ago

0.1.2

2 years ago

0.1.4

1 year ago

0.1.3

2 years ago

0.1.5

1 year ago

0.1.0

2 years ago

0.0.1

2 years ago

0.1.1

2 years ago

0.0.0

2 years ago