flaglint 0.0.1 → 0.1.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/CHANGELOG.md +25 -0
- package/LICENSE +21 -0
- package/README.md +139 -5
- package/dist/bin/flaglint.d.ts +2 -0
- package/dist/bin/flaglint.js +947 -0
- package/dist/bin/flaglint.js.map +1 -0
- package/package.json +49 -10
- package/bin/flaglint.js +0 -20
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-05-18
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `flaglint scan` command — scans codebase for LaunchDarkly SDK usage and reports flag inventory
|
|
13
|
+
- `flaglint migrate` command — analyzes migration readiness and generates an OpenFeature migration plan
|
|
14
|
+
- Detects `variation()`, `variationDetail()`, `allFlags()`, React hooks (`useFlags`, `useLDClient`), HOC (`withLDConsumer`), and Provider (`LDProvider`) patterns
|
|
15
|
+
- Markdown, JSON, and HTML report formats
|
|
16
|
+
- HTML reports include filterable flag table and light/dark mode support
|
|
17
|
+
- Stale flag detection heuristics based on key names (`old`, `deprecated`, `legacy`, `temp`, `tmp`, `test`, `demo`) and file paths
|
|
18
|
+
- Dynamic flag key identification — flags whose keys are determined at runtime
|
|
19
|
+
- Migration readiness score (0–100) with per-pattern deductions
|
|
20
|
+
- Automatic OpenFeature equivalent mapping for all detected call types
|
|
21
|
+
- `.flaglintrc` config file support with Zod validation and clear error messages
|
|
22
|
+
- `--dry-run` flag for `migrate` command
|
|
23
|
+
- Exit code `1` when stale flags found (enables CI blocking)
|
|
24
|
+
- GitHub Actions CI integration across Node.js 18, 20, and 22
|
|
25
|
+
- Test suite with 57 tests and ≥75% coverage across scanner, reporter, and config modules
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FlagLint 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.
|
package/README.md
CHANGED
|
@@ -1,15 +1,149 @@
|
|
|
1
1
|
# FlagLint
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Find stale feature flags. Detect flag debt. Plan your OpenFeature migration.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://https://github.com/flaglint/flagkit-cli/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/flaglint)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## The problem
|
|
12
|
+
|
|
13
|
+
LaunchDarkly flags accumulate. Teams add them, forget to clean them up, and gradually build flag debt — dead code paths controlled by flags nobody manages. When you finally want to migrate to OpenFeature, you don't even know what you have.
|
|
14
|
+
|
|
15
|
+
**FlagLint fixes this.** It scans your codebase, maps every flag usage, identifies stale candidates, and generates a step-by-step OpenFeature migration plan.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
8
20
|
|
|
9
21
|
```bash
|
|
10
22
|
npx flaglint scan
|
|
11
23
|
```
|
|
12
24
|
|
|
13
|
-
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g flaglint
|
|
31
|
+
# or use without installing
|
|
32
|
+
npx flaglint
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
### `flaglint scan [dir]`
|
|
40
|
+
|
|
41
|
+
Scans a directory for LaunchDarkly SDK usage.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
flaglint scan ./src
|
|
45
|
+
flaglint scan --format json --output report.json
|
|
46
|
+
flaglint scan --format html --output report.html
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
| Option | Default | Description |
|
|
50
|
+
|--------|---------|-------------|
|
|
51
|
+
| `--format` | `markdown` | Output format: `json`, `markdown`, `html` |
|
|
52
|
+
| `--output` | stdout | Write report to file |
|
|
53
|
+
| `--config` | auto-detect | Path to `.flaglintrc` |
|
|
54
|
+
|
|
55
|
+
Exit code `0` when no stale flags found, `1` when stale flags exist — enabling CI blocking.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### `flaglint migrate [dir]`
|
|
60
|
+
|
|
61
|
+
Analyzes migration readiness and generates an OpenFeature migration plan.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
flaglint migrate ./src
|
|
65
|
+
flaglint migrate --dry-run
|
|
66
|
+
flaglint migrate --output MIGRATION.md
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Option | Default | Description |
|
|
70
|
+
|--------|---------|-------------|
|
|
71
|
+
| `--output` | `MIGRATION.md` | Write migration plan to file |
|
|
72
|
+
| `--dry-run` | — | Print plan to stdout, do not write file |
|
|
73
|
+
| `--config` | auto-detect | Path to `.flaglintrc` |
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Configuration
|
|
78
|
+
|
|
79
|
+
Create `.flaglintrc` in your project root:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"include": ["**/*.{ts,tsx,js,jsx}"],
|
|
84
|
+
"exclude": ["**/node_modules/**", "**/dist/**"],
|
|
85
|
+
"provider": "launchdarkly",
|
|
86
|
+
"staleThreshold": 1,
|
|
87
|
+
"reportTitle": "My Project Flag Report"
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
| Field | Type | Default | Description |
|
|
92
|
+
|-------|------|---------|-------------|
|
|
93
|
+
| `include` | `string[]` | `["**/*.{ts,tsx,js,jsx}"]` | Glob patterns to scan |
|
|
94
|
+
| `exclude` | `string[]` | `["**/node_modules/**", ...]` | Glob patterns to ignore |
|
|
95
|
+
| `provider` | `string` | `"launchdarkly"` | Feature flag provider |
|
|
96
|
+
| `staleThreshold` | `number` | `1` | Days before a flag is considered stale |
|
|
97
|
+
| `reportTitle` | `string` | — | Custom title for generated reports |
|
|
98
|
+
| `outputDir` | `string` | `"."` | Default output directory |
|
|
99
|
+
|
|
100
|
+
FlagLint searches for config in this order: `--config` flag → `.flaglintrc` → `.flaglintrc.json` → `flaglint.config.json`.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## CI Integration
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
- name: Check for stale flags
|
|
108
|
+
run: npx flaglint scan --format json --output flaglint-report.json
|
|
109
|
+
# exits 1 if stale flags found, blocking the PR
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## What FlagLint detects
|
|
115
|
+
|
|
116
|
+
- `ldClient.variation()` and `ldClient.variationDetail()`
|
|
117
|
+
- `ldClient.allFlags()`
|
|
118
|
+
- `useFlags()`, `useLDClient()` React hooks
|
|
119
|
+
- `<LDProvider>` and `withLDConsumer()` patterns
|
|
120
|
+
- Dynamic flag keys (runtime-determined, flagged for manual review)
|
|
121
|
+
|
|
122
|
+
All detections include the **file path**, **line number**, **call type**, and a **stale heuristic** based on key names and file locations.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## OpenFeature Migration
|
|
127
|
+
|
|
128
|
+
[OpenFeature](https://openfeature.dev) is the vendor-neutral standard for feature flagging (CNCF project). `flaglint migrate` maps your LaunchDarkly SDK calls to OpenFeature equivalents and generates an actionable `MIGRATION.md`:
|
|
129
|
+
|
|
130
|
+
| LaunchDarkly | OpenFeature |
|
|
131
|
+
|---|---|
|
|
132
|
+
| `ldClient.variation(key, ctx, false)` | `client.getBooleanValue(key, false, ctx)` |
|
|
133
|
+
| `ldClient.variationDetail(key, ctx, def)` | `client.getBooleanDetails(key, def, ctx)` |
|
|
134
|
+
| `useFlags()` | `useFlag(key)` per flag |
|
|
135
|
+
| `useLDClient()` | `useOpenFeatureClient()` |
|
|
136
|
+
| `<LDProvider>` | `<OpenFeatureProvider provider={...}>` |
|
|
137
|
+
| `withLDConsumer()(Component)` | `withOpenFeature()(Component)` |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Contributing
|
|
142
|
+
|
|
143
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## License
|
|
14
148
|
|
|
15
|
-
|
|
149
|
+
MIT — see [LICENSE](./LICENSE).
|