-
Notifications
You must be signed in to change notification settings - Fork 28
/
loom.config.ts
62 lines (58 loc) · 1.74 KB
/
loom.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import {createWorkspace, createWorkspaceTestPlugin} from '@shopify/loom';
import {buildLibraryWorkspace, babel} from '@shopify/loom-plugin-build-library';
import {eslint} from '@shopify/loom-plugin-eslint';
import {prettier} from '@shopify/loom-plugin-prettier';
import {stylelint} from '@shopify/loom-plugin-stylelint';
// Needed so TS realises what configuration hooks are provided by Jest (in `jestAdjustments` below)
import type {} from '@shopify/loom-plugin-jest';
// eslint-disable-next-line import/no-default-export
export default createWorkspace((workspace) => {
workspace.use(
buildLibraryWorkspace(),
eslint(),
prettier({files: '**/*.{json,md,yaml,yml}'}),
stylelint({files: '**/*.scss'}),
jestAdjustments(),
setupReact18(),
);
});
// Add root tests folder to jest config
function jestAdjustments() {
return createWorkspaceTestPlugin('WorkspaceTests', ({hooks}) => {
hooks.configure.hook((hooks) => {
hooks.jestConfig?.hook((config) => {
if (Array.isArray(config.projects)) {
config.projects.unshift({
// generating root based on package with index 1 (polaris-viz-core)
...(config.projects[1] as any),
displayName: 'root',
rootDir: 'tests',
});
}
return config;
});
});
});
}
export function setupReact18() {
return babel({
config(babelConfig) {
return {
...babelConfig,
presets: [
...(babelConfig.plugins || []),
[
'@shopify/babel-preset',
{
typescript: true,
react: true,
reactOptions: {
runtime: 'automatic',
},
},
],
],
};
},
});
}