Skip to content

Commit

Permalink
chore: enforce curly braces (#1429)
Browse files Browse the repository at this point in the history
* chore: enforce curly braces

* refactor: apply eslint fixes
  • Loading branch information
G-Rath authored Sep 8, 2023
1 parent e44693f commit eeafcc9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ module.exports = {
'prefer-rest-params': 'error',
'prefer-const': ['error', { destructuring: 'all' }],
'no-var': 'error',
curly: 'error',
},
overrides: [
{
Expand Down
4 changes: 3 additions & 1 deletion src/rules/expect-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ function matchesAssertFunctionName(
`^${p
.split('.')
.map(x => {
if (x === '**') return '[a-z\\d\\.]*';
if (x === '**') {
return '[a-z\\d\\.]*';
}
return x.replace(/\*/gu, '[a-z\\d]*');
})
Expand Down
12 changes: 9 additions & 3 deletions src/rules/no-test-return-statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export default createRule({
t => t.type === AST_NODE_TYPES.ReturnStatement,
);

if (!returnStmt) return;
if (!returnStmt) {
return;
}

context.report({ messageId: 'noReturnValue', node: returnStmt });
},
Expand All @@ -58,13 +60,17 @@ export default createRule({
context,
);

if (testCallExpressions.length === 0) return;
if (testCallExpressions.length === 0) {
return;
}

const returnStmt = node.body.body.find(
t => t.type === AST_NODE_TYPES.ReturnStatement,
);

if (!returnStmt) return;
if (!returnStmt) {
return;
}

context.report({ messageId: 'noReturnValue', node: returnStmt });
},
Expand Down
4 changes: 3 additions & 1 deletion src/rules/no-untyped-mock-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export default createRule({
data: { moduleName: moduleName?.raw ?? './module-name' },
node,
fix(fixer) {
if (!moduleName) return [];
if (!moduleName) {
return [];
}

return [
fixer.insertTextAfter(
Expand Down
8 changes: 6 additions & 2 deletions src/rules/prefer-spy-on.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ export default createRule({
AssignmentExpression(node) {
const { left, right } = node;

if (left.type !== AST_NODE_TYPES.MemberExpression) return;
if (left.type !== AST_NODE_TYPES.MemberExpression) {
return;
}

const jestFnCall = getJestFnCall(right);

if (!jestFnCall) return;
if (!jestFnCall) {
return;
}

context.report({
node,
Expand Down

0 comments on commit eeafcc9

Please sign in to comment.