Skip to content

Commit 07d4123

Browse files
committed
chore: migrate from eslint to oxlint and update configurations
- Added .oxlintrc.json for oxlint configuration, disabling unused variable checks. - Removed eslint.config.js as it is no longer needed. - Updated package.json and package-lock.json to use oxlint and the latest dependencies. - Adjusted GitHub Actions workflow to reflect the change from eslint to oxlint. - Introduced new TypeScript files for setup and testing functionalities. - Updated TypeScript configurations in example exercises to include node types.
1 parent a76a693 commit 07d4123

16 files changed

Lines changed: 1888 additions & 2222 deletions

File tree

.github/workflows/validate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: npm run typecheck
3636
working-directory: ./workshop
3737

38-
- name: ESLint
38+
- name: Oxlint
3939
run: npm run lint
4040
working-directory: ./workshop
4141

@@ -60,7 +60,7 @@ jobs:
6060

6161
- name: 🧪 Run tests
6262
id: run_tests
63-
run: node ./epicshop/test.js ..s
63+
run: node ./epicshop/test.ts ..s
6464

6565
deploy:
6666
name: 🚀 Deploy

.oxlintrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": ["./node_modules/@epic-web/config/oxlint-config.json"],
3+
"rules": {
4+
"eslint/no-unused-vars": "off"
5+
}
6+
}
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import chokidar from 'chokidar'
44
import { $ } from 'execa'
55

66
const __dirname = path.dirname(fileURLToPath(import.meta.url))
7-
const here = (...p) => path.join(__dirname, ...p)
7+
const here = (...p: Array<string>) => path.join(__dirname, ...p)
88

99
const workshopRoot = here('..')
1010

1111
// Watch the exercises directory
1212
const watcher = chokidar.watch(path.join(workshopRoot, 'exercises'), {
1313
ignored: [
14-
/(^|[\/\\])\../, // ignore dotfiles
15-
(path) => {
14+
/(^|[/\\])\./, // ignore dotfiles
15+
(path: string) => {
1616
// Only watch directories up to depth 2
1717
const relativePath = path.slice(workshopRoot.length + 1)
1818
return relativePath.split('/').length > 4
@@ -26,20 +26,20 @@ const debouncedRun = debounce(run, 200)
2626

2727
// Add event listeners.
2828
watcher
29-
.on('addDir', (path) => {
29+
.on('addDir', (_path: string) => {
3030
debouncedRun()
3131
})
32-
.on('unlinkDir', (path) => {
32+
.on('unlinkDir', (_path: string) => {
3333
debouncedRun()
3434
})
35-
.on('error', (error) => console.log(`Watcher error: ${error}`))
35+
.on('error', (error: unknown) => console.log(`Watcher error: ${error}`))
3636

3737
/**
3838
* Simple debounce implementation
3939
*/
40-
function debounce(fn, delay) {
41-
let timer = null
42-
return (...args) => {
40+
function debounce(fn: (...args: Array<unknown>) => unknown, delay: number) {
41+
let timer: ReturnType<typeof setTimeout> | null = null
42+
return (...args: Array<unknown>) => {
4343
if (timer) clearTimeout(timer)
4444
timer = setTimeout(() => {
4545
fn(...args)
@@ -59,9 +59,7 @@ async function run() {
5959
await $({
6060
stdio: 'inherit',
6161
cwd: workshopRoot,
62-
})`node ./epicshop/fix.js`
63-
} catch (error) {
64-
throw error
62+
})`node ./epicshop/fix.ts`
6563
} finally {
6664
running = false
6765
}

epicshop/fix.js renamed to epicshop/fix.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
// This should run by node without any dependencies
22
// because you may need to run it without deps.
33

4-
import cp from 'node:child_process'
54
import fs from 'node:fs'
65
import path from 'node:path'
76
import { fileURLToPath } from 'node:url'
87

98
const __dirname = path.dirname(fileURLToPath(import.meta.url))
10-
const here = (...p) => path.join(__dirname, ...p)
11-
const VERBOSE = false
12-
const logVerbose = (...args) => (VERBOSE ? console.log(...args) : undefined)
9+
const here = (...p: Array<string>) => path.join(__dirname, ...p)
1310

1411
const workshopRoot = here('..')
1512
const examples = (await readDir(here('../examples'))).map(dir =>
@@ -44,7 +41,7 @@ const appsWithPkgJson = [...examples, ...apps].filter(app => {
4441
// e.g. exercises/01-goo/problem.01-great
4542
// name: "exercises__sep__01-goo.problem__sep__01-great"
4643

47-
function relativeToWorkshopRoot(dir) {
44+
function relativeToWorkshopRoot(dir: string) {
4845
return dir.replace(`${workshopRoot}${path.sep}`, '')
4946
}
5047

@@ -90,25 +87,25 @@ async function updateTsconfig() {
9087
}
9188
}
9289

93-
async function writeIfNeeded(filepath, content) {
90+
async function writeIfNeeded(filepath: string, content: string, _opts?: { parser: string }) {
9491
const oldContent = await fs.promises.readFile(filepath, 'utf8')
9592
if (oldContent !== content) {
9693
await fs.promises.writeFile(filepath, content)
9794
}
9895
return oldContent !== content
9996
}
10097

101-
function exists(p) {
98+
function exists(p: string) {
10299
if (!p) return false
103100
try {
104101
fs.statSync(p)
105102
return true
106-
} catch (error) {
103+
} catch {
107104
return false
108105
}
109106
}
110107

111-
async function readDir(dir) {
108+
async function readDir(dir: string) {
112109
if (exists(dir)) {
113110
return fs.promises.readdir(dir)
114111
}

0 commit comments

Comments
 (0)