eslint-plugin-limit-any
v1.0.1
Published
An ESLint plugin to limit the usage of 'any' types in TypeScript. It helps to enforce strict typing.
Downloads
3
Maintainers
Readme
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]
}
}