Skip to content

Commit 1badd6a

Browse files
committed
ref: set checkJs globally to true
1 parent 7a2d7f0 commit 1badd6a

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

eslint.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-check
21
/**
32
* To get started with this ESLint Configuration list be sure to read at least
43
* these sections of the docs:
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
'use strict';
22

3+
// @ts-expect-error csv-parser has no types
34
const csv = require('csv-parser');
45
const fs = require('node:fs');
56

7+
/**
8+
* Transform CSV results into device mapping object
9+
* @param {Array<{name: string, model: string}>} res - Array of device objects
10+
* @returns {Record<string, string>} Device mapping where key is model and value is name
11+
*/
612
const transformResults = res => {
13+
/** @type {Record<string, string>} */
714
const deviceMapping = {};
815
res.forEach(({name, model}) => {
916
if (name && model) {
@@ -12,10 +19,11 @@ const transformResults = res => {
1219
});
1320
return deviceMapping;
1421
};
22+
/** @type {Array<{name: string, model: string}>} */
1523
const results = [];
1624
fs.createReadStream('supported_devices.csv')
1725
.pipe(csv())
18-
.on('data', data => results.push(data))
26+
.on('data', /** @param {any} data */ data => results.push(data))
1927
.on('end', () => {
2028
fs.writeFileSync('devices.json', JSON.stringify(transformResults(results)));
2129
});

tests/js/jest-pegjs-transform.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
const nodeCrypto = require('node:crypto');
44
const peggy = require('peggy');
55

6+
/**
7+
* Generate cache key for Jest transformer
8+
* @param {string} fileData - The file content to transform
9+
* @param {string} _filePath - Path to the file (unused)
10+
* @param {Object} config - Jest configuration object
11+
* @param {string} config.configString - Stringified Jest config
12+
* @param {Object} _options - Transform options (unused)
13+
* @returns {string} MD5 hash for cache key
14+
*/
615
function getCacheKey(fileData, _filePath, config, _options) {
716
return nodeCrypto
817
.createHash('md5')
@@ -11,6 +20,11 @@ function getCacheKey(fileData, _filePath, config, _options) {
1120
.digest('hex');
1221
}
1322

23+
/**
24+
* Transform PEG.js grammar file into JavaScript module
25+
* @param {string} sourceText - The PEG.js grammar source code
26+
* @returns {{code: string}} Transform result with generated JavaScript module code
27+
*/
1428
function process(sourceText) {
1529
return {
1630
code: `module.exports = ${peggy.generate(sourceText, {output: 'source'})}`,

tests/js/test-balancer/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@
33
const fs = require('node:fs');
44
const path = require('node:path');
55

6+
/**
7+
* Jest balance reporter that writes test timing data to a JSON file
8+
* @param {Object} results - Jest test results object
9+
* @param {boolean} results.success - Whether all tests passed
10+
* @param {Array<{testFilePath: string, perfStats: {runtime: number}}>} results.testResults - Array of test result objects
11+
* @returns {Object} The original results object
12+
*/
613
module.exports = results => {
714
if (!results.success) {
815
throw new Error('Balance reporter requires all tests to succeed.');
916
}
1017

1118
const cwd = process.cwd();
19+
/** @type {Record<string, number>} */
1220
const testValues = {};
1321

1422
for (const test of results.testResults) {

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "./config/tsconfig.base.json",
33
"compilerOptions": {
4-
"allowJs": true
4+
"allowJs": true,
5+
"checkJs": true,
56
},
67
"include": [
78
"*.config.mjs",

0 commit comments

Comments
 (0)