{"id":16737341,"url":"https://github.com/yasaichi/remove_data_attributes","last_synced_at":"2025-09-05T11:51:12.532Z","repository":{"id":27387627,"uuid":"112822058","full_name":"yasaichi/remove_data_attributes","owner":"yasaichi","description":"Rails plugin for removing data attributes from views :dash:","archived":false,"fork":false,"pushed_at":"2023-12-15T08:29:43.000Z","size":67,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-19T10:55:21.858Z","etag":null,"topics":["data-attributes","rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yasaichi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","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":"2017-12-02T07:28:19.000Z","updated_at":"2024-02-26T14:57:13.000Z","dependencies_parsed_at":"2024-10-13T00:25:58.454Z","dependency_job_id":"2b1fe0f8-e135-46bd-b206-16b139c5a0ae","html_url":"https://github.com/yasaichi/remove_data_attributes","commit_stats":{"total_commits":47,"total_committers":1,"mean_commits":47.0,"dds":0.0,"last_synced_commit":"15cd134131386fc429adee8d10953a7f063cab36"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/yasaichi/remove_data_attributes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasaichi%2Fremove_data_attributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasaichi%2Fremove_data_attributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasaichi%2Fremove_data_attributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasaichi%2Fremove_data_attributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yasaichi","download_url":"https://codeload.github.com/yasaichi/remove_data_attributes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasaichi%2Fremove_data_attributes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273754078,"owners_count":25161912,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["data-attributes","rails"],"created_at":"2024-10-13T00:25:55.292Z","updated_at":"2025-09-05T11:51:12.480Z","avatar_url":"https://github.com/yasaichi.png","language":"Ruby","readme":"# remove\\_data\\_attributes\n[![Gem Version](https://badge.fury.io/rb/remove_data_attributes.svg)](https://badge.fury.io/rb/remove_data_attributes)\n[![Build Status](https://travis-ci.org/yasaichi/remove_data_attributes.svg?branch=master)](https://travis-ci.org/yasaichi/remove_data_attributes)\n[![Maintainability](https://api.codeclimate.com/v1/badges/eddaa55a25ccd62b9eb8/maintainability)](https://codeclimate.com/github/yasaichi/remove_data_attributes/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/eddaa55a25ccd62b9eb8/test_coverage)](https://codeclimate.com/github/yasaichi/remove_data_attributes/test_coverage)\n\n## Motivation\nAs described in [this post](https://blog.kentcdodds.com/making-your-ui-tests-resilient-to-change-d37a6ee37269), using data attributes as selector makes your UI tests more resilient to change.  \nHowever, there is one little problem in this way: these attributes are useless when running your application in production.\n\n## Solution (with limitations)\nremove_data_attributes is a plugin for Ruby on Rails like [babel-plugin-react-remove-properties](https://github.com/oliviertassinari/babel-plugin-react-remove-properties) for Babel.  \nNote that the plugin can remove __only the data attributes passed into the view helpers__, because there is no room to parse and remove all attributes (including ones embedded in HTML tags) in advance unlike the Babel plugin.\n\n## Installation\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'remove_data_attributes', group: :production\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\n## Usage\nRun the installation generator with:\n\n```sh\n$ rails generate remove_data_attributes:install\n```\n\nAnd then specify `data-*` attributes you'd like to remove in the generated configuration file:\n\n```yaml\ndata_attributes:\n  - data-testid\n```\n\nThis will remove `data-testid` attributes.\n\n## Example\nHere is an example of removing `data-testid` attributes.\n\n### Template\n```ERB\n\u003c%= form_with scope: :user, url: session_path(:user) do |f| %\u003e\n  \u003c%= field_set_tag \"Email\" do %\u003e\n    \u003c%= f.email_field :email, \"data-testid\": \"email\" %\u003e\n  \u003c% end %\u003e\n\n  \u003c%= field_set_tag \"Password\" do %\u003e\n    \u003c%= f.password_field :password, \"data-testid\" =\u003e \"password\" %\u003e\n  \u003c% end %\u003e\n\n  \u003c%= f.submit \"Sign in\", data: { testid: \"submit\" } %\u003e\n\u003c% end %\u003e\n```\n\n### Rendered HTML (formatted for readability)\n```html\n\u003cform action=\"/users/sign_in\" accept-charset=\"UTF-8\" data-remote=\"true\" method=\"post\"\u003e\n  \u003cinput name=\"utf8\" type=\"hidden\" value=\"\u0026#x2713;\" /\u003e\n  \u003cinput type=\"hidden\" name=\"authenticity_token\" value=\"HyOvLlyjIh7Sv7fFt2fKy5+uJNeKwnYobQPs49pl/H7CKSAVrw57jxpERJihR+B77GNSh2pZHG5mEWl0ieYQnQ==\" /\u003e\n\n  \u003cfieldset\u003e\n    \u003clegend\u003eEmail\u003c/legend\u003e\n    \u003cinput type=\"email\" value=\"\" name=\"user[email]\" /\u003e\n  \u003c/fieldset\u003e\n\n  \u003cfieldset\u003e\n    \u003clegend\u003ePassword\u003c/legend\u003e\n    \u003cinput type=\"password\" name=\"user[password]\" /\u003e\n  \u003c/fieldset\u003e\n\n  \u003cinput type=\"submit\" name=\"commit\" value=\"Sign in\" data-disable-with=\"Sign in\" /\u003e\n\u003c/form\u003e\n```\n\n## Contributing\nYou should follow the steps below:\n\n1. [Fork the repository](https://help.github.com/articles/fork-a-repo/)\n2. Create a feature branch: `git checkout -b add-new-feature`\n3. Commit your changes: `git commit -am 'Add new feature'`\n4. Push the branch: `git push origin add-new-feature`\n4. [Send us a pull request](https://help.github.com/articles/about-pull-requests/)\n\n## License\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasaichi%2Fremove_data_attributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyasaichi%2Fremove_data_attributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasaichi%2Fremove_data_attributes/lists"}