chore: run format to resolve CI issues
This commit is contained in:
@@ -269,7 +269,7 @@ function hasTaggedStructure(data) {
|
|||||||
function normalizeTaskIds(tasks) {
|
function normalizeTaskIds(tasks) {
|
||||||
if (!Array.isArray(tasks)) return;
|
if (!Array.isArray(tasks)) return;
|
||||||
|
|
||||||
tasks.forEach(task => {
|
tasks.forEach((task) => {
|
||||||
// Convert task ID to number with validation
|
// Convert task ID to number with validation
|
||||||
if (task.id !== undefined) {
|
if (task.id !== undefined) {
|
||||||
const parsedId = parseInt(task.id, 10);
|
const parsedId = parseInt(task.id, 10);
|
||||||
@@ -280,7 +280,7 @@ function normalizeTaskIds(tasks) {
|
|||||||
|
|
||||||
// Convert subtask IDs to numbers with validation
|
// Convert subtask IDs to numbers with validation
|
||||||
if (Array.isArray(task.subtasks)) {
|
if (Array.isArray(task.subtasks)) {
|
||||||
task.subtasks.forEach(subtask => {
|
task.subtasks.forEach((subtask) => {
|
||||||
if (subtask.id !== undefined) {
|
if (subtask.id !== undefined) {
|
||||||
// Check for dot notation (which shouldn't exist in storage)
|
// Check for dot notation (which shouldn't exist in storage)
|
||||||
if (typeof subtask.id === 'string' && subtask.id.includes('.')) {
|
if (typeof subtask.id === 'string' && subtask.id.includes('.')) {
|
||||||
@@ -442,7 +442,10 @@ function readJSON(filepath, projectRoot = null, tag = null) {
|
|||||||
|
|
||||||
// Normalize IDs in all tags before storing as originalTaggedData
|
// Normalize IDs in all tags before storing as originalTaggedData
|
||||||
for (const tagName in originalTaggedData) {
|
for (const tagName in originalTaggedData) {
|
||||||
if (originalTaggedData[tagName] && Array.isArray(originalTaggedData[tagName].tasks)) {
|
if (
|
||||||
|
originalTaggedData[tagName] &&
|
||||||
|
Array.isArray(originalTaggedData[tagName].tasks)
|
||||||
|
) {
|
||||||
normalizeTaskIds(originalTaggedData[tagName].tasks);
|
normalizeTaskIds(originalTaggedData[tagName].tasks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,23 +26,31 @@ describe('Task Finder', () => {
|
|||||||
test('should find tasks when JSON contains string IDs (normalized to numbers)', () => {
|
test('should find tasks when JSON contains string IDs (normalized to numbers)', () => {
|
||||||
// Simulate tasks loaded from JSON with string IDs and mixed subtask notations
|
// Simulate tasks loaded from JSON with string IDs and mixed subtask notations
|
||||||
const tasksWithStringIds = [
|
const tasksWithStringIds = [
|
||||||
{ id: "1", title: 'First Task' },
|
{ id: '1', title: 'First Task' },
|
||||||
{ id: "2", title: 'Second Task', subtasks: [
|
{
|
||||||
{ id: "1", title: 'Subtask One' },
|
id: '2',
|
||||||
{ id: "2.2", title: 'Subtask Two (with dotted notation)' } // Testing dotted notation
|
title: 'Second Task',
|
||||||
]},
|
subtasks: [
|
||||||
{ id: "5", title: 'Fifth Task', subtasks: [
|
{ id: '1', title: 'Subtask One' },
|
||||||
{ id: "5.1", title: 'Subtask with dotted ID' }, // Should normalize to 1
|
{ id: '2.2', title: 'Subtask Two (with dotted notation)' } // Testing dotted notation
|
||||||
{ id: "3", title: 'Subtask with simple ID' } // Should stay as 3
|
]
|
||||||
]}
|
},
|
||||||
|
{
|
||||||
|
id: '5',
|
||||||
|
title: 'Fifth Task',
|
||||||
|
subtasks: [
|
||||||
|
{ id: '5.1', title: 'Subtask with dotted ID' }, // Should normalize to 1
|
||||||
|
{ id: '3', title: 'Subtask with simple ID' } // Should stay as 3
|
||||||
|
]
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
// The readJSON function should normalize these IDs to numbers
|
// The readJSON function should normalize these IDs to numbers
|
||||||
// For this test, we'll manually normalize them to simulate what happens
|
// For this test, we'll manually normalize them to simulate what happens
|
||||||
tasksWithStringIds.forEach(task => {
|
tasksWithStringIds.forEach((task) => {
|
||||||
task.id = parseInt(task.id, 10);
|
task.id = parseInt(task.id, 10);
|
||||||
if (task.subtasks) {
|
if (task.subtasks) {
|
||||||
task.subtasks.forEach(subtask => {
|
task.subtasks.forEach((subtask) => {
|
||||||
// Handle dotted notation like "5.1" -> extract the subtask part
|
// Handle dotted notation like "5.1" -> extract the subtask part
|
||||||
if (typeof subtask.id === 'string' && subtask.id.includes('.')) {
|
if (typeof subtask.id === 'string' && subtask.id.includes('.')) {
|
||||||
const parts = subtask.id.split('.');
|
const parts = subtask.id.split('.');
|
||||||
|
|||||||
Reference in New Issue
Block a user