🕵️ Code PushUp plugin for evaluating package.json
configurations 📦
The plugin crawls the file base depending on your configuration and checks the content package.json
files.
You can configure the plugin with the following options:
directory
- directory to crawl as stringlicense
- expected value oflicense
property inpackage.json
type
- expected value oftype
property inpackage.json
dependencies
- package dependencies as objectdevDependencies
- package dependencies as objectoptionalDependencies
- package dependencies as object
-
If you haven't already, install @code-pushup/cli and create a configuration file.
-
Copy the plugin source as is into your project
-
Add this plugin to the
plugins
array in your Code PushUp CLI config file (e.g.code-pushup.config.js
).Pass in the path or the directory to crawl (relative to
process.cwd()
).import packageJsonPlugin from './package-json.plugin'; export default { // ... plugins: [ // ... packageJsonPlugin({ directory: 'dist', license: 'MIT', type: 'module', dependencies: { package1: '0.0.1', }, devDependencies: { package2: '0.0.1', }, optionalDependencies: { package3: '0.0.1', }, }), ], };
-
-
(Optional) Reference audits (or groups) which you wish to include in custom categories (use
npx code-pushup print-config
to list audits and groups).Assign weights based on what influence each audit and group should have on the overall category score (assign weight 0 to only include it for extra info, without influencing the category score).
Use the recommendedRefs as quick starting point:
import packageJsonPlugin, { recommendedRefs } from './package-json.plugin';
export default {
// ...
categories: [
// ...
{
slug: 'package-json',
title: 'Package Json',
refs: [...recommendedRefs],
},
],
};
Or set up more fine-grained categories over the exported group references:
import packageJsonPlugin, { packageJsonDocumentationGroupRef, packageJsonPerformanceGroupRef, packageJsonVersionControlGroupRef } from './package-json.plugin';
export default {
// ...
categories: [
// ...
{
slug: 'bug-prevention',
title: 'Bug prevention',
refs: [packageJsonVersionControlGroupRef],
},
{
slug: 'performance',
title: 'Performance',
refs: [packageJsonPerformanceGroupRef],
},
{
slug: 'documentation',
title: 'Documentation',
refs: [packageJsonDocumentationGroupRef],
},
],
};
- Run the CLI with
npx code-pushup collect
and view or upload report (refer to CLI docs).
Detailed information about the audits can be found in the docs folder of the plugin.
The following audits are present:
Documentation:
Performance:
Bug Prevention:
You can use the following exports:
Preconfigured audit and group references are available
The following groups can be referenced are present: