@reidbuilds/slop 0.2.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.
Files changed (62) hide show
  1. package/.claude/settings.local.json +11 -0
  2. package/.firebaserc +5 -0
  3. package/README.md +73 -0
  4. package/cli/analyzer.js +150 -0
  5. package/cli/index.js +182 -0
  6. package/cli/learner.js +156 -0
  7. package/cli/reporter.js +126 -0
  8. package/cli/scanner.js +45 -0
  9. package/ff-slop.md +27 -0
  10. package/firebase.json +16 -0
  11. package/functions/index.js +30 -0
  12. package/functions/package-lock.json +2755 -0
  13. package/functions/package.json +12 -0
  14. package/hardcoresyn-slop.md +1887 -0
  15. package/package.json +17 -0
  16. package/slop-index/catches.jsonl +590 -0
  17. package/slop-index/patterns/001-hallucinated-imports.md +39 -0
  18. package/slop-index/patterns/002-comment-restatement.md +53 -0
  19. package/slop-index/patterns/003-unnecessary-abstraction.md +56 -0
  20. package/slop-index/patterns/004-unused-imports.md +41 -0
  21. package/slop-index/patterns/005-hardcoded-config.md +49 -0
  22. package/slop-index/patterns/006-deprecated-api-confidence.md +52 -0
  23. package/slop-index/patterns/007-try-catch-everything.md +63 -0
  24. package/slop-index/patterns/008-generic-variable-names.md +49 -0
  25. package/slop-index/patterns/009-stub-with-shell.md +61 -0
  26. package/slop-index/patterns/010-async-misuse.md +64 -0
  27. package/slop-index/patterns/011-console-log-left-in.md +53 -0
  28. package/slop-index/patterns/012-over-engineered-simple.md +64 -0
  29. package/slop-index/patterns/013-emoji-debugging.md +44 -0
  30. package/slop-index/patterns/014-fake-async-simulation.md +71 -0
  31. package/slop-index/patterns/015-credential-fallbacks.md +51 -0
  32. package/slop-index/patterns/016-mock-data-pollution.md +75 -0
  33. package/slop-index/proposed/.gitkeep +0 -0
  34. package/slop-index/proposed/017-emoji-progress-logging.md +44 -0
  35. package/slop-index/proposed/018-test-credentials-in-fallbacks.md +54 -0
  36. package/slop-index/proposed/019-fake-loading-simulation.md +75 -0
  37. package/slop-index/proposed/020-configuration-debugging-left-in.md +53 -0
  38. package/slop-index/proposed/021-emoji-production-logging.md +42 -0
  39. package/slop-index/proposed/022-fake-delay-simulation.md +70 -0
  40. package/slop-index/proposed/023-credential-hardcoding-with-fallbacks.md +57 -0
  41. package/slop-index/proposed/024-repetitive-error-pattern.md +76 -0
  42. package/slop-index/proposed/025-environment-specific-fallbacks.md +55 -0
  43. package/slop-index/proposed/026-emoji-production-logs.md +46 -0
  44. package/slop-index/proposed/027-credentials-in-debug-logs.md +48 -0
  45. package/slop-index/proposed/028-repetitive-service-wrappers.md +59 -0
  46. package/slop-index/proposed/029-forced-non-null-assertions.md +59 -0
  47. package/slop-index/proposed/030-production-credential-fallbacks.md +51 -0
  48. package/slop-index/proposed/031-fake-version-confidence.md +50 -0
  49. package/slop-index/proposed/032-forced-non-null-assertions.md +53 -0
  50. package/slop-index/proposed/033-emoji-production-logs.md +44 -0
  51. package/slop-index/proposed/034-realistic-mock-data-leakage.md +62 -0
  52. package/slop-index/proposed/035-production-credential-exposure.md +43 -0
  53. package/slop-index/proposed/036-identical-wrapper-proliferation.md +53 -0
  54. package/slop-index/proposed/037-forced-null-assertions.md +50 -0
  55. package/slop-index/proposed/038-emoji-production-logging.md +42 -0
  56. package/slop-index/proposed/039-fake-delay-operations.md +52 -0
  57. package/slop-index/proposed/040-forced-null-assertion-chains.md +45 -0
  58. package/slop-index/proposed/041-production-debug-configuration.md +45 -0
  59. package/slop-index/proposed/042-repetitive-firebase-wrappers.md +51 -0
  60. package/slop-index/proposed/043-hardcoded-process-timeouts.md +48 -0
  61. package/slop-index/proposed/044-fictional-package-versions.md +37 -0
  62. package/test-sample.js +89 -0
