npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@commitlint/config-nx-scopes

v19.5.0

Published

Shareable commitlint config enforcing nx project names as scopes

Downloads

154,673

Readme

@commitlint/config-nx-scopes

Lint your nx project commits

Shareable commitlint config enforcing nx project and workspace names as scopes. Use with @commitlint/cli and @commitlint/prompt-cli.

Getting started

npm install --save-dev @commitlint/config-nx-scopes @commitlint/cli
echo "module.exports = {extends: ['@commitlint/config-nx-scopes']};" > commitlint.config.js

Filtering projects

You can filter projects by providing a filter function as the second parameter to getProjects(). The function will be called with an object containing each projects' name, projectType, and tags. Simply return a boolean to indicate whether the project should be included or not.

As an example, the following code demonstrates how to select only applications that are not end-to-end tests.

In your .commitlintrc.js file:

async function getConfig() {
  const {
    default: {
      utils: {getProjects},
    },
  } = await import('@commitlint/config-nx-scopes');

  return {
    rules: {
      'scope-enum': async (ctx) => [
        2,
        'always',
        [
          ...(await getProjects(
            ctx,
            ({name, projectType}) =>
              !name.includes('e2e') && projectType == 'application'
          )),
        ],
      ],
    },
    // . . .
  };
}

module.exports = getConfig();

Here is another example where projects tagged with 'stage:end-of-life' are not allowed to be used as the scope for a commit.

In your .commitlintrc.js file:

async function getConfig() {
  const {
    default: {
      utils: {getProjects},
    },
  } = await import('@commitlint/config-nx-scopes');

  return {
    rules: {
      'scope-enum': async (ctx) => [
        2,
        'always',
        [
          ...(await getProjects(
            ctx,
            ({tags}) => !tags.includes('stage:end-of-life')
          )),
        ],
      ],
    },
    // . . .
  };
}

module.exports = getConfig();

Examples

❯ cat commitlint.config.js
{
  extends: ['@commitlint/config-nx-scopes']
}

❯ tree packages

packages
├── api
├── app
└── web

❯ echo "build(api): change something in api's build" | commitlint
⧗   input: build(api): change something in api's build
✔   found 0 problems, 0 warnings

❯ echo "test(foo): this won't pass" | commitlint
⧗   input: test(foo): this won't pass
✖   scope must be one of [api, app, web] [scope-enum]
✖   found 1 problems, 0 warnings

❯ echo "ci: do some general maintenance" | commitlint
⧗   input: ci: do some general maintenance
✔   found 0 problems, 0 warnings

Consult Rules reference for a list of available rules.