🛡️ SafeCode Pro
SafeCode Pro is a powerful Visual Studio Code extension designed to enforce safe coding standards and prevent runtime errors in JavaScript and AngularJS projects.
It detects unsafe patterns, enforces naming rules, blocks ES6 syntax inside AngularJS folders, and checks only modified lines using Git — just like GitLens.
✨ Features
🧠 Smart Safety & Null-Check Detection
- Detects unsafe object method usage
(Object.keys, Object.values, Object.entries, Reflect.ownKeys, etc.)
- Highlights unsafe array method usage
(map, filter, reduce, find, etc.)
- Detects unsafe property access
(data.name → use data?.name)
- Automatically skips:
- Comments (
//, /* */)
- Imports & requires
- Assignments (
obj.a.b = 10)
- Known safe globals (
console, Math, JSON, etc.)
🔍 Git-Aware Modified Line Scanning
SafeCode Pro checks only the changed lines, not the whole file:
✔ Modified lines
✔ Newly added lines
✔ Works after restarting VS Code
✔ Untracked (new) files → scans entire file
✔ Faster and behaves exactly like GitLens
🏗️ Multi-Line Safe Block Detection
Variables inside safe blocks automatically become safe:
if (Array.isArray(data)) {
data.map(() => {}); // safe
data.filter(() => {}); // safe
}
if (isObject(user)) {
Object.keys(user); // safe
}
.
🛑 ES6 Blocking for AngularJS Projects
Inside:
/public/app/**/*.js
SafeCode Pro blocks ES6+ syntax:
✔ let, const
✔ Arrow functions ()=>
✔ Template literals `text`
✔ Destructuring {a,b}=obj & [x,y]=arr
✔ Spread operator ...
✔ Classes
✔ import / export
✔ async, await
✔ Native Promise (suggest \$q instead)
✔ Ideal for teams maintaining legacy AngularJS codebases.
## 🏛️ Naming Convention Enforcement
| Type | Rule | Example |
|-----------|---------------------------|-------------|
| Object | Must start with `o` | `oUser` |
| Array | Must start with `a` | `aItems` |
| Boolean | Must start with `is` | `isActive` |
| Functions | Must start with a verb | `getData()` |
| Setters | Must start with `set` | `setUser()` |
### React `useState` Rule
```js
const [user, setUser] = useState({});
🧠 Code Safety Examples
❗ Unsafe Object Access
```js
Object.keys(data);
✅ Use:
if (isObject(data)) {
Object.keys(data);
}
❗ Unsafe Array Access
data.map(item => item.name); // ⛔ unsafe if data is not an array
✅ Use:
if (Array.isArray(data)) {
data.map(item => item.name);
}
❗ Unsafe Property Access
const name = data.name; // ⛔ unsafe if data is null/undefined
✅ Use:
const name = data?.name; // ✅ safe access
---
## 📂 Supported File Types
- .js
- .jsx
---
## 🚀 Getting Started
Install from VS Code Marketplace:
Open Visual Studio Code
Go to the Extensions Panel
Search for: SafeCode Pro
Click Install
Or install via CLI:
code --install-extension duraidev.safecode-pro
---
## 🔧 Configuration
Works automatically. No setup needed.
---
## 🛠 Planned Features
- TypeScript/TSX support
- Customizable naming rules
- Auto-fix suggestions
- Project-level configuration
---
## 👨💻 Author
Built with ❤️ by Durai Raja
---
## ⭐ Feedback
If SafeCode Pro helps you, please leave a ⭐ rating on the Marketplace.