A Visual Studio Code extension that provides real-time linting for Slim template files using slim-lint.
- Real-time linting: Get instant feedback as you type
- Error highlighting: Visual indicators for syntax errors and style violations
- Warning support: Distinguish between errors and warnings
- Configuration support: Use your project's
.slim-lint.yml
configuration - Multiple executable support: Works with
slim-lint
,bundle exec slim-lint
, andgem exec slim-lint
- Cross-platform: Works on Windows, macOS, and Linux
- Performance optimized: Efficient linting with timeout protection
Before using this extension, you need to have slim-lint
installed on your system:
# Install via RubyGems
gem install slim_lint
# Or if using Bundler, add to your Gemfile
gem 'slim_lint'
bundle install
- Ruby: Version 2.0 or higher
- slim-lint: Latest version recommended
- VS Code: Version 1.32.0 or higher
- Open VS Code
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
- Search for "Slim Lint"
- Click Install
The extension can be configured through VS Code settings:
Setting | Default | Description |
---|---|---|
slimLint.executablePath |
slim-lint |
Path to slim-lint executable |
slimLint.configurationPath |
.slim-lint.yml |
Path to slim-lint configuration file |
{
"slimLint.executablePath": "slim-lint",
"slimLint.configurationPath": ".slim-lint.yml"
}
{
"slimLint.executablePath": "bundle exec slim-lint",
"slimLint.configurationPath": ".slim-lint.yml"
}
{
"slimLint.executablePath": "slim-lint",
"slimLint.configurationPath": "/path/to/custom/slim-lint.yml"
}
Create a .slim-lint.yml
file in your project root to configure linting rules:
# .slim-lint.yml
linters:
LineLength:
enabled: true
max: 120
TrailingWhitespace:
enabled: true
TrailingBlankLines:
enabled: true
RuboCop:
enabled: true
ignored_cops:
- 'Layout/LineLength'
The extension automatically lints your Slim files when:
- You open a
.slim
file - You save a
.slim
file - You make changes to a
.slim
file
You can manually trigger linting by:
- Opening the Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
- Typing "Slim Lint: Run Linter"
- Selecting the command
Linting issues are displayed as:
- Errors: Red underlines and entries in the Problems panel
- Warnings: Yellow underlines and entries in the Problems panel
Hover over underlined code to see the full error message.
Solution: Install slim-lint globally or update your executable path setting.
# Install globally
gem install slim_lint
# Or update VS Code settings
{
"slimLint.executablePath": "bundle exec slim-lint"
}
Solution: Create a .slim-lint.yml
file in your project root or update the configuration path setting.
Solution: Check file permissions and ensure slim-lint is executable.
# Make slim-lint executable
chmod +x $(which slim-lint)
Solution: The linting process is taking too long. This can happen with large files or complex configurations.
- Check your
.slim-lint.yml
configuration - Consider excluding large files
- Update the timeout setting if needed
Enable debug logging by opening the Output panel and selecting "Slim Lint" from the dropdown. This will show detailed information about the linting process.
- Use appropriate configuration: Avoid enabling unnecessary linters
- Exclude large files: Add large files to your
.slim-lint.yml
exclusions - Use Bundler: If your project uses Bundler, use
bundle exec slim-lint
- Optimize your setup: Ensure slim-lint is properly installed and accessible
.slim
- Standard Slim template files.html.slim
- HTML Slim template files
We welcome contributions! Please see our Contributing Guidelines for details.
- Clone the repository
- Install dependencies:
npm install
- Compile TypeScript:
npm run compile
- Run tests:
npm test
- Lint code:
npm run lint
The extension includes comprehensive tests. Run them with:
npm test
See CHANGELOG.md for a complete list of changes.
This extension is licensed under the MIT License. See LICENSE for details.
- Issues: GitHub Issues
- Documentation: slim-lint Documentation
- VS Code Extensions: Extension Marketplace
- slim-lint - The linting tool that powers this extension
- Shopify Ruby - Comprehensive Ruby development extension pack
- Ruby LSP - Language Server Protocol for Ruby
- Slim - Slim syntax highlighting