Skip to content

Commit ee6e1be

Browse files
committedJan 16, 2023
[Refactor] minor performance refactors
1 parent 3cb966e commit ee6e1be

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed
 

‎scripts/copyMetafiles.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const files = [
88
'.nycrc',
99
];
1010

11-
const directories = [
11+
const directories = [].concat(
1212
'memo-parser',
13-
...resolverDirectories,
13+
resolverDirectories,
1414
'utils',
15-
];
15+
);
1616

1717
for (const directory of directories) {
1818
for (const file of files) {

‎src/rules/export.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ const tsTypePrefix = 'type:';
3737
*/
3838
function isTypescriptFunctionOverloads(nodes) {
3939
const nodesArr = Array.from(nodes);
40-
const types = new Set(nodesArr.map(node => node.parent.type));
4140

4241
const idents = flatMap(nodesArr, (node) => (
4342
node.declaration && (
@@ -51,6 +50,7 @@ function isTypescriptFunctionOverloads(nodes) {
5150
return true;
5251
}
5352

53+
const types = new Set(nodesArr.map(node => node.parent.type));
5454
if (!types.has('TSDeclareFunction')) {
5555
return false;
5656
}

‎src/rules/no-namespace.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,7 @@ function getVariableNamesInScope(scopeManager, node) {
144144
currentNode = currentNode.parent;
145145
scope = scopeManager.acquire(currentNode, true);
146146
}
147-
return new Set([
148-
...scope.variables.map(variable => variable.name),
149-
...scope.upper.variables.map(variable => variable.name),
150-
]);
147+
return new Set(scope.variables.concat(scope.upper.variables).map(variable => variable.name));
151148
}
152149

153150
/**

‎tests/src/rules/consistent-type-specifier-style.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,14 @@ context('TypeScript', () => {
367367
},
368368
});
369369
ruleTester.run('consistent-type-specifier-style', rule, {
370-
valid: [
371-
...COMMON_TESTS.valid,
372-
...TS_ONLY.valid,
373-
],
374-
invalid: [
375-
...COMMON_TESTS.invalid,
376-
...TS_ONLY.invalid,
377-
],
370+
valid: [].concat(
371+
COMMON_TESTS.valid,
372+
TS_ONLY.valid,
373+
),
374+
invalid: [].concat(
375+
COMMON_TESTS.invalid,
376+
TS_ONLY.invalid,
377+
),
378378
});
379379
});
380380

@@ -391,13 +391,13 @@ context('Babel/Flow', () => {
391391
},
392392
});
393393
ruleTester.run('consistent-type-specifier-style', rule, {
394-
valid: [
395-
...COMMON_TESTS.valid,
396-
...FLOW_ONLY.valid,
397-
],
398-
invalid: [
399-
...COMMON_TESTS.invalid,
400-
...FLOW_ONLY.invalid,
401-
],
394+
valid: [].concat(
395+
COMMON_TESTS.valid,
396+
FLOW_ONLY.valid,
397+
),
398+
invalid: [].concat(
399+
COMMON_TESTS.invalid,
400+
FLOW_ONLY.invalid,
401+
),
402402
});
403403
});

0 commit comments

Comments
 (0)