eslint-plugin-baseline-js 0.1.0-alpha.1 → 0.1.0

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/README.md CHANGED
@@ -2,25 +2,19 @@
2
2
 
3
3
  # eslint-plugin-baseline-js
4
4
 
5
- ![baseline](./docs/assets/baseline-wordmark-dark.svg)
5
+ ![baseline](https://web-platform-dx.github.io/web-features/assets/img/baseline-wordmark-dark.svg)
6
6
 
7
7
  Enforce the JavaScript Baseline (`widely` / `newly` / `year`) with a single ESLint rule powered by web‑features.
8
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
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>
10
+ [![CI](https://github.com/3ru/eslint-plugin-baseline-js/actions/workflows/ci.yml/badge.svg)](https://github.com/3ru/eslint-plugin-baseline-js/actions/workflows/ci.yml)
11
+ [![Release](https://github.com/3ru/eslint-plugin-baseline-js/actions/workflows/release.yml/badge.svg)](https://github.com/3ru/eslint-plugin-baseline-js/actions/workflows/release.yml)
16
12
  <img alt="License" src="https://img.shields.io/badge/license-MIT-blue" />
17
13
 
18
14
  </div>
19
15
 
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
-
16
+ > [!NOTE]
17
+ > This project hasn’t reached a major release yet, so behavior and options may change. Please feel free to report false negatives/positives and any rough edges as [issues](https://github.com/3ru/eslint-plugin-baseline-js/issues).
24
18
 
25
19
  ## Install
26
20
 
@@ -43,26 +37,52 @@ export default [
43
37
  plugins: { "baseline-js": baselineJs },
44
38
  rules: {
45
39
  // Allow only "widely available" Baseline features
46
- "baseline-js/use-baseline": ["error", { baseline: "widely" }],
40
+ "baseline-js/use-baseline": ["error", { available: "widely" }],
47
41
  },
48
42
  },
49
43
  ];
50
44
  ```
51
45
 
46
+ ## Preset Configs
47
+
48
+ This plugin ships Flat Config presets you can call from `configs`:
49
+
50
+ ```js
51
+ import baselineJs from "eslint-plugin-baseline-js";
52
+
53
+ export default [
54
+ // Register the plugin once (required for Flat Config)
55
+ { plugins: { "baseline-js": baselineJs } },
56
+
57
+ // Recommended: enables Web APIs & JS builtins detection with `preset: 'auto'`.
58
+ // Level defaults to 'error'; pass level to change severity
59
+ ...baselineJs.configs.recommended({ available: "widely", level: "warn" }),
60
+
61
+ // TypeScript-aware: requires type info for instance-member checks (`preset: 'type-aware'`).
62
+ // Works best with @typescript-eslint/parser and a proper tsconfig.
63
+ // ...baselineJs.configs["recommended-ts"]({ available: "widely", level: "error" }),
64
+ ];
65
+ ```
66
+
67
+ Note on plugin key
68
+ - Presets assume the plugin is registered under the key `"baseline-js"`.
69
+
70
+ See more real-world configs in [`examples/`](https://github.com/3ru/eslint-plugin-baseline-js/tree/main/examples)
71
+
52
72
  ## Common Configurations
53
73
 
54
74
  ```js
55
75
  // Newly available (more permissive)
56
- 'baseline-js/use-baseline': ['warn', { baseline: 'newly' }];
76
+ 'baseline-js/use-baseline': ['warn', { available: 'newly' }];
57
77
 
58
78
  // Year-based – allow features that became Baseline in or before 2020
59
- 'baseline-js/use-baseline': ['error', { baseline: 2020 }];
79
+ 'baseline-js/use-baseline': ['error', { available: 2020 }];
60
80
 
61
81
  // Ignore knobs for pragmatic adoption
62
82
  'baseline-js/use-baseline': [
63
83
  'error',
64
84
  {
65
- baseline: 2018,
85
+ available: 2018,
66
86
  // Skip specific web-features by ID (or regex as '/.../')
67
87
  ignoreFeatures: ['nullish-coalescing', '/^optional-/'],
68
88
  // Skip reports produced on certain ESTree node types
@@ -90,6 +110,11 @@ export default [
90
110
  | `"newly"` | the feature is marked as limited (`false`) |
91
111
  | `year` (number) | the feature’s Baseline year is greater than `year` |
92
112
 
113
+
114
+ ### Demo
115
+ <img width="963" height="192" alt="getYear is deprecated" src="https://github.com/user-attachments/assets/e04e4a5c-c104-4945-96d6-889a47b7bcde" />
116
+
117
+
93
118
  ## How It Works
94
119
 
95
120
  1. Data → `scripts/build-features.mjs`