Skip to content

Commit 357f613

Browse files
JakubAndrysekurish
authored andcommitted
chore: update ESLint configuration and improve project setup
- Removed the legacy .eslintignore file and integrated ignore patterns into the new TypeScript-based ESLint configuration. - Added a new eslint.config.ts file to define ESLint rules and settings for TypeScript and JavaScript files. - Updated package.json to change the CLI command to use tsx for execution and adjusted devDependencies for ESLint and TypeScript. - Modified GitHub workflows to use pnpm for dependency management and updated Node.js version to 24. - Enhanced tsconfig.json to include additional TypeScript files and exclude unnecessary directories. - Refactored various source files to improve code quality and maintainability.
1 parent e287f86 commit 357f613

File tree

15 files changed

+289
-1559
lines changed

15 files changed

+289
-1559
lines changed

.eslintignore

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

.github/workflows/cli-integration-test.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ jobs:
1515
- name: Checkout repository
1616
uses: actions/checkout@v4
1717

18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v4
20+
1821
- name: Setup Node.js
1922
uses: actions/setup-node@v4
2023
with:
21-
node-version: '20'
22-
cache: 'npm'
24+
node-version: '20.x'
25+
cache: 'pnpm'
2326

2427
- name: Install dependencies
25-
run: npm ci
28+
run: pnpm install --frozen-lockfile
2629

2730
- name: Build CLI
28-
run: npm run build
31+
run: pnpm run build
2932

3033
- name: Clone test project
3134
run: git clone https://github.com/wokwi/esp-idf-hello-world.git test-project
@@ -40,10 +43,10 @@ jobs:
4043
steps:
4144
- name: "Wait for boot and hello message"
4245
wait-serial: "Hello world!"
43-
44-
- name: "Wait for chip information"
46+
47+
- name: "Wait for chip information"
4548
wait-serial: "This is esp32 chip"
46-
49+
4750
- name: "Wait for restart message"
4851
wait-serial: "Restarting in 10 seconds"
4952
EOF
@@ -52,12 +55,11 @@ jobs:
5255
uses: wokwi/wokwi-ci-server-action@v1
5356

5457
- name: Test CLI with basic expect-text
55-
run: npm start -- test-project --timeout 5000 --expect-text "Hello"
58+
run: pnpm cli test-project --timeout 5000 --expect-text "Hello"
5659
env:
5760
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
5861

5962
- name: Test CLI with scenario file
60-
run: npm start -- test-project --scenario test-scenario.yaml --timeout 15000
63+
run: pnpm cli test-project --scenario test-scenario.yaml --timeout 15000
6164
env:
6265
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
63-

.github/workflows/release.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12-
- name: 'Install NPM dependencies'
13-
run: npm ci
12+
- name: 'Install pnpm'
13+
uses: pnpm/action-setup@v4
14+
- name: 'Setup Node.js'
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: '20.x'
18+
cache: 'pnpm'
19+
- name: 'Install dependencies'
20+
run: pnpm install --frozen-lockfile
1421
- name: 'Install LDID'
1522
run: |
1623
wget -O /usr/local/bin/ldid https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_linux_x86_64
@@ -20,7 +27,7 @@ jobs:
2027
sudo apt-get update
2128
sudo apt-get install -y binfmt-support qemu-user-static
2229
- name: 'Build'
23-
run: npm run package
30+
run: pnpm run package
2431
- name: Upload Release
2532
uses: ncipollo/release-action@v1
2633
with:

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ jobs:
1111
runs-on: ubuntu-24.04
1212
steps:
1313
- uses: actions/checkout@v4
14+
- name: Install pnpm
15+
uses: pnpm/action-setup@v4
1416
- name: Use Node.js
1517
uses: actions/setup-node@v4
1618
with:
1719
node-version: '20.x'
20+
cache: 'pnpm'
1821
- name: Install dependencies
19-
run: npm ci
22+
run: pnpm install --frozen-lockfile
2023
- name: Run tests
21-
run: npm test
24+
run: pnpm test

