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.
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
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"
]
}
💼 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. | 🔧 |