stimulus-lsp
stimulus-lsp copied to clipboard
Code Action: Refactor shorthand-value definition to explicit version
When a Stimulus value definition uses the shorthand-version we can offer a code action to expand the definition to the explicit version
import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static values = {
name: String /* ┌───────────────────────────────────────────────────────────────────────┐
│ Quick-Fix... (⌘.) │
└───────────────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────────────┐
│ Quick-Fix │
├────────────────────────────────────────────────────────────────┤
│ Implement default value for "name" │
├────────────────────────────────────────────────────────────────┤
│ Refactor value definition to explicit version │
└────────────────────────────────────────────────────────────────┘ */
}
}
Running either of the code actions should apply this diff:
import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static values = {
- name: String
+ name: {
+ type: String,
+ default: ""
+ }
}
}
Depends on https://github.com/marcoroth/stimulus-parser/issues/79