eslint-plugin-misc

ESLint plugin

This project is maintained by iliubinskii

ESLint plugin

Table of contents

Overview

A collection of ESLint rules for JavaScript and TypeScript files.

Installation

npm install --save-dev eslint-plugin-misc
// .eslintrc.js
module.exports = {
  extends: "plugin:misc/all",
  parser: "@typescript-eslint/parser",
  plugins: ["misc"]
};

Configs

Rules

Synonyms

You can use the same rule several times by adding synonym:

// .eslintrc.synonyms.cjs
module.exports = ["misc/wrap/class-methods-use-this", "misc/wrap/no-shadow"];

// .eslintrc.js
module.exports = {
  rules: {
    // Same as ESLint core rule, but suppresses warnings for methods that have "this" parameter.
    "misc/wrap/class-methods-use-this": [
      "error",
      {
        plugin: "eslint",
        rule: "class-methods-use-this",
        skip: "FunctionExpression[params.0.name=this]"
      }
    ],
    // Same as typescript-eslint rule, but suppresses warnings for enums.
    "misc/wrap/no-shadow": [
      "error",
      {
        plugin: "@typescript-eslint/eslint-plugin",
        rule: "no-shadow",
        skip: "TSEnumDeclaration *"
      }
    ]
  }
};

Custom checks

Many custom checks can be created without writing full-fledged ESLint plugin. Use the rules below to create custom checks or adapt existing third-party rules:

If you want to apply one rule several times (e.g. restrict several syntaxes), use rule synonyms.

Planned rules