{"id":13533085,"url":"https://github.com/sds/slim-lint","last_synced_at":"2025-04-12T20:38:08.886Z","repository":{"id":30647334,"uuid":"34202925","full_name":"sds/slim-lint","owner":"sds","description":"Configurable tool for analyzing Slim templates","archived":false,"fork":false,"pushed_at":"2025-03-06T21:35:29.000Z","size":449,"stargazers_count":217,"open_issues_count":19,"forks_count":62,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-05T19:06:40.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sds.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-19T10:49:41.000Z","updated_at":"2025-03-15T16:27:27.000Z","dependencies_parsed_at":"2023-12-13T06:31:44.010Z","dependency_job_id":"714ee495-09e4-4142-9969-f3569d75a70f","html_url":"https://github.com/sds/slim-lint","commit_stats":{"total_commits":345,"total_committers":50,"mean_commits":6.9,"dds":0.2579710144927536,"last_synced_commit":"695f0b18b5fc66b09ff5d368c37ffffc1a375f49"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds%2Fslim-lint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds%2Fslim-lint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds%2Fslim-lint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds%2Fslim-lint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sds","download_url":"https://codeload.github.com/sds/slim-lint/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631656,"owners_count":21136554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:01:16.469Z","updated_at":"2025-04-12T20:38:08.847Z","avatar_url":"https://github.com/sds.png","language":"Ruby","funding_links":[],"categories":["Other","Awesome Ruby CLIs"],"sub_categories":["Linting"],"readme":"# Slim-Lint\n\n[![Gem Version](https://badge.fury.io/rb/slim_lint.svg)](http://badge.fury.io/rb/slim_lint)\n[![Build Status](https://github.com/sds/slim-lint/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/sds/slim-lint/actions/workflows/test.yml?query=branch%3Amaster)\n[![Code Climate](https://codeclimate.com/github/sds/slim-lint.svg)](https://codeclimate.com/github/sds/slim-lint)\n[![Coverage Status](https://coveralls.io/repos/sds/slim-lint/badge.svg)](https://coveralls.io/r/sds/slim-lint)\n[![Inline docs](http://inch-ci.org/github/sds/slim-lint.svg?branch=master)](http://inch-ci.org/github/sds/slim-lint)\n\n`slim-lint` is a tool to help keep your [Slim](https://slim-template.github.io/) files\nclean and readable. In addition to style and lint checks, it integrates with\n[RuboCop](https://github.com/rubocop/rubocop) to bring its powerful static\nanalysis tools to your Slim templates.\n\nYou can run `slim-lint` manually from the command line, or integrate it into\nyour [SCM hooks](https://github.com/sds/overcommit).\n\n* [Requirements](#requirements)\n* [Installation](#installation)\n* [Usage](#usage)\n* [Configuration](#configuration)\n* [Linters](#linters)\n* [Editor Integration](#editor-integration)\n* [Git Integration](#git-integration)\n* [GitHub Integration](#github-integration)\n* [Rake Integration](#rake-integration)\n* [Contributing](#contributing)\n* [Changelog](#changelog)\n* [License](#license)\n\n## Requirements\n\n * Ruby 3.0+\n * Slim 3.0+\n\n## Installation\n\n```bash\ngem install slim_lint\n```\n\n## Usage\n\nRun `slim-lint` from the command line by passing in a directory (or multiple\ndirectories) to recursively scan:\n\n```bash\nslim-lint app/views/\n```\n\nYou can also specify a list of files explicitly:\n\n```bash\nslim-lint app/**/*.slim\n```\n\n`slim-lint` will output any problems with your Slim, including the offending\nfilename and line number.\n\nCommand Line Flag         | Description\n--------------------------|----------------------------------------------------\n`-c`/`--config`           | Specify which configuration file to use\n`-e`/`--exclude`          | Exclude one or more files from being linted\n`-i`/`--include-linter`   | Specify which linters you specifically want to run\n`-x`/`--exclude-linter`   | Specify which linters you _don't_ want to run\n`--stdin-file-path [file]`| Pipe source from STDIN, using file in offense reports\n`--[no-]color`            | Whether to output in color\n`--reporter [reporter]`   | Specify which output formatter to use\n`--show-linters`          | Show all registered linters\n`--show-reporters`        | Show all available reporters\n`-h`/`--help`             | Show command line flag documentation\n`-v`/`--version`          | Show version\n`-V`/`--verbose-version`  | Show detailed version information\n\n## Configuration\n\n`slim-lint` will automatically recognize and load any file with the name\n`.slim-lint.yml` as a configuration file. It loads the configuration based on\nthe directory `slim-lint` is being run from, ascending until a configuration\nfile is found. Any configuration loaded is automatically merged with the\ndefault configuration (see [`config/default.yml`](config/default.yml)).\n\nHere's an example configuration file:\n\n```yaml\nexclude:\n  - 'exclude/files/in/this/directory/from/all/linters/**/*.slim'\n\nlinters:\n  EmptyControlStatement:\n    exclude:\n      - 'app/views/directory_of_files_to_exclude/**/*.slim'\n      - 'specific/file/to/exclude.slim'\n\n  LineLength:\n    include: 'specific/directory/to/include/**/*.slim'\n    max: 100\n\n  RedundantDiv:\n    enabled: false\n```\n\nAll linters have an `enabled` option which can be `true` or `false`, which\ncontrols whether the linter is run, along with linter-specific options. The\ndefaults are defined in [`config/default.yml`](config/default.yml).\n\n### Linter Options\n\nOption        | Description\n--------------|----------------------------------------------------------------\n`enabled`     | If `false`, this linter will never be run. This takes precedence over any other option.\n`include`     | List of files or glob patterns to scope this linter to. This narrows down any files specified via the command line.\n`exclude`     | List of files or glob patterns to exclude from this linter. This excludes any files specified via the command line or already filtered via the `include` option.\n\n### Global File Exclusion\n\nThe `exclude` global configuration option allows you to specify a list of files\nor glob patterns to exclude from all linters. This is useful for ignoring\nthird-party code that you don't maintain or care to lint. You can specify a\nsingle string or a list of strings for this option.\n\n### Skipping Frontmatter\n\nSome static blog generators such as [Jekyll](https://jekyllrb.com/) include\nleading frontmatter to the template for their own tracking purposes.\n`slim-lint` allows you to ignore these headers by specifying the\n`skip_frontmatter` option in your `.slim-lint.yml` configuration:\n\n```yaml\nskip_frontmatter: true\n```\n\n### Disabling Linters For Specific Code\n\n#### Slim-lint linters\n\nTo disable a slim-lint linter, you can use a slim comment:\n```slim\n/ slim-lint:disable TagCase\nIMG src=\"images/cat.gif\"\n/ slim-lint:enable TagCase\n```\n\n### Rubocop cops\nTo disable Rubocop cop, you can use a comment control statement:\n```slim\n- # rubocop:disable Rails/OutputSafety\np = raw(@blog.content)\n- # rubocop:enable Rails/OutputSafety\n```\n## Linters\n\nYou can find detailed documentation on all supported linters by following the\nlink below:\n\n### [» Linters Documentation](lib/slim_lint/linter/README.md)\n\n## Editor Integration\n\n### Sublime Text\n\nInstall the\n[Sublime slim-lint plugin](https://sublime.wbond.net/packages/SublimeLinter-slim-lint).\n\n### Emacs\n\nIf you use Flycheck, support for `slim-lint` is included as of version\n20160718.215 installed from MELPA.\n\n### Atom\n\nInstall the [`linter-slim-lint`](https://github.com/mattaschmann/linter-slim-lint)\nplugin by running `apm install linter-slim-lint`.\n\n### Visual Studio Code\n\nInstall the\n[VS Code slim-lint plugin](https://marketplace.visualstudio.com/items?itemName=aliariff.slim-lint).\n\n## Git Integration\n\nIf you'd like to integrate `slim-lint` into your Git workflow, check out\n[overcommit](https://github.com/sds/overcommit), a powerful and flexible\nGit hook manager.\n\n## Github Integration\n\nTo run `slim-lint` in your [GitHub Actions](https://docs.github.com/en/actions) CI pipeline,\nuse the `github` reporter, for example:\n\n```yml\non:\n  pull_request:\n  push:\n    branches: [ main ]\n\njobs:\n  lint:\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v4\n\n      - name: Set up Ruby\n        uses: ruby/setup-ruby@v1\n        with:\n          ruby-version: .ruby-version\n          bundler-cache: true\n\n      - name: Lint Slim templates for consistent style\n        run: bundle exec slim-lint -r github app/views\n```\n\nOn lint failures, this setup will create annotations in your pull requests on GitHub.\n\n## Rake Integration\n\nTo execute `slim-lint` via a [Rake](https://github.com/ruby/rake) task, make\nsure you have `rake` included in your gem path (e.g. via `Gemfile`), and add\nthe following to your `Rakefile`:\n\n```ruby\nrequire 'slim_lint/rake_task'\n\nSlimLint::RakeTask.new\n```\n\nBy default, when you execute `rake slim_lint`, the above configuration is\nequivalent to running `slim-lint .`, which will lint all `.slim` files in the\ncurrent directory and its descendants.\n\nYou can customize your task by writing:\n\n```ruby\nrequire 'slim_lint/rake_task'\n\nSlimLint::RakeTask.new do |t|\n  t.config = 'custom/config.yml'\n  t.files = ['app/views', 'custom/*.slim']\n  t.quiet = true # Don't display output from slim-lint to STDOUT\nend\n```\n\nYou can also use this custom configuration with a set of files specified via\nthe command line:\n\n```\n# Single quotes prevent shell glob expansion\nrake 'slim_lint[app/views, custom/*.slim]'\n```\n\nFiles specified in this manner take precedence over the task's `files`\nattribute.\n\n## Contributing\n\nWe love getting feedback with or without pull requests. If you do add a new\nfeature, please add tests so that we can avoid breaking it in the future.\n\nSpeaking of tests, we use `rspec`, which can be run by executing the following\nfrom the root directory of the repository:\n\n```bash\nbundle exec rspec\n```\n\n## Changelog\n\nIf you're interested in seeing the changes and bug fixes between each version\nof `slim-lint`, read the [Slim-Lint Changelog](CHANGELOG.md).\n\n## License\n\nThis project is released under the [MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsds%2Fslim-lint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsds%2Fslim-lint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsds%2Fslim-lint/lists"}