Skip to content

Commit 793476a

Browse files
ikreymeremma-sgShrinks99
authored
TypeScript Conversion! (#257)
- Update all of archiveweb.page to use TypeScript * Convert entire project to TS using some tools from https://github.com/stripe-archive/flow-to-typescript-codemod * Set up ESLint with rules from replaywebpage, and autofix a bunch of things * Run format + lint on all files * Remove checked-in built files * Replaces outdated node-sass with sass - Update dependencies to wabac.js 2.20.0 and awp-sw 0.5.0, also updated to TS - App: fixes for opening links in new window - Some improvements to embed viewer, additional customizations, additional event messages passed from iframe - Supersedes PR #228 --------- Co-authored-by: emma <hi@emma.cafe> Co-authored-by: Henry Wilkinson <henry@wilkinson.graphics>
1 parent 3e714ac commit 793476a

Some content is hidden

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

76 files changed

+12829
-7617
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
src/static/*
1+
static/*

.eslintrc.js

Lines changed: 98 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,100 @@
1+
/* eslint-env node */
2+
/** @type { import("eslint").Linter.Config } */
13
module.exports = {
2-
"env": {
3-
"browser": true,
4-
"es6": true,
5-
"webextensions": true
6-
},
7-
"extends": "eslint:recommended",
8-
"parserOptions": {
9-
"ecmaVersion": 2018,
10-
"sourceType": "module"
11-
},
12-
"rules": {
13-
"no-restricted-globals": [
14-
2,
15-
"event", "error"
16-
],
17-
"indent": [
18-
"error",
19-
2
20-
],
21-
"linebreak-style": [
22-
"error",
23-
"unix"
24-
],
25-
"quotes": [
26-
"error",
27-
"double"
28-
],
29-
"semi": [
30-
"error",
31-
"always"
32-
]
33-
}
4+
env: {
5+
browser: true,
6+
es6: true,
7+
webextensions: true,
8+
},
9+
extends: [
10+
"eslint:recommended",
11+
"plugin:@typescript-eslint/eslint-recommended",
12+
"plugin:wc/recommended",
13+
"plugin:lit/recommended",
14+
"prettier",
15+
],
16+
plugins: ["@typescript-eslint", "lit"],
17+
parser: "@typescript-eslint/parser",
18+
parserOptions: {
19+
project: ["./tsconfig.eslint.json"],
20+
tsconfigRootDir: __dirname,
21+
},
22+
root: true,
23+
rules: {
24+
/* start stylistic rules */
25+
"@typescript-eslint/adjacent-overload-signatures": "error",
26+
"@typescript-eslint/array-type": "error",
27+
"@typescript-eslint/consistent-type-imports": [
28+
"error",
29+
{
30+
fixStyle: "inline-type-imports",
31+
},
32+
],
33+
"@typescript-eslint/prefer-readonly": "warn",
34+
"@typescript-eslint/class-literal-property-style": ["warn", "getters"],
35+
"@typescript-eslint/consistent-generic-constructors": "error",
36+
"@typescript-eslint/consistent-type-assertions": "error",
37+
"@typescript-eslint/no-confusing-non-null-assertion": "warn",
38+
"@typescript-eslint/no-inferrable-types": "warn",
39+
"@typescript-eslint/non-nullable-type-assertion-style": "warn",
40+
"@typescript-eslint/prefer-for-of": "warn",
41+
// "@typescript-eslint/prefer-nullish-coalescing": "warn",
42+
"@typescript-eslint/prefer-optional-chain": "warn",
43+
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
44+
/* end stylistic rules */
45+
46+
/* start recommended rules */
47+
"no-restricted-globals": [2, "event", "error"],
48+
"@typescript-eslint/no-base-to-string": "warn",
49+
"@typescript-eslint/no-duplicate-enum-values": "error",
50+
"@typescript-eslint/no-duplicate-type-constituents": "warn",
51+
"@typescript-eslint/no-explicit-any": "warn",
52+
"@typescript-eslint/no-extra-non-null-assertion": "error",
53+
// "@typescript-eslint/no-floating-promises": "warn",
54+
"@typescript-eslint/no-for-in-array": "warn",
55+
"no-unused-vars": "off",
56+
"@typescript-eslint/no-unused-vars": [
57+
"warn",
58+
{
59+
argsIgnorePattern: "^_",
60+
varsIgnorePattern: "^_",
61+
destructuredArrayIgnorePattern: "^_",
62+
},
63+
],
64+
"no-implied-eval": "off",
65+
"@typescript-eslint/no-implied-eval": "error",
66+
"no-loss-of-precision": "off",
67+
"@typescript-eslint/no-loss-of-precision": "warn",
68+
"@typescript-eslint/no-misused-new": "error",
69+
"@typescript-eslint/no-misused-promises": [
70+
"error",
71+
{ checksVoidReturn: { arguments: false } },
72+
],
73+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
74+
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
75+
"@typescript-eslint/no-redundant-type-constituents": "warn",
76+
"@typescript-eslint/no-this-alias": "warn",
77+
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
78+
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
79+
// "@typescript-eslint/no-unsafe-argument": "warn",
80+
// "@typescript-eslint/no-unsafe-assignment": "warn",
81+
// "@typescript-eslint/no-unsafe-call": "warn",
82+
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
83+
"@typescript-eslint/no-unsafe-enum-comparison": "warn",
84+
// "@typescript-eslint/no-unsafe-member-access": "warn",
85+
// "@typescript-eslint/no-unsafe-return": "warn",
86+
"@typescript-eslint/prefer-as-const": "warn",
87+
"require-await": "off",
88+
"@typescript-eslint/require-await": "warn",
89+
"@typescript-eslint/restrict-template-expressions": "warn",
90+
"@typescript-eslint/unbound-method": "off",
91+
},
92+
ignorePatterns: [
93+
"ruffle/**/*",
94+
"build/**/*",
95+
"/sw.js",
96+
"/ui.js",
97+
"dist/**/*",
98+
],
99+
reportUnusedDisableDirectives: true,
34100
};

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ body:
88
id: version
99
attributes:
1010
label: ArchiveWeb.page Version
11-
description: "This can be found on the app home page under \"About\""
11+
description: 'This can be found on the app home page under "About"'
1212
placeholder: "v0.11.3"
1313
validations:
1414
required: true
@@ -20,7 +20,7 @@ body:
2020
"I was trying to archive a page however..."
2121
2222
Please submit any screenshots/videos that can be used to understand how to reproduce the issue. You can attach images by clicking this area to highlight it and then dragging files into the browser window.
23-
23+
2424
If something wasn't captured in the way you expect please include a link to the archived item if possible.
2525
validations:
2626
required: true

.github/ISSUE_TEMPLATE/feature-change.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ body:
2525
label: Requirements
2626
description: |
2727
Intended primarily for use by Webrecorder team, leave blank if unknown.
28-
28+
2929
List the outcomes of the feature being implemented without design or implementation details.
3030
placeholder: |
3131
1. Item metadata should show links to the collections that the item belongs to.
@@ -43,6 +43,6 @@ body:
4343
placeholder: |
4444
- [ ] Mockups:
4545
- [ ] Design:
46-
- [ ] UI:
46+
- [ ] UI:
4747
validations:
4848
required: false

.github/workflows/buildapp.yaml

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -48,53 +48,52 @@ jobs:
4848
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4949

5050
run: |
51-
if [ "$GITHUB_REF" == "refs/heads/main" ] || [ -f ./force_release ]; then
52-
export YARN_BUILD_CMD="release"
53-
else
54-
export YARN_BUILD_CMD="dist"
55-
fi
51+
if [ "$GITHUB_REF" == "refs/heads/main" ] || [ -f ./force_release ]; then
52+
export YARN_BUILD_CMD="release"
53+
else
54+
export YARN_BUILD_CMD="dist"
55+
fi
5656
57-
if [ "$RUNNER_OS" == "Linux" ]; then
58-
if [ "$PLATFORM" == "linux" ]; then
59-
#mkdir -p plugins-linux;
60-
#pushd plugins-linux;
61-
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/libpepflashplayer.so";
62-
#popd;
57+
if [ "$RUNNER_OS" == "Linux" ]; then
58+
if [ "$PLATFORM" == "linux" ]; then
59+
#mkdir -p plugins-linux;
60+
#pushd plugins-linux;
61+
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/libpepflashplayer.so";
62+
#popd;
6363
64-
docker run --rm \
65-
-e GH_TOKEN=${GH_TOKEN} \
66-
-e YARN_BUILD_CMD=${YARN_BUILD_CMD} \
67-
-v ${PWD}:/project \
68-
-v ~/.cache/electron:/root/.cache/electron \
69-
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
70-
electronuserland/builder:16-wine \
71-
/bin/bash -c "yarn --link-duplicates --pure-lockfile --ignore-engines install && yarn run $YARN_BUILD_CMD --linux --x64"
72-
else
73-
#mkdir -p plugins-win;
74-
#pushd plugins-win;
75-
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/pepflashplayer-x86_64.dll";
76-
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/pepflashplayer-x86.dll";
77-
#popd;
64+
docker run --rm \
65+
-e GH_TOKEN=${GH_TOKEN} \
66+
-e YARN_BUILD_CMD=${YARN_BUILD_CMD} \
67+
-v ${PWD}:/project \
68+
-v ~/.cache/electron:/root/.cache/electron \
69+
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
70+
electronuserland/builder:16-wine \
71+
/bin/bash -c "yarn --link-duplicates --pure-lockfile --ignore-engines install && yarn run $YARN_BUILD_CMD --linux --x64"
72+
else
73+
#mkdir -p plugins-win;
74+
#pushd plugins-win;
75+
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/pepflashplayer-x86_64.dll";
76+
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/pepflashplayer-x86.dll";
77+
#popd;
7878
79-
docker run --rm \
80-
-e GH_TOKEN=${GH_TOKEN} \
81-
-e WIN_CSC_LINK=${WIN_CSC_LINK} \
82-
-e WIN_CSC_KEY_PASSWORD=${WIN_CSC_KEY_PASSWORD} \
83-
-e YARN_BUILD_CMD=${YARN_BUILD_CMD} \
84-
-v ${PWD}:/project \
85-
-v ~/.cache/electron:/root/.cache/electron \
86-
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
87-
electronuserland/builder:16-wine \
88-
/bin/bash -c "yarn --link-duplicates --pure-lockfile --ignore-engines install && yarn run $YARN_BUILD_CMD --win --x64 --ia32"
89-
fi
90-
else
91-
#mkdir -p plugins-mac;
92-
#pushd plugins-mac;
93-
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/PepperFlashPlayer.plugin.zip";
94-
#unzip PepperFlashPlayer.plugin.zip;
95-
#rm PepperFlashPlayer.plugin.zip;
96-
#popd;
97-
yarn --link-duplicates --pure-lockfile --ignore-engines install
98-
yarn run $YARN_BUILD_CMD
99-
fi
100-
79+
docker run --rm \
80+
-e GH_TOKEN=${GH_TOKEN} \
81+
-e WIN_CSC_LINK=${WIN_CSC_LINK} \
82+
-e WIN_CSC_KEY_PASSWORD=${WIN_CSC_KEY_PASSWORD} \
83+
-e YARN_BUILD_CMD=${YARN_BUILD_CMD} \
84+
-v ${PWD}:/project \
85+
-v ~/.cache/electron:/root/.cache/electron \
86+
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
87+
electronuserland/builder:16-wine \
88+
/bin/bash -c "yarn --link-duplicates --pure-lockfile --ignore-engines install && yarn run $YARN_BUILD_CMD --win --x64 --ia32"
89+
fi
90+
else
91+
#mkdir -p plugins-mac;
92+
#pushd plugins-mac;
93+
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/PepperFlashPlayer.plugin.zip";
94+
#unzip PepperFlashPlayer.plugin.zip;
95+
#rm PepperFlashPlayer.plugin.zip;
96+
#popd;
97+
yarn --link-duplicates --pure-lockfile --ignore-engines install
98+
yarn run $YARN_BUILD_CMD
99+
fi

.github/workflows/buildext.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
- name: Install Node.js, NPM and Yarn
1717
uses: actions/setup-node@v3
1818
with:
19-
node-version: '18.x'
20-
cache: 'yarn'
19+
node-version: "18.x"
20+
cache: "yarn"
2121

2222
- name: Yarn Install
2323
run: yarn install --frozen-lockfile

.github/workflows/npm-release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
- uses: actions/checkout@v3
1111
- uses: actions/setup-node@v3
1212
with:
13-
node-version: '18.x'
14-
registry-url: 'https://registry.npmjs.org'
15-
cache: 'yarn'
13+
node-version: "18.x"
14+
registry-url: "https://registry.npmjs.org"
15+
cache: "yarn"
1616

1717
- name: Yarn Install
1818
run: yarn install --frozen-lockfile

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
!examples/*.warc
55
**/node_modules
66
.DS_Store
7-
!dist/embed/*
8-
7+
dist

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
LICENSE.md
2+
static/*

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"esbenp.prettier-vscode",
5+
"runem.lit-plugin",
6+
"streetsidesoftware.code-spell-checker"
7+
]
8+
}

0 commit comments

Comments
 (0)