npm.io
1.0.0 • Published 6h ago

eslint-plugin-ts-compat

Licence
MIT
Version
1.0.0
Deps
4
Size
106 kB
Vulns
0
Weekly
0
Stars
1

eslint-plugin-ts-compat

npm version Build Status License

This is a eslint-plugin to check browser compat base on TypeScript.

  • You can ban some code even Babel and Polyfills could not solve.
  • Use Typescript for type check.

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-ts-compat:

npm install eslint-plugin-ts-compat --save-dev

Usage

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

{
    "plugins": ["ts-compat"],
    "parser": "@typescript-eslint/parser",
}

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

{
    "rules": {
        "ts-compat/no-regexp-flags": 2
    }
}

This plugin exports a recommended config that enforces good practices.

{
    "extends": [
        "plugin:ts-compat/recommended"
    ]
}

Support a browserslist configuration to preset rules.

{
    "extends": [
        "plugin:ts-compat/browserslist"
    ]
}

Rules

Configurations enabled in.
Set in the recommended configuration.
Automatically fixable by the --fix CLI option.

Name Description
no-array-index Disable array index
no-atomics Disable Atomics object.
no-bigint Disable BigInt.
no-binary Disable binary data APIs.
no-class-list Disable classList
no-date-parse Not allow parse date string.
no-document-current-script Disable document.currentScript.
no-event-listener Disable standard event
no-event-timestamp Disable Event.prototype.timeStamp
no-function-length Disable Function.prototype.length
no-function-name Disable Function.prototype.name
no-map-iterator Disable the Map iterator APIs.
no-proxy Disable Proxy object.
no-reflect Disable Reflect object.
no-regexp-flags Disable RegExp.prototype.flags
no-regexp-sticky Disable regexp sticky
no-regexp-unicode Disable JavaScript built-in: RegExp: unicode
no-regexp-unicode-sets Disable JavaScript built-in: RegExp: unicodeSet
no-set-iterator Disable the Set iterator APIs.
no-string-htmlify-methods Disable the String HTML methods
no-string-index Disable string index
no-string-normalize Disable String.prototype.normalize
no-symbol Disable Symbol and symbol keyed properties.
no-symbol-description Disable Symbol.prototype.description
no-timer-args-exceed Not allow using the third argument of setTimeout & setInterval.
no-top-level-await Disable Top-Level await.
no-weakrefs Disable WeakRef and FinalizationRegistry.
prefer-anonymous-function-expression Prefer anonymous function expression.
prefer-enum-plain-object Only allow enumeration on plain object.
prefer-immuable-url Prefer immuable url
prefer-inner-text Prefer .innerText
prefer-sealed-class Prefer sealed class
prefer-url-href Prefer url href.

Keywords