eslint-plugin-limit-any

1.0.1 • Public • Published

eslint-plugin-limit-any

An ESLint plugin to limit the usage of 'any' types in TypeScript. It helps to enforce strict typing and improve code quality.

Installation

First, you need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-limit-any:

npm install eslint-plugin-limit-any --save-dev

Usage

count

The count rule limits the number of 'any' types in your TypeScript code. You can configure this rule in your ESLint configuration file.

// eslint.config.js
"use strict";
const tsParser = require("@typescript-eslint/parser");
// Import the ESLint plugin locally
const limitAnyRule = require("eslint-plugin-limit-any");

module.exports = [
  {
    files: ["**/*.ts"],
    languageOptions: {
      parser: tsParser,
      sourceType: "commonjs",
      ecmaVersion: "latest",
    },
    plugins: { "limit-any": limitAnyRule },
    rules: {
      "limit-any/count": ["error", 4],
    },
  },
];
//.eslintrc.json
{
  "root": true,
  "env": {
    "node": true
  },
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint", "limit-any"],
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended"
  ],
  "rules": {
    "limit-any/count": ["error", 4]
  }
}

Package Sidebar

Install

npm i eslint-plugin-limit-any

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

4.86 kB

Total Files

8

Last publish

Collaborators

  • wyy5552