@@ -0,0 +1,76 @@
1
+ ---
2
+ id: 024
3
+ name: repetitive-error-pattern
4
+ severity: medium
5
+ languages: [javascript, typescript]
6
+ tags: [error-handling, duplication, maintainability]
7
+ added: 2026-05-20
8
+ ---
9
+
10
+ # Pattern: Repetitive Error Pattern
11
+
12
+ ## Description
13
+ AI generates identical error handling patterns across multiple functions, creating the same try-catch structure with generic error messages and state updates. This leads to code duplication and makes it harder to provide specific error context or handle different error types appropriately.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ const fetchUsers = async () => {
18
+ try {
19
+ const response = await api.getUsers();
20
+ if (response.success) {
21
+ setUsers(response.data);
22
+ } else {
23
+ setError(response.error || 'Failed to fetch users');
24
+ }
25
+ } catch (err) {
26
+ setError(err instanceof Error ? err.message : 'Failed to fetch users');
27
+ }
28
+ };
29
+
30
+ const fetchPosts = async () => {
31
+ try {
32
+ const response = await api.getPosts();
33
+ if (response.success) {
34
+ setPosts(response.data);
35
+ } else {
36
+ setError(response.error || 'Failed to fetch posts');
37
+ }
38
+ } catch (err) {
39
+ setError(err instanceof Error ? err.message : 'Failed to fetch posts');
40
+ }
41
+ };
42
+ ```
43
+
44
+ ## Why AI Does This
45
+ AI models learn common error handling patterns and apply them consistently across similar functions. While consistency can be good, the AI doesn't recognize when the repetitive pattern should be abstracted or when different error types need specific handling strategies.
46
+
47
+ ## Catch Signal
48
+ - Multiple functions with identical try-catch structure
49
+ - Same error fallback message pattern repeated
50
+ - Identical error instanceof checks across functions
51
+ - Generic 'Failed to fetch X' messages with only noun changing
52
+ - Same response.success checking pattern duplicated
53
+
54
+ ## Fix Template
55
+ ```
56
+ const createAsyncHandler = <T>(operation: string, setter: (data: T) => void) => {
57
+ return async (apiCall: () => Promise<ApiResponse<T>>) => {
58
+ try {
59
+ const response = await apiCall();
60
+ if (response.success) {
61
+ setter(response.data);
62
+ } else {
63
+ handleApiError(response.error, operation);
64
+ }
65
+ } catch (err) {
66
+ handleUnexpectedError(err, operation);
67
+ }
68
+ };
69
+ };
70
+
71
+ const fetchUsers = createAsyncHandler('fetch users', setUsers);
72
+ const fetchPosts = createAsyncHandler('fetch posts', setPosts);
73
+ ```
74
+
75
+ ## Severity Rationale
76
+ medium — Medium severity because it creates maintainability issues and generic error handling but doesn't break functionality.
@@ -0,0 +1,55 @@
1
+ ---
2
+ id: 025
3
+ name: environment-specific-fallbacks
4
+ severity: high
5
+ languages: [javascript, typescript]
6
+ tags: [security, configuration, deployment]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Environment Specific Fallbacks
11
+
12
+ ## Description
13
+ Production credentials or environment-specific identifiers are hardcoded as fallback values in configuration objects. This creates security risks and deployment coupling where production keys, API endpoints, or database identifiers are embedded directly in source code and used when environment variables are missing.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ const firebaseConfig = {
18
+ apiKey: process.env.FIREBASE_API_KEY || 'AIzaSyB0uWItoUyaozcnjntgG9kck6GJx84GQNY',
19
+ projectId: process.env.FIREBASE_PROJECT_ID || 'hardcore-synergy',
20
+ storageBucket: process.env.FIREBASE_STORAGE_BUCKET || 'hardcore-synergy.firebasestorage.app'
21
+ };
22
+
23
+ const stripeConfig = {
24
+ publishableKey: process.env.STRIPE_KEY || 'pk_test_51SrKL12EWDoWzTlbooO1c6Y3k1oMpjc2JAk266LPVK6TGgRPthyf4eeGjhFh6lDGeZEz3YxDxDUhQ4wBcnemfU1v00BKalQrEu'
25
+ };
26
+ ```
27
+
28
+ ## Why AI Does This
29
+ AI generates realistic fallback configurations to ensure code appears complete and functional, often using actual credential formats it has seen in training data. It prioritizes making code that 'works out of the box' over proper security practices, and may not fully understand the security implications of embedding production credentials in source code.
30
+
31
+ ## Catch Signal
32
+ - Environment variable checks with || operator followed by real API keys or tokens
33
+ - Fallback values containing actual domain names, project IDs, or service identifiers
34
+ - Configuration objects mixing environment variables with hardcoded production values
35
+ - Real credential patterns (pk_test_, AIzaSy, etc.) used as fallback strings
36
+ - Production service URLs or identifiers as string literals in fallbacks
37
+
38
+ ## Fix Template
39
+ ```
40
+ const firebaseConfig = {
41
+ apiKey: process.env.FIREBASE_API_KEY || (() => { throw new Error('FIREBASE_API_KEY environment variable is required') })(),
42
+ projectId: process.env.FIREBASE_PROJECT_ID || (() => { throw new Error('FIREBASE_PROJECT_ID environment variable is required') })(),
43
+ storageBucket: process.env.FIREBASE_STORAGE_BUCKET || (() => { throw new Error('FIREBASE_STORAGE_BUCKET environment variable is required') })()
44
+ };
45
+
46
+ // Or use a validation function
47
+ function requireEnv(key: string): string {
48
+ const value = process.env[key];
49
+ if (!value) throw new Error(`${key} environment variable is required`);
50
+ return value;
51
+ }
52
+ ```
53
+
54
+ ## Severity Rationale
55
+ high — Exposes production credentials and creates security vulnerabilities that could lead to unauthorized access to services.
@@ -0,0 +1,46 @@
1
+ ---
2
+ id: 026
3
+ name: emoji-production-logs
4
+ severity: medium
5
+ languages: [javascript, typescript, python, shell]
6
+ tags: [logging, production, professionalism]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Emoji Production Logs
11
+
12
+ ## Description
13
+ Console output and log messages in production scripts contain emoji characters for visual decoration or status indication. This creates unprofessional logs, can cause encoding issues in different environments or log aggregation systems, and makes log parsing more difficult for monitoring tools.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ console.log('🔥 Firebase Config Debug:');
18
+ console.log('✓ Firebase app initialized:', app.name);
19
+ console.log('🔍 Finding "Sweat Starter Test 1" program...');
20
+ console.log('✅ Successfully populated program!');
21
+ console.error('❌ Program not found');
22
+ console.log('🔑 Loading Stripe with key:', key);
23
+ ```
24
+
25
+ ## Why AI Does This
26
+ AI adds emoji to make console output more visually appealing and user-friendly, treating console logs like user interface elements. It mimics modern development practices where emoji are common in commit messages and informal communication, but doesn't distinguish between development debugging and production logging contexts.
27
+
28
+ ## Catch Signal
29
+ - Console.log statements with emoji characters (🔥, ✅, ❌, 🔍, etc.)
30
+ - Status indicators using emoji instead of text in production scripts
31
+ - Emoji used in error messages or success confirmations in logs
32
+ - Script output containing Unicode emoji characters
33
+ - Log messages that prioritize visual appeal over machine readability
34
+
35
+ ## Fix Template
36
+ ```
37
+ console.log('Firebase Config Debug:');
38
+ console.log('Firebase app initialized:', app.name);
39
+ console.log('Finding "Sweat Starter Test 1" program...');
40
+ console.log('SUCCESS: Successfully populated program!');
41
+ console.error('ERROR: Program not found');
42
+ console.log('Loading Stripe with key:', key.substring(0, 20) + '...');
43
+ ```
44
+
45
+ ## Severity Rationale
46
+ medium — Creates unprofessional output and potential encoding issues but doesn't break functionality.
@@ -0,0 +1,48 @@
1
+ ---
2
+ id: 027
3
+ name: credentials-in-debug-logs
4
+ severity: high
5
+ languages: [javascript, typescript]
6
+ tags: [security, logging, credentials]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Credentials In Debug Logs
11
+
12
+ ## Description
13
+ Debug console statements log sensitive credentials, API keys, or configuration values that should never appear in production logs. Even when credentials are meant to be semi-public (like Stripe publishable keys), logging them creates unnecessary exposure and security risks.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ console.log('🔑 Loading Stripe with key:', STRIPE_PUBLISHABLE_KEY);
18
+ console.log('🔑 Full key (for debugging):', STRIPE_PUBLISHABLE_KEY);
19
+ console.log('Firebase Config:', {
20
+ apiKey: firebaseConfig.apiKey,
21
+ authDomain: firebaseConfig.authDomain,
22
+ projectId: firebaseConfig.projectId
23
+ });
24
+ ```
25
+
26
+ ## Why AI Does This
27
+ AI treats all configuration as debugging information and logs it to help with troubleshooting, without understanding the security implications. It may not distinguish between public configuration (like project IDs) and sensitive credentials, or understand that even 'public' keys shouldn't be logged in production systems.
28
+
29
+ ## Catch Signal
30
+ - Console.log statements that output API keys, tokens, or credentials
31
+ - Debug logging that includes full configuration objects with sensitive data
32
+ - Credential values being logged even when partially masked elsewhere
33
+ - Environment variables or secrets being output to console for debugging
34
+ - Configuration validation that logs actual credential values instead of just presence checks
35
+
36
+ ## Fix Template
37
+ ```
38
+ console.log('Loading Stripe with key:', STRIPE_PUBLISHABLE_KEY.substring(0, 20) + '...');
39
+ console.log('Stripe key configured:', STRIPE_PUBLISHABLE_KEY ? 'YES' : 'NO');
40
+ console.log('Firebase Config Status:', {
41
+ apiKey: firebaseConfig.apiKey ? 'CONFIGURED' : 'MISSING',
42
+ authDomain: firebaseConfig.authDomain ? 'CONFIGURED' : 'MISSING',
43
+ projectId: firebaseConfig.projectId // Project ID is safe to log
44
+ });
45
+ ```
46
+
47
+ ## Severity Rationale
48
+ high — Exposes sensitive credentials in logs which could be accessed by unauthorized parties or stored insecurely.
@@ -0,0 +1,59 @@
1
+ ---
2
+ id: 028
3
+ name: repetitive-service-wrappers
4
+ severity: low
5
+ languages: [javascript, typescript]
6
+ tags: [abstraction, duplication, maintenance]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Repetitive Service Wrappers
11
+
12
+ ## Description
13
+ Multiple nearly identical wrapper functions that perform the same initialization steps and return configured service instances. Each function follows the exact same pattern with only the final service name parameter changing, creating unnecessary code duplication and maintenance overhead.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ const getCreateJobFn = () => {
18
+ ensureFirebaseReady();
19
+ const functions = getFunctions(app, 'us-central1');
20
+ return httpsCallable(functions, 'createJob');
21
+ };
22
+ const getUpdateJobFn = () => {
23
+ ensureFirebaseReady();
24
+ const functions = getFunctions(app, 'us-central1');
25
+ return httpsCallable(functions, 'updateJob');
26
+ };
27
+ const getDeleteJobFn = () => {
28
+ ensureFirebaseReady();
29
+ const functions = getFunctions(app, 'us-central1');
30
+ return httpsCallable(functions, 'deleteJob');
31
+ };
32
+ ```
33
+
34
+ ## Why AI Does This
35
+ AI creates individual wrapper functions for each service method to maintain clear separation and explicit naming, following patterns it has learned about creating dedicated functions for each API endpoint. It prioritizes explicit, readable function names over DRY principles, and may not recognize when the pattern repetition creates maintenance burden.
36
+
37
+ ## Catch Signal
38
+ - Multiple functions with identical structure but different final parameter
39
+ - Wrapper functions that only change the last argument to a service call
40
+ - Repeated initialization code across multiple service wrapper functions
41
+ - Functions that follow the exact same pattern with only string literals differing
42
+ - Service wrappers that are used exactly once and provide no additional logic
43
+
44
+ ## Fix Template
45
+ ```
46
+ function createFirebaseFunction(functionName: string) {
47
+ ensureFirebaseReady();
48
+ const functions = getFunctions(app, 'us-central1');
49
+ return httpsCallable(functions, functionName);
50
+ }
51
+
52
+ // Usage
53
+ const createJob = createFirebaseFunction('createJob');
54
+ const updateJob = createFirebaseFunction('updateJob');
55
+ const deleteJob = createFirebaseFunction('deleteJob');
56
+ ```
57
+
58
+ ## Severity Rationale
59
+ low — Creates code duplication and maintenance overhead but doesn't impact functionality or security.
@@ -0,0 +1,59 @@
1
+ ---
2
+ id: 029
3
+ name: forced-non-null-assertions
4
+ severity: medium
5
+ languages: [typescript]
6
+ tags: [type-safety, runtime-errors, null-safety]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Forced Non Null Assertions
11
+
12
+ ## Description
13
+ Non-null assertion operators (!) are used to bypass TypeScript's null safety checks without proper validation, creating potential runtime errors. The code assumes properties exist after checking parent objects, but doesn't verify the properties themselves are non-null.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ const stats = {
18
+ weightChange: latestEntry && previousEntry
19
+ ? latestEntry.weight! - previousEntry.weight!
20
+ : 0,
21
+ totalChange: latestEntry && firstEntry
22
+ ? latestEntry.weight! - firstEntry.weight!
23
+ : 0,
24
+ };
25
+
26
+ // Usage without checking if user exists
27
+ const profileUrl = user!.profile!.avatar!.url;
28
+ ```
29
+
30
+ ## Why AI Does This
31
+ AI uses non-null assertions to quickly resolve TypeScript compilation errors without fully understanding the runtime implications. It sees that parent objects are checked for existence and assumes their properties must also exist, not recognizing that optional properties can be undefined even when the parent object exists.
32
+
33
+ ## Catch Signal
34
+ - Non-null assertion operator (!) used on optional properties
35
+ - Force unwrapping without corresponding null checks for the specific property
36
+ - Assertions used to bypass TypeScript errors rather than handle null cases
37
+ - Multiple chained non-null assertions on nested optional properties
38
+ - Assumptions about property existence based only on parent object existence
39
+
40
+ ## Fix Template
41
+ ```
42
+ const stats = {
43
+ weightChange: latestEntry?.weight && previousEntry?.weight
44
+ ? latestEntry.weight - previousEntry.weight
45
+ : 0,
46
+ totalChange: latestEntry?.weight && firstEntry?.weight
47
+ ? latestEntry.weight - firstEntry.weight
48
+ : 0,
49
+ };
50
+
51
+ // Or with proper validation
52
+ function getWeightChange(latest: Entry | null, previous: Entry | null): number {
53
+ if (!latest?.weight || !previous?.weight) return 0;
54
+ return latest.weight - previous.weight;
55
+ }
56
+ ```
57
+
58
+ ## Severity Rationale
59
+ medium — Can cause runtime errors and defeats TypeScript's null safety benefits, but issues are typically caught during testing.
@@ -0,0 +1,51 @@
1
+ ---
2
+ id: 030
3
+ name: production-credential-fallbacks
4
+ severity: high
5
+ languages: [javascript, typescript]
6
+ tags: [security, credentials, environment]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Production Credential Fallbacks
11
+
12
+ ## Description
13
+ Real production credentials, API keys, and service configuration values are hardcoded as fallback values when environment variables are missing. This creates security vulnerabilities and environment coupling, as production secrets become embedded in source code that could be exposed in version control or client-side builds.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ const STRIPE_KEY = process.env.STRIPE_KEY || 'pk_live_51SrKL12EWDoWzTlbooO1c6Y3k1oMpjc2JAk266LPVK6TGgRPthyf4eeGjhFh6lDGeZEz3YxDxDUhQ4wBcnemfU1v00BKalQrEu';
18
+ const firebaseConfig = {
19
+ apiKey: process.env.FIREBASE_API_KEY || 'AIzaSyB0uWItoUyaozcnjntgG9kck6GJx84GQNY',
20
+ projectId: process.env.FIREBASE_PROJECT_ID || 'my-production-app'
21
+ };
22
+ ```
23
+
24
+ ## Why AI Does This
25
+ AI models generate fallback values to ensure code runs immediately without configuration errors, and they often use realistic-looking credentials from training data or generate plausible keys. They prioritize functional completeness over security best practices, creating working examples that inadvertently embed real or realistic production credentials.
26
+
27
+ ## Catch Signal
28
+ - Real API keys or tokens in fallback values after || operator
29
+ - Production service URLs or project IDs as default values
30
+ - Environment variable patterns with actual credentials as fallbacks
31
+ - Firebase, Stripe, AWS, or other service credentials hardcoded
32
+ - Realistic-looking keys with proper prefixes (pk_, sk_, AIzaSy, etc.)
33
+
34
+ ## Fix Template
35
+ ```
36
+ const STRIPE_KEY = process.env.STRIPE_KEY;
37
+ if (!STRIPE_KEY) {
38
+ throw new Error('STRIPE_KEY environment variable is required');
39
+ }
40
+
41
+ const firebaseConfig = {
42
+ apiKey: process.env.FIREBASE_API_KEY || '',
43
+ projectId: process.env.FIREBASE_PROJECT_ID || 'development-project'
44
+ };
45
+ if (!firebaseConfig.apiKey) {
46
+ throw new Error('Firebase configuration incomplete');
47
+ }
48
+ ```
49
+
50
+ ## Severity Rationale
51
+ high — Exposes real production credentials in source code, creating immediate security vulnerabilities.
@@ -0,0 +1,50 @@
1
+ ---
2
+ id: 031
3
+ name: fake-version-confidence
4
+ severity: medium
5
+ languages: [javascript, typescript, html]
6
+ tags: [dependencies, versioning, cdn]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Fake Version Confidence
11
+
12
+ ## Description
13
+ Code confidently references specific version numbers of libraries or CDN resources that don't exist, such as Firebase 12.8.0 or other non-existent versions. AI generates plausible but incorrect version numbers, creating import failures and broken dependencies that won't be caught until runtime.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ import { initializeApp } from 'https://www.gstatic.com/firebasejs/12.8.0/firebase-app.js';
18
+ // Firebase v12 doesn't exist - current is v10.x
19
+
20
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/react/19.4.2/react.min.js"></script>
21
+ <!-- React 19.4.2 doesn't exist -->
22
+
23
+ const stripe = require('stripe')('^5.2.8');
24
+ // Assumes version exists without verification
25
+ ```
26
+
27
+ ## Why AI Does This
28
+ AI models extrapolate version numbering patterns from training data without understanding actual release cycles or semantic versioning constraints. They generate plausible-looking version numbers that follow expected patterns but don't correspond to real releases, prioritizing code completeness over accuracy.
29
+
30
+ ## Catch Signal
31
+ - CDN URLs with non-existent version numbers
32
+ - Import statements referencing impossible version combinations
33
+ - Version numbers that don't follow project's actual release pattern
34
+ - Future versions or versions higher than latest release
35
+ - Mixing of incompatible version ranges across dependencies
36
+
37
+ ## Fix Template
38
+ ```
39
+ import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js';
40
+ // Use actual current version
41
+
42
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/react.min.js"></script>
43
+ <!-- Verify version exists before using -->
44
+
45
+ const stripe = require('stripe')('3.10.0');
46
+ // Check actual available versions
47
+ ```
48
+
49
+ ## Severity Rationale
50
+ medium — Causes import failures and broken builds, but can be easily detected and fixed during development.
@@ -0,0 +1,53 @@
1
+ ---
2
+ id: 032
3
+ name: forced-non-null-assertions
4
+ severity: medium
5
+ languages: [typescript]
6
+ tags: [typescript, null-safety, runtime-errors]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Forced Non Null Assertions
11
+
12
+ ## Description
13
+ Excessive use of TypeScript's non-null assertion operator (!) to bypass type checking without proper null/undefined validation, often in contexts where the value could legitimately be null or undefined. This defeats TypeScript's null safety and creates potential runtime errors.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ const user = users.find(u => u.id === targetId);
18
+ const profile = user!.profile; // user could be undefined
19
+
20
+ const weight = latestEntry?.weight;
21
+ const change = weight! - previousWeight!; // weights could be null
22
+
23
+ const element = document.getElementById('myId');
24
+ element!.addEventListener('click', handler); // element could be null
25
+ ```
26
+
27
+ ## Why AI Does This
28
+ AI models use non-null assertions as a quick way to resolve TypeScript compilation errors without implementing proper null checking logic. They prioritize making code compile over ensuring runtime safety, treating the ! operator as a simple way to assert confidence in values that the type system correctly identifies as potentially nullable.
29
+
30
+ ## Catch Signal
31
+ - Non-null assertions on array find() or DOM query results
32
+ - Multiple ! operators in arithmetic or property access chains
33
+ - Non-null assertions on optional properties without prior validation
34
+ - Using ! operator immediately after optional chaining (?.) operators
35
+ - Non-null assertions in contexts where null/undefined is a valid state
36
+
37
+ ## Fix Template
38
+ ```
39
+ const user = users.find(u => u.id === targetId);
40
+ if (!user) throw new Error('User not found');
41
+ const profile = user.profile;
42
+
43
+ const weight = latestEntry?.weight;
44
+ const change = (weight && previousWeight) ? weight - previousWeight : 0;
45
+
46
+ const element = document.getElementById('myId');
47
+ if (element) {
48
+ element.addEventListener('click', handler);
49
+ }
50
+ ```
51
+
52
+ ## Severity Rationale
53
+ medium — Creates potential runtime errors by bypassing type safety, but impact depends on actual null occurrence frequency.
@@ -0,0 +1,44 @@
1
+ ---
2
+ id: 033
3
+ name: emoji-production-logs
4
+ severity: low
5
+ languages: [javascript, typescript]
6
+ tags: [logging, professionalism, encoding]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Emoji Production Logs
11
+
12
+ ## Description
13
+ Using emoji characters in production logging, console output, and script messages that will appear in production environments. This creates unprofessional output in production logs and can cause encoding issues in different terminal environments or log aggregation systems.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ console.log('🔥 Starting Firebase initialization...');
18
+ console.log('✅ Database connection established');
19
+ console.error('❌ Authentication failed');
20
+ logger.info('🚀 Deployment successful!');
21
+ console.log('🔍 Processing user data...');
22
+ ```
23
+
24
+ ## Why AI Does This
25
+ AI models use emojis to make output more visually appealing and user-friendly, drawing from examples in tutorials and development blogs where emojis are used for visual distinction. They don't distinguish between development-friendly output and production logging requirements, treating console messages as user-facing rather than system logs.
26
+
27
+ ## Catch Signal
28
+ - Emoji characters in console.log, console.error, or logger calls
29
+ - Emojis in production scripts or deployment tools
30
+ - Unicode emoji in system messages or status updates
31
+ - Emojis in error messages or success confirmations
32
+ - Visual symbols in logging that aren't standard ASCII
33
+
34
+ ## Fix Template
35
+ ```
36
+ console.log('Starting Firebase initialization...');
37
+ console.log('Database connection established');
38
+ console.error('Authentication failed');
39
+ logger.info('Deployment successful!');
40
+ console.log('Processing user data...');
41
+ ```
42
+
43
+ ## Severity Rationale
44
+ low — Affects log readability and professionalism but doesn't impact core functionality or security.
@@ -0,0 +1,62 @@
1
+ ---
2
+ id: 034
3
+ name: realistic-mock-data-leakage
4
+ severity: medium
5
+ languages: [javascript, typescript]
6
+ tags: [security, privacy, data]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Realistic Mock Data Leakage
11
+
12
+ ## Description
13
+ Mock or example data that appears realistic enough to be mistaken for real user data, including plausible email addresses, phone numbers, addresses, or personal information. While using example.com domains, the realistic nature creates risks of accidental exposure or confusion with real data during development and testing.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ const mockUsers = [
18
+ {
19
+ name: 'Emma Wilson',
20
+ email: 'emma.wilson@example.com',
21
+ phone: '(555) 123-4567',
22
+ address: '123 Main St, Springfield, IL 62701',
23
+ ssn: '123-45-6789'
24
+ },
25
+ {
26
+ name: 'John Smith',
27
+ email: 'john.smith@company.com', // not example.com
28
+ creditCard: '4532-1234-5678-9012'
29
+ }
30
+ ];
31
+ ```
32
+
33
+ ## Why AI Does This
34
+ AI models generate realistic-looking data to make examples more relatable and demonstrate proper data structures, often drawing from common names and realistic patterns in training data. They aim to create convincing examples that help developers understand data flow, but don't consider the risks of realistic personal information in codebases.
35
+
36
+ ## Catch Signal
37
+ - Realistic personal names combined with contact information
38
+ - Plausible addresses, phone numbers, or identification numbers
39
+ - Credit card numbers or financial information in mock data
40
+ - Email addresses not using example.com or test domains
41
+ - Mock data that could be mistaken for real customer information
42
+
43
+ ## Fix Template
44
+ ```
45
+ const mockUsers = [
46
+ {
47
+ name: 'Test User 1',
48
+ email: 'testuser1@example.com',
49
+ phone: '000-000-0000',
50
+ address: '123 Test St, Test City, TS 00000',
51
+ id: 'mock-user-1'
52
+ },
53
+ {
54
+ name: 'Sample User',
55
+ email: 'sample@example.com',
56
+ id: 'mock-user-2'
57
+ }
58
+ ];
59
+ ```
60
+
61
+ ## Severity Rationale
62
+ medium — Could lead to privacy concerns or confusion with real data, but typically doesn't affect core application security.
@@ -0,0 +1,43 @@
1
+ ---
2
+ id: 035
3
+ name: production-credential-exposure
4
+ severity: high
5
+ languages: [javascript, typescript]
6
+ tags: [security, credentials, production]
7
+ added: 2026-05-21
8
+ ---
9
+
10
+ # Pattern: Production Credential Exposure
11
+
12
+ ## Description
13
+ AI generates code that explicitly logs or exposes credentials and API keys in production environments, often with debugging statements that print full keys or configuration details to console logs where they can be harvested by attackers or leaked in log aggregation systems.
14
+
15
+ ## What It Looks Like
16
+ ```
17
+ console.log('🔑 Full key (for debugging):', STRIPE_PUBLISHABLE_KEY);
18
+ console.log('Firebase Config Debug:');
19
+ console.log(' - API Key:', firebaseConfig.apiKey);
20
+ console.log(' - Auth Domain:', firebaseConfig.authDomain);
21
+ ```
22
+
23
+ ## Why AI Does This
24
+ AI models generate debugging code to help developers verify configuration without understanding the security implications of logging credentials in production. They treat all configuration as equally safe to log and don't distinguish between public and private data.
25
+
26
+ ## Catch Signal
27
+ - console.log statements containing API keys or tokens
28
+ - Full credential values being printed to logs
29
+ - Configuration objects logged with sensitive fields
30
+ - Debug statements that expose authentication details
31
+ - Production code that prints environment variables
32
+
33
+ ## Fix Template
34
+ ```
35
+ // Log only non-sensitive configuration details
36
+ console.log('🔑 Stripe key configured:', STRIPE_PUBLISHABLE_KEY ? '✓' : '✗');
37
+ console.log('Firebase Config Status:');
38
+ console.log(' - API Key:', firebaseConfig.apiKey ? '✓ Set' : '✗ MISSING');
39
+ console.log(' - Project ID:', firebaseConfig.projectId); // Project ID is public
40
+ ```
41
+
42
+ ## Severity Rationale
43
+ high — High severity because credential exposure creates immediate security vulnerabilities that can be exploited by attackers.