You’ll first need to install eslint:
npm install --save-dev eslint
Next, install @masknet/eslint-plugin
:
npm install --save-dev @masknet/eslint-plugin
Add @masknet
to the plugins section of your .eslintrc
configuration file.
{
"$schema": "https://dimensiondev.github.io/eslint-plugin/src/schema.json",
"plugins": ["@masknet"],
"rules": {
"@masknet/array/no-unneeded-flat-map": "warn",
"@masknet/array/prefer-from": "error",
"@masknet/browser/no-persistent-storage": "error",
"@masknet/browser/no-set-html": "error",
"@masknet/browser/prefer-location-assign": "warn",
"@masknet/jsx/no-class-component": "warn",
"@masknet/jsx/no-logical": "error",
"@masknet/jsx/no-set-html": "error",
"@masknet/jsx/no-template-literal": "warn",
"@masknet/jsx/no-unneeded-nested": "warn",
"@masknet/jsx/prefer-test-id": "error",
"@masknet/string/no-data-url": "error",
"@masknet/string/no-interpolation": "warn",
"@masknet/string/no-locale-case": "error",
"@masknet/string/no-simple-template-literal": "warn",
"@masknet/string/no-unneeded-to-string": "warn",
"@masknet/type/no-const-enum": "error",
"@masknet/type/no-empty-literal": "error",
"@masknet/type/no-force-cast-via-top-type": "error",
"unicorn/no-instanceof-array": "off",
"@masknet/type/no-instanceof-wrapper": "error",
"@masknet/type/no-number-constructor": "error",
"@masknet/type/no-wrapper-type-reference": "error",
"@masknet/type/prefer-return-type-annotation": "warn",
"@masknet/unicode/no-bidi": "error",
"@masknet/unicode/no-invisible": "error",
"@masknet/unicode/specific-set": "error",
"@masknet/no-builtin-base64": "error",
"@masknet/no-default-error": "error",
"@masknet/no-for-in": "warn",
"@masknet/no-redundant-variable": "warn",
"@masknet/no-single-return": "warn",
"@masknet/no-then": "warn",
"@masknet/no-timer": "error",
"@masknet/no-top-level": "error",
"@masknet/no-unsafe-date": "error",
"@masknet/prefer-default-export": "warn",
"@masknet/prefer-defer-import": "error",
"@masknet/prefer-early-return": "warn",
"@masknet/prefer-fetch": "warn",
"@masknet/prefer-timer-id": "error"
}
}
Key: = recommended, = fixable, = suggestions, = configurable, = requires type information
Array#flatMap((x) => x)
when simpler alternatives existArray.from(...)
over new Array(...)
Element#{inner,outer}HTML
location.assign(...)
over location.*
dangerouslySetInnerHTML
jsx attributedata-test-id
attribute is present on interactive DOM elements to help with UI testingString#toLocale{Upper,Lower}Case()
String#toString()
when simpler alternatives existT
to unrelated or incompatible type Q
via T as any as Q
instanceof
for wrapper objectsNumber
constructorPromise#then(...)