Skip to content

Commit

Permalink
adds eslint and action for lint checking
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronzi committed Aug 30, 2024
1 parent 4d04378 commit 418d059
Show file tree
Hide file tree
Showing 97 changed files with 2,859 additions and 2,024 deletions.
File renamed without changes.
27 changes: 27 additions & 0 deletions .github/workflows/lint-aas-web-ui.yml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 0 additions & 35 deletions .github/workflows/prettier.yml

This file was deleted.

97 changes: 97 additions & 0 deletions aas-web-ui/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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,
];
17 changes: 14 additions & 3 deletions aas-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
Expand Down
7 changes: 3 additions & 4 deletions aas-web-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useNavigationStore } from '@/store/NavigationStore';
import { useAASStore } from '@/store/AASDataStore';
import AppNavigation from '@/components/AppNavigation/AppNavigation.vue';
import RequestHandling from '@/mixins/RequestHandling';
import SubmodelElementHandling from '@/mixins/SubmodelElementHandling';
import AppNavigation from '@/components/AppNavigation/AppNavigation.vue';
import { useAASStore } from '@/store/AASDataStore';
import { useNavigationStore } from '@/store/NavigationStore';
interface AASType {
endpoints: Array<{
Expand Down
23 changes: 11 additions & 12 deletions aas-web-ui/src/UserPlugins/HelloWorldPlugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,27 @@
<!-- Display SubmodelElement -->
<SubmodelElementWrapper
:SubmodelElementObject="SubmodelElement"
@updateValue="updatePluginValue"></SubmodelElementWrapper>
@update-value="updatePluginValue"></SubmodelElementWrapper>
</div>
</v-container>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { useTheme } from 'vuetify';
import { useAASStore } from '@/store/AASDataStore';
import SubmodelElementWrapper from '@/components/UIComponents/SubmodelElementWrapper.vue';
import RequestHandling from '@/mixins/RequestHandling'; // Mixin to handle the requests to the AAS
import SubmodelElementHandling from '@/mixins/SubmodelElementHandling'; // Mixin to handle typical SubmodelElement-Actions
import SubmodelElementWrapper from '@/components/UIComponents/SubmodelElementWrapper.vue';
import { useAASStore } from '@/store/AASDataStore';
export default defineComponent({
name: 'PluginJSONArray',
SemanticID: 'http://hello.world.de/plugin_submodel', // SemanticID of the HelloWorld-Plugin
props: ['submodelElementData'],
SemanticID: 'http://hello.world.de/plugin_submodel',
components: {
SubmodelElementWrapper,
},
mixins: [RequestHandling, SubmodelElementHandling],
mixins: [RequestHandling, SubmodelElementHandling], // SemanticID of the HelloWorld-Plugin
props: ['submodelElementData'],
setup() {
const theme = useTheme();
Expand All @@ -50,18 +49,18 @@
};
},
mounted() {
// console.log('HelloWorldPlugin mounted');
this.initializePlugin(); // Initialize the HelloWorld-Plugin when the component is mounted
},
computed: {
// Get the selected Treeview Node (SubmodelElement) from the store
SelectedNode() {
return this.aasStore.getSelectedNode;
},
},
mounted() {
// console.log('HelloWorldPlugin mounted');
this.initializePlugin(); // Initialize the HelloWorld-Plugin when the component is mounted
},
methods: {
// Function to initialize the HelloWorld-Plugin
initializePlugin() {
Expand Down
85 changes: 41 additions & 44 deletions aas-web-ui/src/components/AASTreeview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
</div>
<!-- TODO: Replace with Vuetify Treeview Component when it get's released in Q1 2023 -->
<VTreeview
v-else
v-for="item in submodelData"
v-else
:key="item.id"
class="root"
:item="item"
Expand All @@ -35,19 +35,16 @@

<script lang="ts">
import { defineComponent } from 'vue';
import { useNavigationStore } from '@/store/NavigationStore';
import { useAASStore } from '@/store/AASDataStore';
import { useEnvStore } from '@/store/EnvironmentStore';
import VTreeview from '@/components/UIComponents/VTreeview.vue';
import RequestHandling from '@/mixins/RequestHandling';
import SubmodelElementHandling from '@/mixins/SubmodelElementHandling';
import VTreeview from '@/components/UIComponents/VTreeview.vue';
import { useAASStore } from '@/store/AASDataStore';
import { useEnvStore } from '@/store/EnvironmentStore';
import { useNavigationStore } from '@/store/NavigationStore';
export default defineComponent({
name: 'AASTreeview',
components: {
RequestHandling, // Mixin to handle the requests to the AAS
VTreeview,
},
mixins: [RequestHandling, SubmodelElementHandling],
Expand All @@ -73,8 +70,40 @@
};
},
mounted() {
this.initTreeWithRouteParams();
computed: {
// get selected AAS from Store
SelectedAAS() {
return this.aasStore.getSelectedAAS;
},
// get the trigger for AAS selection from Store
triggerAAS() {
return this.navigationStore.getTriggerAASSelected;
},
// gets loading State from Store
loading() {
return this.aasStore.getLoadingState;
},
// get AAS Registry URL from Store
aasRegistryServerURL() {
return this.navigationStore.getAASRegistryURL;
},
// get Submodel Registry URL from Store
submodelRegistryURL() {
return this.navigationStore.getSubmodelRegistryURL;
},
// get the updated Treeview Node from Store
updatedNode() {
return this.aasStore.getUpdatedNode;
},
// get the init treeview flag from Store
initTree() {
return this.aasStore.getInitTreeByReferenceElement;
},
},
watch: {
Expand Down Expand Up @@ -111,40 +140,8 @@
},
},
computed: {
// get selected AAS from Store
SelectedAAS() {
return this.aasStore.getSelectedAAS;
},
// get the trigger for AAS selection from Store
triggerAAS() {
return this.navigationStore.getTriggerAASSelected;
},
// gets loading State from Store
loading() {
return this.aasStore.getLoadingState;
},
// get AAS Registry URL from Store
aasRegistryServerURL() {
return this.navigationStore.getAASRegistryURL;
},
// get Submodel Registry URL from Store
submodelRegistryURL() {
return this.navigationStore.getSubmodelRegistryURL;
},
// get the updated Treeview Node from Store
updatedNode() {
return this.aasStore.getUpdatedNode;
},
// get the init treeview flag from Store
initTree() {
return this.aasStore.getInitTreeByReferenceElement;
},
mounted() {
this.initTreeWithRouteParams();
},
methods: {
Expand Down
Loading

0 comments on commit 418d059

Please sign in to comment.