Skip to content

Commit 36632e3

Browse files
Port to TypeScript (#11)
Co-authored-by: Marcin Michalski <[email protected]>
1 parent 00ab57c commit 36632e3

19 files changed

+36195
-116
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[*.{js,ts,mjs}]
2+
indent_size = 2

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
node_modules/

.eslintrc.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
env:
2+
node: true
3+
es6: true
4+
5+
globals:
6+
Atomics: readonly
7+
SharedArrayBuffer: readonly
8+
9+
ignorePatterns:
10+
- '!.*'
11+
- '**/node_modules/.*'
12+
- '**/dist/.*'
13+
14+
parser: '@typescript-eslint/parser'
15+
16+
parserOptions:
17+
ecmaVersion: 2023
18+
sourceType: module
19+
project:
20+
- './tsconfig.json'
21+
22+
plugins:
23+
- '@typescript-eslint'
24+
25+
extends:
26+
- eslint:recommended
27+
- plugin:@typescript-eslint/eslint-recommended
28+
- plugin:@typescript-eslint/recommended
29+
- plugin:github/recommended
30+
31+
rules:
32+
{
33+
'camelcase': 'off',
34+
'eslint-comments/no-use': 'off',
35+
'eslint-comments/no-unused-disable': 'off',
36+
'import/no-namespace': 'off',
37+
'no-console': 'off',
38+
'i18n-text/no-en': 'off',
39+
'no-constant-condition': 'off',
40+
'@typescript-eslint/array-type': 'error',
41+
'@typescript-eslint/await-thenable': 'error',
42+
'@typescript-eslint/ban-ts-comment': 'error',
43+
'@typescript-eslint/consistent-type-assertions': 'error',
44+
'@typescript-eslint/explicit-member-accessibility': ['error', { 'accessibility': 'no-public' }],
45+
'@typescript-eslint/explicit-function-return-type': ['error', { 'allowExpressions': true }],
46+
'@typescript-eslint/func-call-spacing': ['error', 'never'],
47+
'@typescript-eslint/no-array-constructor': 'error',
48+
'@typescript-eslint/no-empty-interface': 'error',
49+
'@typescript-eslint/no-explicit-any': 'error',
50+
'@typescript-eslint/no-extraneous-class': 'error',
51+
'@typescript-eslint/no-for-in-array': 'error',
52+
'@typescript-eslint/no-inferrable-types': 'error',
53+
'@typescript-eslint/no-misused-new': 'error',
54+
'@typescript-eslint/no-namespace': 'error',
55+
'@typescript-eslint/no-non-null-assertion': 'warn',
56+
'@typescript-eslint/no-require-imports': 'error',
57+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
58+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
59+
'@typescript-eslint/no-unused-vars': 'error',
60+
'@typescript-eslint/no-useless-constructor': 'error',
61+
'@typescript-eslint/no-var-requires': 'error',
62+
'@typescript-eslint/prefer-for-of': 'warn',
63+
'@typescript-eslint/prefer-function-type': 'warn',
64+
'@typescript-eslint/prefer-includes': 'error',
65+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
66+
'@typescript-eslint/promise-function-async': 'error',
67+
'@typescript-eslint/require-array-sort-compare': 'error',
68+
'@typescript-eslint/restrict-plus-operands': 'error',
69+
'@typescript-eslint/semi': ['error', 'always'],
70+
'@typescript-eslint/type-annotation-spacing': 'error',
71+
'@typescript-eslint/unbound-method': 'error'
72+
}

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto eol=lf
2+
3+
dist/** -diff linguist-generated=true
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Verify built files are up to date
2+
on:
3+
pull_request:
4+
merge_group:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
check-dist:
11+
name: Check dist/
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
id: checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
id: setup-node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version-file: .node-version
24+
cache: npm
25+
26+
- name: Install Dependencies
27+
id: install
28+
run: npm ci
29+
30+
- name: Build dist/ Directory
31+
id: build
32+
run: npm run bundle
33+
34+
- name: Compare Directories
35+
id: diff
36+
run: |
37+
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
38+
echo "Detected uncommitted changes after build. See status below:"
39+
git diff --ignore-space-at-eol --text dist/
40+
exit 1
41+
fi

.github/workflows/lint.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Lint
2+
on:
3+
pull_request:
4+
merge_group:
5+
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-22.04
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
with:
13+
show-progress: false
14+
- name: Setup Node.js
15+
id: setup-node
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version-file: .node-version
19+
cache: npm
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
- name: Lint
24+
run: npm run lint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.6.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ jobs:
4949
| interval | The number of seconds in between polls of the GitHub API for check run conclusions. | No | `5` |
5050
| timeout | The number of seconds before the job is declared a failure if check runs have not yet concluded. | No | `300` |
5151
| name | The name of the Sloth's own check run. This is used to ensure Sloth does not wait upon itself. | No | `"sloth"` |
52-
| ignored | A comma separated list of check run names to ignore when determining an overall result. | No | `""` |
52+
| ignored | A multi-line list of check run names to ignore when determining an overall result. | No | `""` |

action.yml

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ inputs:
1111
description: "Git reference to inspect check runs for. The default supports Pull Requests, Merge Queues as well as branch pushes."
1212
required: false
1313
default: ${{ github.event.pull_request.head.sha || github.sha }}
14-
initial-delay:
15-
description: "The number of seconds in between polls of the GitHub API for check run conclusions."
16-
required: false
17-
default: "5"
1814
interval:
1915
description: "Interval in seconds between check of checks (default 5)"
2016
required: false
@@ -28,22 +24,9 @@ inputs:
2824
required: false
2925
default: "sloth"
3026
ignored:
31-
description: "A comma separated list of check run names to ignore when determining an overall result."
27+
description: "A multi-line list of check run names to ignore when determining an overall result."
3228
required: false
3329
default: ""
3430
runs:
35-
using: "composite"
36-
steps:
37-
- name: Await CI outcome
38-
id: sloth
39-
shell: bash
40-
run: |
41-
${GITHUB_ACTION_PATH}/bin/sloth.sh \
42-
${{ inputs.token }} \
43-
${{ inputs.ref }} \
44-
${{ github.repository }} \
45-
${{ inputs.initial-delay }} \
46-
${{ inputs.interval }} \
47-
${{ inputs.timeout }} \
48-
"${{ inputs.name }}" \
49-
"${{ inputs.ignored }}"
31+
using: node20
32+
main: dist/index.js

0 commit comments

Comments
 (0)