Remove Empty Attribute
한국어 README
remove-empty-attribute is a VS Code extension that removes empty HTML-like attributes from the active editor.
It is designed for files that contain HTML tags, such as:
- HTML
- React JSX
- React TSX
- JSP
Features
- Removes empty quoted attributes such as
name="" and id=''
- Removes empty JSX-style string expressions such as
name={""} and id={''}
- Keeps non-empty attributes unchanged
Example
Before:
<input type="text" name="" id="" placeholder="Task" />
<input type="date" name={""} id={''} />
After:
<input type="text" placeholder="Task" />
<input type="date" />
Usage
- Open a file that contains HTML-like tags.
- Open the Command Palette.
- Run
Remove Empty Attributes.
The command scans the active editor and removes only attributes whose value is an empty string.
Development
- Run
npm install
- Run
npm run watch
- Press
F5 in VS Code to launch the Extension Development Host
- Open an HTML, JSX, TSX, or JSP file in the new window
- Run
Remove Empty Attributes from the Command Palette
Notes
- This extension currently runs as a manual command.
- It does not remove boolean attributes.
- It does not change attributes with non-empty values.
| |