fix(sonar): add localeCompare compare function to bare sort() calls (javascript:S2871)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9f78a1552f
commit
a60b7e555d
@ -7,7 +7,7 @@
|
||||
function _abCastMarkdown(data) {
|
||||
const payload = data || {};
|
||||
const segments = Array.isArray(payload.segments) ? payload.segments : [];
|
||||
const speakers = [...new Set(segments.filter(s => s?.type === 'dialogue' && s.speaker).map(s => String(s.speaker)))].sort();
|
||||
const speakers = [...new Set(segments.filter(s => s?.type === 'dialogue' && s.speaker).map(s => String(s.speaker)))].sort((a, b) => a.localeCompare(b));
|
||||
const lines = [`# ${payload.title || 'Cast Script'}`, ''];
|
||||
const metaBits = [];
|
||||
if (payload.savedAt) metaBits.push('exported ' + new Date(payload.savedAt).toISOString().slice(0, 16).replace('T', ' '));
|
||||
|
||||
@ -237,7 +237,7 @@ async function libraryRenderCharacters(opts) {
|
||||
container.appendChild(bar);
|
||||
|
||||
const searchQuery = inStudio ? '' : String(window._libCharsQuery || '').trim().toLowerCase();
|
||||
const bookNames = Object.keys(byBook).sort();
|
||||
const bookNames = Object.keys(byBook).sort((a, b) => a.localeCompare(b));
|
||||
const head = document.createElement('div');
|
||||
head.className = 'lib-chars-scope';
|
||||
if (inStudio) {
|
||||
@ -294,7 +294,7 @@ async function libraryRenderCharacters(opts) {
|
||||
|
||||
const productions = document.createDocumentFragment();
|
||||
let shownBands = 0;
|
||||
Object.keys(byBook).sort().forEach(function (book, bandIndex) {
|
||||
Object.keys(byBook).sort((a, b) => a.localeCompare(b)).forEach(function (book, bandIndex) {
|
||||
const chars = byBook[book].sort(_charSortCmp[sortMode] || _charSortCmp.tier);
|
||||
if (sortDir === 'desc') chars.reverse();
|
||||
// Narrator stays pinned first regardless of sort — same convention as
|
||||
|
||||
@ -335,7 +335,7 @@ function populateLibraryFilters() {
|
||||
const sexOrder = ['F','M','N'];
|
||||
const sexes = [...sexSet]
|
||||
.sort((a, b) => (sexOrder.indexOf(a) < 0 ? 99 : sexOrder.indexOf(a)) - (sexOrder.indexOf(b) < 0 ? 99 : sexOrder.indexOf(b)));
|
||||
const types = [...typeSet].sort();
|
||||
const types = [...typeSet].sort((a, b) => a.localeCompare(b));
|
||||
const tags = [...tagSet].sort((a, b) => a.localeCompare(b));
|
||||
const groups = [...groupSet].sort((a, b) => a.localeCompare(b));
|
||||
const sig = JSON.stringify([langs, sexes, types, tags, groups]);
|
||||
@ -3464,7 +3464,7 @@ function renderVoiceGroupsBar() {
|
||||
const g = (v.group || '').trim();
|
||||
if (g) groups[g] = (groups[g] || 0) + 1;
|
||||
});
|
||||
const names = Object.keys(groups).sort();
|
||||
const names = Object.keys(groups).sort((a, b) => a.localeCompare(b));
|
||||
if (!names.length) { bar.hidden = true; bar.innerHTML = ''; return; }
|
||||
bar.hidden = false;
|
||||
const active = window._voiceGroupFilter || '';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user