Skip to content

Commit

Permalink
PB-1384 : modularize proj, number and coordinate utils
Browse files Browse the repository at this point in the history
in prep work to the elevation profile module, I started modularizing what will be used by both the viewer and the future elevation profile component.

I used the opportunity of having a smaller scoped project to switch to Typescript entirely all the utilities.
Migration to ESLint9 was also done here, meaning there are some changes because of new linter rules. Some ESLint8 plugins weren't available in ESLint9 so I had to find equivalents, but they don't have exactly the same way of linting
  • Loading branch information
pakb committed Jan 31, 2025
1 parent 1aeb13a commit 31c921a
Show file tree
Hide file tree
Showing 619 changed files with 19,973 additions and 15,632 deletions.
68 changes: 0 additions & 68 deletions .eslintrc.cjs

This file was deleted.

8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ yarn-error.log*
vite.config.js.timestamp-*.mjs

# Cypress and friends
tests/cypress/downloads
tests/cypress/videos
tests/cypress/screenshots
tests/results/*
**/tests/cypress/downloads
**/tests/cypress/videos
**/tests/cypress/screenshots
**/tests/results/*

# Git
*.orig
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v22
28 changes: 15 additions & 13 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"printWidth": 100,
"singleQuote": true,
"semi": false,
"trailingComma": "es5",
"tabWidth": 4,
"jsxSingleQuote": false,
"plugins": ["prettier-plugin-jsdoc", "@prettier/plugin-xml"],
"overrides": [{
"files": "*.md",
"options": {
"tabWidth": 2
}
}]
"printWidth": 100,
"singleQuote": true,
"semi": false,
"trailingComma": "es5",
"tabWidth": 4,
"jsxSingleQuote": false,
"plugins": ["prettier-plugin-jsdoc", "@prettier/plugin-xml"],
"overrides": [
{
"files": "*.md",
"options": {
"tabWidth": 2
}
}
]
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md)

## Project structure

This is a [Vue](https://vuejs.org/) app that is served through `src/main.js`, using [Vuex](https://vuex.vuejs.org/) as a state manager.
This is a [Vue](https://vuejs.org/) app that is served through `src/main.ts`, using [Vuex](https://vuex.vuejs.org/) as a state manager.
The app is divided into modules (or chunks) that are stored into `src/modules`. The goal is for each of these modules to be able to be externalized if needed. They should explicitly state their dependencies to other modules' component or store element in their `README.md` (dependency to the main store's modules is not required to be stated)

Each module should have a root component, called `{Name of the module}Module.vue` that loads all needed component into the template. It should also have a `README.md` file at the root explaining what this module is about.
Expand All @@ -59,11 +59,11 @@ Here's a sample of what project folder structure looks like :
│   (used by NPM targets)
├── src
│   ├── main.js
│   ├── main.ts
│   ├── App.vue
│   ├── modules
│   │ ├── <Module name>
│   │ │ ├── index.js
│   │ │ ├── index.ts
│   │ │ └── other moduleName related files such as
│   │ a components folder or a store folder
│   ├── store
Expand Down
21 changes: 21 additions & 0 deletions adr/2025-01-27_modularization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Modularization of the project

> Status: accepted
> Date: 27.01.2025
> Author: Pascal Barth, Stefan Heinemann, Stefan Biegler, Jürgen Hansmann
## Context

We want to re-use part of this project to help us build the new product we are planning with geocat.ch, geodienste.ch and kgk-cgc.ch

There is also the idea to replace our outdated JS API (https://api3.geo.admin.ch/api/doc.html)

There is a need to have re-usable components, such as a map component, or helpers to transform our layer definition into OpenLayers equivalent (with the correct LV95 config, etc...)

## Descision

It was decided to split this project into multiple "modules" that can then be published on NPM as stand-alone packages.

That means transforming this project into a monorepo, and making it possible to develop the "npm package" sides of the project alongside the webapp (and have hot-reload capabilities)
96 changes: 96 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import js from '@eslint/js'
import markdown from '@eslint/markdown'
import {
configureVueProject,
defineConfigWithVueTs,
vueTsConfigs,
} from '@vue/eslint-config-typescript'
import pluginCypress from 'eslint-plugin-cypress/flat'
import mocha from 'eslint-plugin-mocha'
import perfectionist from 'eslint-plugin-perfectionist'
import pluginVue from 'eslint-plugin-vue'
import globals from 'globals'

configureVueProject({
scriptLangs: ['ts', 'js'],
})

export default defineConfigWithVueTs(
js.configs.recommended,
...pluginVue.configs['flat/recommended'],
pluginCypress.configs.recommended,
vueTsConfigs.recommendedTypeCheckedOnly,
{
ignores: ['.gitignore', '**/node_modules', '**/.github', '**/dist', '**/*.md'],
},
{
plugins: {
mocha,
perfectionist,
},

languageOptions: {
ecmaVersion: 'latest',

globals: {
...globals.browser,
...globals.vitest,
...globals.node,
__APP_VERSION__: true,
__CESIUM_STATIC_PATH__: true,
defineModel: 'readonly',
VITE_ENVIRONMENT: true,
},

sourceType: 'module',
},

rules: {
eqeqeq: ['error', 'always'],
'mocha/no-exclusive-tests': 'error',
'no-console': 'error',
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
},
],
'no-var': 'error',
'perfectionist/sort-imports': [
'error',
{ type: 'alphabetical', internalPattern: ['^@/.*'] },
],
'vue/html-indent': ['error', 4],
'vue/max-attributes-per-line': ['error', { singleline: 1, multiline: 1 }],
},
},
{
files: ['**/*.ts', '**/*.tsx'],
// switching to TypeScript unused var rule (instead of JS rule), so that no error is raised
// on unused param from abstract function arguments
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
},
},
{
files: ['tests/**/*.{js,ts,jsx,tsx}', 'src/**/__test__/**/*.spec.js', 'scripts/**'],
rules: {
'no-console': 'off',
'no-prototype-builtins': 'off',
},
},
{
files: ['**/*.md'],
ignores: ['!**/*.md', '**/LICENSE.md'],
plugins: {
markdown: markdown,
},
processor: 'markdown/markdown',
rules: {
'no-irregular-whitespace': 'off',
},
}
)
14 changes: 7 additions & 7 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": ["node_modules", "dist"]
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": ["node_modules", "dist"]
}
Loading

0 comments on commit 31c921a

Please sign in to comment.