https://github.com/3ru/eslint-baseline-compat-contrast
Type‑aware Baseline linting demo
https://github.com/3ru/eslint-baseline-compat-contrast
Last synced: 8 months ago
JSON representation
Type‑aware Baseline linting demo
- Host: GitHub
- URL: https://github.com/3ru/eslint-baseline-compat-contrast
- Owner: 3ru
- Created: 2025-09-20T11:21:47.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-09-20T11:24:31.000Z (9 months ago)
- Last Synced: 2025-10-03T09:57:44.641Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Baseline vs compat — Type-aware contrast
This minimal demo shows a case that `eslint-plugin-compat` often misses but `eslint-plugin-baseline-js` (type‑aware) detects:
- A typed instance method: `arr.toSorted()` where `arr: number[]`.
- `eslint-plugin-baseline-js` uses TypeScript type information to confirm `arr` is an `Array` and flags `toSorted` when the Baseline is set to 2022.
- `eslint-plugin-compat` can detect `[].toSorted()` (array literal) but generally can’t infer that an arbitrary identifier `arr` is an Array without types, so it usually misses `arr.toSorted()`.
## Install
```bash
npm i
```
## Run (baseline, type‑aware)
```bash
npm run lint:baseline
```
Expected: an error for `arr.toSorted()` from `eslint-plugin-baseline-js`.
Example output:
```sh
baseline-demo-contrast/src/sort.ts
5:5 error Feature 'Array by copy' (array-by-copy) became Baseline in 2023 and exceeds 2022 baseline-js/use-baseline
✖ 1 problem (1 error, 0 warnings)
```
If you uncomment the literal case (`[3, 1, 2].toSorted()`), it will also be flagged under the same Baseline policy.
## Run (compat)
```bash
npm run lint:compat
```
Expected: no error for `arr.toSorted()` (identifier receiver). If you uncomment the literal case `[3, 1, 2].toSorted()`, `eslint-plugin-compat` flags that line only (the identifier case remains unflagged).