Skip to content

Commit

Permalink
Merge branch 'FYLE-86cv5nv0n' of github.com:fylein/fyle-mobile-app in…
Browse files Browse the repository at this point in the history
…to FYLE-86cv5nv19
  • Loading branch information
suyashpatil78 committed Apr 29, 2024
2 parents 7b084f0 + 37b3443 commit 630e384
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions eslint-custom-rules/rules/eslint-plugin-prefer-deep-freeze.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module.exports = {

if (filename.endsWith('.data.ts')) {
const { id, init } = node;

if (id && init && init.type === 'ObjectExpression') {
if (id && init && (init.type === 'ObjectExpression' || init.type === 'ArrayExpression')) {
const fix = (fixer) => {
const variableText = sourceCode.getText(init);
const start = init.range[0];
Expand All @@ -39,7 +39,7 @@ module.exports = {
);
}

// Wrap the object with deepFreeze method
// Wrap the object or array with deepFreeze method
fixes.push(
fixer.replaceTextRange(
[start, end],
Expand All @@ -50,11 +50,13 @@ module.exports = {
return fixes;
};

context.report({
node,
message: `Use deep-freeze-strict function on variable "${id.name} to avoid flaky tests"`,
fix,
});
if (init.type === 'ObjectExpression' || init.type === 'ArrayExpression') {
context.report({
node,
message: `Use deep-freeze-strict function on variable "${id.name}" to avoid flaky tests`,
fix,
});
}
}
}
},
Expand Down

0 comments on commit 630e384

Please sign in to comment.