Skip to content

rspack-contrib/rsbuild-plugin-publint

Repository files navigation

rsbuild-plugin-publint

Run publint to lint npm packages after the build.

npm version license downloads

Preview

rsbuild-plugin-publint is the perfect partner for Rslib. When building a library, publint helps you to lint the npm package and give suggestions to improve its compatibility with different environments.

Preview

Usage

Install:

npm add rsbuild-plugin-publint -D

Add plugin to your rslib.config.ts or rsbuild.config.ts:

import { pluginPublint } from "rsbuild-plugin-publint";

export default {
  plugins: [pluginPublint()],
};

Options

enable

Whether to enable publint.

  • Type: boolean
  • Default: true

For example, only run publint in the CI environment:

pluginPublint({
  enable: Boolean(process.env.CI),
});

publintOptions

Options for publint. See publint - API for more details.

  • Type: import('publint').Options
  • Default:
const defaultOptions = {
  pkgDir: api.context.rootPath,
};
  • Example:
pluginPublint({
  publintOptions: {
    level: "error",
  },
});

throwOn

Specify when to throw an error based on message severity.

  • Type: 'error' | 'warning' | 'suggestion' | 'never'
  • Default: 'error'
  • Example:
pluginPublint({
  throwOn: "warning",
});

Optional values:

  • 'error': Only throw on errors.
  • 'warning': Throw on errors and warnings.
  • 'suggestion': Throw on errors, warnings and suggestions.
  • 'never': Never throw an error.

License

MIT.