eslint-plugin-baseline-js 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +132 -0
- package/dist/index.cjs +1312 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.mts +22 -0
- package/dist/index.mjs +1287 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 eslint-plugin-baseline-js contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# eslint-plugin-baseline-js
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Enforce the JavaScript Baseline (`widely` / `newly` / `year`) with a single ESLint rule powered by web‑features.
|
|
8
|
+
This plugin delegates detection to eslint-plugin-es-x and ESLint core (plus a few small gap‑filling rules) and reports with one consistent Baseline message.
|
|
9
|
+
|
|
10
|
+
<a href="https://github.com/3ru/eslint-plugin-baseline-js/actions/workflows/ci.yml">
|
|
11
|
+
<img alt="CI" src="https://img.shields.io/github/actions/workflow/status/3ru/eslint-plugin-baseline-js/ci.yml?label=CI&logo=github" />
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://github.com/3ru/eslint-plugin-baseline-js/actions/workflows/release.yml">
|
|
14
|
+
<img alt="Release" src="https://img.shields.io/github/actions/workflow/status/3ru/eslint-plugin-baseline-js/release.yml?label=release&logo=github" />
|
|
15
|
+
</a>
|
|
16
|
+
<img alt="License" src="https://img.shields.io/badge/license-MIT-blue" />
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
> [!WARNING]
|
|
21
|
+
> Alpha testing: Behavior and options may change.
|
|
22
|
+
> Questions or ideas? Please open an [issue](https://github.com/3ru/eslint-plugin-baseline-js/issues)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
- npm: `npm i -D eslint-plugin-baseline-js`
|
|
28
|
+
- pnpm: `pnpm add -D eslint-plugin-baseline-js`
|
|
29
|
+
- yarn: `yarn add -D eslint-plugin-baseline-js`
|
|
30
|
+
|
|
31
|
+
Recommended
|
|
32
|
+
- ESLint >= 8.57 (Flat Config)
|
|
33
|
+
|
|
34
|
+
## Quick Start (Flat Config)
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
// eslint.config.js
|
|
38
|
+
import baselineJs from "eslint-plugin-baseline-js";
|
|
39
|
+
|
|
40
|
+
export default [
|
|
41
|
+
{
|
|
42
|
+
files: ["**/*.{js,ts,jsx,tsx}"],
|
|
43
|
+
plugins: { "baseline-js": baselineJs },
|
|
44
|
+
rules: {
|
|
45
|
+
// Allow only "widely available" Baseline features
|
|
46
|
+
"baseline-js/use-baseline": ["error", { baseline: "widely" }],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Common Configurations
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
// Newly available (more permissive)
|
|
56
|
+
'baseline-js/use-baseline': ['warn', { baseline: 'newly' }];
|
|
57
|
+
|
|
58
|
+
// Year-based – allow features that became Baseline in or before 2020
|
|
59
|
+
'baseline-js/use-baseline': ['error', { baseline: 2020 }];
|
|
60
|
+
|
|
61
|
+
// Ignore knobs for pragmatic adoption
|
|
62
|
+
'baseline-js/use-baseline': [
|
|
63
|
+
'error',
|
|
64
|
+
{
|
|
65
|
+
baseline: 2018,
|
|
66
|
+
// Skip specific web-features by ID (or regex as '/.../')
|
|
67
|
+
ignoreFeatures: ['nullish-coalescing', '/^optional-/'],
|
|
68
|
+
// Skip reports produced on certain ESTree node types
|
|
69
|
+
ignoreNodeTypes: ['WithStatement', '/Expression$/'],
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
// Turn off in tests or generated folders (ESLint standard overrides)
|
|
74
|
+
export default [
|
|
75
|
+
{ /* project defaults ... */ },
|
|
76
|
+
{
|
|
77
|
+
files: ['**/*.test.*', 'coverage/**'],
|
|
78
|
+
rules: { 'baseline-js/use-baseline': 'off' },
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## What Gets Reported?
|
|
84
|
+
|
|
85
|
+
> Features from web‑features (group: `"javascript"`) that exceed your configured Baseline.
|
|
86
|
+
|
|
87
|
+
| Baseline setting | Reports when... |
|
|
88
|
+
| ---------------- | ----------------------------------- |
|
|
89
|
+
| `"widely"` | the feature is not in Baseline “high” |
|
|
90
|
+
| `"newly"` | the feature is marked as limited (`false`) |
|
|
91
|
+
| `year` (number) | the feature’s Baseline year is greater than `year` |
|
|
92
|
+
|
|
93
|
+
## How It Works
|
|
94
|
+
|
|
95
|
+
1. Data → `scripts/build-features.mjs`
|
|
96
|
+
- Extracts the minimal JavaScript subset from [`web‑features`](https://github.com/web-platform-dx/web-features) into `src/baseline/features.ts`.
|
|
97
|
+
2. Mapping → `src/baseline/mapping.mjs`
|
|
98
|
+
- Maps web‑features IDs to underlying rules (prefer `eslint-plugin-es-x` / ESLint core; custom rules only when necessary).
|
|
99
|
+
3. Resolution → `src/baseline/resolve.ts`
|
|
100
|
+
- Classifies “beyond baseline” by bucket (`high/low/false → widely/newly/limited`) or year.
|
|
101
|
+
|
|
102
|
+
## Coverage
|
|
103
|
+
|
|
104
|
+
We publish a generated coverage report that lists all JavaScript features from web‑features
|
|
105
|
+
and shows which ones are currently mapped by this plugin.
|
|
106
|
+
|
|
107
|
+
- Report: [docs/coverage.md](docs/coverage.md)
|
|
108
|
+
- Regenerate locally: `pnpm gen:coverage`
|
|
109
|
+
- The release workflow also regenerates and commits this file.
|
|
110
|
+
|
|
111
|
+
## Options (rule)
|
|
112
|
+
|
|
113
|
+
| Option | Type | Default | Description |
|
|
114
|
+
| ---------------------- | ------------------------- | ---------- | ----------- |
|
|
115
|
+
| `baseline` | `widely`, `newly`, `number`, `widely` | Baseline level or year (alias: `available`). |
|
|
116
|
+
| `ignoreFeatures` | `string[]` | — | Skip specific web‑features by ID (supports regex `/.../`). |
|
|
117
|
+
| `ignoreNodeTypes` | `string[]` | — | Suppress reports by ESTree `node.type` (supports regex `/.../`). |
|
|
118
|
+
|
|
119
|
+
## Baseline for HTML and CSS
|
|
120
|
+
|
|
121
|
+
Baseline works best when HTML, CSS, and JS all align. For markup and styles, enable the "use-baseline" rules from these ESLint plugins:
|
|
122
|
+
|
|
123
|
+
- ESLint for CSS: https://github.com/eslint/css
|
|
124
|
+
- HTML ESLint: https://github.com/yeonjuan/html-eslint
|
|
125
|
+
|
|
126
|
+
## Branding Note (Baseline)
|
|
127
|
+
|
|
128
|
+
The Baseline name and logos are Google trademarks. Logo assets are licensed under CC BY‑ND 4.0. If you use Baseline logos alongside this plugin, please follow the [official guidelines](https://web-platform-dx.github.io/web-features/name-and-logo-usage-guidelines/) and do not imply sponsorship, affiliation, or endorsement by Google. We embed the official Baseline icons via their published URLs (unmodified).
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT
|