Skip to content

Commit a265175

Browse files
committed
refactor: replace 'Array.from' with '[...]'
1 parent e084dfc commit a265175

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-nested-components.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,25 @@ export default createRule<[], MessageID>({
5858
...collector.listeners,
5959
...collectorLegacy.listeners,
6060
"Program:exit"(node) {
61-
const functionComponents = Array.from(collector.ctx.getAllComponents(node).values());
62-
const classComponents = Array.from(collectorLegacy.ctx.getAllComponents(node).values());
61+
const functionComponents = [
62+
...collector
63+
.ctx
64+
.getAllComponents(node)
65+
.values(),
66+
];
67+
const classComponents = [
68+
...collectorLegacy
69+
.ctx
70+
.getAllComponents(node)
71+
.values(),
72+
];
6373
const isFunctionComponent = (node: TSESTree.Node): node is AST.TSESTreeFunction => {
64-
return AST.isFunction(node) && functionComponents.some(component => component.node === node);
74+
return AST.isFunction(node)
75+
&& functionComponents.some(component => component.node === node);
6576
};
6677
const isClassComponent = (node: TSESTree.Node): node is AST.TSESTreeClass => {
67-
return AST.isClass(node) && classComponents.some(component => component.node === node);
78+
return AST.isClass(node)
79+
&& classComponents.some(component => component.node === node);
6880
};
6981
for (const { name: componentName, node: component } of functionComponents) {
7082
// Do not mark objects containing render methods

packages/plugins/eslint-plugin-react-x/src/rules/prefer-destructuring-assignment.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ export default createRule<[], MessageID>({
5151
},
5252

5353
"Program:exit"(node) {
54-
const components = Array.from(ctx.getAllComponents(node).values());
54+
const components = [
55+
...ctx
56+
.getAllComponents(node)
57+
.values(),
58+
];
5559
function isFunctionComponent(block: TSESTree.Node): block is AST.TSESTreeFunction {
5660
if (!AST.isFunction(block)) {
5761
return false;

scripts/build-used-by.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async function buildUsedByImage(users: string[]) {
7878

7979
const token = process.env["GITHUB_TOKEN"];
8080
const avatars = await Promise.all(projects.map(async (repo) => fetchGitHubAvatar(repo, token)));
81-
const avatarsDeDup = Array.from(new Set(avatars));
81+
const avatarsDeDup = [...new Set(avatars)];
8282
const img = await buildUsedByImage(avatarsDeDup);
8383
await fs.writeFile("website/assets/used_by.png", img);
8484
await fs.writeFile("website/public/used_by.png", img);

0 commit comments

Comments
 (0)