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

eslint-plugin-mongoose-performance

v0.0.1

Published

Custom ESLint rules for Mongoose, focusing on performance

Downloads

41

Readme

Local Development and Testing of eslint-plugin-mongoose-performance

This guide will help you set up, test, and finally publish eslint-plugin-mongoose-performance for use in your projects.

Prerequisites

  • Yarn installed globally
  • ESLint properly set up in your project
  • Node.js environment
  • npm account with a valid authentication token

1. Linking the Plugin Locally

To test your changes in a real project without publishing the package to npm, you can link the plugin locally using Yarn’s link feature.

Step 1: Link the Plugin

Inside the eslint-plugin-mongoose-performance plugin directory, run the following command:

yarn link

This will create a symbolic link in your global Yarn directory, allowing other projects to use this local version of the plugin.

Step 2: Link the Plugin in Your Project

Now, in the project where you want to test the ESLint plugin, run:

yarn link "eslint-plugin-mongoose-performance"

This will create a symbolic link in your project, pointing to the local version of the plugin.

Step 3: Update ESLint Configuration

To use your custom plugin, update your .eslintrc.js (or equivalent ESLint configuration file) in the project where you want to test the plugin:

module.exports = {
  plugins: ['mongoose-performance'], // Reference the plugin without the 'eslint-plugin-' prefix

  rules: {
    'mongoose-performance/your-rule-name': 'error', // Replace 'your-rule-name' with your custom rule
  },
};

2. Running ESLint with the Plugin

After linking the plugin and updating your ESLint configuration, run ESLint in your project to test the plugin:

yarn eslint . --ext .js,.ts

This will apply the custom rules defined in eslint-plugin-mongoose-performance.

3. Updating the Plugin

If you make updates to the plugin source code while testing, changes will automatically be reflected in the linked project because the link points to the plugin's source folder. However, if your plugin requires a build step, follow these instructions:

Step 1: Rebuild the Plugin (if applicable)

If your plugin uses a build system (e.g., TypeScript or Babel), you must rebuild the plugin after making changes. For example, with TypeScript, run:

yarn build

or

tsc

This will compile the updated source code to the appropriate output folder (usually lib/).

Step 2: Rerun ESLint

Once your plugin is rebuilt, rerun ESLint in your project to see the updates in action:

yarn eslint . --ext .js,.ts

4. Unlinking the Plugin

When you are done testing your plugin locally, you can unlink it from your project to restore the original state.

Unlink the Plugin

In the project where you linked the plugin, run:

yarn unlink "eslint-plugin-mongoose-performance"

This will remove the symbolic link to the local plugin.

If needed, you can also unlink the global link by running the following command inside the plugin directory:

yarn unlink

5. Publishing the Plugin

After completing the development and testing of your eslint-plugin-mongoose-performance plugin, you can publish it to npm for broader usage.

Step 1: Set Up npm Authentication

To publish the package, ensure that you have your npm token properly configured in a .npmrc file. You can generate an authentication token from the npm website by logging in to your account.

Create or update your .npmrc file with the following content:

//registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN_HERE

Replace YOUR_NPM_TOKEN_HERE with your actual npm authentication token.

Step 2: Publish to npm

Once the .npmrc file is properly set up and you’ve finalized the plugin, you can publish it to npm by running:

yarn publish

This will push your plugin to the npm registry. After publishing, others can install and use it directly via npm or Yarn:

yarn add eslint-plugin-mongoose-performance

6. Troubleshooting

  • ESLint Cache Issues: If changes are not reflecting, try clearing the ESLint cache by running:

    yarn eslint . --ext .js,.ts --no-cache
  • Editor Issues: Some editors may cache ESLint rules. Try restarting your editor/IDE if changes are not reflecting.

  • npm Authentication: If you encounter authentication issues during publishing, ensure your .npmrc is correctly set up and that the token is valid.