diff --git a/.github/workflows/build-aas-ui.yml b/.github/workflows/build-aas-web-ui.yml similarity index 100% rename from .github/workflows/build-aas-ui.yml rename to .github/workflows/build-aas-web-ui.yml diff --git a/.github/workflows/lint-aas-web-ui.yml b/.github/workflows/lint-aas-web-ui.yml new file mode 100644 index 00000000..8c33fb44 --- /dev/null +++ b/.github/workflows/lint-aas-web-ui.yml @@ -0,0 +1,27 @@ +name: Lint AAS Web UI + +on: + pull_request: + paths: + - 'aas-web-ui/**' + +jobs: + lint: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./aas-web-ui + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install Dependencies + run: yarn install + + - name: Run Linter + run: yarn lint:check diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml deleted file mode 100644 index 48ba78fd..00000000 --- a/.github/workflows/prettier.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Code Formatting - -on: - pull_request: - branches: [main] - paths: - - 'aas-web-ui/**' - -jobs: - prettier: - name: Prettier Check - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '22' - - - name: Install Prettier - run: | - npm install --global prettier@latest - npm install --global prettier-plugin-vue - - - name: Run Prettier - run: | - cd aas-web-ui - prettier_output=$(prettier --check --config ./.prettierrc --ignore-path ./.prettierignore --no-error-on-unmatched-pattern **/*.ts **/*.vue **/*.json **/*.js) - echo "$prettier_output" - if ! echo "$prettier_output" | grep -q 'All matched files use Prettier code style!'; then - echo "Formatting issues found" - exit 1 - fi diff --git a/aas-web-ui/eslint.config.mjs b/aas-web-ui/eslint.config.mjs new file mode 100644 index 00000000..e86006f9 --- /dev/null +++ b/aas-web-ui/eslint.config.mjs @@ -0,0 +1,97 @@ +import js from '@eslint/js'; +import eslintConfigPrettier from 'eslint-config-prettier'; +import prettier from 'eslint-plugin-prettier'; +import pluginPromise from 'eslint-plugin-promise'; +import simpleImportSort from 'eslint-plugin-simple-import-sort'; +import vue from 'eslint-plugin-vue'; +import ts from 'typescript-eslint'; + +export default [ + { + ignores: ['{dist,public}/**/*', 'vue-shim.d.ts'], + }, + + { + languageOptions: { + ecmaVersion: 'latest', + }, + }, + + // js + js.configs.recommended, + + // ts + ...ts.configs.recommended, + { + rules: { + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-unused-expressions': ['error', { allowTernary: true }], + }, + }, + + // vue + ...vue.configs['flat/recommended'], + { + // files: ['*.vue', '**/*.vue'], + languageOptions: { + parserOptions: { + parser: ts.parser, + }, + }, + }, + { + rules: { + 'vue/multi-word-component-names': 'off', + 'vue/no-unused-vars': ['error', { ignorePattern: '^_' }], + 'vue/max-attributes-per-line': ['error', { singleline: 5 }], + }, + }, + + // Sort imports + { + plugins: { + 'simple-import-sort': simpleImportSort, + }, + rules: { + 'simple-import-sort/imports': [ + 'error', + { + groups: [ + [ + '^\\u0000', // all side effects (0 at start) + '^[^/\\.].*\u0000$', // external types (0 at end) + '^\\..*\u0000$', // internal types (0 at end) + '^@?\\w', // Starts with @ + '^[^.]', // any + '^\\.', // local + ], + ], + }, + ], + 'simple-import-sort/exports': 'error', + '@typescript-eslint/no-explicit-any': ['warn', { ignoreRestArgs: true }], + }, + }, + + // Promise + pluginPromise.configs['flat/recommended'], + { + rules: { + 'promise/always-return': 'off', + 'promise/catch-or-return': 'off', + }, + }, + + // Prettier + { + plugins: { + prettier, + }, + rules: { + 'prettier/prettier': 'error', + }, + }, + + // Disable rules that conflict with Prettier + eslintConfigPrettier, +]; diff --git a/aas-web-ui/package.json b/aas-web-ui/package.json index a33e0127..366fbc00 100644 --- a/aas-web-ui/package.json +++ b/aas-web-ui/package.json @@ -7,7 +7,9 @@ "scripts": { "dev": "vite", "build": "vue-tsc --noEmit && vite build", - "preview": "vite preview" + "preview": "vite preview", + "lint:check": "eslint ./", + "lint:fix": "eslint --fix ./" }, "dependencies": { "@fontsource/roboto": "^5.0.14", @@ -30,18 +32,27 @@ "webfontloader": "^1.0.0" }, "devDependencies": { + "@eslint/js": "^9.9.1", + "@types/eslint__js": "^8.42.3", "@types/leaflet": "^1.9.12", "@types/md5": "^2.3.5", "@types/node": "^22.4.1", "@types/three": "^0.166.0", "@types/uuid": "^10.0.0", "@types/webfontloader": "^1.6.38", - "@types/lodash": "^4.17.7", "@vitejs/plugin-vue": "^5.1.2", - "prettier": "3.3.3", + "eslint": "^9.9.1", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-promise": "^7.1.0", + "eslint-plugin-simple-import-sort": "^12.1.1", + "eslint-plugin-vue": "^9.27.0", + "prettier": "^3.3.3", "sass": "^1.77.8", "typescript": "^5.5.4", + "typescript-eslint": "^8.3.0", "vite": "^5.4.2", + "vite-plugin-eslint": "^1.8.1", "vite-plugin-vuetify": "^2.0.4", "vue-tsc": "^2.0.29" } diff --git a/aas-web-ui/src/App.vue b/aas-web-ui/src/App.vue index 484f2be4..44174e31 100644 --- a/aas-web-ui/src/App.vue +++ b/aas-web-ui/src/App.vue @@ -16,12 +16,11 @@