Skip to content

Commit f9bbaf6

Browse files
committed
Fix: rename variables to improve readability.
1 parent c4bbe25 commit f9bbaf6

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

lib/rules/no-identical-tests.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,32 @@ module.exports = {
3636
*compare two test cases despite of properties order.
3737
*@returns {boolean} if eq, return true, else return false.
3838
*/
39-
function eq (ta, tb) {
40-
if (ta.type !== tb.type) {
39+
function eq (testA, testB) {
40+
if (testA.type !== testB.type) {
4141
return false;
4242
}
4343

44-
if (ta.type !== 'ObjectExpression') {
45-
return sourceCode.getText(ta) === sourceCode.getText(tb);
44+
if (testA.type !== 'ObjectExpression') {
45+
return sourceCode.getText(testA) === sourceCode.getText(testB);
4646
}
4747

48-
const pa = ta.properties || [];
49-
const pb = tb.properties || [];
48+
const propertiesA = testA.properties || [];
49+
const propertiesB = testB.properties || [];
5050

5151
// if properties length not eq; return false;
52-
if (pa.length !== pb.length) {
52+
if (propertiesA.length !== propertiesB.length) {
5353
return false;
5454
}
5555

56-
// convert array to object
57-
const paObj = Object.create(null);
58-
pa.forEach(item => {
56+
const propertiesSetA = new Set();
57+
propertiesA.forEach(item => {
5958
const code = sourceCode.getText(item);
60-
paObj[code] = true;
59+
propertiesSetA.add(code);
6160
});
6261

63-
for (let i = 0; i < pb.length; i++) {
64-
const code = sourceCode.getText(pb[i]);
65-
if (!paObj[code]) {
62+
for (let i = 0; i < propertiesB.length; i++) {
63+
const code = sourceCode.getText(propertiesB[i]);
64+
if (!propertiesSetA.has(code)) {
6665
return false;
6766
}
6867
}

0 commit comments

Comments
 (0)