Skip to content

Commit d8668aa

Browse files
authored
Merge pull request #1 from QuesmaOrg/refactor
A serious refactor
2 parents 63056e1 + a5614f8 commit d8668aa

25 files changed

+1702
-1668
lines changed

.eslintrc.cjs

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

.prettierrc.json

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

CLAUDE.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
## Development Workflow
22

3+
- Use pnpm as the package manager (configured in package.json)
34
- Run pnpm lint before any commit (and after major edits as well).
45
- With each commit (and only commit) increment patch version by one. Unless there is a direct instruction to increase minor (or major) version.
56

67
## Code Quality Rules
78

8-
- NEVER fail silently - always log errors and make failures visible to users when appropriate.
9+
- NEVER fail silently - always log errors and make failures visible to users when appropriate.
10+
11+
## Type Safety Requirements
12+
13+
- AVOID using `any` types to mask type checking - this defeats the purpose of TypeScript
14+
- AVOID using `as` casting without proper validation - it bypasses type safety
15+
- DO import types directly from libraries when available
16+
- DO use type guards and runtime validation when interfacing with untyped external systems
17+
- AVOID patterns like `export type WebRInstance = any` - these mask real type safety issues
18+
- AVOID creating type aliases that just re-export types - import directly instead
19+
- ALL functions must have explicit return types - this is enforced by ESLint rules

README.md

Lines changed: 32 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,50 @@
1-
# WebR ggplot2 & dplyr Demo
1+
# WebR ggplot2 Demo
22

