File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
javascript/packages/linter Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { hasBalancedParentheses, splitByTopLevelComma } from "./string-utils.js"
77import type { UnboundLintOffense , LintContext , FullRuleConfig } from "../types.js"
88import type { ParseResult , ERBContentNode } from "@herb-tools/core"
99
10- export const STRICT_LOCALS_PATTERN = / ^ l o c a l s : \s + \( [ ^ ) ] * \) \s * $ /
10+ export const STRICT_LOCALS_PATTERN = / ^ l o c a l s : \s + \( . * \) \s * $ / s
1111
1212function isValidStrictLocalsFormat ( content : string ) : boolean {
1313 return STRICT_LOCALS_PATTERN . test ( content )
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ describe("ERBStrictLocalsCommentSyntaxRule", () => {
3030 expectNoOffenses ( `<%# locals: (callback: -> { nil }) %>` )
3131 } )
3232
33+ test ( "allows i18n method calls with parentheses as default values" , ( ) => {
34+ expectNoOffenses ( `<%# locals: (title: t("translation_key_for.title"), message:) %>` )
35+ expectNoOffenses ( `<%# locals: (label: I18n.t("key"), value:) %>` )
36+ expectNoOffenses ( `<%# locals: (a: foo(bar(baz())), b:) %>` )
37+ } )
38+
3339 test ( "allows double-splat for optional keyword arguments" , ( ) => {
3440 expectNoOffenses ( `<%# locals: (message: "Hello", **attributes) %>` )
3541 expectNoOffenses ( `<%# locals: (**options) %>` )
You can’t perform that action at this time.
0 commit comments