Comparing ObjectId from mongodb module
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
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"
}
}
- objectid-compare
When comparation sign '===' is used, and both sides are type of ObjectId, or can be ObjectId, warning will be shown.
- LinkedIn - @almedin