aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-01-08 21:36:43 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-01-09 19:53:03 +0100
commitd07e7b834831230b53860d0919a68edc2d36193d (patch)
treea1f2a021563ddff54f33341c475fc6c6eb787388 /config
parentNew configurations based on review comments (WIP) (diff)
downloadsophie-d07e7b834831230b53860d0919a68edc2d36193d.tar.gz
sophie-d07e7b834831230b53860d0919a68edc2d36193d.tar.zst
sophie-d07e7b834831230b53860d0919a68edc2d36193d.zip
build: Eslint fixes for multi-module project
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'config')
-rw-r--r--config/buildConstants.js4
-rw-r--r--config/fileURLToDirname.js (renamed from config/utils.js)2
-rw-r--r--config/getEsbuildConfig.js (renamed from config/esbuildConfig.js)2
-rw-r--r--config/jest.config.base.js4
-rw-r--r--config/jestEsbuildTransform.js23
-rw-r--r--config/jestEsbuildTransformer.js28
-rw-r--r--config/tsconfig.base.json19
7 files changed, 54 insertions, 28 deletions
diff --git a/config/buildConstants.js b/config/buildConstants.js
index 627c895..9083d78 100644
--- a/config/buildConstants.js
+++ b/config/buildConstants.js
@@ -1,7 +1,7 @@
1import { readFileSync } from 'fs'; 1import { readFileSync } from 'fs';
2import { join } from 'path'; 2import { join } from 'path';
3 3
4import { fileURLToDirname } from './utils.js'; 4import fileURLToDirname from './fileURLToDirname.js';
5 5
6const thisDir = fileURLToDirname(import.meta.url); 6const thisDir = fileURLToDirname(import.meta.url);
7 7
@@ -9,6 +9,8 @@ const thisDir = fileURLToDirname(import.meta.url);
9// so we have to use the synchronous filesystem API. 9// so we have to use the synchronous filesystem API.
10const electronVendorsJson = readFileSync(join(thisDir, '../.electron-vendors.cache.json'), 'utf8'); 10const electronVendorsJson = readFileSync(join(thisDir, '../.electron-vendors.cache.json'), 'utf8');
11 11
12/** @type {{ chrome: number; node: number; }} */
13// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
12const { chrome: chromeVersion, node: nodeVersion } = JSON.parse(electronVendorsJson); 14const { chrome: chromeVersion, node: nodeVersion } = JSON.parse(electronVendorsJson);
13 15
14/** @type {string} */ 16/** @type {string} */
diff --git a/config/utils.js b/config/fileURLToDirname.js
index d3e13d9..70654cb 100644
--- a/config/utils.js
+++ b/config/fileURLToDirname.js
@@ -5,6 +5,6 @@ import { fileURLToPath } from 'url';
5 * @param {string} url 5 * @param {string} url
6 * @returns {string} 6 * @returns {string}
7 */ 7 */
8export function fileURLToDirname(url) { 8export default function fileURLToDirname(url) {
9 return dirname(fileURLToPath(url)); 9 return dirname(fileURLToPath(url));
10} 10}
diff --git a/config/esbuildConfig.js b/config/getEsbuildConfig.js
index 93419fb..b338d68 100644
--- a/config/esbuildConfig.js
+++ b/config/getEsbuildConfig.js
@@ -15,7 +15,7 @@ const modeString = JSON.stringify(mode);
15 * @param {Record<string, unknown>} [extraMetaEnvVars] 15 * @param {Record<string, unknown>} [extraMetaEnvVars]
16 * @returns {import('esbuild').BuildOptions} 16 * @returns {import('esbuild').BuildOptions}
17 */ 17 */
18export function getConfig(config, extraMetaEnvVars) { 18export default function getEsbuildConfig(config, extraMetaEnvVars) {
19 return { 19 return {
20 logLevel: 'info', 20 logLevel: 'info',
21 bundle: true, 21 bundle: true,
diff --git a/config/jest.config.base.js b/config/jest.config.base.js
index 2ca021b..463e498 100644
--- a/config/jest.config.base.js
+++ b/config/jest.config.base.js
@@ -1,13 +1,13 @@
1import { join } from 'path'; 1import { join } from 'path';
2 2
3import { fileURLToDirname } from './utils.js'; 3import fileURLToDirname from './fileURLToDirname.js';
4 4
5const thisDir = fileURLToDirname(import.meta.url); 5const thisDir = fileURLToDirname(import.meta.url);
6 6
7/** @type {import('@jest/types').Config.InitialOptions} */ 7/** @type {import('@jest/types').Config.InitialOptions} */
8export default { 8export default {
9 transform: { 9 transform: {
10 '\\.tsx?$': join(thisDir, 'jestEsbuildTransform.js'), 10 '\\.tsx?$': join(thisDir, 'jestEsbuildTransformer.js'),
11 }, 11 },
12 extensionsToTreatAsEsm: [ 12 extensionsToTreatAsEsm: [
13 '.ts', 13 '.ts',
diff --git a/config/jestEsbuildTransform.js b/config/jestEsbuildTransform.js
deleted file mode 100644
index 4bf49e6..0000000
--- a/config/jestEsbuildTransform.js
+++ /dev/null
@@ -1,23 +0,0 @@
1import { transform } from 'esbuild';
2
3import { node } from './buildConstants.js';
4
5/** @type {import('@jest/transform').AsyncTransformer<undefined>} */
6const transformer = {
7 canInstrument: false,
8 async processAsync(source, filePath) {
9 const { code, map } = await transform(source, {
10 loader: filePath.endsWith('tsx') ? 'tsx' : 'ts',
11 sourcefile: filePath,
12 format: 'esm',
13 target: node,
14 sourcemap: true,
15 });
16 return {
17 code,
18 map,
19 };
20 },
21};
22
23export default transformer;
diff --git a/config/jestEsbuildTransformer.js b/config/jestEsbuildTransformer.js
new file mode 100644
index 0000000..b6f2fc3
--- /dev/null
+++ b/config/jestEsbuildTransformer.js
@@ -0,0 +1,28 @@
1import { transform } from 'esbuild';
2
3import { node } from './buildConstants.js';
4
5/**
6 * @param {string} source
7 * @param {import('@jest/types').Config.Path} filePath
8 * @return {Promise<import('@jest/transform').TransformedSource>}
9 */
10async function processAsync(source, filePath) {
11 const { code, map } = await transform(source, {
12 loader: filePath.endsWith('tsx') ? 'tsx' : 'ts',
13 sourcefile: filePath,
14 format: 'esm',
15 target: node,
16 sourcemap: true,
17 });
18 return {
19 code,
20 map,
21 };
22}
23
24/** @type {import('@jest/transform').AsyncTransformer<void>} */
25export default {
26 canInstrument: false,
27 processAsync,
28};
diff --git a/config/tsconfig.base.json b/config/tsconfig.base.json
new file mode 100644
index 0000000..255f334
--- /dev/null
+++ b/config/tsconfig.base.json
@@ -0,0 +1,19 @@
1{
2 "compilerOptions": {
3 "module": "esnext",
4 "target": "esnext",
5 "moduleResolution": "node",
6 "esModuleInterop": true,
7 "allowSyntheticDefaultImports": true,
8 "strict": true,
9 "noImplicitOverride": true,
10 "noImplicitReturns": true,
11 "exactOptionalPropertyTypes": true,
12 "isolatedModules": true,
13 "skipLibCheck": true,
14 "checkJs": true,
15 "lib": [
16 "esnext"
17 ]
18 }
19}