3-
A minimal Vue.js application demonstrating interactive R data visualization and manipulation using WebR, ggplot2, and dplyr in the browser.
3+
Interactive R data visualization in the browser using [WebR](https://webr.r-wasm.org/), [ggplot2](https://ggplot2.tidyverse.org/), and Vue.js.
44

5-
## Features
5+
## What is it?
66

7-
- 🎨 **Interactive Code Editor**: Monaco editor with R syntax highlighting
8-
- 📊 **Built-in Examples**: Pre-configured examples for ggplot2 and dplyr
9-
- 📁 **CSV Upload**: Drag-and-drop CSV file upload functionality
10-
- 🖥️ **Real-time Output**: Live R code execution with stdout/stderr display
11-
- 📈 **Plot Visualization**: SVG plot rendering in the browser
12-
- 🎯 **Clean Architecture**: Well-organized Vue 3 components with TypeScript
7+
A web application that runs R code directly in your browser - no server required. Features live code editing, CSV upload, and interactive plots.
138

14-
## Tech Stack
15-
16-
- **Vue 3** with TypeScript
17-
- **Vite** for build tooling
18-
- **WebR** for R in the browser
19-
- **Monaco Editor** for code editing
20-
- **ESLint** with strict rules
21-
- **Prettier** for code formatting
22-
- **pnpm** for package management
23-
24-
## Quick Start
9+
## License
2510

26-
1. **Install dependencies**:
27-
```bash
28-
pnpm install
29-
```
11+
MIT License
3012

31-
2. **Run development server**:
32-
```bash
33-
pnpm dev
34-
```
13+
## Author
3514

36-
3. **Build for production**:
37-
```bash
38-
pnpm build
39-
```
15+
Developed by [Piotr Migdal](https://p.migdal.pl/) from [Quesma](https://quesma.com/)
4016

41-
## Usage
17+
## Installation
4218

43-
1. **Select Examples**: Choose from pre-built examples in the dropdown
44-
2. **Upload CSV**: Drag and drop CSV files or click to browse
45-
3. **Edit Code**: Use the Monaco editor to write R code
46-
4. **Run Code**: Click "Run Code" to execute R scripts
47-
5. **View Results**: See output, plots, and any errors in the output panel
19+
Prerequisites:
20+
- Node.js 18+
21+
- [pnpm](https://pnpm.io/)
4822

49-
## Example Scripts
23+
```bash
24+
# Clone repository
25+
git clone https://github.com/QuesmaOrg/demo-webr-ggplot.git
26+
cd demo-webr-ggplot
5027

51-
- **Basic ggplot2**: Simple scatter plot with mtcars dataset
52-
- **dplyr filtering**: Data manipulation and summarization
53-
- **Enhanced scatter plot**: Color mapping and trend lines
54-
- **Bar chart**: Grouped bar charts with custom styling
55-
- **CSV template**: Template for working with uploaded data
28+
# Install dependencies
29+
pnpm install
5630

57-
## Project Structure
31+
# Start development server
32+
pnpm dev
5833

34+
# Build for production
35+
pnpm build
5936
```
60-
src/
61-
├── components/ # Vue components
62-
│ ├── CodeEditor.vue # Monaco editor wrapper
63-
│ ├── FileUpload.vue # CSV upload component
64-
│ ├── ExampleSelector.vue # Example dropdown
65-
│ └── OutputDisplay.vue # Results display
66-
├── composables/ # Vue composables
67-
│ └── useWebR.ts # WebR integration logic
68-
├── data/ # Static data
69-
│ └── examples.ts # R code examples
70-
├── types/ # TypeScript types
71-
│ └── index.ts # Type definitions
72-
├── App.vue # Main application
73-
├── main.ts # Application entry point
74-
└── style.css # Global styles
75-
```
76-
77-
## Development
7837

79-
- **Linting**: `pnpm lint`
80-
- **Formatting**: `pnpm format`
81-
- **Type checking**: `pnpm build` (includes vue-tsc)
82-
83-
## WebR Configuration
84-
85-
The application uses WebR with the following packages pre-installed:
86-
- `ggplot2` for data visualization
87-
- `dplyr` for data manipulation
88-
89-
WebR is configured with CORS headers and proper service worker setup for browser compatibility.
90-
91-
## Contributing
38+
## Usage
9239

93-
1. Follow the existing code style (ESLint + Prettier)
94-
2. Use TypeScript for type safety
95-
3. Keep components small and focused
96-
4. Add examples for new R functionality
40+
1. Open http://localhost:5173 in your browser
41+
2. Select an example or write your own R code
42+
3. Upload CSV files via drag & drop
43+
4. Click "Run Code" to execute
9744

98-
## License
45+
## Stack
9946

100-
MIT License - feel free to use this project as a starting point for your own WebR applications.
47+
- [WebR](https://webr.r-wasm.org/) - R in WebAssembly
48+
- [Vue 3](https://vuejs.org/) + TypeScript
49+
- [Vite](https://vitejs.dev/) - Build tool
50+
- [Monaco Editor](https://microsoft.github.io/monaco-editor/) - Code editor

eslint.config.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import pluginVue from 'eslint-plugin-vue'
2+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
3+
4+
export default defineConfigWithVueTs(
5+
{
6+
ignores: ['dist/**', 'node_modules/**', '*.d.ts', 'coverage/**', '.vite/**']
7+
},
8+
pluginVue.configs['flat/recommended'],
9+
vueTsConfigs.recommended,
10+
{
11+
files: ['**/*.{ts,tsx,vue,js,jsx,mjs,cjs}'],
12+
rules: {
13+
'@typescript-eslint/no-unused-vars': ['error', {
14+
argsIgnorePattern: '^_',
15+
varsIgnorePattern: '^_',
16+
caughtErrorsIgnorePattern: '^_'
17+
}],
18+
'@typescript-eslint/no-explicit-any': 'warn',
19+
'@typescript-eslint/explicit-function-return-type': 'error',
20+
'@typescript-eslint/explicit-module-boundary-types': 'error',
21+
22+
'vue/multi-word-component-names': 'off',
23+
'vue/block-order': ['error', {
24+
order: ['script', 'template', 'style']
25+
}],
26+
27+
'no-console': ['warn', { allow: ['warn', 'error'] }],
28+
'no-debugger': 'error',
29+
'prefer-const': 'error',
30+
'no-var': 'error'
31+
}
32+
}
33+
)

package.json

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,29 @@
11
{
22
"name": "webr-ggplot2-demo",
33
"private": true,
4-
"version": "0.1.6",
4+
"version": "0.1.8",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "vue-tsc --noEmit && vite build",
8+
"build": "vite build",
99
"preview": "vite preview",
10-
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
11-
"format": "prettier --write src/"
10+
"lint": "eslint . --fix"
1211
},
1312
"dependencies": {
14-
"@monaco-editor/loader": "^1.5.0",
1513
"monaco-editor": "^0.52.2",
16-
"vue": "^3.4.0",
14+
"vue": "^3.5.18",
1715
"webr": "^0.5.4"
1816
},
1917
"devDependencies": {
20-
"@rushstack/eslint-patch": "^1.3.3",
21-
"@tsconfig/node18": "^18.2.2",
22-
"@types/node": "^18.19.9",
23-
"@vitejs/plugin-vue": "^4.5.2",
24-
"@vue/eslint-config-prettier": "^8.0.0",
25-
"@vue/eslint-config-typescript": "^12.0.0",
26-
"@vue/tsconfig": "^0.5.1",
27-
"eslint": "^8.49.0",
28-
"eslint-plugin-vue": "^9.17.0",
29-
"prettier": "^3.0.3",
30-
"typescript": "~5.3.0",
31-
"vite": "^5.0.10",
32-
"vue-tsc": "^1.8.25"
18+
"@types/node": "^24.1.0",
19+
"@typescript-eslint/eslint-plugin": "^8.38.0",
20+
"@typescript-eslint/parser": "^8.38.0",
21+
"@vitejs/plugin-vue": "^6.0.1",
22+
"@vue/eslint-config-typescript": "^14.6.0",
23+
"eslint": "^9.32.0",
24+
"eslint-plugin-vue": "^10.4.0",
25+
"typescript": "~5.9.2",
26+
"vite": "^7.0.6"
3327
},
34-
"packageManager": "[email protected]+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808"
28+
"packageManager": "[email protected]"
3529
}

0 commit comments

Comments
 (0)