Skip to content

Commit 1b0f98a

Browse files
committed
fix(ci): add ESLint configuration and fix lint errors
- Add .eslintrc.json configuration file - Install eslint-plugin-jest dependency - Fix no-constant-condition error in listOrgRepos - Add explicit return type to SocialPreviewTemplate - Update test script to pass with no tests
1 parent b741675 commit 1b0f98a

5 files changed

Lines changed: 112 additions & 6 deletions

File tree

.eslintrc.json

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

package-lock.json

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"format:write": "npx prettier --write .",
1313
"format:check": "npx prettier --check .",
1414
"lint": "npx eslint src --ext .ts,.tsx",
15-
"test": "npx jest",
15+
"test": "npx jest --passWithNoTests",
1616
"all": "npm run format:write && npm run lint && npm run test && npm run build"
1717
},
1818
"engines": {
@@ -36,6 +36,7 @@
3636
"@typescript-eslint/eslint-plugin": "^8.16.0",
3737
"@typescript-eslint/parser": "^8.16.0",
3838
"eslint": "^8.0.1",
39+
"eslint-plugin-jest": "^29.12.1",
3940
"jest": "^29.7.0",
4041
"prettier": "3.4.1",
4142
"react": "^18.3.0",

src/github.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,31 @@ export class GitHubClient {
8282
let page = 1
8383
const perPage = 100
8484

85-
while (true) {
85+
let hasMore = true
86+
while (hasMore) {
8687
const { data } = await this.octokit.repos.listForOrg({
8788
org,
8889
type: 'public',
8990
per_page: perPage,
9091
page
9192
})
9293

93-
if (data.length === 0) break
94+
if (data.length === 0) {
95+
hasMore = false
96+
continue
97+
}
9498

9599
for (const repo of data) {
96100
if (!repo.archived) {
97101
repos.push(repo.name)
98102
}
99103
}
100104

101-
if (data.length < perPage) break
102-
page++
105+
if (data.length < perPage) {
106+
hasMore = false
107+
} else {
108+
page++
109+
}
103110
}
104111

105112
return repos.sort()

src/template.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react'
12
import type { RepoData } from './github.js'
23

34
// Brand colors
@@ -36,7 +37,7 @@ export function SocialPreviewTemplate({
3637
repo,
3738
logoFullBase64,
3839
calvinBase64
39-
}: TemplateProps) {
40+
}: TemplateProps): React.ReactElement {
4041
const repoUrl = `https://www.github.com/${repo.owner}/${repo.name}`
4142

4243
return (

0 commit comments

Comments
 (0)