Skip to content

Commit 2f6b157

Browse files
authored
Update development tooling (#634)
1 parent b30fc37 commit 2f6b157

File tree

217 files changed

+4746
-3164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+4746
-3164
lines changed

.eslintrc.js

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
module.exports = {
2-
extends: ['plugin:@sewing-kit/typescript', 'plugin:@sewing-kit/prettier'],
2+
extends: [
3+
'plugin:@shopify/typescript',
4+
'plugin:@shopify/jest',
5+
'plugin:@shopify/prettier',
6+
],
37
ignorePatterns: [
8+
'build/',
9+
'examples/',
410
'node_modules/',
5-
'**/build/',
11+
'packages/*/build/',
612
'packages/*/*.d.ts',
713
'packages/*/*.js',
814
'!packages/*/.eslintrc.js',
915
'packages/*/*.mjs',
1016
'packages/*/*.node',
1117
'packages/*/*.esnext',
12-
'examples/',
13-
'scripts/argo-admin/',
1418
],
1519
rules: {
16-
// Conflicts with prettier rule
17-
'lines-around-comment': 'off',
18-
// These are all removed in a resolution version of the typescript rules we have,
19-
// but are enabled in the shared config written against an older version.
20-
'@typescript-eslint/camelcase': 'off',
21-
'@typescript-eslint/ban-ts-ignore': 'off',
22-
'@typescript-eslint/class-name-casing': 'off',
20+
// Codebase was originally written without some strict Shopify conventions
21+
'import/order': 'off',
22+
'@typescript-eslint/naming-convention': 'off',
23+
24+
// This rule is just bad
25+
'@typescript-eslint/consistent-indexed-object-style': 'off',
2326
},
2427
overrides: [
2528
{
26-
files: ['sewing-kit.config.ts', 'config/sewing-kit/**/*'],
29+
files: ['loom.config.ts', 'config/loom/**/*'],
2730
rules: {
31+
// Doesn’t understand that loom dependencies come from the root package.json
2832
'import/no-extraneous-dependencies': 'off',
2933
},
3034
},
35+
{
36+
files: ['**/.eslintrc.js'],
37+
env: {node: true},
38+
},
3139
],
3240
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Prepare repo
2+
runs:
3+
using: 'composite'
4+
steps:
5+
- uses: actions/setup-node@v3
6+
name: Setup node.js and yarn
7+
with:
8+
cache: yarn
9+
node-version-file: '.nvmrc'
10+
11+
- name: Yarn install
12+
run: yarn install --frozen-lockfile
13+
shell: bash

.github/workflows/ci.yml

+23-86
Original file line numberDiff line numberDiff line change
@@ -5,80 +5,38 @@ on: [push]
55
jobs:
66
type-check:
77
runs-on: ubuntu-latest
8-
98
steps:
10-
- uses: actions/checkout@v1
11-
name: Checkout
12-
13-
- uses: actions/setup-node@v1
14-
name: Setup node.js and yarn
15-
with:
16-
node-version: 16.13.1
17-
18-
- name: Get yarn cache directory
19-
id: yarn-cache-get-dir
20-
run: echo "::set-output name=dir::$(yarn cache dir)"
21-
22-
- uses: actions/cache@v1
23-
id: yarn-cache
24-
name: Restore yarn cache
25-
with:
26-
path: ${{ steps.yarn-cache-get-dir.outputs.dir }}
27-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
28-
restore-keys: |
29-
${{ runner.os }}-yarn-
30-
31-
- name: Yarn install
32-
run: yarn install --frozen-lockfile
9+
- uses: actions/checkout@v3
10+
- uses: ./.github/workflows/actions/prepare
3311

34-
- uses: actions/cache@v1
35-
id: typescript-cache
12+
- id: typescript-cache
3613
name: Restore TypeScript cache
14+
uses: actions/cache@v1
3715
with:
38-
path: .sewing-kit/cache/typescript/
39-
key: ${{ runner.os }}-typescript-v5-${{ github.sha }}
16+
path: |
17+
packages/*/build/ts
18+
packages/*/build/*.tsbuildinfo
19+
key: ${{ runner.os }}-typescript-v1-${{ github.sha }}
4020
restore-keys: |
41-
${{ runner.os }}-typescript-v5-
21+
${{ runner.os }}-typescript-v1-
4222
4323
- name: Type check
4424
run: yarn type-check
4525

4626
test:
4727
runs-on: ubuntu-latest
48-
4928
steps:
50-
- uses: actions/checkout@v1
51-
name: Checkout
52-
53-
- uses: actions/setup-node@v1
54-
name: Setup node.js and yarn
55-
with:
56-
node-version: 16.13.1
57-
58-
- name: Get yarn cache directory
59-
id: yarn-cache-get-dir
60-
run: echo "::set-output name=dir::$(yarn cache dir)"
29+
- uses: actions/checkout@v3
30+
- uses: ./.github/workflows/actions/prepare
6131

62-
- uses: actions/cache@v1
63-
id: yarn-cache
64-
name: Restore yarn cache
65-
with:
66-
path: ${{ steps.yarn-cache-get-dir.outputs.dir }}
67-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
68-
restore-keys: |
69-
${{ runner.os }}-yarn-
70-
71-
- name: Yarn install
72-
run: yarn install --frozen-lockfile
73-
74-
- uses: actions/cache@v1
75-
id: jest-cache
32+
- id: jest-cache
7633
name: Restore jest cache
34+
uses: actions/cache@v1
7735
with:
78-
path: .sewing-kit/cache/jest/
79-
key: ${{ runner.os }}-jest-${{ github.sha }}
36+
path: .loom/cache/jest/
37+
key: ${{ runner.os }}-jest-v1-${{ github.sha }}
8038
restore-keys: |
81-
${{ runner.os }}-jest-
39+
${{ runner.os }}-jest-v1-
8240
8341
- name: Test
8442
run: yarn test
@@ -87,38 +45,17 @@ jobs:
8745
runs-on: ubuntu-latest
8846

8947
steps:
90-
- uses: actions/checkout@v1
91-
name: Checkout
92-
93-
- uses: actions/setup-node@v1
94-
name: Setup node.js and yarn
95-
with:
96-
node-version: 16.13.1
97-
98-
- name: Get yarn cache directory
99-
id: yarn-cache-get-dir
100-
run: echo "::set-output name=dir::$(yarn cache dir)"
101-
102-
- uses: actions/cache@v1
103-
id: yarn-cache
104-
name: Restore yarn cache
105-
with:
106-
path: ${{ steps.yarn-cache-get-dir.outputs.dir }}
107-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
108-
restore-keys: |
109-
${{ runner.os }}-yarn-
110-
111-
- name: Yarn install
112-
run: yarn install --frozen-lockfile
48+
- uses: actions/checkout@v3
49+
- uses: ./.github/workflows/actions/prepare
11350

114-
- uses: actions/cache@v1
115-
id: eslint-cache
51+
- id: eslint-cache
11652
name: Restore ESLint cache
53+
uses: actions/cache@v1
11754
with:
118-
path: .sewing-kit/cache/eslint
119-
key: ${{ runner.os }}-eslint-${{ github.sha }}
55+
path: .loom/cache/eslint
56+
key: ${{ runner.os }}-eslint-v1-${{ github.sha }}
12057
restore-keys: |
121-
${{ runner.os }}-eslint-
58+
${{ runner.os }}-eslint-v1-
12259
12360
- name: Lint
12461
run: yarn lint

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
2+
.loom
23
.sewing-kit
34
.DS_STORE
45
**/build

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
packages/*/build
3+
packages/web-pixels-extension/src/schemas/pixel-events.jtd.json

config/loom/index.ts

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {createComposedProjectPlugin, Package} from '@shopify/loom';
2+
import {buildLibrary, babel} from '@shopify/loom-plugin-build-library';
3+
4+
const PLUGIN = 'UiExtensions.DefaultProject';
5+
6+
export function defaultProjectPlugin({react = false} = {}) {
7+
return createComposedProjectPlugin<Package>(PLUGIN, [
8+
buildLibrary({
9+
commonjs: true,
10+
esmodules: true,
11+
esnext: true,
12+
targets: 'extends @shopify/browserslist-config, node 14.17.0',
13+
jestTestEnvironment: 'jsdom',
14+
}),
15+
babel({
16+
config: {
17+
presets: [
18+
[
19+
'@shopify/babel-preset',
20+
{
21+
typescript: true,
22+
react,
23+
reactOptions: react
24+
? {
25+
runtime: 'automatic',
26+
importSource: 'react',
27+
}
28+
: undefined,
29+
},
30+
],
31+
],
32+
},
33+
}),
34+
]);
35+
}

config/sewing-kit/index.ts

-67
This file was deleted.

config/typescript/tsconfig.admin.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
"downlevelIteration": true,
88
"resolveJsonModule": true,
99
"noUnusedLocals": false,
10-
"noImplicitAny": false,
10+
"noImplicitAny": false
1111
},
12-
"exclude": [
13-
"node_modules"
14-
]
12+
"exclude": ["node_modules"]
1513
}

config/typescript/tsconfig.base.json

+2-26
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,7 @@
11
{
2+
"extends": "@shopify/typescript-configs/library.json",
23
"compilerOptions": {
34
"composite": true,
4-
"declaration": true,
5-
"declarationMap": true,
6-
"pretty": true,
7-
"allowSyntheticDefaultImports": true,
8-
"esModuleInterop": true,
9-
"moduleResolution": "node",
10-
"module": "commonjs",
11-
"target": "es2017",
12-
"strict": true,
13-
"noImplicitAny": true,
14-
"noImplicitThis": true,
15-
"noUnusedLocals": true,
16-
"noUnusedParameters": true,
17-
"sourceMap": false,
18-
"noEmitOnError": false,
19-
"lib": [
20-
"dom",
21-
"dom.iterable",
22-
"es2015",
23-
"es2016",
24-
"es2017",
25-
"es2018",
26-
"esnext",
27-
"esnext.asynciterable"
28-
],
29-
"typeRoots": ["../../node_modules/@types", "./typings"]
5+
"emitDeclarationOnly": true
306
}
317
}

loom.config.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {createWorkspace} from '@shopify/loom';
2+
import {eslint} from '@shopify/loom-plugin-eslint';
3+
import {prettier} from '@shopify/loom-plugin-prettier';
4+
import {buildLibraryWorkspace} from '@shopify/loom-plugin-build-library';
5+
6+
export default createWorkspace((workspace) => {
7+
workspace.use(
8+
buildLibraryWorkspace(),
9+
eslint(),
10+
prettier({files: '**/*.{md,json,yaml,yml}'}),
11+
);
12+
});

0 commit comments

Comments
 (0)