diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b08f1ec97..b8d6d1b34 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,6 +9,10 @@ // Set *default* container specific settings.json values on container create. "settings": { + "[erb]": { + "editor.defaultFormatter": "marcoroth.herb-lsp", + "editor.formatOnSave": true + }, "sqltools.connections": [ { "name": "Rails Development Database", @@ -38,6 +42,7 @@ // Add the IDs of extensions you want installed when the container is created. "extensions": [ "rebornix.Ruby", + "marcoroth.herb-lsp", "mtxr.sqltools", "mtxr.sqltools-driver-pg" ], @@ -46,7 +51,7 @@ // "forwardPorts": [3000, 5432], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "script/replicate-bug", + "postCreateCommand": "npm ci && script/replicate-bug", // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. "remoteUser": "vscode" diff --git a/.erb_lint.yml b/.erb_lint.yml index 6e01701b8..5b52ad0bf 100644 --- a/.erb_lint.yml +++ b/.erb_lint.yml @@ -1,13 +1,10 @@ --- -EnableDefaultLinters: true +EnableDefaultLinters: false exclude: - '**/vendor/**/*' - 'test/sandbox/app/components/content_security_policy_nonce_component.html.erb' linters: - ErbSafety: - enabled: true - FinalNewline: - enabled: true + # Herb handles HTML and ERB rules; keep Standard's embedded Ruby checks. Rubocop: enabled: true rubocop_config: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 932056115..cf851d066 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -112,7 +112,7 @@ jobs: with: path: vendor/bundle key: gems-build-rails-8-ruby-3.2-${{ hashFiles('**/Gemfile.lock') }} - - name: Lint with Standard and ERB Lint + - name: Lint Ruby, including Ruby embedded in ERB run: | bundle config path vendor/bundle bundle update @@ -120,6 +120,19 @@ jobs: bundle exec erb_lint --lint-all env: RAILS_VERSION: '~> 8' + herb: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + persist-credentials: false + - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5 + with: + node-version: 22 + cache: npm + - run: npm ci + - run: npm run herb:lint + - run: npm run herb:format:check yard-lint: runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index 42fec50d4..bce56e0b8 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ build-iPhoneSimulator/ # Appraisal /gemfiles/.bundle/ + +# Template development tools +/node_modules/ diff --git a/.herb.yml b/.herb.yml new file mode 100644 index 000000000..5874a21a6 --- /dev/null +++ b/.herb.yml @@ -0,0 +1,67 @@ +version: 0.11.2 +framework: actionview + +files: + include: + - "**/*.erb" + exclude: + - "**/*.tt" + - "**/*.text.erb" + - "**/*.json.erb" + - "**/*.css.erb" + # Jekyll processes this file as Liquid, not Action View. + - "docs/404.html" + +linter: + enabled: true + failLevel: hint + rules: + all: + enabled: true + actionview-no-implicit-partial: + exclude: + # These render ViewComponent instances, not implicit Active Record partials. + - "app/views/view_components/preview.html.erb" + - "test/sandbox/app/components/cacheable_explicit_dependency_component.html.erb" + - "test/sandbox/app/components/cacheable_method_built_component.html.erb" + actionview-prefer-form-with: + exclude: + # Compatibility fixtures must continue exercising form_for. + - "test/sandbox/app/components/form_for_component.html.erb" + - "test/sandbox/app/components/form_partial_component.html.erb" + - "test/sandbox/app/components/incompatible_form_component.html.erb" + actionview-no-local-assigns: + exclude: + # The preview security regression demonstrates access to arbitrary locals. + - "test/sandbox/app/views/internal/secret.html.erb" + erb-require-template-format: + exclude: + # These fixtures test templates without a format suffix. + - "test/sandbox/app/components/no_format_component.erb" + - "test/sandbox/app/components/format_less_parent_component.erb" + - "test/sandbox/app/components/format_less_child_component.erb" + erb-no-silent-statement: + exclude: + # Slot setters register content without emitting their return value. + - "performance/components/slots_wrapper_component.html.erb" + erb-strict-locals-required: + exclude: + # Object rendering supplies implicit locals to this compatibility fixture. + - "test/sandbox/app/views/integration_examples/_test_partial.html.erb" + html-no-inline-script-elements: + exclude: + # System tests render these as standalone HTML, without an asset server. + - "test/sandbox/app/components/simple_javascript_interaction_with_js_included_component.html.erb" + - "test/sandbox/app/views/layouts/application.html.erb" + +formatter: + enabled: true + indentWidth: 2 + indentStyle: space + maxLineLength: 80 + exclude: + # This template emits Markdown, where indentation and line breaks are syntax. + - "lib/docs/docs_builder_component.html.erb" + rewriter: + pre: + - tailwind-class-sorter diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..396941026 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["marcoroth.herb-lsp"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..f3f58d0c4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "[erb]": { + "editor.defaultFormatter": "marcoroth.herb-lsp", + "editor.formatOnSave": true + } +} diff --git a/app/views/view_components/index.html.erb b/app/views/view_components/index.html.erb index df54d7810..093dc7659 100644 --- a/app/views/view_components/index.html.erb +++ b/app/views/view_components/index.html.erb @@ -1,8 +1,13 @@ <% @previews.each do |preview| %> -

<%= link_to preview.preview_name.titleize, preview_view_component_path(preview.preview_name) %>

+

+ <%= link_to preview.preview_name.titleize, preview_view_component_path(preview.preview_name) %> +

+ <% end %> diff --git a/app/views/view_components/previews.html.erb b/app/views/view_components/previews.html.erb index b9fc319db..cbe2d5169 100644 --- a/app/views/view_components/previews.html.erb +++ b/app/views/view_components/previews.html.erb @@ -1,6 +1,9 @@

<%= @preview.preview_name.titleize %>

+ diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index dcfce9319..99b79ffa1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,10 @@ nav_order: 6 ## main +* Enable all Herb lint rules, template formatting, Tailwind class sorting, and editor support for development. + + *Joel Hawksley* + * Adopt rubyfmt for Ruby formatting while retaining compatible Standard lint rules. *Joel Hawksley* diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..739fff89a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,630 @@ +{ + "name": "view-component-development", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "view-component-development", + "devDependencies": { + "@herb-tools/formatter": "0.11.2", + "@herb-tools/language-server": "0.11.2", + "@herb-tools/linter": "0.11.2" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@herb-tools/analysis": { + "version": "0.11.2", + "integrity": "sha512-kAsliQmpP9HIIv2OliSLrCXX0etfC5CIkWNM+zx1wRzeC/hVD4drQs4uCKdWlXcIVqva34gsDIqI5dDOdZfaVQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@herb-tools/core": "0.11.2", + "picomatch": "^4.0.7", + "tinyglobby": "^0.2.15" + }, + "peerDependencies": { + "@herb-tools/core": "0.11.2" + } + }, + "node_modules/@herb-tools/client": { + "version": "0.11.2", + "integrity": "sha512-B/IvlDZcg6LNsFKfk9xKWWx8aNc/oAtgRcFZo0gXhOGwVuSh9rQOUIuE6KHC/Iv9IcvkewrGSxAJMeMY2tYwqw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@herb-tools/config": { + "version": "0.11.2", + "integrity": "sha512-7zP+xr2QGlarJx1E95eIkeCALnnv6wEyX6NIgtdZ+nmBlVtoTugMMr83upjmpxxR4iwLmLTU4p24chZzP5LcJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@herb-tools/core": "0.11.2", + "picomatch": "^4.0.7", + "tinyglobby": "^0.2.16", + "yaml": "^2.9.1" + } + }, + "node_modules/@herb-tools/core": { + "version": "0.11.2", + "integrity": "sha512-5v4cd4PZ882tWHHBTKXXxbacN31PeH/i6UT8na43JWlw81qev2WRCpMTNe4LSLGAYuEA/nH12BO69IoKiYLn0Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ruby/prism": "2.1.0" + } + }, + "node_modules/@herb-tools/formatter": { + "version": "0.11.2", + "integrity": "sha512-XzwBEDitVImC0rvknBZXIWg6rRYyQWWykurbGczbYoKZuAf/t2EHsK0Ljc82rcefv7H7ymZeubeWNxjIaFkJ5w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@herb-tools/config": "0.11.2", + "@herb-tools/core": "0.11.2", + "@herb-tools/highlighter": "0.11.2", + "@herb-tools/node-wasm": "0.11.2", + "@herb-tools/printer": "0.11.2", + "@herb-tools/rewriter": "0.11.2", + "@ruby/prism": "2.1.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "herb-format": "bin/herb-format" + } + }, + "node_modules/@herb-tools/highlighter": { + "version": "0.11.2", + "integrity": "sha512-GHvqh5/DoDX3hYQRFiLCWxqOGP03vwhu0054dDgNj67p1zGItdTLR9GChb0YnMPd6cPhdR7sVPbVxG0h3u9Reg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@herb-tools/core": "0.11.2", + "@herb-tools/node-wasm": "0.11.2", + "ansi_up": "^6.0.6" + }, + "bin": { + "herb-highlight": "bin/herb-highlight" + } + }, + "node_modules/@herb-tools/language-server": { + "version": "0.11.2", + "integrity": "sha512-pX3XQLyDb8tg+owicW5XArK3Tpm/gXqVQk9/ocj2xTuRFwQJQNm6tRZKBqgSOKEh0b4rduRZpEePFOKOlI59pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@herb-tools/analysis": "0.11.2", + "@herb-tools/config": "0.11.2", + "@herb-tools/core": "0.11.2", + "@herb-tools/formatter": "0.11.2", + "@herb-tools/language-service": "0.11.2", + "@herb-tools/linter": "0.11.2", + "@herb-tools/node-wasm": "0.11.2", + "@herb-tools/printer": "0.11.2", + "@herb-tools/rewriter": "0.11.2", + "vscode-html-languageservice": "^5.1.0", + "vscode-languageserver": "^10.1.2", + "vscode-languageserver-textdocument": "^1.0.15" + }, + "bin": { + "herb-language-server": "bin/herb-language-server" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@herb-tools/language-service": { + "version": "0.11.2", + "integrity": "sha512-ffFydGbPWUZ0hsMvGV2axD25sBjf1QP5TquU2QsTfYMQQEn1IAPYDfYFJkQqLKTN00IYd1xPX1J6tZmBIDSwyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@herb-tools/analysis": "0.11.2", + "@herb-tools/client": "0.11.2", + "@herb-tools/config": "0.11.2", + "@herb-tools/core": "0.11.2", + "@herb-tools/printer": "0.11.2", + "@herb-tools/rewriter": "0.11.2", + "vscode-html-languageservice": "^5.1.0", + "vscode-languageserver-textdocument": "^1.0.15", + "vscode-languageserver-types": "^3.18.3" + }, + "peerDependencies": { + "@herb-tools/core": "0.11.2", + "vscode-html-languageservice": "^5.1.0", + "vscode-languageserver-textdocument": "^1.0.15" + } + }, + "node_modules/@herb-tools/linter": { + "version": "0.11.2", + "integrity": "sha512-7doeONcRI01kl0anyAcv+kxd+H3zx2ApgpXWwoQt4N0W2iSxSqNZg+itHyom+f0SDq3LS902Z4lNn1QNmECE8Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@herb-tools/analysis": "0.11.2", + "@herb-tools/client": "0.11.2", + "@herb-tools/config": "0.11.2", + "@herb-tools/core": "0.11.2", + "@herb-tools/highlighter": "0.11.2", + "@herb-tools/node-wasm": "0.11.2", + "@herb-tools/printer": "0.11.2", + "@herb-tools/rewriter": "0.11.2", + "@ruby/prism": "2.1.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.29", + "postcss-selector-parser": "^7.1.7", + "tinyglobby": "^0.2.15" + }, + "bin": { + "herb-lint": "bin/herb-lint" + } + }, + "node_modules/@herb-tools/node-wasm": { + "version": "0.11.2", + "integrity": "sha512-o8k2wjePfym17jdqzKypek+LyGzvLvJsQPpnVqAxRl4bg+CVtlbZonFW+1ScYgrffcJKdiUVeruOn//iOxFJug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@herb-tools/core": "0.11.2", + "@ruby/prism": "2.1.0" + } + }, + "node_modules/@herb-tools/printer": { + "version": "0.11.2", + "integrity": "sha512-D6VDvRZrz0a56l1XW0l+zJoxlF57w7WrrvA3Zfhg4c0hGRTL8cjEQWxr69gasn539K5Zs72gXlvUEIfbLuTlWg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@herb-tools/config": "0.11.2", + "@herb-tools/core": "0.11.2", + "@herb-tools/node-wasm": "0.11.2", + "tinyglobby": "^0.2.15" + }, + "bin": { + "herb-print": "bin/herb-print" + } + }, + "node_modules/@herb-tools/rewriter": { + "version": "0.11.2", + "integrity": "sha512-ilIU2DbqSYK0wahP3HzFp5zSlMxqzYhXyCr8ZHNvDcIjc6E/PnbF6cLl+IJS1A+6hGJLc6DOyjk+UYd4t5MZOw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@herb-tools/core": "0.11.2", + "@herb-tools/printer": "0.11.2", + "@herb-tools/tailwind-class-sorter": "0.11.2", + "@ruby/prism": "2.1.0", + "tinyglobby": "^0.2.15" + } + }, + "node_modules/@herb-tools/tailwind-class-sorter": { + "version": "0.11.2", + "integrity": "sha512-DiAfzGIjiYz4IIZUkeqfThTli2eSskc8R/ccUNCFsAlgK7CW+Y+Rrhf4DjlYMHrITMnAoQ8iwQVju7TqNBuXjg==", + "dev": true, + "license": "MIT", + "dependencies": { + "clear-module": "^4.1.3", + "escalade": "^3.2.0", + "jiti": "^2.7.0", + "postcss": "^8.5.29", + "postcss-import": "^17.0.1" + }, + "engines": { + "node": ">=14.21.3" + }, + "peerDependencies": { + "tailwindcss": "^3.0 || ^4.0" + }, + "peerDependenciesMeta": { + "tailwindcss": { + "optional": true + } + } + }, + "node_modules/@ruby/prism": { + "version": "2.1.0", + "integrity": "sha512-+lMGoxR5YQ8HEX7e2EuLn4H9GBpaDIrIkwtaAdTo/+lhzCxijAOhjrNBMFJtFr+DhbX+32CrA+j0R/WsLYrefw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@vscode/l10n": { + "version": "0.0.18", + "integrity": "sha1-kW06XpYNurR8HFb1iny1CHsTXJU=", + "dev": true, + "license": "MIT" + }, + "node_modules/ansi_up": { + "version": "6.0.6", + "integrity": "sha1-gE+vMfA4XlYtL3EnXqjP8Nnc9tw=", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "integrity": "sha1-s2MKvYlDQy9Us/BRkjjjPNffL3M=", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/clear-module": { + "version": "4.1.3", + "integrity": "sha1-BYi+VJcLK+8h22Z79rbMdI0An9s=", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^2.0.0", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "integrity": "sha1-BfdaJdq5jk+x3NXhRywFRtUFfI8=", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "integrity": "sha1-ARo/aYVroYnf+n3I/M6Z0qh5A+U=", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "integrity": "sha1-7Sq5Z6MxreYvGNB32uGSaE1Q01A=", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "integrity": "sha1-LALYZNl/PqbIgwxGTL0Rq26rehw=", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "integrity": "sha1-jGLYy5C+sqrV0KW2dYGtmFTD8AM=", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-core-module": { + "version": "2.18.0", + "integrity": "sha512-qyax9fgaKOEC4qK8WZn7Q4IcoZC9RC1O1fFxRcRTq/oMMkWT/uXpqpXa12kzWR409zAt1drYN9N9BO26UmBCmw==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/jiti": { + "version": "2.7.0", + "integrity": "sha1-l0Io8vTKK8IYhaF5e0X+po6VDGQ=", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/nanoid": { + "version": "3.3.20", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/parent-module": { + "version": "2.0.0", + "integrity": "sha1-+nH4j/GlDCfhXY/3Tg46lSO/hwg=", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "integrity": "sha1-+8EUtgykKzDZ2vWFjkvWi77bZzU=", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "integrity": "sha1-PTIa8+q5ObCDyPkpodEs2oHCa2s=", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "integrity": "sha1-YxM2ADTMs2s9xh7L3/eBIfkP4h8=", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.33", + "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-import": { + "version": "17.0.1", + "integrity": "sha512-lthLZRa+sMc/xo+lG7TMUvOviwP9ngR0VULnvfXTyOE3JIc0mFrbjcubI6Jx52X+B3IKt9yfp6wwVWE768JezA==", + "dev": true, + "license": "MIT", + "dependencies": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + }, + "engines": { + "node": ">=22.0.0" + }, + "peerDependencies": { + "postcss": "^8.0.0" + } + }, + "node_modules/postcss-selector-parser": { + "version": "7.2.1", + "integrity": "sha512-GwxlMgTTXwIom+ebC7an3k6RaJDwklRQQnfiXsLPGicu8FYV/k/+1/9YY2OU2+r938H2t4X0TDxoif+HP2rjzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "integrity": "sha1-cjwJkgg2um0+WvAZ+SvAlxwC5RQ=", + "dev": true, + "license": "MIT" + }, + "node_modules/read-cache": { + "version": "1.0.2", + "integrity": "sha1-O/pA4nV0IWvYkyds7XXYHmZJylI=", + "dev": true, + "license": "MIT" + }, + "node_modules/resolve": { + "version": "1.22.14", + "integrity": "sha512-1ZjYvR9sbkiwC5+9QHetqW5HmA2pHRMaoupD01t2HlYnV/vydC2zPwLixhsMieSWVZt0JJRg5LVIk0Ow1D/TrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "is-core-module": "^2.18.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "integrity": "sha1-w1IlhD3493bfIcV1V7wIfp39/Gk=", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map-js": { + "version": "1.2.4", + "integrity": "sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "integrity": "sha1-btpL00SjyUrqN21MwxvHcxEDngk=", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "integrity": "sha1-ViqabJ6ys7Ej05cZ+a9btE/NdjE=", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-html-languageservice": { + "version": "5.6.2", + "integrity": "sha1-MvUyYdpdD61PachdwA3mZJ4hC9E=", + "dev": true, + "license": "MIT", + "dependencies": { + "@vscode/l10n": "^0.0.18", + "vscode-languageserver-textdocument": "^1.0.12", + "vscode-languageserver-types": "^3.17.5", + "vscode-uri": "^3.1.0" + } + }, + "node_modules/vscode-jsonrpc": { + "version": "9.0.3", + "integrity": "sha512-qETYf9PCl1lVfwR+oBmMfc4vP2nqLNA35ABxorw3j06+xlKRgDVxbLgKm4Y/xPL0YWdeDjLoI4ImICIT3nB0zQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/vscode-languageserver": { + "version": "10.1.2", + "integrity": "sha512-pXPWde3RytdeBVEs6PulOOT5OpeXC5GkWRpcT11f5rNn41jviQsAYPyAqJ/0oVGETQLKPJtYbHNiMPlfLb0NTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "vscode-languageserver-protocol": "3.18.4" + }, + "bin": { + "installServerIntoExtension": "bin/installServerIntoExtension" + } + }, + "node_modules/vscode-languageserver-protocol": { + "version": "3.18.4", + "integrity": "sha512-CCXbyr99dafRJzJH/0Ryk7ly5T8XPmSR0//OuF2w4m+9JiOin7zcAT5iET8GRE7Z9taFBejb3GbM0a0mbjdbrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "vscode-jsonrpc": "9.0.3", + "vscode-languageserver-types": "3.18.4" + } + }, + "node_modules/vscode-languageserver-protocol/node_modules/vscode-languageserver-types": { + "version": "3.18.4", + "integrity": "sha512-nQsacoiijvl0fRf2q28uFDrAVwRhdCa3QveiF7/CX0r18mLR5FU/1WskSsCKOjmEbtteKUnY8x8Yzxop+k0zwg==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-languageserver-textdocument": { + "version": "1.0.16", + "integrity": "sha512-qeNEuOi9a3qkqRf7Gfez2WL2VwlBTLCNekHBGO9kxPVUp9XuY15yfTJ9jwvOwKI0I2MhUUfZq95NSp+LK1CLQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-languageserver-types": { + "version": "3.18.6", + "integrity": "sha512-DEDtik4YupS+nOg4JxqJ2H5ec/m4tTD9a5mGcBVGYkQKZQo1AIF3ZToiP8+A0kUzyhyqX5dMnPDEnhtmzts7GA==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-uri": { + "version": "3.2.0", + "integrity": "sha1-HLH9PO50JrZnMq/D+4Y0PVltX7Q=", + "dev": true, + "license": "MIT" + }, + "node_modules/yaml": { + "version": "2.9.1", + "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..162f65777 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "view-component-development", + "private": true, + "engines": { + "node": ">=22" + }, + "scripts": { + "herb:lint": "herb-lint", + "herb:lint:fix": "herb-lint --fix", + "herb:format": "herb-format", + "herb:format:check": "herb-format --check" + }, + "devDependencies": { + "@herb-tools/formatter": "0.11.2", + "@herb-tools/language-server": "0.11.2", + "@herb-tools/linter": "0.11.2" + } +} diff --git a/performance/views/benchmarks/_nested.html.erb b/performance/views/benchmarks/_nested.html.erb index 12b942ba0..94bd34590 100644 --- a/performance/views/benchmarks/_nested.html.erb +++ b/performance/views/benchmarks/_nested.html.erb @@ -1 +1,3 @@ +<%# locals: (name:) %> +

