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