aislop 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/LICENSE +21 -0
- package/README.md +339 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +4349 -0
- package/dist/engine-info-DBG3uXLc.js +39 -0
- package/dist/expo-doctor-CGXGLgMJ.js +126 -0
- package/dist/expo-doctor-vDz4kh9-.js +127 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.js +3880 -0
- package/dist/json-DkpW9UQj.js +30 -0
- package/dist/json-L5x3hQdy.js +31 -0
- package/dist/subprocess-99puEEGl.js +59 -0
- package/package.json +81 -0
- package/scripts/postinstall-tools.mjs +235 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 heavykenny
|
|
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
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# aislop
|
|
2
|
+
|
|
3
|
+
**Stop AI slop from shipping.**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/aislop)
|
|
6
|
+
[](https://github.com/heavykenny/aislop/actions/workflows/ci.yml)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
AI coding assistants are fast, but they leave behind a trail of sloppy code: swallowed exceptions, trivial comments that restate the obvious, unused imports, `as any` casts, empty catch blocks, leftover `console.log` calls, and copy-paste duplication. **aislop** catches all of it in one command.
|
|
10
|
+
|
|
11
|
+
`aislop` is a unified code-quality CLI for multi-language repositories. It runs formatting, linting, code-quality, AI-pattern, architecture, and security checks behind a single command and summarizes everything as one score out of 100.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
$ npx aislop scan
|
|
15
|
+
|
|
16
|
+
aislop Scan v0.1.0
|
|
17
|
+
|
|
18
|
+
✓ Project my-app (typescript)
|
|
19
|
+
Source files: 142
|
|
20
|
+
|
|
21
|
+
✓ Formatting: done (0 issues)
|
|
22
|
+
✓ Linting: done (2 warnings)
|
|
23
|
+
✓ Code Quality: done (1 warning)
|
|
24
|
+
! Maintainability: done (4 warnings)
|
|
25
|
+
✓ Security: done (0 issues)
|
|
26
|
+
|
|
27
|
+
Score: 80/100 (Healthy)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Why aislop?
|
|
33
|
+
|
|
34
|
+
Code generated by AI assistants often looks correct at first glance but is full of quality issues that pass review because they are spread across dozens of files. No single existing linter catches all of them. `aislop` was built to be the one tool that does:
|
|
35
|
+
|
|
36
|
+
- **Catches AI-specific patterns** that ESLint and Prettier ignore: trivial comments (`// Import React`), thin wrappers, generic names (`data2`, `helper_1`), swallowed exceptions
|
|
37
|
+
- **Multi-language** -- TypeScript, JavaScript, Python, Go, Rust, Ruby, PHP in one CLI
|
|
38
|
+
- **Single score** -- one number to gate PRs, track in CI, and trend over time
|
|
39
|
+
- **Zero config to start** -- run `npx aislop scan` and get results immediately
|
|
40
|
+
- **Batteries included** -- ships with oxlint, biome, and knip; downloads ruff and golangci-lint automatically on install
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
### Run without installing
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx aislop scan
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Install as a dev dependency
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# npm
|
|
56
|
+
npm install --save-dev aislop
|
|
57
|
+
|
|
58
|
+
# yarn
|
|
59
|
+
yarn add --dev aislop
|
|
60
|
+
|
|
61
|
+
# pnpm
|
|
62
|
+
pnpm add -D aislop
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Global install
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install -g aislop
|
|
69
|
+
aislop scan
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`aislop` ships with Node-based tooling (oxlint, biome, knip) as package dependencies. On install it also downloads bundled binaries for **ruff** and **golangci-lint**. To skip those downloads:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
AISLOP_SKIP_TOOL_DOWNLOAD=1 npm install
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Some checks depend on tools already present on your machine: `gofmt`, `govulncheck`, `cargo`, `rubocop`, `phpcs`, `php-cs-fixer`. Run `aislop doctor` to see what is available.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Quick start
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Scan the current directory
|
|
86
|
+
npx aislop scan
|
|
87
|
+
|
|
88
|
+
# Auto-fix formatting and lint issues
|
|
89
|
+
npx aislop fix
|
|
90
|
+
|
|
91
|
+
# Scan only changed files (great for pre-commit)
|
|
92
|
+
npx aislop scan --changes
|
|
93
|
+
|
|
94
|
+
# Scan only staged files
|
|
95
|
+
npx aislop scan --staged
|
|
96
|
+
|
|
97
|
+
# CI-friendly JSON output
|
|
98
|
+
npx aislop ci
|
|
99
|
+
|
|
100
|
+
# Initialize config files
|
|
101
|
+
npx aislop init
|
|
102
|
+
|
|
103
|
+
# Interactive menu
|
|
104
|
+
npx aislop
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Commands
|
|
110
|
+
|
|
111
|
+
| Command | What it does |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `aislop` | Interactive TTY menu (falls back to `scan` in non-TTY) |
|
|
114
|
+
| `aislop scan [dir]` | Run all enabled engines and print a scored report |
|
|
115
|
+
| `aislop fix [dir]` | Apply safe auto-fixes (formatting + lint) |
|
|
116
|
+
| `aislop ci [dir]` | Output JSON for CI pipelines |
|
|
117
|
+
| `aislop init [dir]` | Create `.aislop/config.yml` and `.aislop/rules.yml` |
|
|
118
|
+
| `aislop doctor [dir]` | Report which tools are installed and available |
|
|
119
|
+
| `aislop rules [dir]` | List all built-in and configured rules |
|
|
120
|
+
|
|
121
|
+
### Flags
|
|
122
|
+
|
|
123
|
+
| Flag | Description |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `--changes` | Only scan files changed from `HEAD` |
|
|
126
|
+
| `--staged` | Only scan staged files |
|
|
127
|
+
| `-d, --verbose` | Show detailed per-file output |
|
|
128
|
+
| `--json` | Output JSON instead of terminal UI |
|
|
129
|
+
| `-v, --version` | Print version |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## What it catches
|
|
134
|
+
|
|
135
|
+
`aislop` groups checks into six engines. Each engine runs in parallel for speed.
|
|
136
|
+
|
|
137
|
+
### Formatting
|
|
138
|
+
|
|
139
|
+
Enforces consistent formatting using the best tool for each language.
|
|
140
|
+
|
|
141
|
+
| Language | Tool |
|
|
142
|
+
|---|---|
|
|
143
|
+
| TypeScript / JavaScript | Biome |
|
|
144
|
+
| Python | ruff format |
|
|
145
|
+
| Go | gofmt |
|
|
146
|
+
| Rust | cargo fmt |
|
|
147
|
+
| Ruby | rubocop |
|
|
148
|
+
| PHP | php-cs-fixer |
|
|
149
|
+
|
|
150
|
+
### Linting
|
|
151
|
+
|
|
152
|
+
Catches bugs and bad practices.
|
|
153
|
+
|
|
154
|
+
| Language | Tool |
|
|
155
|
+
|---|---|
|
|
156
|
+
| TypeScript / JavaScript | oxlint (bundled, with React/Next.js awareness) |
|
|
157
|
+
| Python | ruff |
|
|
158
|
+
| Go | golangci-lint |
|
|
159
|
+
| Rust | clippy |
|
|
160
|
+
| Ruby | rubocop |
|
|
161
|
+
|
|
162
|
+
### Code quality
|
|
163
|
+
|
|
164
|
+
Measures structural complexity and finds dead code.
|
|
165
|
+
|
|
166
|
+
| Rule | What it checks |
|
|
167
|
+
|---|---|
|
|
168
|
+
| `complexity/function-too-long` | Functions exceeding configurable line limit (default: 80) |
|
|
169
|
+
| `complexity/file-too-large` | Files exceeding configurable line limit (default: 400) |
|
|
170
|
+
| `complexity/deep-nesting` | Control-flow nesting beyond threshold (default: 5) |
|
|
171
|
+
| `complexity/too-many-params` | Functions with too many parameters (default: 6) |
|
|
172
|
+
| `duplication/block` | Cross-file duplicate code blocks (12+ lines) |
|
|
173
|
+
| `knip/files`, `knip/exports`, `knip/types` | Dead code via knip (JS/TS) |
|
|
174
|
+
|
|
175
|
+
### AI slop detection (Maintainability)
|
|
176
|
+
|
|
177
|
+
The rules that make aislop unique. These catch the patterns AI assistants leave behind.
|
|
178
|
+
|
|
179
|
+
| Rule | Severity | What it catches |
|
|
180
|
+
|---|---|---|
|
|
181
|
+
| `ai-slop/trivial-comment` | warning | Comments restating the code (`// Import React`, `// Return the value`) |
|
|
182
|
+
| `ai-slop/swallowed-exception` | error | Empty catch blocks, catch blocks that only log (JS/TS/Python/Go/Ruby/Java) |
|
|
183
|
+
| `ai-slop/thin-wrapper` | warning | Functions that only delegate to another function |
|
|
184
|
+
| `ai-slop/generic-naming` | info | AI-generated names: `helper_1`, `data2`, `temp1` |
|
|
185
|
+
| `ai-slop/unused-import` | warning | Unused imports (JS/TS and Python) |
|
|
186
|
+
| `ai-slop/console-leftover` | warning | `console.log`/`debug`/`info` left in production code |
|
|
187
|
+
| `ai-slop/todo-stub` | info | Unresolved TODO/FIXME/HACK comments |
|
|
188
|
+
| `ai-slop/unreachable-code` | warning | Code after `return`/`throw` statements |
|
|
189
|
+
| `ai-slop/constant-condition` | warning | `if (true)`, `if (false)`, `if (0)` |
|
|
190
|
+
| `ai-slop/empty-function` | info | Empty function bodies |
|
|
191
|
+
| `ai-slop/unsafe-type-assertion` | warning | `as any` in TypeScript |
|
|
192
|
+
| `ai-slop/double-type-assertion` | warning | `as unknown as X` pattern |
|
|
193
|
+
| `ai-slop/ts-directive` | info | `@ts-ignore` / `@ts-expect-error` usage |
|
|
194
|
+
|
|
195
|
+
### Security
|
|
196
|
+
|
|
197
|
+
Finds secrets, risky constructs, and vulnerable dependencies.
|
|
198
|
+
|
|
199
|
+
| Rule | What it catches |
|
|
200
|
+
|---|---|
|
|
201
|
+
| `security/hardcoded-secret` | API keys, AWS credentials, JWT tokens, database URLs, passwords |
|
|
202
|
+
| `security/eval` | `eval()` usage (JS/TS/Python/Ruby/PHP) |
|
|
203
|
+
| `security/innerhtml` | `.innerHTML` and `dangerouslySetInnerHTML` |
|
|
204
|
+
| `security/sql-injection` | String concatenation in SQL queries |
|
|
205
|
+
| `security/shell-injection` | User input in command execution |
|
|
206
|
+
| `security/vulnerable-dependency` | npm/pip/cargo/go dependency audit |
|
|
207
|
+
|
|
208
|
+
### Architecture (opt-in)
|
|
209
|
+
|
|
210
|
+
Custom import and path rules defined in `.aislop/rules.yml`.
|
|
211
|
+
|
|
212
|
+
| Rule type | Example |
|
|
213
|
+
|---|---|
|
|
214
|
+
| `forbid_import` | Ban `axios` project-wide |
|
|
215
|
+
| `forbid_import_from_path` | Controllers cannot import database modules |
|
|
216
|
+
| `require_pattern` | Require error handling in API routes |
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Scoring
|
|
221
|
+
|
|
222
|
+
Every diagnostic contributes a weighted penalty:
|
|
223
|
+
|
|
224
|
+
| Severity | Penalty |
|
|
225
|
+
|---|---|
|
|
226
|
+
| Error | 3.0 |
|
|
227
|
+
| Warning | 1.0 |
|
|
228
|
+
| Info | 0.25 |
|
|
229
|
+
|
|
230
|
+
Penalties are multiplied by engine weight (configurable, security defaults to 2x). The final score uses logarithmic scaling so a few issues cause a noticeable drop, but the score does not collapse to zero from minor findings.
|
|
231
|
+
|
|
232
|
+
| Score | Label |
|
|
233
|
+
|---|---|
|
|
234
|
+
| 75 -- 100 | Healthy |
|
|
235
|
+
| 50 -- 74 | Needs Work |
|
|
236
|
+
| 0 -- 49 | Critical |
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Configuration
|
|
241
|
+
|
|
242
|
+
Run `aislop init` to generate `.aislop/config.yml`:
|
|
243
|
+
|
|
244
|
+
```yaml
|
|
245
|
+
version: 1
|
|
246
|
+
|
|
247
|
+
engines:
|
|
248
|
+
format: true
|
|
249
|
+
lint: true
|
|
250
|
+
code-quality: true
|
|
251
|
+
ai-slop: true
|
|
252
|
+
architecture: false # opt-in, needs rules.yml
|
|
253
|
+
security: true
|
|
254
|
+
|
|
255
|
+
quality:
|
|
256
|
+
maxFunctionLoc: 80
|
|
257
|
+
maxFileLoc: 400
|
|
258
|
+
maxNesting: 5
|
|
259
|
+
maxParams: 6
|
|
260
|
+
|
|
261
|
+
security:
|
|
262
|
+
audit: true
|
|
263
|
+
auditTimeout: 25000
|
|
264
|
+
|
|
265
|
+
scoring:
|
|
266
|
+
weights:
|
|
267
|
+
format: 0.5
|
|
268
|
+
lint: 1.0
|
|
269
|
+
code-quality: 1.5
|
|
270
|
+
ai-slop: 1.0
|
|
271
|
+
architecture: 1.0
|
|
272
|
+
security: 2.0
|
|
273
|
+
thresholds:
|
|
274
|
+
good: 75
|
|
275
|
+
ok: 50
|
|
276
|
+
|
|
277
|
+
ci:
|
|
278
|
+
failBelow: 0 # set to e.g. 70 to fail CI below that score
|
|
279
|
+
format: json
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## CI / CD
|
|
285
|
+
|
|
286
|
+
### GitHub Actions
|
|
287
|
+
|
|
288
|
+
```yaml
|
|
289
|
+
- uses: actions/setup-node@v4
|
|
290
|
+
with:
|
|
291
|
+
node-version: 20
|
|
292
|
+
|
|
293
|
+
- run: npx aislop ci
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Fail below a score threshold
|
|
297
|
+
|
|
298
|
+
Set `ci.failBelow` in `.aislop/config.yml`:
|
|
299
|
+
|
|
300
|
+
```yaml
|
|
301
|
+
ci:
|
|
302
|
+
failBelow: 70
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
`aislop ci` exits with code 1 when the score is below the threshold.
|
|
306
|
+
|
|
307
|
+
### Pre-commit hook
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
npx aislop scan --staged
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Supported languages
|
|
316
|
+
|
|
317
|
+
| Language | Format | Lint | Code quality | AI slop | Security |
|
|
318
|
+
|---|---|---|---|---|---|
|
|
319
|
+
| TypeScript | Biome | oxlint | knip, complexity | All rules | All rules |
|
|
320
|
+
| JavaScript | Biome | oxlint | knip, complexity | All rules | All rules |
|
|
321
|
+
| Python | ruff | ruff | complexity | Imports, exceptions, comments | Secrets, audit |
|
|
322
|
+
| Go | gofmt | golangci-lint | complexity | Exceptions, comments | Secrets, audit |
|
|
323
|
+
| Rust | cargo fmt | clippy | complexity | Comments | Secrets, audit |
|
|
324
|
+
| Ruby | rubocop | rubocop | complexity | Exceptions, comments | Secrets |
|
|
325
|
+
| PHP | php-cs-fixer | -- | complexity | Comments | Secrets |
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Contributing
|
|
330
|
+
|
|
331
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, project architecture, and how to add new rules or engines.
|
|
332
|
+
|
|
333
|
+
## Security
|
|
334
|
+
|
|
335
|
+
See [SECURITY.md](SECURITY.md) for reporting vulnerabilities.
|
|
336
|
+
|
|
337
|
+
## License
|
|
338
|
+
|
|
339
|
+
[MIT](LICENSE) -- see the [LICENSE](LICENSE) file.
|
package/dist/cli.d.ts
ADDED