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-canonical-vocabulary

v1.4.0

Published

## Getting Started

Downloads

13

Readme

eslint-plugin-canonical-vocabulary

Getting Started

This ESLint plugin helps developers maintain a consistent vocabulary in their code. By defining canonical terms, developers can ensure that their codebase remains coherent and understandable.

Requirements

The only requirement is that you have ESLint version 5 or higher in your project.

How to Use

  1. First, you need to install eslint-plugin-canonical-vocabulary as a dev-dependency. You can do this using your preferred package manager:
npm install eslint-plugin-canonical-vocabulary  --save-dev
yarn add -D eslint-plugin-canonical-vocabulary
pnpm install eslint-plugin-canonical-vocabulary  --save-dev
  1. Next, integrate the plugin into your .eslintrc.js configuration (or the respective ESLint configuration file you're using).
{
  "plugins": ["canonical-vocabulary"],
  "rules": {
    // ... other rules

    "canonical-vocabulary/canonical-vocabulary": [
      "error",
      [
        {
          "words": ["TaxValue", "TaxAmt", "TaxationAmount"],
          "fixTo": "TaxAmount",
          "message": "To maintain consistency when referring to tax-related amounts in our code, always use <fixTo> instead of terms like <word>."
        },
        {
          "words": ["EduFee", "ScholarCost", "StudyExpense"],
          "fixTo": "TuitionFee"
        }
      ]
    ]

  },
}
  1. About the rule parameters
  • words (required) A list of words and terms you want to avoid
  • fixTo (optional) The word or term you recommend should be used
  • message (optional) A message with the reasons for the decision, you can use the <word> syntax to display the found word and the <fixTo> syntax to display the recommended word
  1. You can configure the severity of the rule as "error", "warn", or "off" based on your project's requirements.

  2. If you want, you can leave your canonical words in a separate file, example

// canonicalWords.js
const canonicalWords = [
  {
    words: ["BankCode", "TransactNum", "BankingRef"],
    fixTo: "TransactionCode",
    message:
      "When referring to bank transaction codes, always use <fixTo> to avoid ambiguity. Avoid using non-standard terms like <word>.",
  },
];

// eslintrc.js
const canonicalWords = require("./canonicalWords.js");
module.exports = {
  plugins: ["canonical-vocabulary"],
  rules: {
    "canonical-vocabulary/canonical-vocabulary": ["error", canonicalWords],
  },
};
  1. If you have a large code base and want to enable the rule only for new files, you can disable or modify the rule for certain folders and files, just use overrides as in the example below

The 'overrides' feature allows you to define different rules for specific files and folders. This is useful if, for example, a rule impacts the code a lot or you have legacy code that you don't want to modify

{
  plugins: ["canonical-vocabulary"],
  rules: {
    // other rules, includes canonical-vocabulary
  },

  "overrides": [
    {
      "files": ["*external_context\\/*", "*\\.spec.ts"],
      "rules": {
        "canonical-vocabulary/canonical-vocabulary": "off",
      }
    }
  ]
};

Contributing to the project

Would you like to contribute to the project? Excellent! In our contributing.md guide, you'll find information on how to create a Pull Request, code standards we follow, and how to report bugs. Your contribution is valuable and will help improve the tool for everyone.

I hope these explanations and examples are clear and useful!

Known issues

To report issues, if possible, please provide a snippet or link to the code on GitHub where the issue can be replicated. You can report issues here.

You can make suggestions here

Next steps

The purpose of this plugin is to prevent the code base from having different terms for the same thing, this plugin is not intended to be a spell checker, if you are interested consider using eslint-plugin-spellcheck.

Align the recommended terms with your team and manually build your list.