@fabriziosalmi/slopless 1.4.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 +21 -0
- package/README.md +142 -0
- package/dist/engine/api.d.ts +16 -0
- package/dist/engine/api.js +543 -0
- package/dist/index.d.ts +122 -0
- package/dist/index.js +590 -0
- package/package.json +59 -0
- package/rules/VBC-001.yaml +33 -0
- package/rules/VBC-002.yaml +13 -0
- package/rules/VBC-003.yaml +36 -0
- package/rules/VBC-004.yaml +33 -0
- package/rules/VBC-005.yaml +24 -0
- package/rules/VBC-006.yaml +16 -0
- package/rules/VBC-007.yaml +28 -0
- package/rules/VBC-008.yaml +21 -0
- package/rules/VBC-009.yaml +24 -0
- package/rules/VBC-010.yaml +24 -0
- package/rules/VBC-011.yaml +21 -0
- package/rules/VBC-012.yaml +21 -0
- package/rules/VBC-013.yaml +17 -0
- package/rules/VBC-014.yaml +15 -0
- package/rules/VBC-015.yaml +40 -0
- package/rules/VBC-016.yaml +21 -0
- package/rules/VBC-017.yaml +23 -0
- package/rules/VBC-018.yaml +19 -0
- package/rules/VBC-019.yaml +42 -0
- package/rules/VBC-020.yaml +22 -0
- package/rules/VBC-021.yaml +22 -0
- package/rules/VBC-022.yaml +21 -0
- package/rules/VBC-023.yaml +22 -0
- package/rules/VBC-024.yaml +26 -0
- package/rules/VBC-025.yaml +13 -0
- package/rules/VBC-026.yaml +17 -0
- package/rules/VBC-027.yaml +27 -0
- package/rules/VBC-028.yaml +18 -0
- package/rules/VBC-029.yaml +22 -0
- package/rules/VBC-030.yaml +22 -0
- package/rules/VBC-032.yaml +20 -0
- package/rules/VBC-033.yaml +26 -0
- package/rules/VBC-034.yaml +41 -0
- package/rules/VBC-035.yaml +30 -0
- package/rules/VBC-039.yaml +18 -0
- package/rules/VBC-042.yaml +26 -0
- package/rules/VBC-045.yaml +13 -0
- package/rules/VBC-046.yaml +13 -0
- package/rules/VBC-048.yaml +23 -0
- package/rules/VBC-049.yaml +19 -0
- package/rules/VBC-051.yaml +23 -0
- package/rules/VBC-052.yaml +19 -0
- package/rules/VBC-053.yaml +19 -0
- package/rules/VBC-054.yaml +29 -0
- package/rules/VBC-056.yaml +28 -0
- package/rules/VBC-057.yaml +18 -0
- package/rules/VBC-058.yaml +18 -0
- package/rules/VBC-059.yaml +21 -0
- package/rules/VBC-063-B.yaml +15 -0
- package/rules/VBC-063.yaml +18 -0
- package/rules/VBC-065.yaml +33 -0
- package/rules/VBC-066.yaml +16 -0
- package/rules/VBC-068.yaml +21 -0
- package/rules/VBC-070.yaml +19 -0
- package/rules/VBC-077.yaml +35 -0
- package/rules/VBC-079.yaml +18 -0
- package/rules/VBC-080.yaml +18 -0
- package/rules/VBC-084.yaml +22 -0
- package/rules/VBC-086.yaml +22 -0
- package/rules/VBC-090.yaml +28 -0
- package/rules/VBC-096.yaml +19 -0
- package/rules/VBC-097.yaml +21 -0
- package/rules/VBC-098.yaml +18 -0
- package/rules/VBC-101.yaml +23 -0
- package/rules/VBC-102.yaml +20 -0
- package/rules/VBC-103.yaml +35 -0
- package/rules/VBC-104.yaml +24 -0
- package/rules/VBC-106.yaml +14 -0
- package/rules/VBC-112.yaml +20 -0
- package/rules/VBC-113.yaml +19 -0
- package/rules/VBC-117.yaml +21 -0
- package/rules/VBC-123.yaml +29 -0
- package/rules/VBC-131.yaml +20 -0
- package/rules/VBC-150.yaml +27 -0
- package/rules/VBC-153.yaml +21 -0
- package/rules/VBC-158.yaml +16 -0
- package/rules/VBC-161.yaml +27 -0
- package/rules/VBC-172.yaml +25 -0
- package/rules/VBC-197.yaml +22 -0
- package/rules/VBC-201.yaml +35 -0
- package/rules/VBC-206.yaml +19 -0
- package/rules/VBC-208.yaml +27 -0
- package/rules/VBC-212.yaml +19 -0
- package/rules/VBC-215.yaml +24 -0
- package/rules/VBC-305.yaml +20 -0
- package/rules/VBC-324.yaml +24 -0
- package/rules/VBC-334.yaml +23 -0
- package/rules/VBC-338.yaml +32 -0
- package/rules/VBC-340.yaml +22 -0
- package/rules/VBC-344.yaml +19 -0
- package/rules/VBC-347.yaml +21 -0
- package/rules/VBC-348.yaml +19 -0
- package/rules/VBC-385.yaml +21 -0
- package/rules/VBC-398.yaml +22 -0
- package/rules/VBC-401.yaml +12 -0
- package/rules/VBC-414.yaml +23 -0
- package/rules/VBC-421.yaml +20 -0
- package/rules/VBC-501.yaml +18 -0
- package/rules/VBC-502.yaml +23 -0
- package/rules/VBC-503.yaml +18 -0
- package/rules/VBC-504.yaml +20 -0
- package/rules/VBC-800.yaml +17 -0
- package/rules/VBC-901.yaml +48 -0
- package/rules/VBC-902.yaml +19 -0
- package/rules/VBC-903.yaml +17 -0
- package/rules/VBC-904.yaml +21 -0
- package/rules/VBC-905.yaml +17 -0
- package/rules/VBC-906.yaml +29 -0
- package/rules/VBC-907.yaml +24 -0
- package/rules/VBC-908.yaml +22 -0
- package/rules/VBC-909.yaml +21 -0
- package/rules/VBC-910.yaml +18 -0
- package/rules/VBC-911.yaml +21 -0
- package/rules/VBC-913.yaml +30 -0
- package/rules/VBC-914.yaml +31 -0
- package/rules/VBC-915.yaml +19 -0
- package/rules/VBC-916.yaml +24 -0
- package/rules/VBC-917.yaml +21 -0
- package/rules/VBC-918.yaml +22 -0
- package/rules/VBC-920.yaml +20 -0
- package/rules/VBC-921.yaml +45 -0
- package/rules/VBC-922.yaml +15 -0
- package/rules/VBC-923.yaml +15 -0
- package/rules/VBC-924.yaml +12 -0
- package/rules/VBC-925.yaml +14 -0
- package/rules/VBC-926.yaml +14 -0
- package/rules/VBC-927.yaml +24 -0
- package/rules/VBC-928.yaml +25 -0
- package/rules/VBC-929.yaml +21 -0
- package/rules/VBC-930.yaml +16 -0
- package/rules/VBC-931.yaml +16 -0
- package/rules/VBC-932.yaml +16 -0
- package/rules/VBC-933.yaml +28 -0
- package/rules/VBC-934.yaml +24 -0
- package/rules/VBC-935.yaml +26 -0
- package/rules/VBC-936.yaml +24 -0
- package/rules/VBC-937.yaml +24 -0
- package/rules/VBC-938.yaml +23 -0
- package/rules/VBC-939.yaml +23 -0
- package/rules/VBC-940.yaml +30 -0
- package/rules/VBC-941.yaml +28 -0
- package/rules/VBC-942.yaml +23 -0
- package/rules/VBC-943.yaml +22 -0
- package/rules/VBC-944.yaml +26 -0
- package/rules/VBC-945.yaml +33 -0
- package/rules/VBC-946.yaml +26 -0
- package/rules/VBC-947.yaml +22 -0
- package/rules/VBC-948.yaml +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 slopless 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
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Slopless
|
|
2
|
+
|
|
3
|
+
[](https://github.com/fabriziosalmi/slopless/actions/workflows/ci.yml) [](https://fabriziosalmi.github.io/slopless/)
|
|
4
|
+
|
|
5
|
+
Slopless is a static analysis tool designed to identify and mitigate unstructured coding patterns, undocumented assumptions, and heuristic-driven development practices (colloquially termed "vibecoding"). It employs a multi-tiered analysis engine combining deterministic regular expressions, Abstract Syntax Tree (AST) inspection, and structural semantic heuristics.
|
|
6
|
+
|
|
7
|
+
## Architecture and Capabilities
|
|
8
|
+
|
|
9
|
+
- **Rule Engine**: 148 rigorous rules spanning security, maintainability, accessibility, and documentation integrity. Every rule ships executable examples — a snippet it must flag and one it must leave alone — run on every commit.
|
|
10
|
+
- **AST Inspection**: Deep structural validation to identify excessive cyclomatic complexity, parameter limits, and empty control flow blocks.
|
|
11
|
+
- **Deep Semantic Validation**: Opt-in TypeScript TypeChecker (`--type-check`) for resolving inherited types, identifying floating promises, and validating structural intent beyond AST boundaries.
|
|
12
|
+
- **Heuristic Auto-Fixes**: Autonomous modification of known anti-patterns (e.g., `var` to `let`) using `--fix`.
|
|
13
|
+
- **Concurrency Pooling**: Fault-tolerant AST parsing distributed across CPU-bound boundaries to guarantee stability on massive monorepos without OOM crashes.
|
|
14
|
+
- **Lexical Scoping**: AST-aware token scanning maps every string and comment in JS/TS, and each rule declares the scope it applies to (`code`, `strings`, `comments`, `all`). A rule about `eval()` stays quiet inside a comment; a rule about hardcoded IPs looks only inside string literals.
|
|
15
|
+
- **Rule Precedence**: A specific rule declares the general ones it `supersedes`, so a single `// TODO: implement this` produces one finding, not four.
|
|
16
|
+
- **LSP IDE Integration**: Ships with `vscode-slopless` for real-time Squiggly-Line diagnostics inside VS Code and Cursor.
|
|
17
|
+
|
|
18
|
+
## GitHub Action
|
|
19
|
+
|
|
20
|
+
```yaml
|
|
21
|
+
- uses: fabriziosalmi/slopless@v1
|
|
22
|
+
with:
|
|
23
|
+
patterns: "src/**/*.ts" # optional; add format: sarif, type-check: "true", args: ...
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Runs the bundled CLI directly — no npm install in your job. Exit code 1 on errors (warnings pass).
|
|
27
|
+
|
|
28
|
+
`@v1` is a moving tag: it follows every 1.x release, which is convenient and means
|
|
29
|
+
you are trusting this repository not to change under you. To remove that trust,
|
|
30
|
+
pin to the commit instead — Dependabot will keep it current:
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
- uses: fabriziosalmi/slopless@<commit-sha> # pin to the release you audited
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install -D @fabriziosalmi/slopless
|
|
40
|
+
# or run it without installing
|
|
41
|
+
npx @fabriziosalmi/slopless
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
> The unscoped `slopless` on npm is an unrelated prose linter by another author.
|
|
45
|
+
> This project publishes as **`@fabriziosalmi/slopless`**; the binary it installs
|
|
46
|
+
> is still called `slopless`.
|
|
47
|
+
|
|
48
|
+
## Supply Chain
|
|
49
|
+
|
|
50
|
+
- **No dependencies.** `npm install @fabriziosalmi/slopless` pulls exactly one
|
|
51
|
+
package. Everything the linter needs is compiled into the bundle, so there is no
|
|
52
|
+
transitive install surface to compromise. CI fails if a runtime dependency
|
|
53
|
+
reappears, or if the bundle stops running without `node_modules`.
|
|
54
|
+
- **Signed provenance.** Releases publish from GitHub Actions over OIDC, with no
|
|
55
|
+
npm token in existence. Every tarball carries an attestation binding it to the
|
|
56
|
+
commit and the workflow run that produced it. Verify it yourself:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm audit signatures
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- **Reproducible bundle.** `dist/index.js` is committed so the Action can run with
|
|
63
|
+
no install step. CI rebuilds it from source and fails if the committed bundle
|
|
64
|
+
differs by a byte, so it cannot be tampered with independently of the source.
|
|
65
|
+
- **Pinned actions.** Every third-party action is pinned to a commit SHA, not a
|
|
66
|
+
moving tag, with Dependabot keeping the pins current.
|
|
67
|
+
- **No telemetry.** Nothing is reported anywhere. The only rule that touches the
|
|
68
|
+
network is `VBC-401` (broken links), which fetches the URLs it finds in the
|
|
69
|
+
Markdown you point it at, and nothing else.
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
|
|
73
|
+
### Instant Initialization
|
|
74
|
+
```bash
|
|
75
|
+
npx @fabriziosalmi/slopless --init
|
|
76
|
+
```
|
|
77
|
+
*Creates `slopless.config.json` and `.sloplessignore` in your workspace.*
|
|
78
|
+
|
|
79
|
+
### Lint the Project
|
|
80
|
+
```bash
|
|
81
|
+
npx @fabriziosalmi/slopless
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Auto-Fix and Deep Semantic Check
|
|
85
|
+
```bash
|
|
86
|
+
npx @fabriziosalmi/slopless --fix --type-check
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### CI/CD Integration (SARIF)
|
|
90
|
+
```bash
|
|
91
|
+
npx @fabriziosalmi/slopless --format sarif > gl-sast-report.json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Lint Specific Directories
|
|
95
|
+
```bash
|
|
96
|
+
npx @fabriziosalmi/slopless "src/**/*.ts" "docs/**/*.md"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Rule Taxonomy
|
|
100
|
+
|
|
101
|
+
- **Core/Security**: Detection of exposed credentials, `eval()` usage, `innerHTML` assignments, SQL built by concatenation, command injection, prototype pollution, insecure file permissions (`chmod 777`), and hardcoded paths.
|
|
102
|
+
- **Clean Code**: Identification of magic numbers, unannotated complex regular expressions, excessive nesting, `async` functions that never await, and non-descriptive variable names.
|
|
103
|
+
- **UX/DX**: Enforcement of accessibility standards (alt attributes, focus visibility, accessible names on icon-only buttons) and prevention of user experience dark patterns.
|
|
104
|
+
- **Documentation**: Detection of generated filler content, non-inclusive language, and broken external references.
|
|
105
|
+
|
|
106
|
+
Full documentation at [fabriziosalmi.github.io/slopless](https://fabriziosalmi.github.io/slopless/):
|
|
107
|
+
[all 148 rules](https://fabriziosalmi.github.io/slopless/rules/) ·
|
|
108
|
+
[configuration](https://fabriziosalmi.github.io/slopless/configuration) ·
|
|
109
|
+
[writing a rule](https://fabriziosalmi.github.io/slopless/writing-a-rule) ·
|
|
110
|
+
[the scanner bug story](https://fabriziosalmi.github.io/slopless/story)
|
|
111
|
+
|
|
112
|
+
## Writing a Rule
|
|
113
|
+
|
|
114
|
+
A rule is one YAML file in `rules/`, named after its id.
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
id: VBC-999
|
|
118
|
+
name: my-rule
|
|
119
|
+
severity: warning # error blocks the run, warning does not
|
|
120
|
+
category: clean-code
|
|
121
|
+
match:
|
|
122
|
+
regex: console\.log\(
|
|
123
|
+
file_types: [js, ts]
|
|
124
|
+
scan: code # code (default) | strings | comments | all
|
|
125
|
+
multiline: false # true evaluates the regex against the whole file
|
|
126
|
+
message: Left a console.log at line {line}.
|
|
127
|
+
tests: # required — the suite fails if a rule ships without them
|
|
128
|
+
fire:
|
|
129
|
+
- 'console.log("x");'
|
|
130
|
+
quiet:
|
|
131
|
+
- 'logger.info("x");'
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`scan` decides which lexical scope a match must live in, which is what keeps a
|
|
135
|
+
code rule quiet inside a comment and a string rule quiet inside code. `supersedes`
|
|
136
|
+
lets a specific rule silence a general one on the same line. Rules can also use
|
|
137
|
+
`ast_check`, `semantic_check`, `git_check` or `type_check` instead of `regex`;
|
|
138
|
+
those declare `tests.external` naming the test file that covers them.
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
MIT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface Violation {
|
|
2
|
+
ruleId: string;
|
|
3
|
+
name: string;
|
|
4
|
+
severity: 'error' | 'warning';
|
|
5
|
+
message: string;
|
|
6
|
+
file: string;
|
|
7
|
+
line: number;
|
|
8
|
+
fix?: {
|
|
9
|
+
pattern: string;
|
|
10
|
+
replacement: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare function lintText(content: string, filePath: string, configPath?: string): Promise<Violation[]>;
|
|
15
|
+
|
|
16
|
+
export { lintText };
|