nested hello <%= name %>

diff --git a/performance/views/benchmarks/_partial.html.erb b/performance/views/benchmarks/_partial.html.erb index 6a642003b..99d9dc03a 100644 --- a/performance/views/benchmarks/_partial.html.erb +++ b/performance/views/benchmarks/_partial.html.erb @@ -1,5 +1,7 @@ +<%# locals: (name:) %> +

hello <%= name %>

<% 50.times do %> - <%= render "nested", name: name, nested: false %> + <%= render "benchmarks/nested", name: name %> <% end %> diff --git a/test/sandbox/app/components/cacheable_untracked_parent_component.html.erb b/test/sandbox/app/components/cacheable_untracked_parent_component.html.erb index 6898f8e50..eb8a681dd 100644 --- a/test/sandbox/app/components/cacheable_untracked_parent_component.html.erb +++ b/test/sandbox/app/components/cacheable_untracked_parent_component.html.erb @@ -1 +1,3 @@ -
<%= render UntrackedChildComponent.new %>
+
+ <%= render UntrackedChildComponent.new %> +
diff --git a/test/sandbox/app/components/collection_counter_component.html.erb b/test/sandbox/app/components/collection_counter_component.html.erb index cc543236d..5d09f90fd 100644 --- a/test/sandbox/app/components/collection_counter_component.html.erb +++ b/test/sandbox/app/components/collection_counter_component.html.erb @@ -1,5 +1,6 @@
- <%= @item.title %> + <%= image_tag @item.url, alt: @item.title %> +
Photo.<%= @counter %> - <%= @item.caption %>
diff --git a/test/sandbox/app/components/collection_iteration_component.html.erb b/test/sandbox/app/components/collection_iteration_component.html.erb index 440cea0ef..945a433d8 100644 --- a/test/sandbox/app/components/collection_iteration_component.html.erb +++ b/test/sandbox/app/components/collection_iteration_component.html.erb @@ -1,5 +1,9 @@ -
"> - <%= @item.title %> +
+ <%= image_tag @item.url, alt: @item.title %> +
Photo.<%= @counter %> - <%= @item.caption %>
diff --git a/test/sandbox/app/components/collection_iteration_extend_override_component.html.erb b/test/sandbox/app/components/collection_iteration_extend_override_component.html.erb index 52c176cba..e369db137 100644 --- a/test/sandbox/app/components/collection_iteration_extend_override_component.html.erb +++ b/test/sandbox/app/components/collection_iteration_extend_override_component.html.erb @@ -1,5 +1,9 @@ -
"> - <%= @override.title %> +
+ <%= image_tag @override.url, alt: @override.title %> +
Photo.<%= @counter %> - <%= @override.caption %>
diff --git a/test/sandbox/app/components/content_for_component.html.erb b/test/sandbox/app/components/content_for_component.html.erb index 48e29733f..3772efede 100644 --- a/test/sandbox/app/components/content_for_component.html.erb +++ b/test/sandbox/app/components/content_for_component.html.erb @@ -1,2 +1,3 @@ <% content_for(:foo, "bar") %> +
Hello content for
diff --git a/test/sandbox/app/components/forwarding_slot_wrapper_component.html.erb b/test/sandbox/app/components/forwarding_slot_wrapper_component.html.erb index 4d1939750..32f572855 100644 --- a/test/sandbox/app/components/forwarding_slot_wrapper_component.html.erb +++ b/test/sandbox/app/components/forwarding_slot_wrapper_component.html.erb @@ -1,5 +1,5 @@ <%= render(ForwardingSlotComponent.new) do |panel| %> - <% panel.with_target_content do |header| %> + <% panel.with_target_content do %> Target content <% end %> <% end %> diff --git a/test/sandbox/app/components/lambda_slot_passthrough_component.html.erb b/test/sandbox/app/components/lambda_slot_passthrough_component.html.erb index 56b438089..f76411db9 100644 --- a/test/sandbox/app/components/lambda_slot_passthrough_component.html.erb +++ b/test/sandbox/app/components/lambda_slot_passthrough_component.html.erb @@ -2,6 +2,7 @@
<%= lambda_slot %>
+
<%= content %>
diff --git a/test/sandbox/app/components/nested_shared_state/header_component.html.erb b/test/sandbox/app/components/nested_shared_state/header_component.html.erb index 463622557..d04b5d5ef 100644 --- a/test/sandbox/app/components/nested_shared_state/header_component.html.erb +++ b/test/sandbox/app/components/nested_shared_state/header_component.html.erb @@ -1,4 +1,9 @@ <%= content_tag(:div, **@tag_arguments) do %> - <% if @selectable %>Selectable<% end %> - <% cells.each do |cell| %><%= cell %><% end %> + <% if @selectable %> + Selectable + <% end %> + + <% cells.each do |cell| %> + <%= cell %> + <% end %> <% end %> diff --git a/test/sandbox/app/components/partial_component.html.erb b/test/sandbox/app/components/partial_component.html.erb index 047170063..611d0b203 100644 --- a/test/sandbox/app/components/partial_component.html.erb +++ b/test/sandbox/app/components/partial_component.html.erb @@ -1,3 +1,3 @@ -<%= render partial: "test_partial" %> -<%= render "test_partial" %> +<%= render partial: "integration_examples/test_partial" %> +<%= render "integration_examples/test_partial" %> <%= render PartialModel.new(to_partial_path: "test_partial") %> diff --git a/test/sandbox/app/components/path_component.html.erb b/test/sandbox/app/components/path_component.html.erb index dff60c4ff..2ccf7dd97 100644 --- a/test/sandbox/app/components/path_component.html.erb +++ b/test/sandbox/app/components/path_component.html.erb @@ -1 +1 @@ - <%= root_path %> +<%= root_path %> diff --git a/test/sandbox/app/components/polymorphic_slot_component.html.erb b/test/sandbox/app/components/polymorphic_slot_component.html.erb index 1c07db548..69d7def83 100644 --- a/test/sandbox/app/components/polymorphic_slot_component.html.erb +++ b/test/sandbox/app/components/polymorphic_slot_component.html.erb @@ -2,9 +2,11 @@ <% if header? %> <% end %> + <% items.each do |item| %> <%= item %> <% end %> + <% fields.each do |field| %> <%= field %> <% end %> diff --git a/test/sandbox/app/components/product_component.html.erb b/test/sandbox/app/components/product_component.html.erb index b9b7f6a95..6bb151d68 100644 --- a/test/sandbox/app/components/product_component.html.erb +++ b/test/sandbox/app/components/product_component.html.erb @@ -1,6 +1,10 @@
  • Product

    -

    "><%= @product.name %>

    + +

    + <%= @product.name %> +

    +

    <%= @notice %>

    <%= @product.name %> counter: <%= @counter %>

  • diff --git a/test/sandbox/app/components/simple_javascript_interaction_with_js_included_component.html.erb b/test/sandbox/app/components/simple_javascript_interaction_with_js_included_component.html.erb index 9d81c7e4e..12aa6b4d3 100644 --- a/test/sandbox/app/components/simple_javascript_interaction_with_js_included_component.html.erb +++ b/test/sandbox/app/components/simple_javascript_interaction_with_js_included_component.html.erb @@ -1,9 +1,9 @@ - diff --git a/test/sandbox/app/components/simple_javascript_interaction_without_js_included_component.html.erb b/test/sandbox/app/components/simple_javascript_interaction_without_js_included_component.html.erb index a2f16769b..f8b14eb21 100644 --- a/test/sandbox/app/components/simple_javascript_interaction_without_js_included_component.html.erb +++ b/test/sandbox/app/components/simple_javascript_interaction_without_js_included_component.html.erb @@ -1,4 +1,5 @@ - -
    + + + diff --git a/test/sandbox/app/components/slot_name_override_component.html.erb b/test/sandbox/app/components/slot_name_override_component.html.erb index 46b603473..b949851ac 100644 --- a/test/sandbox/app/components/slot_name_override_component.html.erb +++ b/test/sandbox/app/components/slot_name_override_component.html.erb @@ -1,7 +1,7 @@
    <% if title? %> -
    - <%= title %> -
    +
    + <%= title %> +
    <% end %>
    diff --git a/test/sandbox/app/components/slots_before_render_component.html.erb b/test/sandbox/app/components/slots_before_render_component.html.erb index b1c4009b9..c48c8cbc4 100644 --- a/test/sandbox/app/components/slots_before_render_component.html.erb +++ b/test/sandbox/app/components/slots_before_render_component.html.erb @@ -2,6 +2,7 @@
    <%= title %>
    +
    <% if greetings.any? %> <% greetings.each do |greeting| %> diff --git a/test/sandbox/app/components/slots_before_render_component/my_greeting_component.html.erb b/test/sandbox/app/components/slots_before_render_component/my_greeting_component.html.erb index fcf71d457..3b9a2a2c8 100644 --- a/test/sandbox/app/components/slots_before_render_component/my_greeting_component.html.erb +++ b/test/sandbox/app/components/slots_before_render_component/my_greeting_component.html.erb @@ -1,3 +1,3 @@

    - <%= "#{greeting} #{content}" %> + <%= greeting %> <%= content %>

    diff --git a/test/sandbox/app/components/slots_before_render_component/my_title_component.html.erb b/test/sandbox/app/components/slots_before_render_component/my_title_component.html.erb index cbdccda3e..43f7a1bbc 100644 --- a/test/sandbox/app/components/slots_before_render_component/my_title_component.html.erb +++ b/test/sandbox/app/components/slots_before_render_component/my_title_component.html.erb @@ -1,3 +1,3 @@

    - <%= "#{prefix} - #{content}" %> + <%= prefix %> - <%= content %>

    diff --git a/test/sandbox/app/components/slots_component.html.erb b/test/sandbox/app/components/slots_component.html.erb index 93c9a6138..2bc8ce866 100644 --- a/test/sandbox/app/components/slots_component.html.erb +++ b/test/sandbox/app/components/slots_component.html.erb @@ -1,14 +1,16 @@
    <% if title? %> -
    - <%= title %> -
    +
    + <%= title %> +
    <% end %> + <% if subtitle? %> -
    - <%= subtitle %> -
    +
    + <%= subtitle %> +
    <% end %> + +
    <% if items? %> <% items.each do |item| %> diff --git a/test/sandbox/app/components/slots_with_empty_lambda_component.html.erb b/test/sandbox/app/components/slots_with_empty_lambda_component.html.erb index 532e4c50e..e4215aa16 100644 --- a/test/sandbox/app/components/slots_with_empty_lambda_component.html.erb +++ b/test/sandbox/app/components/slots_with_empty_lambda_component.html.erb @@ -1,4 +1,4 @@ -<%= items.each do |item| %> +<% items.each do |item| %>

    <%= item.title %>

    diff --git a/test/sandbox/app/components/slots_with_pos_arg_component.html.erb b/test/sandbox/app/components/slots_with_pos_arg_component.html.erb index 1650f7559..63bf8bfe7 100644 --- a/test/sandbox/app/components/slots_with_pos_arg_component.html.erb +++ b/test/sandbox/app/components/slots_with_pos_arg_component.html.erb @@ -1,4 +1,4 @@ -<%= items.each do |item| %> +<% items.each do |item| %>

    <%= item.title %>

    diff --git a/test/sandbox/app/components/turbo_stream_component.html.erb b/test/sandbox/app/components/turbo_stream_component.html.erb index c1ffb202f..b0595be17 100644 --- a/test/sandbox/app/components/turbo_stream_component.html.erb +++ b/test/sandbox/app/components/turbo_stream_component.html.erb @@ -1 +1,3 @@ -<%= turbo_stream.update "area1" do %>Hello, world!<% end %> +<%= turbo_stream.update "area1" do %> + Hello, world! +<% end %> diff --git a/test/sandbox/app/components/url_component.html.erb b/test/sandbox/app/components/url_component.html.erb index 79baae44b..2077dcd21 100644 --- a/test/sandbox/app/components/url_component.html.erb +++ b/test/sandbox/app/components/url_component.html.erb @@ -1 +1 @@ - <%= root_url %> +<%= root_url %> diff --git a/test/sandbox/app/components/url_helper_component.html.erb b/test/sandbox/app/components/url_helper_component.html.erb index 8395fca03..641a69747 100644 --- a/test/sandbox/app/components/url_helper_component.html.erb +++ b/test/sandbox/app/components/url_helper_component.html.erb @@ -1 +1 @@ -root +<%= link_to "root", @url, target: "_blank" %> diff --git a/test/sandbox/app/lib/primer/state_component.html.erb b/test/sandbox/app/lib/primer/state_component.html.erb index f7025dea2..ce479cbe7 100644 --- a/test/sandbox/app/lib/primer/state_component.html.erb +++ b/test/sandbox/app/lib/primer/state_component.html.erb @@ -1,3 +1,7 @@ -
    +
    <%= content %>
    diff --git a/test/sandbox/app/views/forms/_label.html.erb b/test/sandbox/app/views/forms/_label.html.erb index 01a139906..21e4d182f 100644 --- a/test/sandbox/app/views/forms/_label.html.erb +++ b/test/sandbox/app/views/forms/_label.html.erb @@ -1,3 +1,5 @@ +<%# locals: (form:) %> + <%= form.label :published do %> <%= form.check_box :published %> <% end %> diff --git a/test/sandbox/app/views/integration_examples/_controller_inline.html.erb b/test/sandbox/app/views/integration_examples/_controller_inline.html.erb index 2e8715543..eb416180a 100644 --- a/test/sandbox/app/views/integration_examples/_controller_inline.html.erb +++ b/test/sandbox/app/views/integration_examples/_controller_inline.html.erb @@ -1 +1,3 @@ +<%# locals: (message:) %> +
    <%= message %>
    diff --git a/test/sandbox/app/views/integration_examples/_erb_partial.html.erb b/test/sandbox/app/views/integration_examples/_erb_partial.html.erb index ec3737c1d..82566bb2b 100644 --- a/test/sandbox/app/views/integration_examples/_erb_partial.html.erb +++ b/test/sandbox/app/views/integration_examples/_erb_partial.html.erb @@ -1,4 +1,5 @@ +<%# locals: () %> +
    - What's up! - <%= render HamlComponent.new(message: "It works!") %> + What's up! <%= render HamlComponent.new(message: "It works!") %>
    diff --git a/test/sandbox/app/views/integration_examples/cached_partial.html.erb b/test/sandbox/app/views/integration_examples/cached_partial.html.erb index a3336f706..874c2f1e5 100644 --- a/test/sandbox/app/views/integration_examples/cached_partial.html.erb +++ b/test/sandbox/app/views/integration_examples/cached_partial.html.erb @@ -1,3 +1,3 @@ <% cache ["true"] do %> - <%= render "erb_partial" %> + <%= render "integration_examples/erb_partial" %> <% end %> diff --git a/test/sandbox/app/views/integration_examples/partial.html.erb b/test/sandbox/app/views/integration_examples/partial.html.erb index 27d813395..d1444470e 100644 --- a/test/sandbox/app/views/integration_examples/partial.html.erb +++ b/test/sandbox/app/views/integration_examples/partial.html.erb @@ -1,2 +1,2 @@ -partial:<%= render partial: "test_partial" %> +partial:<%= render partial: "integration_examples/test_partial" %> component:<%= render PartialComponent.new %> diff --git a/test/sandbox/app/views/integration_examples/products.html.erb b/test/sandbox/app/views/integration_examples/products.html.erb index 512177efb..399a01fd1 100644 --- a/test/sandbox/app/views/integration_examples/products.html.erb +++ b/test/sandbox/app/views/integration_examples/products.html.erb @@ -1,4 +1,5 @@

    Products for sale

    +
      <%= render(ProductComponent.with_collection(@products, notice: "Today only")) %>
    diff --git a/test/sandbox/app/views/integration_examples/slots.html.erb b/test/sandbox/app/views/integration_examples/slots.html.erb index 26aa31989..c388fbc28 100644 --- a/test/sandbox/app/views/integration_examples/slots.html.erb +++ b/test/sandbox/app/views/integration_examples/slots.html.erb @@ -2,6 +2,7 @@ <% component.with_title do %>

    This is my title!

    <% end %> + <% component.with_subtitle do %> This is my subtitle! <% end %> @@ -9,6 +10,7 @@ <% component.with_tab do %>

    Tab A

    <% end %> + <% component.with_tab do %>

    Tab B

    <% end %> @@ -16,9 +18,11 @@ <% component.with_item do %>

    Item A

    <% end %> + <% component.with_item(highlighted: true) do %>

    Item B

    <% end %> + <% component.with_item do %>

    Item C

    <% end %> diff --git a/test/sandbox/app/views/integration_examples/translations_in_block.html.erb b/test/sandbox/app/views/integration_examples/translations_in_block.html.erb index df1c089ab..83f092604 100644 --- a/test/sandbox/app/views/integration_examples/translations_in_block.html.erb +++ b/test/sandbox/app/views/integration_examples/translations_in_block.html.erb @@ -11,9 +11,11 @@ <% component.with_title do %> <%= t(".local_relative_key") %> <% end %> + <% component.with_item do %> <%= t(".local_relative_key") %> <% end %> + <% component.with_footer do %> <%= t(".local_relative_key") %> <% end %> diff --git a/test/sandbox/app/views/internal/secret.html.erb b/test/sandbox/app/views/internal/secret.html.erb index 50021b26e..b58168f76 100644 --- a/test/sandbox/app/views/internal/secret.html.erb +++ b/test/sandbox/app/views/internal/secret.html.erb @@ -1,3 +1,11 @@ -
    VC_PREVIEW_POC_SECRET=<%= Rails.application.secret_key_base %>
    -
    VC_PREVIEW_POC_LOCAL=<%= local_assigns[:poc_local] || local_assigns["poc_local"] %>
    -
    VC_PREVIEW_POC_REQUEST=<%= params[:request_marker] %>
    +
    + VC_PREVIEW_POC_SECRET=<%= Rails.application.secret_key_base %> +
    + +
    + VC_PREVIEW_POC_LOCAL=<%= local_assigns[:poc_local] || local_assigns["poc_local"] %> +
    + +
    + VC_PREVIEW_POC_REQUEST=<%= params[:request_marker] %> +
    diff --git a/test/sandbox/app/views/layouts/admin.html.erb b/test/sandbox/app/views/layouts/admin.html.erb index 1892c1937..324f11668 100644 --- a/test/sandbox/app/views/layouts/admin.html.erb +++ b/test/sandbox/app/views/layouts/admin.html.erb @@ -1,10 +1,12 @@ + - - ViewComponent - Admin - Test - <%= stylesheet_link_tag "admin" %> - - - <%= yield %> - + + ViewComponent - Admin - Test + <%= stylesheet_link_tag "admin" %> + + + + <%= yield %> + diff --git a/test/sandbox/app/views/layouts/admin/application_Foobar.html.erb b/test/sandbox/app/views/layouts/admin/application_Foobar.html.erb index 1892c1937..324f11668 100644 --- a/test/sandbox/app/views/layouts/admin/application_Foobar.html.erb +++ b/test/sandbox/app/views/layouts/admin/application_Foobar.html.erb @@ -1,10 +1,12 @@ + - - ViewComponent - Admin - Test - <%= stylesheet_link_tag "admin" %> - - - <%= yield %> - + + ViewComponent - Admin - Test + <%= stylesheet_link_tag "admin" %> + + + + <%= yield %> + diff --git a/test/sandbox/app/views/layouts/application.html.erb b/test/sandbox/app/views/layouts/application.html.erb index 7695bb9d7..d48ec221e 100644 --- a/test/sandbox/app/views/layouts/application.html.erb +++ b/test/sandbox/app/views/layouts/application.html.erb @@ -1,20 +1,22 @@ + - - ViewComponent - Test - <%= stylesheet_link_tag "application" %> - - - <%= yield %> + + ViewComponent - Test + <%= stylesheet_link_tag "application" %> + + + + <%= yield %> - - + + diff --git a/test/sandbox/app/views/layouts/explicit_in_action.html.erb b/test/sandbox/app/views/layouts/explicit_in_action.html.erb index 24b60902d..7eaee9ea4 100644 --- a/test/sandbox/app/views/layouts/explicit_in_action.html.erb +++ b/test/sandbox/app/views/layouts/explicit_in_action.html.erb @@ -1,10 +1,12 @@ + - - ViewComponent - Test - <%= stylesheet_link_tag "application" %> - - - <%= yield %> - + + ViewComponent - Test + <%= stylesheet_link_tag "application" %> + + + + <%= yield %> + diff --git a/test/sandbox/app/views/layouts/global_for_action.html.erb b/test/sandbox/app/views/layouts/global_for_action.html.erb index e3f1b91c1..6f018ed04 100644 --- a/test/sandbox/app/views/layouts/global_for_action.html.erb +++ b/test/sandbox/app/views/layouts/global_for_action.html.erb @@ -1,10 +1,12 @@ + - - ViewComponent - Test - <%= stylesheet_link_tag "application" %> - - - <%= yield %> - + + ViewComponent - Test + <%= stylesheet_link_tag "application" %> + + + + <%= yield %> + diff --git a/test/sandbox/app/views/layouts/with_content_for.html.erb b/test/sandbox/app/views/layouts/with_content_for.html.erb index 1fe14bc7e..7c058b993 100644 --- a/test/sandbox/app/views/layouts/with_content_for.html.erb +++ b/test/sandbox/app/views/layouts/with_content_for.html.erb @@ -1,11 +1,13 @@ + - - ViewComponent - Global For Action - Test - <%= stylesheet_link_tag "application" %> - - - <%= yield %> - Foo: <%= content_for(:foo) %> - + + ViewComponent - Global For Action - Test + <%= stylesheet_link_tag "application" %> + + + + <%= yield %> + Foo: <%= content_for(:foo) %> + diff --git a/test/sandbox/app/views/partial_helper/_fragment.html.erb b/test/sandbox/app/views/partial_helper/_fragment.html.erb index 25310b08f..9ebe9ab7c 100644 --- a/test/sandbox/app/views/partial_helper/_fragment.html.erb +++ b/test/sandbox/app/views/partial_helper/_fragment.html.erb @@ -1 +1,3 @@ +<%# locals: () %> + <%= expensive_message %> diff --git a/test/sandbox/app/views/shared/_action_menu_panel.html.erb b/test/sandbox/app/views/shared/_action_menu_panel.html.erb index 5e8d98862..f6f80592b 100644 --- a/test/sandbox/app/views/shared/_action_menu_panel.html.erb +++ b/test/sandbox/app/views/shared/_action_menu_panel.html.erb @@ -1,3 +1,5 @@ +<%# locals: () %> + <%= render ActionMenuComponent.new do |menu| %> <% menu.with_list do |list| %> <% list.with_item do %> diff --git a/test/sandbox/app/views/shared/_deep_navigation.html.erb b/test/sandbox/app/views/shared/_deep_navigation.html.erb index 690ad6820..b76bd174e 100644 --- a/test/sandbox/app/views/shared/_deep_navigation.html.erb +++ b/test/sandbox/app/views/shared/_deep_navigation.html.erb @@ -1,3 +1,5 @@ +<%# locals: () %> + <%= render SectionComponent.new do |section| %> <% section.with_nav do |nav| %> <% nav.with_action_menu do |menu| %> diff --git a/test/sandbox/app/views/shared/_lambda_slot_translation.html.erb b/test/sandbox/app/views/shared/_lambda_slot_translation.html.erb index 5a9c55446..ac62bec4a 100644 --- a/test/sandbox/app/views/shared/_lambda_slot_translation.html.erb +++ b/test/sandbox/app/views/shared/_lambda_slot_translation.html.erb @@ -1,3 +1,5 @@ +<%# locals: () %> + <%= render LambdaSlotOuterComponent.new do |outer| %> <% outer.with_inner do |inner| %> <% inner.with_aside do %> diff --git a/test/sandbox/app/views/shared/_partial.html.erb b/test/sandbox/app/views/shared/_partial.html.erb index 37f0bddbd..2d6eefee4 100644 --- a/test/sandbox/app/views/shared/_partial.html.erb +++ b/test/sandbox/app/views/shared/_partial.html.erb @@ -1 +1,3 @@ +<%# locals: () %> + <%= yield %> diff --git a/test/sandbox/app/views/shared/_yielding_form_partial.html.erb b/test/sandbox/app/views/shared/_yielding_form_partial.html.erb index d4f2ca982..d949ee534 100644 --- a/test/sandbox/app/views/shared/_yielding_form_partial.html.erb +++ b/test/sandbox/app/views/shared/_yielding_form_partial.html.erb @@ -1,3 +1,5 @@ +<%# locals: (form:) %> + <%= form.label :something do %> <%= yield %> <% end %> diff --git a/test/sandbox/app/views/shared/_yielding_partial.html.erb b/test/sandbox/app/views/shared/_yielding_partial.html.erb index 10503e2b3..f252b0e1f 100644 --- a/test/sandbox/app/views/shared/_yielding_partial.html.erb +++ b/test/sandbox/app/views/shared/_yielding_partial.html.erb @@ -1 +1,3 @@ -hello <%= yield %> +<%# locals: () %> + +hello <%= yield %> diff --git a/test/sandbox/app/views/view_components/_inline.html.erb b/test/sandbox/app/views/view_components/_inline.html.erb index 95ee82c14..3a223845e 100644 --- a/test/sandbox/app/views/view_components/_inline.html.erb +++ b/test/sandbox/app/views/view_components/_inline.html.erb @@ -1 +1,3 @@ +<%# locals: () %> + Hello, world! diff --git a/test/sandbox/test/components/previews/lambda_slot_passthrough_component_preview/default.html.erb b/test/sandbox/test/components/previews/lambda_slot_passthrough_component_preview/default.html.erb index 0aac5aed9..231dff939 100644 --- a/test/sandbox/test/components/previews/lambda_slot_passthrough_component_preview/default.html.erb +++ b/test/sandbox/test/components/previews/lambda_slot_passthrough_component_preview/default.html.erb @@ -1,3 +1,5 @@ <%= render LambdaSlotPassthroughComponent.new do |component| %> - <% component.with_lambda_slot do %>hello,world!<% end %> + <% component.with_lambda_slot do %> + hello,world! + <% end %> <% end %> diff --git a/test/sandbox/test/integration_test.rb b/test/sandbox/test/integration_test.rb index f555e1765..3a2a9975b 100644 --- a/test/sandbox/test/integration_test.rb +++ b/test/sandbox/test/integration_test.rb @@ -226,7 +226,7 @@ def test_rendering_component_with_content get("/content") assert_response(:success) assert_select("div.State--green") - assert_select("div[title='Status: Open']") + assert_select("[role='status'][aria-label='Status: Open']", text: "Open") assert_includes(response.body, "Open") end @@ -553,11 +553,14 @@ def test_does_not_render_additional_newline_with_render_in def test_render_component_in_turbo_stream without_template_annotations do get(turbo_stream_path, headers: {"HTTP_ACCEPT" => "text/vnd.turbo-stream.html"}) - expected_response_body = <<~TURBOSTREAM - - TURBOSTREAM - - assert_equal(expected_response_body, response.body) + assert_response(:success) + assert_equal("text/vnd.turbo-stream.html", response.media_type) + assert_select("turbo-stream", count: 1) + assert_select("turbo-stream[action='update'][target='area1']", count: 1) do + assert_select("template", count: 1) do + assert_select("span", text: "Hello, world!", count: 1) + end + end end end diff --git a/test/sandbox/test/rendering_allocations_test.rb b/test/sandbox/test/rendering_allocations_test.rb index 617d70ac1..0513440e2 100644 --- a/test/sandbox/test/rendering_allocations_test.rb +++ b/test/sandbox/test/rendering_allocations_test.rb @@ -14,13 +14,13 @@ class RenderingAllocationsTest < ViewComponent::TestCase }.freeze COLLECTION_ALLOCATIONS = { - ["7.1", "3.2"] => 76, - ["7.2", "3.3"] => 79, - ["8.0", "3.4"] => 67, - ["8.1", "4.0"] => 53, - ["8.1", "4.1"] => 53, - ["8.2", "4.0"] => 53, - ["8.2", "4.1"] => 53 + ["7.1", "3.2"] => 74, + ["7.2", "3.3"] => 77, + ["8.0", "3.4"] => 65, + ["8.1", "4.0"] => 52, + ["8.1", "4.1"] => 52, + ["8.2", "4.0"] => 52, + ["8.2", "4.1"] => 52 }.freeze class TestController < IntegrationExamplesController