From fbe24be0588a565b91adab3d3bbcc9fe5e599d48 Mon Sep 17 00:00:00 2001 From: Marco Roth Date: Sat, 21 Mar 2026 02:50:18 +0100 Subject: [PATCH] Linter: Implement `actionview-strict-locals-first-line` rule --- .../packages/linter/docs/rules/README.md | 33 +++++ .../actionview-strict-locals-first-line.md | 65 +++++++++ javascript/packages/linter/src/rules.ts | 2 + .../actionview-strict-locals-first-line.ts | 119 ++++++++++++++++ .../src/rules/erb-strict-locals-required.ts | 11 +- javascript/packages/linter/src/rules/index.ts | 1 + ...w-strict-locals-first-line.autofix.test.ts | 127 ++++++++++++++++++ ...ctionview-strict-locals-first-line.test.ts | 102 ++++++++++++++ 8 files changed, 452 insertions(+), 8 deletions(-) create mode 100644 javascript/packages/linter/docs/rules/actionview-strict-locals-first-line.md create mode 100644 javascript/packages/linter/src/rules/actionview-strict-locals-first-line.ts create mode 100644 javascript/packages/linter/test/autofix/actionview-strict-locals-first-line.autofix.test.ts create mode 100644 javascript/packages/linter/test/rules/actionview-strict-locals-first-line.test.ts diff --git a/javascript/packages/linter/docs/rules/README.md b/javascript/packages/linter/docs/rules/README.md index 45b93e98f..04b426b5d 100644 --- a/javascript/packages/linter/docs/rules/README.md +++ b/javascript/packages/linter/docs/rules/README.md @@ -4,9 +4,16 @@ This page contains documentation for all Herb Linter rules. ## Available Rules +#### Action View + - [`actionview-no-silent-helper`](./actionview-no-silent-helper.md) - Disallow silent ERB tags for Action View helpers - [`actionview-no-silent-render`](./actionview-no-silent-render.md) - Disallow calling `render` without outputting the result - [`actionview-no-void-element-content`](./actionview-no-void-element-content.md) - Disallow content arguments for void Action View elements +- [`actionview-strict-locals-first-line`](./actionview-strict-locals-first-line.md) - Require strict locals on the first line of partials with a blank line after. + + +#### ERB + - [`erb-comment-syntax`](./erb-comment-syntax.md) - Disallow Ruby comments immediately after ERB tags - [`erb-no-case-node-children`](./erb-no-case-node-children.md) - Don't use `children` for `case/when` and `case/in` nodes - [`erb-no-conditional-html-element`](./erb-no-conditional-html-element.md) - Disallow conditional HTML elements @@ -36,12 +43,21 @@ This page contains documentation for all Herb Linter rules. - [`erb-require-whitespace-inside-tags`](./erb-require-whitespace-inside-tags.md) - Requires whitespace around ERB tags - [`erb-right-trim`](./erb-right-trim.md) - Enforce consistent right-trimming syntax. - [`erb-strict-locals-comment-syntax`](./erb-strict-locals-comment-syntax.md) - Enforce strict locals comment syntax. +- [`erb-strict-locals-required`](./erb-strict-locals-required.md) - Require strict locals in Rails partials. + + +#### Herb + - [`herb-disable-comment-malformed`](./herb-disable-comment-malformed.md) - Detect malformed `herb:disable` comments. - [`herb-disable-comment-missing-rules`](./herb-disable-comment-missing-rules.md) - Require rule names in `herb:disable` comments. - [`herb-disable-comment-no-duplicate-rules`](./herb-disable-comment-no-duplicate-rules.md) - Disallow duplicate rule names in `herb:disable` comments. - [`herb-disable-comment-no-redundant-all`](./herb-disable-comment-no-redundant-all.md) - Disallow redundant use of `all` in `herb:disable` comments. - [`herb-disable-comment-unnecessary`](./herb-disable-comment-unnecessary.md) - Detect unnecessary `herb:disable` comments. - [`herb-disable-comment-valid-rule-name`](./herb-disable-comment-valid-rule-name.md) - Validate rule names in `herb:disable` comments. + + +#### HTML + - [`html-allowed-script-type`](./html-allowed-script-type.md) - Restrict allowed `type` attributes for `