| 118 | } |
| 119 | |
| 120 | func (c *jsonToolConfig) Unset(scope Scope, keyPath string) (bool, string, error) { |
| 121 | parts, err := Parse(keyPath) |
| 122 | if err != nil { |
| 123 | return false, "", err |
| 124 | } |
| 125 | path := c.PathFor(scope) |
| 126 | if path == "" { |
| 127 | return false, "", fmt.Errorf("editorconfig: %s scope %s unsupported", c.spec.name, scope) |
| 128 | } |
| 129 | data, _, err := loadJSON(path) |
| 130 | if err != nil { |
| 131 | return false, "", err |
| 132 | } |
| 133 | found := Unset(data, parts) |
| 134 | if !found { |
| 135 | return false, path, nil |
| 136 | } |
| 137 | if err := writeJSON(path, data); err != nil { |
| 138 | return false, "", err |
| 139 | } |
| 140 | return true, path, nil |
| 141 | } |
| 142 | |
| 143 | func writeJSON(path string, data map[string]any) error { |
| 144 | if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { |