Skip to content

Commit 18bcb8a

Browse files
43081jdanielroe
andauthored
chore: add e18e lint plugin (#1019)
Co-authored-by: Daniel Roe <daniel@roe.dev>
1 parent 26f139b commit 18bcb8a

File tree

10 files changed

+72
-56
lines changed

10 files changed

+72
-56
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ jobs:
3333

3434
- uses: pnpm/action-setup@1e1c8eafbd745f64b1ef30a7d7ed7965034c486c # 1e1c8eafbd745f64b1ef30a7d7ed7965034c486c
3535
name: 🟧 Install pnpm
36-
# pnpm cache skipped deliberately as the project is not actually installed here
36+
with:
37+
cache: true
38+
39+
- name: 📦 Install dependencies (root only, no scripts)
40+
run: pnpm install --filter . --ignore-scripts
3741

3842
- name: 🔠 Lint project
39-
run: node scripts/lint.ts
43+
run: pnpm lint
4044

4145
types:
4246
name: 💪 Type check

.oxlintrc.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://unpkg.com/oxlint/configuration_schema.json",
33
"plugins": ["unicorn", "typescript", "oxc", "vue", "vitest"],
4+
"jsPlugins": ["@e18e/eslint-plugin"],
45
"categories": {
56
"correctness": "error",
67
"suspicious": "warn",
@@ -11,8 +12,27 @@
1112
"no-await-in-loop": "off",
1213
"unicorn/no-array-sort": "off",
1314
"no-restricted-globals": "error",
14-
"typescript/consistent-type-imports": "error"
15+
"typescript/consistent-type-imports": "error",
16+
"e18e/prefer-array-from-map": "error",
17+
"e18e/prefer-timer-args": "error",
18+
"e18e/prefer-date-now": "error",
19+
"e18e/prefer-regex-test": "error",
20+
"e18e/prefer-array-some": "error"
1521
},
22+
"overrides": [
23+
{
24+
"files": [
25+
"server/**/*",
26+
"cli/**/*",
27+
"scripts/**/*",
28+
"modules/**/*",
29+
"app/components/OgImage/*"
30+
],
31+
"rules": {
32+
"no-console": "off"
33+
}
34+
}
35+
],
1636
"ignorePatterns": [
1737
".output/**",
1838
".data/**",

knip.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ const config: KnipConfig = {
3939

4040
/** Some components import types from here, but installing it directly could lead to a version mismatch */
4141
'vue-router',
42+
43+
/** Oxlint plugins don't get picked up yet */
44+
'@e18e/eslint-plugin',
4245
],
4346
ignoreUnresolved: ['#components', '#oauth/config'],
4447
},

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
"vue-data-ui": "3.14.7"
102102
},
103103
"devDependencies": {
104+
"@e18e/eslint-plugin": "0.1.4",
104105
"@intlify/core-base": "11.2.8",
105106
"@npm/types": "2.1.0",
106107
"@playwright/test": "1.58.1",

pnpm-lock.yaml

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

scripts/lint.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

server/api/atproto/author-profiles.get.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ export default defineCachedEventHandler(
4949

5050
if (handles.length === 0) {
5151
return {
52-
authors: authors.map(author => ({
53-
...author,
54-
avatar: null,
55-
profileUrl: null,
56-
})),
52+
authors: authors.map(author => Object.assign(author, { avatar: null, profileUrl: null })),
5753
}
5854
}
5955

@@ -68,11 +64,14 @@ export default defineCachedEventHandler(
6864
}
6965
}
7066

71-
const resolvedAuthors: ResolvedAuthor[] = authors.map(author => ({
72-
...author,
73-
avatar: author.blueskyHandle ? avatarMap.get(author.blueskyHandle) || null : null,
74-
profileUrl: author.blueskyHandle ? `https://bsky.app/profile/${author.blueskyHandle}` : null,
75-
}))
67+
const resolvedAuthors: ResolvedAuthor[] = authors.map(author =>
68+
Object.assign(author, {
69+
avatar: author.blueskyHandle ? avatarMap.get(author.blueskyHandle) || null : null,
70+
profileUrl: author.blueskyHandle
71+
? `https://bsky.app/profile/${author.blueskyHandle}`
72+
: null,
73+
}),
74+
)
7675

7776
return { authors: resolvedAuthors }
7877
},

server/utils/dependency-analysis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const analyzeDependencyTree = defineCachedFunction(
179179
const resolved = await resolveDependencyTree(name, version, { trackDepth: true })
180180

181181
// Convert to array with query info
182-
const packages: PackageQueryInfo[] = [...resolved.values()].map(pkg => ({
182+
const packages: PackageQueryInfo[] = Array.from(resolved.values(), pkg => ({
183183
name: pkg.name,
184184
version: pkg.version,
185185
depth: pkg.depth!,

server/utils/readme.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,14 @@ function resolveImageUrl(url: string, packageName: string, repoInfo?: Repository
264264
return resolved
265265
}
266266

267+
// Helper to prefix id attributes with 'user-content-'
268+
function prefixId(tagName: string, attribs: sanitizeHtml.Attributes) {
269+
if (attribs.id && !attribs.id.startsWith('user-content-')) {
270+
attribs.id = `user-content-${attribs.id}`
271+
}
272+
return { tagName, attribs }
273+
}
274+
267275
export async function renderReadmeHtml(
268276
content: string,
269277
packageName: string,
@@ -398,14 +406,6 @@ ${html}
398406

399407
const rawHtml = marked.parse(content) as string
400408

401-
// Helper to prefix id attributes with 'user-content-'
402-
const prefixId = (tagName: string, attribs: sanitizeHtml.Attributes) => {
403-
if (attribs.id && !attribs.id.startsWith('user-content-')) {
404-
attribs.id = `user-content-${attribs.id}`
405-
}
406-
return { tagName, attribs }
407-
}
408-
409409
const sanitized = sanitizeHtml(rawHtml, {
410410
allowedTags: ALLOWED_TAGS,
411411
allowedAttributes: ALLOWED_ATTR,

test/e2e/test-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ async function handleJsdelivrCdn(route: Route): Promise<boolean> {
313313
const pathname = decodeURIComponent(url.pathname)
314314

315315
// README file requests - return 404 (package pages work fine without README)
316-
if (pathname.match(/readme/i)) {
316+
if (/readme/i.test(pathname)) {
317317
await route.fulfill({ status: 404, body: 'Not found' })
318318
return true
319319
}

0 commit comments

Comments
 (0)