aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-01-09 22:16:29 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-01-09 22:17:26 +0100
commitfb7118ff1c8f0dcd61f15e51b193512283d83fa1 (patch)
tree721cee6a64b44a56b7f05f39750a65cda5fb4ef6 /config
parentbuild: Add eslint-plugin-jest (diff)
downloadsophie-fb7118ff1c8f0dcd61f15e51b193512283d83fa1.tar.gz
sophie-fb7118ff1c8f0dcd61f15e51b193512283d83fa1.tar.zst
sophie-fb7118ff1c8f0dcd61f15e51b193512283d83fa1.zip
build: Add eslint-plugin-unicorn
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'config')
-rw-r--r--config/buildConstants.js10
-rw-r--r--config/fileURLToDirname.js10
-rw-r--r--config/fileUrlToDirname.js10
-rw-r--r--config/jest.config.base.js14
4 files changed, 22 insertions, 22 deletions
diff --git a/config/buildConstants.js b/config/buildConstants.js
index 3c55500..dfe2ab0 100644
--- a/config/buildConstants.js
+++ b/config/buildConstants.js
@@ -1,14 +1,14 @@
1import { readFileSync } from 'fs'; 1import { readFileSync } from 'node:fs';
2import { join } from 'path'; 2import path from 'node:path';
3 3
4import fileURLToDirname from './fileURLToDirname.js'; 4import fileUrlToDirname from './fileUrlToDirname.js';
5 5
6const thisDir = fileURLToDirname(import.meta.url); 6const thisDir = fileUrlToDirname(import.meta.url);
7 7
8// We import this from a vite config, where top-level await is not available (es2021), 8// We import this from a vite config, where top-level await is not available (es2021),
9// so we have to use the synchronous filesystem API. 9// so we have to use the synchronous filesystem API.
10const electronVendorsJson = readFileSync( 10const electronVendorsJson = readFileSync(
11 join(thisDir, '../.electron-vendors.cache.json'), 11 path.join(thisDir, '../.electron-vendors.cache.json'),
12 'utf8', 12 'utf8',
13); 13);
14 14
diff --git a/config/fileURLToDirname.js b/config/fileURLToDirname.js
deleted file mode 100644
index 70654cb..0000000
--- a/config/fileURLToDirname.js
+++ /dev/null
@@ -1,10 +0,0 @@
1import { dirname } from 'path';
2import { fileURLToPath } from 'url';
3
4/**
5 * @param {string} url
6 * @returns {string}
7 */
8export default function fileURLToDirname(url) {
9 return dirname(fileURLToPath(url));
10}
diff --git a/config/fileUrlToDirname.js b/config/fileUrlToDirname.js
new file mode 100644
index 0000000..9b51305
--- /dev/null
+++ b/config/fileUrlToDirname.js
@@ -0,0 +1,10 @@
1import path from 'node:path';
2import { fileURLToPath } from 'node:url';
3
4/**
5 * @param {string} url
6 * @returns {string}
7 */
8export default function fileUrlToDirname(url) {
9 return path.dirname(fileURLToPath(url));
10}
diff --git a/config/jest.config.base.js b/config/jest.config.base.js
index 21f93be..d9865f9 100644
--- a/config/jest.config.base.js
+++ b/config/jest.config.base.js
@@ -1,24 +1,24 @@
1import { join } from 'path'; 1import path from 'node:path';
2 2
3import fileURLToDirname from './fileURLToDirname.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, 'jestEsbuildTransformer.js'), 10 '\\.tsx?$': path.join(thisDir, 'jestEsbuildTransformer.js'),
11 }, 11 },
12 extensionsToTreatAsEsm: ['.ts', '.tsx'], 12 extensionsToTreatAsEsm: ['.ts', '.tsx'],
13 moduleNameMapper: { 13 moduleNameMapper: {
14 '^@sophie/(.+)$': join(thisDir, '../packages/$1/src/index.ts'), 14 '^@sophie/(.+)$': path.join(thisDir, '../packages/$1/src/index.ts'),
15 '^(\\.{1,2}/.*)\\.jsx?$': '$1', 15 '^(\\.{1,2}/.*)\\.jsx?$': '$1',
16 // Workaround for jest to recognize the vendored dependencies of chalk. 16 // Workaround for jest to recognize the vendored dependencies of chalk.
17 '^#ansi-styles$': join( 17 '^#ansi-styles$': path.join(
18 thisDir, 18 thisDir,
19 '../node_modules/chalk/source/vendor/ansi-styles/index.js', 19 '../node_modules/chalk/source/vendor/ansi-styles/index.js',
20 ), 20 ),
21 '^#supports-color$': join( 21 '^#supports-color$': path.join(
22 thisDir, 22 thisDir,
23 '../node_modules/chalk/source/vendor/supports-color/index.js', 23 '../node_modules/chalk/source/vendor/supports-color/index.js',
24 ), 24 ),