3 rules for ngStato best practices. Zero config with recommended preset.
npm install -D @ngstato/eslint-plugin// eslint.config.js
import ngstato from '@ngstato/eslint-plugin'
export default [
ngstato.configs.recommended
]| Rule | Default | Description |
|---|---|---|
ngstato/no-state-mutation-outside-action |
error |
Prevent direct state mutation outside actions |
ngstato/no-async-without-error-handling |
warn |
Require try/catch in async actions |
ngstato/require-devtools |
warn |
Suggest connectDevTools() after createStore() |
// ❌ Error
this.store.count = 5
// ✅ OK
actions: {
setCount(state, n: number) { state.count = n }
}// ⚠️ Warning
actions: {
async loadUsers(state) {
state.users = await http.get('/users') // no try/catch
}
}
// ✅ OK — try/catch
actions: {
async loadUsers(state) {
try {
state.users = await http.get('/users')
} catch (e) {
state.error = (e as Error).message
}
}
}
// ✅ OK — wrapped in retryable
actions: {
loadUsers: retryable(async (state) => {
state.users = await http.get('/users')
}, { attempts: 3 })
}// ⚠️ Warning
const store = createStore({ count: 0 })
// missing: connectDevTools(store, 'Counter')
// ✅ OK
const store = createStore({ count: 0 })
connectDevTools(store, 'Counter')MIT