Skip to content

almedinhodzic/objectid-compare

Repository files navigation

eslint-plugin-objectid-compare

Comparing ObjectId from mongodb module

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-objectid-compare:

npm install eslint-plugin-objectid-compare --save-dev

Usage

Add objectid-compare to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "objectid-compare"
    ]
}

Also this plugin required parser options, so please add in your .eslintrc configuration file:

{
    "parserOptions": {
        "project": ["path/to/your/tsconfig/file"]
    },
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "objectid-compare/rule-name": "warn"
    }
}

For currently supported rule:

{
    "rules": {
        "objectid-compare/objectid-compare": "warn"
    }
}

Supported Rules

  • objectid-compare

Usage - Examples

When comparation sign '===' is used, and both sides are type of ObjectId, or can be ObjectId, warning will be shown.

Example 1: example-1 Example 2: example-2


Author Info

About

Comparing ObjectId types with eslint plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published