eslint.config.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { defineConfig } from 'eslint/config';
2+
import eslint from '@eslint/js';
3+
import eslintConfigPrettier from 'eslint-config-prettier';
4+
import tseslint from 'typescript-eslint';
5+
6+
export default defineConfig(
7+
// Apply to all TypeScript and JavaScript files
8+
{
9+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.mjs', '**/*.cjs'],
10+
},
11+
12+
// Ignore patterns
13+
{
14+
ignores: [
15+
'**/node_modules/**',
16+
'**/dist/**',
17+
'**/build/**',
18+
'**/.git/**',
19+
'**/coverage/**',
20+
'**/*.min.js',
21+
],
22+
},
23+
24+
// Base ESLint recommended rules
25+
eslint.configs.recommended,
26+
27+
// TypeScript ESLint recommended rules with type checking
28+
...tseslint.configs.recommendedTypeChecked,
29+
30+
// TypeScript specific configuration
31+
{
32+
languageOptions: {
33+
parserOptions: {
34+
projectService: {
35+
allowDefaultProject: ['*.js', '*.mjs', '*.cjs'],
36+
defaultProject: './tsconfig.json',
37+
},
38+
tsconfigRootDir: import.meta.dirname,
39+
},
40+
},
41+
},
42+
43+
// Rules for JavaScript files (without type checking)
44+
{
45+
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
46+
...tseslint.configs.disableTypeChecked,
47+
},
48+
49+
// Custom TypeScript rule overrides
50+
{
51+
rules: {
52+
'@typescript-eslint/explicit-function-return-type': 'off',
53+
'@typescript-eslint/strict-boolean-expressions': 'off',
54+
'@typescript-eslint/restrict-template-expressions': 'off',
55+
'@typescript-eslint/method-signature-style': 'off',
56+
'@typescript-eslint/no-unsafe-assignment': 'off',
57+
'@typescript-eslint/no-unsafe-call': 'off',
58+
'@typescript-eslint/no-unsafe-argument': 'off',
59+
'@typescript-eslint/no-unsafe-member-access': 'off',
60+
'@typescript-eslint/no-explicit-any': 'off',
61+
'@typescript-eslint/require-await': 'off',
62+
// allow unused variables if they start with _
63+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
64+
'no-undef': 'off',
65+
},
66+
},
67+
68+
// Prettier config (must be last to override conflicting rules)
69+
eslintConfigPrettier,
70+
);

package.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint": "eslint .",
1111
"lint:fix": "eslint . --fix",
1212
"test": "npm run lint && vitest --run",
13-
"cli": "pnpm --filter jaculus-tools run cli",
13+
"cli": "tsx packages/wokwi-cli/src/main.ts",
1414
"prepare": "husky install"
1515
},
1616
"author": "Uri Shaked",
@@ -31,20 +31,17 @@
3131
"yaml": "^2.3.1"
3232
},
3333
"devDependencies": {
34-
"@typescript-eslint/eslint-plugin": "^5.59.1",
34+
"@eslint/js": "^9.39.1",
3535
"esbuild": "^0.25.2",
36-
"eslint": "^8.39.0",
37-
"eslint-config-prettier": "^8.8.0",
38-
"eslint-config-standard-with-typescript": "^34.0.1",
39-
"eslint-plugin-import": "^2.27.5",
40-
"eslint-plugin-n": "^15.7.0",
41-
"eslint-plugin-promise": "^6.1.1",
36+
"eslint": "^9.39.1",
37+
"eslint-config-prettier": "^10.1.8",
4238
"husky": "^8.0.0",
39+
"jiti": "^2.6.1",
4340
"lint-staged": "^15.4.3",
4441
"prettier": "^3.5.0",
4542
"rimraf": "^5.0.0",
4643
"tsx": "^4.19.2",
47-
"typescript": "^5.2.2",
44+
"typescript": "^5.9.3",
4845
"typescript-eslint": "^8.46.3",
4946
"vitest": "^3.0.5"
5047
},

packages/wokwi-cli/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
"scripts": {
88
"build": "node tools/build.js",
99
"package": "npm run build && pkg --public -o dist/bin/wokwi-cli -t node20-linuxstatic-arm64,node20-linuxstatic-x64,node20-macos-arm64,node20-macos-x64,node20-win-x64 dist/cli.cjs",
10-
"start": "tsx src/main.ts",
10+
"cli": "tsx src/main.ts",
1111
"test": "npm run lint && vitest --run",
12-
"test:watch": "vitest --watch",
13-
"prepare": "husky install"
12+
"test:watch": "vitest --watch"
1413
},
1514
"keywords": [
1615
"esp32",

packages/wokwi-cli/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { parse as tomlParse } from '@iarna/toml';
22
import type { WokwiTOML } from './WokwiConfig.js';
33

4-
export async function parseConfig(data: string, configRoot: string) {
4+
export async function parseConfig(data: string, _configRoot: string) {
55
const tomlSource = data.replace(/\r\n/g, '\n');
66
try {
77
const tomlData = tomlParse(tomlSource);

packages/wokwi-cli/src/esp/idfProjectConfig.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ type ICreateConfigForIDFProjectParams = Pick<
1313
>;
1414

1515
export function createConfigForIDFProject(idfProjectDescription: ICreateConfigForIDFProjectParams) {
16-
// eslint-disable-next-line @typescript-eslint/naming-convention
1716
const { build_dir, project_path, app_elf } = idfProjectDescription;
1817
const relativeBuildDir = path.relative(project_path, build_dir);
1918

packages/wokwi-cli/src/project/initProjectWizard.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,9 @@ export async function initProjectWizard(rootDir: string, opts: { diagramFile?: s
158158
name: 'Wokwi GDB',
159159
type: 'cppdbg',
160160
request: 'launch',
161-
// eslint-disable-next-line no-template-curly-in-string
162161
program: '${workspaceFolder}/' + elfPath,
163-
// eslint-disable-next-line no-template-curly-in-string
164162
cwd: '${workspaceFolder}',
165163
MIMode: 'gdb',
166-
// eslint-disable-next-line no-template-curly-in-string
167164
miDebuggerPath: '${command:espIdf.getToolchainGdb}',
168165
miDebuggerServerAddress: 'localhost:3333',
169166
},

0 commit comments

Comments
 (0)