Cursor rule
.cursor/rules/stimulus_conventions.mdc[object Object]
Cursor rules
Quality
44/100
Scores the file, not the repository.Length
279 words
0 headings · 3 code blocksRepository
9.3k
— · pushed 0 days agoLast changed
2 days ago
First indexed 2 days ago.123456This rule describes how to write Stimulus controllers.78- **Use declarative actions, not imperative event listeners**9 - Instead of assigning a Stimulus target and binding it to an event listener in the initializer, always write Controllers + ERB views declaratively by using Stimulus actions in ERB to call methods in the Stimulus JS controller. Below are good vs. bad code.1011 BAD code:1213```js14 // BAD!!!! DO NOT DO THIS!!15 // Imperative - controller does all the work16 export default class extends Controller {17 static targets = ["button", "content"]1819 connect() {20 this.buttonTarget.addEventListener("click", this.toggle.bind(this))21 }2223 toggle() {24 this.contentTarget.classList.toggle("hidden")25 this.buttonTarget.textContent = this.contentTarget.classList.contains("hidden") ? "Show" : "Hide"26 }27 }28```2930 GOOD code:3132```erb33 <!-- Declarative - HTML declares what happens -->3435 <div data-controller="toggle">36 <button data-action="click->toggle#toggle" data-toggle-target="button">Show</button>37 <div data-toggle-target="content" class="hidden">Hello World!</div>38 </div>39```4041```js42 // Declarative - controller just responds43 export default class extends Controller {44 static targets = ["button", "content"]4546 toggle() {47 this.contentTarget.classList.toggle("hidden")48 this.buttonTarget.textContent = this.contentTarget.classList.contains("hidden") ? "Show" : "Hide"49 }50 }51```5253- **Keep Stimulus controllers lightweight and simple**54 - Always aim for less than 7 controller targets. Any more is a sign of too much complexity.55 - Use private methods and expose a clear public API5657- **Keep Stimulus controllers focused on what they do best**58 - Domain logic does NOT belong in a Stimulus controller59 - Stimulus controllers should aim for a single responsibility, or a group of highly related responsibilities60 - Make good use of Stimulus's callbacks, actions, targets, values, and classes6162- **Component controllers should not be used outside the component**63 - If a Stimulus controller is in the app/components directory, it should only be used in its component view. It should not be used anywhere in app/views.64
Also in we-promise/sure
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| we-promise/sure.cursor/rules/api-endpoint-consistency.mdc · 9.3k | Cursor rules | styletesting-strategygitsecurity+2 | 57/100 | 2 days ago | |
| we-promise/sure.cursor/rules/cursor_rules.mdc · 9.3k | Cursor rules | no sections | 36/100 | 2 days ago | |
| we-promise/sure.cursor/rules/general-rules.mdc · 9.3k | Cursor rules | styledo-not | 44/100 | 2 days ago | |
| we-promise/sure.cursor/rules/project-conventions.mdc · 9.3k | Cursor rules | styledependenciesdatabaseui+2 | 59/100 | 2 days ago | |
| we-promise/sure.cursor/rules/project-design.mdc · 9.3k | Cursor rules | style | 58/100 | 2 days ago | |
| we-promise/sure.cursor/rules/self_improve.mdc · 9.3k | Cursor rules | no sections | 36/100 | 2 days ago | |
| we-promise/sure.cursor/rules/testing.mdc · 9.3k | Cursor rules | styletesting-strategy | 52/100 | 2 days ago | |
| we-promise/sure.cursor/rules/ui-ux-design-guidelines.mdc · 9.3k | Cursor rules | styledo-not | 49/100 | 2 days ago | |
| we-promise/sure.cursor/rules/view_conventions.mdc · 9.3k | Cursor rules | style | 52/100 | 2 days ago | |
| we-promise/sure.github/copilot-instructions.md · 9.3k | Copilot instructions | setuptestlint-formatstyle+10 | 88/100 | 2 days ago | |
| we-promise/sureAGENTS.md · 9.3k | AGENTS.md | buildtestlint-formatstyle+7 | 78/100 | 2 days ago | |
| we-promise/sureCLAUDE.md · 9.3k | CLAUDE.md | setuptestlint-formatstyle+11 | 93/100 | 2 days ago |
Diff against .cursor/rules/api-endpoint-consistency.mdc Diff against .cursor/rules/cursor_rules.mdc Diff against .cursor/rules/general-rules.mdc Diff against .cursor/rules/project-conventions.mdc Diff against .cursor/rules/project-design.mdc Diff against .cursor/rules/self_improve.mdc Diff against .cursor/rules/testing.mdc Diff against .cursor/rules/ui-ux-design-guidelines.mdc Diff against .cursor/rules/view_conventions.mdc Diff against .github/copilot-instructions.md Diff against AGENTS.md Diff against CLAUDE.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/proto.mdc · 126 | Cursor rules | buildlint-formatstylearch+3 | 96/100 | 3 days ago | |
| nerds-odd-e/doughnut.cursor/rules/cli.mdc · 49 | Cursor rules | setupbuildteststyle+4 | 96/100 | 3 days ago | |
| K-Mistele/opensearch.cursor/rules/default.mdc · 30 | Cursor rules | buildtestlint-formatstyle+2 | 94/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/task-context-loading.mdc · 126 | Cursor rules | archtypesdatabasedo-not+1 | 93/100 | 3 days ago |
