aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCopilot <198982749+Copilot@users.noreply.github.com>2025-11-07 19:57:35 +0100
committerGitHub <noreply@github.com>2025-11-07 19:57:35 +0100
commitd08e350a4b44c755f65d50227329e212efafb1b2 (patch)
tree6ef970552b18ce11ae42d2029945fe4363195f65
parentf7fc0b5a397e4eaa7a604edb97169ee3d5c5f82e (diff)
Add formatting tools and VSCode configuration (#83)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: arielcostas <94913521+arielcostas@users.noreply.github.com> Co-authored-by: Ariel Costas Guerrero <ariel@costas.dev>
-rw-r--r--.gitignore1
-rw-r--r--.vscode/extensions.json11
-rw-r--r--.vscode/settings.json61
-rw-r--r--README.md43
-rw-r--r--src/frontend/.prettierignore9
-rw-r--r--src/frontend/.prettierrc10
-rw-r--r--src/frontend/eslint.config.js32
-rw-r--r--src/frontend/package-lock.json1
-rw-r--r--src/frontend/package.json3
-rw-r--r--src/gtfs_vigo_stops/pyproject.toml13
10 files changed, 184 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 531de93..8ed8f99 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,7 @@ dist-ssr
# Editor directories and files
.vscode/*
!.vscode/extensions.json
+!.vscode/settings.json
.idea
.DS_Store
*.suo
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..4819347
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,11 @@
+{
+ "recommendations": [
+ "esbenp.prettier-vscode",
+ "dbaeumer.vscode-eslint",
+ "charliermarsh.ruff",
+ "ms-dotnettools.csharp",
+ "ms-dotnettools.csdevkit",
+ "editorconfig.editorconfig",
+ "bradlc.vscode-tailwindcss"
+ ]
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..ccafd3e
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,61 @@
+{
+ "editor.formatOnSave": true,
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
+ "editor.codeActionsOnSave": {
+ "source.fixAll.eslint": "explicit",
+ "source.organizeImports": "explicit"
+ },
+ "[typescript]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[typescriptreact]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[javascript]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[javascriptreact]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[json]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[jsonc]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[css]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[html]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[markdown]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[python]": {
+ "editor.defaultFormatter": "charliermarsh.ruff",
+ "editor.codeActionsOnSave": {
+ "source.fixAll.ruff": "explicit",
+ "source.organizeImports.ruff": "explicit"
+ }
+ },
+ "[csharp]": {
+ "editor.defaultFormatter": "ms-dotnettools.csharp"
+ },
+ "files.eol": "\n",
+ "files.insertFinalNewline": true,
+ "files.trimTrailingWhitespace": true,
+ "eslint.validate": [
+ "javascript",
+ "javascriptreact",
+ "typescript",
+ "typescriptreact"
+ ],
+ "eslint.workingDirectories": [
+ {
+ "pattern": "./src/frontend"
+ }
+ ],
+ "typescript.tsdk": "src/frontend/node_modules/typescript/lib",
+ "typescript.enablePromptUseWorkspaceTsdk": true
+}
diff --git a/README.md b/README.md
index a1cfad1..1532b7a 100644
--- a/README.md
+++ b/README.md
@@ -58,6 +58,49 @@ TODO: Update instructions
2. Open your browser and navigate to `http://localhost:5173`.
+## Code Formatting and Linting
+
+This project uses automated formatting and linting tools to ensure code consistency.
+
+### Frontend (TypeScript/JavaScript)
+
+- **Prettier**: Code formatting
+- **ESLint**: Code linting
+
+```sh
+cd src/frontend
+npm run format # Auto-format all files
+npm run checkformat # Check formatting without making changes
+npm run lint # Run ESLint
+npm run lint:fix # Auto-fix ESLint issues
+```
+
+### Python
+
+- **Ruff**: Formatting and linting (configured in `pyproject.toml`)
+
+```sh
+cd src/gtfs_vigo_stops
+ruff format . # Format Python files
+ruff check . # Check for linting issues
+```
+
+### C#
+
+- **EditorConfig**: Formatting rules (configured in `.editorconfig`)
+- Format on save is enabled in VSCode
+
+### VSCode Setup
+
+When you open this project in VSCode, you'll be prompted to install recommended extensions. These include:
+- Prettier
+- ESLint
+- Ruff
+- C# Dev Kit
+- EditorConfig
+
+The project is configured to auto-format on save.
+
## Contributing
Contributions are welcome! Please open an issue or submit a pull request.
diff --git a/src/frontend/.prettierignore b/src/frontend/.prettierignore
new file mode 100644
index 0000000..639a305
--- /dev/null
+++ b/src/frontend/.prettierignore
@@ -0,0 +1,9 @@
+node_modules
+dist
+build
+.react-router
+coverage
+*.min.js
+*.min.css
+package-lock.json
+.vscode
diff --git a/src/frontend/.prettierrc b/src/frontend/.prettierrc
new file mode 100644
index 0000000..115ffb9
--- /dev/null
+++ b/src/frontend/.prettierrc
@@ -0,0 +1,10 @@
+{
+ "semi": true,
+ "trailingComma": "es5",
+ "singleQuote": false,
+ "printWidth": 80,
+ "tabWidth": 2,
+ "useTabs": false,
+ "arrowParens": "always",
+ "endOfLine": "lf"
+}
diff --git a/src/frontend/eslint.config.js b/src/frontend/eslint.config.js
new file mode 100644
index 0000000..2439911
--- /dev/null
+++ b/src/frontend/eslint.config.js
@@ -0,0 +1,32 @@
+import js from "@eslint/js";
+import globals from "globals";
+import reactHooks from "eslint-plugin-react-hooks";
+import reactRefresh from "eslint-plugin-react-refresh";
+import tseslint from "typescript-eslint";
+
+export default tseslint.config(
+ { ignores: ["dist", "build", ".react-router", "node_modules"] },
+ {
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
+ files: ["**/*.{ts,tsx}"],
+ languageOptions: {
+ ecmaVersion: 2020,
+ globals: globals.browser,
+ },
+ plugins: {
+ "react-hooks": reactHooks,
+ "react-refresh": reactRefresh,
+ },
+ rules: {
+ ...reactHooks.configs.recommended.rules,
+ "react-refresh/only-export-components": [
+ "warn",
+ { allowConstantExport: true },
+ ],
+ "@typescript-eslint/no-unused-vars": [
+ "error",
+ { argsIgnorePattern: "^_" },
+ ],
+ },
+ }
+);
diff --git a/src/frontend/package-lock.json b/src/frontend/package-lock.json
index 2c28547..947918b 100644
--- a/src/frontend/package-lock.json
+++ b/src/frontend/package-lock.json
@@ -43,6 +43,7 @@
"jiti": "^2.6.1",
"maplibre-gl": "^5.9.0",
"pmtiles": "^4.3.0",
+ "prettier": "^3.6.2",
"react-map-gl": "^8.1.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.0",
diff --git a/src/frontend/package.json b/src/frontend/package.json
index 367d106..048ee98 100644
--- a/src/frontend/package.json
+++ b/src/frontend/package.json
@@ -8,6 +8,8 @@
"dev": "react-router dev --host",
"start": "react-router-serve ./build/server/index.js",
"typecheck": "react-router typegen && tsc",
+ "lint": "eslint .",
+ "lint:fix": "eslint . --fix",
"format": "prettier --write .",
"checkformat": "prettier --check ."
},
@@ -46,6 +48,7 @@
"jiti": "^2.6.1",
"maplibre-gl": "^5.9.0",
"pmtiles": "^4.3.0",
+ "prettier": "^3.6.2",
"react-map-gl": "^8.1.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.0",
diff --git a/src/gtfs_vigo_stops/pyproject.toml b/src/gtfs_vigo_stops/pyproject.toml
index f0268e7..6b28831 100644
--- a/src/gtfs_vigo_stops/pyproject.toml
+++ b/src/gtfs_vigo_stops/pyproject.toml
@@ -10,3 +10,16 @@ dependencies = [
"pytest>=8.4.1",
"requests>=2.32.3",
]
+
+[tool.ruff]
+line-length = 88
+target-version = "py313"
+
+[tool.ruff.lint]
+select = ["E", "F", "I", "W"]
+ignore = []
+
+[tool.ruff.format]
+quote-style = "double"
+indent-style = "space"
+