eslint-plugin-ts-compat

0.11.0 • Public • Published

eslint-plugin-ts-compat

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-class-list Disable classList
no-event-listener Disable standard event
no-function-name Disable Function.prototype.name
no-regexp-flags Disable RegExp.prototype.flags
no-regexp-sticky Disable regexp sticky
no-regexp-unicode Disable JavaScript built-in: RegExp: unicode
no-string-index Disable string index 🔧
no-symbol Disable Symbol factory function.
prefer-immuable-url Prefer immuable url
prefer-inner-text Prefer .innerText 🔧
prefer-url-href Prefer url href. 🔧

Package Sidebar

Install

npm i eslint-plugin-ts-compat

Weekly Downloads

2

Version

0.11.0

License

MIT

Unpacked Size

38.6 kB

Total Files

22

Last publish

Collaborators

  • linsk