0.15.0 • Published 8 months ago
eslint-plugin-ts-compat v0.15.0
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-devNext, install eslint-plugin-ts-compat:
npm install eslint-plugin-ts-compat --save-devUsage
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-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-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-string-index | Disable string index | ✅ | 🔧 |
| no-symbol | Disable Symbol factory function. | ✅ | |
| no-timer-args-exceed | Not allow using the third argument of setTimeout & setInterval. | ||
| no-top-level-await | Disable Top-Level await. | ✅ | |
| prefer-immuable-url | Prefer immuable url | ✅ | |
| prefer-inner-text | Prefer .innerText | ✅ | 🔧 |
| prefer-url-href | Prefer url href. | 🔧 | |
| sealed-class | Prefer sealed class |