Skip to content

Commit

Permalink
build(csv-issues-esm): eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Aug 27, 2024
1 parent 9d62219 commit 4ea8efa
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 29 deletions.
13 changes: 13 additions & 0 deletions demo/issues-esm/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import globals from "globals";
import js from "@eslint/js";
import mocha from "eslint-plugin-mocha";
import prettier from "eslint-plugin-prettier/recommended";

export default [
{
languageOptions: { globals: { ...globals.node } },
},
js.configs.recommended,
mocha.configs.flat.recommended,
prettier,
];
26 changes: 15 additions & 11 deletions demo/issues-esm/labo/361-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ const interval = setInterval(() => {
const memoryData = process.memoryUsage();
const memoryUsage = {
rss: `${formatMemoryUsage(
memoryData.rss
memoryData.rss,
)} -> Resident Set Size - total memory allocated for the process execution`,
heapTotal: `${formatMemoryUsage(
memoryData.heapTotal
memoryData.heapTotal,
)} -> total size of the allocated heap`,
heapUsed: `${formatMemoryUsage(
memoryData.heapUsed
memoryData.heapUsed,
)} -> actual memory used during the execution`,
external: `${formatMemoryUsage(memoryData.external)} -> V8 external memory`,
};
Expand All @@ -65,10 +65,15 @@ const consume = new Writable({
count++;
callback();
} else {
setTimeout(() => {
count++;
callback();
}, config.random_delay ? Math.random() * config.write_delay : config.write_delay);
setTimeout(
() => {
count++;
callback();
},
config.random_delay
? Math.random() * config.write_delay
: config.write_delay,
);
}
},
});
Expand All @@ -88,11 +93,10 @@ await pipeline(
// Sync
// return JSON.stringify(chunk) + "\n"
// Async
return new Promise( (resolve) => {
return new Promise((resolve) => {
resolve(JSON.stringify(chunk) + "\n");
})

});
}),
// Step 3 - consume
consume
consume,
);
2 changes: 1 addition & 1 deletion demo/issues-esm/lib/298.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ console.log(
encoding: "utf8",
columns: camelCaseColumns,
trim: true,
})
}),
);
2 changes: 1 addition & 1 deletion demo/issues-esm/lib/298.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ assert.deepEqual(
[
{ A: "1", B: 2, C: "3" },
{ A: "4", B: 5, C: "6" },
]
],
);
2 changes: 1 addition & 1 deletion demo/issues-esm/lib/347.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ generate({
year: "birthYear",
phone: "phone",
},
})
}),
)
.pipe(ws);
8 changes: 4 additions & 4 deletions demo/issues-esm/lib/378.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const records = parse(result, {
header
? value
: column === "id"
? parseInt(value) // Cast inteter as number
: column === "value"
? !!value // Cast value as boolean
: value, // Don't cast additionnal fields
? parseInt(value) // Cast inteter as number
: column === "value"
? !!value // Cast value as boolean
: value, // Don't cast additionnal fields
});
assert.deepEqual(records, [
{ id: 1, value: false },
Expand Down
2 changes: 1 addition & 1 deletion demo/issues-esm/lib/381.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const records = parse(
'"1234567890AB","Works",123',
'"123456789012","Doesn\'t",123`',
].join("\n"),
{ columns: true, cast: true }
{ columns: true, cast: true },
);

console.log(records);
Expand Down
2 changes: 1 addition & 1 deletion demo/issues-esm/lib/411.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ await finished(outStream);
// Catch error from skip event
assert.deepStrictEqual(
errors.map((e) => e.message),
["Invalid Record Length: expect 5, got 6 on line 3"]
["Invalid Record Length: expect 5, got 6 on line 3"],
);
2 changes: 1 addition & 1 deletion demo/issues-esm/lib/415.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ await pipeline(
comment_no_infix: true,
}),
stringify({ delimiter: "|" }),
process.stdout
process.stdout,
);
2 changes: 1 addition & 1 deletion demo/issues-esm/lib/423.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ await pipeline(
}),
stringify({ delimiter: "|" }),
// process.stdout
new Writable({ write: (chunk, encoding, callback) => callback() })
new Writable({ write: (chunk, encoding, callback) => callback() }),
);
2 changes: 1 addition & 1 deletion demo/issues-esm/lib/436.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const [headers, ...records] = parse(
Image 2;Second image;200
Image 3;Third image;50
`,
{ delimiter: ";" }
{ delimiter: ";" },
);
console.info("headers", headers);
console.info("records", records);
Expand Down
12 changes: 6 additions & 6 deletions demo/issues-esm/lib/437-memory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'skip test'
"skip test";
// Issue #437
// Steady memory use increase when processing not so large files

Expand Down Expand Up @@ -37,13 +37,13 @@ const interval = setInterval(() => {
const memoryData = process.memoryUsage();
const memoryUsage = {
rss: `${formatMemoryUsage(
memoryData.rss
memoryData.rss,
)} -> Resident Set Size - total memory allocated for the process execution`,
heapTotal: `${formatMemoryUsage(
memoryData.heapTotal
memoryData.heapTotal,
)} -> total size of the allocated heap`,
heapUsed: `${formatMemoryUsage(
memoryData.heapUsed
memoryData.heapUsed,
)} -> actual memory used during the execution`,
external: `${formatMemoryUsage(memoryData.external)} -> V8 external memory`,
};
Expand All @@ -67,7 +67,7 @@ const consume = new Writable({
},
config.random_delay
? Math.random() * config.write_delay
: config.write_delay
: config.write_delay,
);
}
},
Expand All @@ -86,5 +86,5 @@ await pipeline(
// Step 3 - stringify records
stringify(),
// Step 4 - consume
consume
consume,
);
7 changes: 7 additions & 0 deletions demo/issues-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
"throw-deprecation": false,
"timeout": 40000
},
"lint-staged": {
"*.js": "npm run lint:fix",
"*.md": "prettier -w"
},
"scripts": {
"lint:check": "eslint",
"lint:fix": "eslint --fix",
"lint:ts": "tsc --noEmit true",
"test": "mocha 'test/**/*.coffee'"
},
"dependencies": {
Expand Down

0 comments on commit 4ea8efa

Please sign in to comment.