Skip to content

Commit d529bba

Browse files
committed
fix: formatting
1 parent fa96cf3 commit d529bba

12 files changed

+19
-72
lines changed

src/rules/consistent-plural-format.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ export const consistentPluralFormat = createRule<[Options], MessageId>({
6060
const openingElement = node.openingElement
6161

6262
// Check for <Plural> component
63-
if (
64-
openingElement.name.type !== AST_NODE_TYPES.JSXIdentifier ||
65-
openingElement.name.name !== "Plural"
66-
) {
63+
if (openingElement.name.type !== AST_NODE_TYPES.JSXIdentifier || openingElement.name.name !== "Plural") {
6764
return
6865
}
6966

src/rules/no-complex-expressions-in-message.test.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,11 @@ ruleTester.run("no-complex-expressions-in-message", noComplexExpressionsInMessag
128128
// Multiple violations in one message
129129
{
130130
code: "t`${a + b} and ${Math.random()}`",
131-
errors: [
132-
{ messageId: "complexExpression" },
133-
{ messageId: "complexExpression" }
134-
]
131+
errors: [{ messageId: "complexExpression" }, { messageId: "complexExpression" }]
135132
},
136133
{
137134
code: "<Trans>{x * 2} plus {y * 3}</Trans>",
138-
errors: [
139-
{ messageId: "complexExpression" },
140-
{ messageId: "complexExpression" }
141-
]
135+
errors: [{ messageId: "complexExpression" }, { messageId: "complexExpression" }]
142136
}
143137
]
144138
})
145-

src/rules/no-complex-expressions-in-message.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ function getCalleeName(node: TSESTree.Expression): string | null {
2222

2323
if (node.type === AST_NODE_TYPES.MemberExpression && !node.computed) {
2424
const object = getCalleeName(node.object)
25-
const property =
26-
node.property.type === AST_NODE_TYPES.Identifier ? node.property.name : null
25+
const property = node.property.type === AST_NODE_TYPES.Identifier ? node.property.name : null
2726

2827
if (object !== null && property !== null) {
2928
return `${object}.${property}`
@@ -51,10 +50,7 @@ function getMemberExpressionDepth(node: TSESTree.MemberExpression): number {
5150
/**
5251
* Checks if an expression is allowed within a Lingui message.
5352
*/
54-
function isAllowedExpression(
55-
node: TSESTree.Expression,
56-
options: Options
57-
): boolean {
53+
function isAllowedExpression(node: TSESTree.Expression, options: Options): boolean {
5854
// Simple identifiers are always allowed: name, count
5955
if (node.type === AST_NODE_TYPES.Identifier) {
6056
return true
@@ -210,10 +206,7 @@ export const noComplexExpressionsInMessage = createRule<[Options], MessageId>({
210206
// Check <Trans>Hello {expr}</Trans> pattern
211207
JSXElement(node): void {
212208
const openingElement = node.openingElement
213-
if (
214-
openingElement.name.type !== AST_NODE_TYPES.JSXIdentifier ||
215-
openingElement.name.name !== "Trans"
216-
) {
209+
if (openingElement.name.type !== AST_NODE_TYPES.JSXIdentifier || openingElement.name.name !== "Trans") {
217210
return
218211
}
219212

@@ -222,4 +215,3 @@ export const noComplexExpressionsInMessage = createRule<[Options], MessageId>({
222215
}
223216
}
224217
})
225-

src/rules/no-nested-macros.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,3 @@ ruleTester.run("no-nested-macros", noNestedMacros, {
104104
}
105105
]
106106
})
107-

src/rules/no-nested-macros.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ function getMacroName(node: TSESTree.Node): string | null {
4343
/**
4444
* Finds the nearest ancestor that is a Lingui macro.
4545
*/
46-
function findParentMacro(
47-
node: TSESTree.Node,
48-
macros: string[]
49-
): { node: TSESTree.Node; name: string } | null {
46+
function findParentMacro(node: TSESTree.Node, macros: string[]): { node: TSESTree.Node; name: string } | null {
5047
let current = node.parent
5148

5249
while (current) {

src/rules/no-single-tag-message.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,3 @@ ruleTester.run("no-single-tag-message", noSingleTagMessage, {
8080
}
8181
]
8282
})
83-

src/rules/no-single-tag-message.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,18 @@ function isSingleTagJSX(children: TSESTree.JSXChild[]): boolean {
2020
}
2121

2222
const onlyChild = meaningfulChildren[0]
23-
return (
24-
onlyChild?.type === AST_NODE_TYPES.JSXElement || onlyChild?.type === AST_NODE_TYPES.JSXFragment
25-
)
23+
return onlyChild?.type === AST_NODE_TYPES.JSXElement || onlyChild?.type === AST_NODE_TYPES.JSXFragment
2624
}
2725

2826
export const noSingleTagMessage = createRule<[], MessageId>({
2927
name: "no-single-tag-message",
3028
meta: {
3129
type: "problem",
3230
docs: {
33-
description:
34-
"Disallow Lingui messages that consist only of a single JSX element without surrounding text"
31+
description: "Disallow Lingui messages that consist only of a single JSX element without surrounding text"
3532
},
3633
messages: {
37-
singleTag:
38-
"Translation message should not consist only of a single element. Add surrounding text for context."
34+
singleTag: "Translation message should not consist only of a single element. Add surrounding text for context."
3935
},
4036
schema: []
4137
},
@@ -44,10 +40,7 @@ export const noSingleTagMessage = createRule<[], MessageId>({
4440
return {
4541
JSXElement(node): void {
4642
const openingElement = node.openingElement
47-
if (
48-
openingElement.name.type !== AST_NODE_TYPES.JSXIdentifier ||
49-
openingElement.name.name !== "Trans"
50-
) {
43+
if (openingElement.name.type !== AST_NODE_TYPES.JSXIdentifier || openingElement.name.name !== "Trans") {
5144
return
5245
}
5346

@@ -61,4 +54,3 @@ export const noSingleTagMessage = createRule<[], MessageId>({
6154
}
6255
}
6356
})
64-

src/rules/no-unlocalized-strings.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,7 @@ function isIgnoredFunctionArgument(node: TSESTree.Node, ignoreFunctions: string[
146146
if (callee.type === AST_NODE_TYPES.Identifier) {
147147
calleeName = callee.name
148148
} else if (callee.type === AST_NODE_TYPES.MemberExpression) {
149-
if (
150-
callee.object.type === AST_NODE_TYPES.Identifier &&
151-
callee.property.type === AST_NODE_TYPES.Identifier
152-
) {
149+
if (callee.object.type === AST_NODE_TYPES.Identifier && callee.property.type === AST_NODE_TYPES.Identifier) {
153150
calleeName = `${callee.object.name}.${callee.property.name}`
154151
}
155152
}
@@ -276,8 +273,7 @@ export const noUnlocalizedStrings = createRule<[Options], MessageId>({
276273
description: "Detect user-visible strings not wrapped in Lingui translation macros"
277274
},
278275
messages: {
279-
unlocalizedString:
280-
'String "{{text}}" appears to be user-visible text. Wrap it with t`...` or <Trans>.'
276+
unlocalizedString: 'String "{{text}}" appears to be user-visible text. Wrap it with t`...` or <Trans>.'
281277
},
282278
schema: [
283279
{

src/rules/text-restrictions.test.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ ruleTester.run("text-restrictions", textRestrictions, {
8282
{
8383
code: "t`Hello&nbsp;&amp;World`",
8484
options: [{ forbiddenPatterns: ["&nbsp;", "&amp;"], minLength: null }],
85-
errors: [
86-
{ messageId: "forbiddenPattern" },
87-
{ messageId: "forbiddenPattern" }
88-
]
85+
errors: [{ messageId: "forbiddenPattern" }, { messageId: "forbiddenPattern" }]
8986
},
9087

9188
// Too short message
@@ -111,10 +108,7 @@ ruleTester.run("text-restrictions", textRestrictions, {
111108
{
112109
code: "t`X&`",
113110
options: [{ forbiddenPatterns: ["&"], minLength: 5 }],
114-
errors: [
115-
{ messageId: "forbiddenPattern" },
116-
{ messageId: "tooShort" }
117-
]
111+
errors: [{ messageId: "forbiddenPattern" }, { messageId: "tooShort" }]
118112
},
119113

120114
// Regex pattern
@@ -125,4 +119,3 @@ ruleTester.run("text-restrictions", textRestrictions, {
125119
}
126120
]
127121
})
128-

src/rules/text-restrictions.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ export const textRestrictions = createRule<[Options], MessageId>({
107107
// Check <Trans>...</Trans> pattern
108108
JSXElement(node): void {
109109
const openingElement = node.openingElement
110-
if (
111-
openingElement.name.type !== AST_NODE_TYPES.JSXIdentifier ||
112-
openingElement.name.name !== "Trans"
113-
) {
110+
if (openingElement.name.type !== AST_NODE_TYPES.JSXIdentifier || openingElement.name.name !== "Trans") {
114111
return
115112
}
116113

@@ -120,4 +117,3 @@ export const textRestrictions = createRule<[Options], MessageId>({
120117
}
121118
}
122119
})
123-

0 commit comments

Comments
 (0)