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

@bitovi/eslint-plugin-nx-glue

v1.2.0

Published

Allows local ESLint Rules written in TypeScript to be available within Nx workspace

Downloads

4

Readme

ESLint Plugin Nx Glue

Allows local ESLint Rules written in TypeScript to be available within a Nx workspace or any project. This means that developers can create their own custom ESLint Plugins within a project and consume them within that project without having to publish or use Symlinks.

Installation

npm install -D @bitovi/eslint-plugin-nx-glue

This library assumes your project is an Nx workspace. If you are not, you will have to also install nx as a dev-dependency:

npm install -D nx@15

How to Use

Create an eslint-plugin-nx-glue.config.js file at the root of your project. This file will export your ESLint Plugins by name, a path to its exported rules, and which TypeScript configuration to use:

// eslint-plugin-nx-glue.config.js

module.exports = {
  'my-plugin': {
    dir: 'tools/my-rules',
    tsconfig: 'tools/my-rules/tsconfig.json',
  },
};

This example will check tools/my-rules for index.ts that exports an ESLint Plugin:

// tools/my-rules/index.ts

import { myCustomRule} from './rules/my-custom-rule';
import { mySecondCustomRule } from './rules/my-second-custom-rule';

module.exports = {
  rules: {
    'some-custom-rule-name': myCustomRule,
    'another-custom-rule-name': mySecondCustomRule,
  },
};

Now you can include these rules into your eslint configuration by adding @bitovi/nx-glue to your plugins and listing which rules you want to use within overrides:

// .eslintrc

{
  "plugins": ["@bitovi/nx-glue"],
  "overrides": [
    {
      "files": ["*.ts"],
      "rules": {
        "@bitovi/nx-glue/my-plugin/some-custom-rule-name": "error",
        "@bitovi/nx-glue/my-plugin/another-custom-rule-name": "warn"
      }
    }
  ]
}

Configuration Schema

Listed below is a detailed explaination of how the eslint-plugin-glue configuration schema affects how you can consume your custom rules:

// eslint-plugin-nx-glue.config.js

module.exports = {
    '<plugin-name>': {
      dir: 'path/to/rules/from/root/of/project',
      tsconfig: 'path/to/tsconfig/from/root/of/project/tsconfig.json',
    },
    '<plugin-name-2>': {
      dir: 'path/to/rules/from/root/of/project',
      tsconfig: 'path/to/tsconfig/from/root/of/project/tsconfig.json',
    },
    // ...
};

Configuration schema:

  1. plugin-name: Used to distinguish each plugin. This allows for plugins to have the same named rules within the same project.
  2. dir: Path to index.ts from root of project. This is the location of the exported ESLint Plugin.
  3. tsconfig: Path to TypeScript configuration from root of project.

This allows you to consume your custom rules exported by your local ESLint Plugins:

// .eslintrc

{
  "plugins": ["@bitovi/nx-glue"],
  "overrides": [
    {
      "files": ["..."],
      "rules": {
        "@bitovi/nx-glue/<plugin-name>/<custom-rule-name>": "...",
        "@bitovi/nx-glue/<plugin-name>/<custom-rule-name-2>": "...",
        "@bitovi/nx-glue/<plugin-name-2>/<another-custom-rule-name>": "..."
      }
    }
  ]
}

ESLint Extention

If you are using VSCode's ESLint extention, you will have to restart your ESLint server whenever you make changes to your ESLint Plugin(s). You can quickly restart your ESLint server by using the Command Palette and selecting ESLint: Restart ESLint Server.

Overriding Configuration Path

You can set path to your eslint-plugin-glue configuration by setting ESLINT_PLUGIN_GLUE_CONFIG_PATH environment variable. By default, eslint-plugin-glue configuration is expected to be at the root of your project and to be named eslint-plugin-glue.config.js.