Skip to content

Commit 22dd25b

Browse files
authored
fix: use array.tosorted instead of array.sort (#3823)
## Proposed change Preserve immutability of arrays by using `Array.toSorted` instead of `Array.sort` so a copy is created instead of modifying the input ## Related issues <!-- Please make sure to follow the [contribution guidelines](https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md) --> *- No issue associated -* <!-- * 🐛 Fix #issue --> <!-- * 🐛 Fix resolves #issue --> <!-- * 🚀 Feature #issue --> <!-- * 🚀 Feature resolves #issue --> <!-- * :octocat: Pull Request #issue -->
2 parents b1197a0 + 8b57c3c commit 22dd25b

File tree

60 files changed

+160
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+160
-160
lines changed

apps/chrome-devtools/src/app-devtools/theming-panel/theming-panel-pres.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export class ThemingPanelPres {
236236
isPalette,
237237
defaultVariable
238238
}]);
239-
}, []).sort((a, b) => {
239+
}, []).toSorted((a, b) => {
240240
// Others should go at the end
241241
if (a.name === 'others') {
242242
return 1;

apps/github-cascading-app/src/cascading/cascading-probot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export class CascadingProbot extends Cascading {
253253
const { data } = await this.options.octokit.rest.pulls.list(this.options.repo);
254254
return data
255255
.filter(({ head, base }) => (!targetBranch || base.ref === targetBranch) && (!baseBranch || head.ref === baseBranch))
256-
.sort((prA, prB) => (Date.parse(prA.created_at) - Date.parse(prB.created_at)))
256+
.toSorted((prA, prB) => (Date.parse(prA.created_at) - Date.parse(prB.created_at)))
257257
.map((pr): CascadingPullRequestInfo => ({
258258
...pr,
259259
originBranchName: pr.head.ref,

apps/github-cascading-app/src/cascading/cascading.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export abstract class Cascading {
197197
}
198198
return true;
199199
})
200-
.sort((branchObjectA, branchObjectB) => {
200+
.toSorted((branchObjectA, branchObjectB) => {
201201
if (!branchObjectA.semver) {
202202
return 1;
203203
} else if (!branchObjectB.semver) {

apps/showcase/src/components/showcase/sdk/sdk-pres.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class SdkPres {
149149
this.isLoading.set(true);
150150
this.hasErrors.set(false);
151151
return this.petStoreApi.findPetsByStatus({ status: 'available' }).then((pets) => {
152-
this.pets.set(pets.filter((p) => p.category?.name === 'otter').sort((a, b) => (a.id && b.id && (a.id - b.id)) || 0));
152+
this.pets.set(pets.filter((p) => p.category?.name === 'otter').toSorted((a, b) => (a.id && b.id && (a.id - b.id)) || 0));
153153
this.isLoading.set(false);
154154
}).catch(() => {
155155
this.isLoading.set(false);

apps/showcase/tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"jsx": "react",
3737
"allowSyntheticDefaultImports": true,
3838
"lib": [
39-
"ES2022",
39+
"ES2024",
4040
"es6",
4141
"dom",
4242
"dom.iterable"

apps/vscode-extension/src/commands/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const getInfoFromWorkspaceJsonUris = async <T>(
5151
getInfo: (workspaceJsonUri: vscode.Uri) => Promise<T | undefined>
5252
) => {
5353
const workspaceJsonUris = await vscode.workspace.findFiles('{angular,nx}.json');
54-
const sortedWorkspaceJsonUris = workspaceJsonUris.sort(sortWorkspaceUris);
54+
const sortedWorkspaceJsonUris = workspaceJsonUris.toSorted(sortWorkspaceUris);
5555
for (const workspaceJsonUri of sortedWorkspaceJsonUris) {
5656
const infoFromWorkspace = await getInfo(workspaceJsonUri);
5757
if (infoFromWorkspace) {

packages/@ama-mcp/github/src/find-repositories-using-library/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ describe('Find repositories using library', () => {
192192
}]);
193193
expect(response.structuredContent).toEqual(expect.objectContaining({
194194
repositories: [
195-
'testOrg/repo1',
196-
'testOrg/repoCached'
195+
'testOrg/repoCached',
196+
'testOrg/repo1'
197197
]
198198
}));
199199
});

packages/@ama-mcp/github/src/find-repositories-using-library/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export function registerGetRepositoriesUsingLibraryTool(server: McpServer, optio
234234
text: (isLookingForRepos ? 'I did not finish to look for repositories. For the moment:\n' : '')
235235
+ reposUsingLibrary.length
236236
? `The following repositories use ${libraryName} dependencies:\n`
237-
+ reposUsingLibrary.sort().map((repo) => `- ${repo}`).join('\n')
237+
+ reposUsingLibrary.toSorted().map((repo) => `- ${repo}`).join('\n')
238238
: `No repositories found using ${libraryName} dependencies.`
239239
}
240240
],

packages/@ama-sdk/schematics/schematics/typescript/mock/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function ngGenerateMockFn(options: NgGenerateMockSchematicsSchema): Rule {
6666
if (!(new RegExp(`./${dasherizeModelName}/index`).test(currentComponentIndex))) {
6767
currentComponentIndex = `export * from './${dasherizeModelName}/index';\n` + currentComponentIndex;
6868
}
69-
currentComponentIndex = `${currentComponentIndex.split('\n').filter((e) => !!e).sort().join('\n')}\n`;
69+
currentComponentIndex = `${currentComponentIndex.split('\n').filter((e) => !!e).toSorted().join('\n')}\n`;
7070
tree.overwrite(barrelPath, currentComponentIndex);
7171
}
7272
return tree;

packages/@ama-sdk/schematics/schematics/typescript/shell/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('Typescript Shell Generator', () => {
109109
});
110110

111111
it('should generate basic SDK package', () => {
112-
expect(yarnTree.files.sort()).toEqual(baseFileList.sort());
112+
expect(yarnTree.files.toSorted()).toEqual(baseFileList.toSorted());
113113
});
114114

115115
it('should generate correct package name', () => {

0 commit comments

Comments
 (0)