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: :white_check_mark: = recommended, :wrench: = fixable, :bulb: = suggestions, :gear: = configurable, :thought_balloon: = requires type information
- array/no-unneeded-flat-map ✅ 🔧
DisallowArray#flatMap((x) => x)
when simpler alternatives exist - array/prefer-from ✅ 🔧
PreferArray.from(...)
overnew Array(...)
- browser/no-persistent-storage ✅
Disallow use browser persistent storage - browser/no-set-html ✅
Disallow useElement#{inner,outer}HTML
- browser/prefer-location-assign ✅ 🔧
Preferlocation.assign(...)
overlocation.*
- jsx/no-class-component ✅
Disallow React Class Component - jsx/no-logical ⚙️
Limit the complexity of JSX logic expression - jsx/no-set-html ✅
Disallow usedangerouslySetInnerHTML
jsx attribute - jsx/no-template-literal ✅ 🔧
Disallow use template-literal in JSX - jsx/no-unneeded-nested ✅ 🔧
Reduce unneeded JSXFragment nested - jsx/prefer-test-id ⚙️
Enforcesdata-test-id
attribute is present on interactive DOM elements to help with UI testing - string/no-data-url ✅
Disallow use Data URL - string/no-interpolation ✅
Disallow simple string interpolation - string/no-locale-case ✅ 🔧
Disallow useString#toLocale{Upper,Lower}Case()
- string/no-simple-template-literal ✅ 🔧
Disallow simple template-literal - string/no-unneeded-to-string ✅ 🔧 💭
DisallowString#toString()
when simpler alternatives exist - type/no-const-enum 🔧
Disallow use constants enumerate - type/no-empty-literal ⚙️
Disallow empty {array,object} literal - type/no-force-cast-via-top-type ✅
Disallowing cast a typeT
to unrelated or incompatible typeQ
viaT as any as Q
- type/no-instanceof-wrapper ✅ 🔧
Disallowinstanceof
for wrapper objects - type/no-number-constructor ✅
Disallow useNumber
constructor - type/no-wrapper-type-reference ✅ 🔧
Disallow wrapper type for type reference - type/prefer-return-type-annotation ✅ 🔧
Enforce Move return type annotation to function return type - unicode/no-bidi ✅ 🔧
Detect and stop Trojan Source attacks - unicode/no-invisible ✅ 🔧
Disallow invisible characters - unicode/specific-set 🔧 ⚙️
Limit the range of literal characters - no-builtin-base64 🔧
Disallow use built-in base64 function - no-default-error ✅ 💭
Restrict the usage of default (unextended) error - no-for-in ✅
Disallow use for-in - no-redundant-variable ✅ 🔧
Disallow redundant variable - no-single-return ✅
Disallow single-return - no-then ✅
DisallowPromise#then(...)
- no-timer
Disallow use timer function - no-top-level ⚙️
Disallow side-effect at module top-level - no-unsafe-date 💭
Disallow use unsafe Date methods - prefer-default-export ✅ ⚙️
Enforce default export location at top or bottom - prefer-defer-import 🔧 ⚙️
Prefer defer import a module. See https://github.com/tc39/proposal-defer-import-eval and webpack/webpack#16567. - prefer-early-return ✅ 🔧 ⚙️
Prefer early returns over full-body conditional wrapping in function declarations - prefer-fetch ✅
Enforce fetch - prefer-timer-id ✅ 💡
Enforce best practice with timer function