diff --git a/.github/workflows/static_code_analysis.yml b/.github/workflows/static_code_analysis.yml index a951dca6b..27963aced 100644 --- a/.github/workflows/static_code_analysis.yml +++ b/.github/workflows/static_code_analysis.yml @@ -141,3 +141,42 @@ jobs: with: version: latest working-directory: tap/extensions/redis + + - uses: actions/setup-node@v2 + with: + node-version: 16 + + - name: Check modified UI files + id: ui_modified_files + run: devops/check_modified_files.sh ui/ + + - name: ESLint prerequisites ui + if: steps.ui_modified_files.outputs.matched == 'true' + run: | + sudo npm install -g eslint + cd ui + npm run prestart + npm i + + - name: ESLint ui + if: steps.ui_modified_files.outputs.matched == 'true' + run: | + cd ui + npm run eslint + + - name: Check modified ui-common files + id: ui_common_modified_files + run: devops/check_modified_files.sh ui-common/ + + - name: ESLint prerequisites ui-common + if: steps.ui_common_modified_files.outputs.matched == 'true' + run: | + sudo npm install -g eslint + cd ui-common + npm i + + - name: ESLint ui-common + if: steps.ui_common_modified_files.outputs.matched == 'true' + run: | + cd ui-common + npm run eslint diff --git a/devops/ui-common-pack.sh b/devops/ui-common-pack.sh new file mode 100755 index 000000000..319b6e6d3 --- /dev/null +++ b/devops/ui-common-pack.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# exit when any command fails +set -e + +dst_folder=$1 +echo "dst folder: $dst_folder"; + +cd $dst_folder/../ui-common +npm i +npm pack +mv up9-mizu-common-0.0.0.tgz $dst_folder diff --git a/ui-common/.eslintignore b/ui-common/.eslintignore index 2778bd7f8..a804767d2 100644 --- a/ui-common/.eslintignore +++ b/ui-common/.eslintignore @@ -1,6 +1,5 @@ build/ dist/ -src/ node_modules/ .snapshots/ *.min.js \ No newline at end of file diff --git a/ui-common/.eslintrc b/ui-common/.eslintrc deleted file mode 100644 index 4c6c5670c..000000000 --- a/ui-common/.eslintrc +++ /dev/null @@ -1,34 +0,0 @@ -{ - "parser": "@typescript-eslint/parser", - "extends": [ - "standard", - "standard-react", - "plugin:prettier/recommended", - "prettier/standard", - "prettier/react", - "plugin:@typescript-eslint/eslint-recommended" - ], - "env": { - "node": true - }, - "parserOptions": { - "ecmaVersion": 2020, - "ecmaFeatures": { - "legacyDecorators": true, - "jsx": true - } - }, - "settings": { - "react": { - "version": "16" - } - }, - "rules": { - "space-before-function-paren": 0, - "react/prop-types": 0, - "react/jsx-handler-names": 0, - "react/jsx-fragments": 0, - "react/no-unused-prop-types": 0, - "import/export": 0 - } -} diff --git a/ui-common/package-lock.json b/ui-common/package-lock.json index ce3b197b9..4ccc63bd1 100644 --- a/ui-common/package-lock.json +++ b/ui-common/package-lock.json @@ -23,7 +23,7 @@ "moment": "^2.29.1", "node-fetch": "^3.1.1", "numeral": "^2.0.6", - "protobuf-decoder": "^0.1.0", + "protobuf-decoder": "^0.1.2", "react-graph-vis": "^1.0.7", "react-lowlight": "^3.0.0", "react-router-dom": "^6.2.1", @@ -26065,9 +26065,9 @@ } }, "node_modules/protobuf-decoder": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/protobuf-decoder/-/protobuf-decoder-0.1.1.tgz", - "integrity": "sha512-yeyeCkdvOnzv+6/2YNx2FlT7565arz/mb0QnhmXFdHMwnek9Jp/0PpHJVdJkzdFBgi85XQWRcHdWHh2dOBrSng==" + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/protobuf-decoder/-/protobuf-decoder-0.1.2.tgz", + "integrity": "sha512-dKPIsI7W1A88f8WAXHzNujQuDWLAWVviw2svDOlwkpdVlaV8TRjxuBL4tE3dczYWRZ1ZeNts06k9njB4xjnBVQ==" }, "node_modules/proxy-addr": { "version": "2.0.7", @@ -55355,9 +55355,9 @@ } }, "protobuf-decoder": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/protobuf-decoder/-/protobuf-decoder-0.1.1.tgz", - "integrity": "sha512-yeyeCkdvOnzv+6/2YNx2FlT7565arz/mb0QnhmXFdHMwnek9Jp/0PpHJVdJkzdFBgi85XQWRcHdWHh2dOBrSng==" + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/protobuf-decoder/-/protobuf-decoder-0.1.2.tgz", + "integrity": "sha512-dKPIsI7W1A88f8WAXHzNujQuDWLAWVviw2svDOlwkpdVlaV8TRjxuBL4tE3dczYWRZ1ZeNts06k9njB4xjnBVQ==" }, "proxy-addr": { "version": "2.0.7", diff --git a/ui-common/package.json b/ui-common/package.json index e8f00e77c..dc666a247 100644 --- a/ui-common/package.json +++ b/ui-common/package.json @@ -19,7 +19,8 @@ "test:build": "run-s build", "test:lint": "eslint .", "predeploy": "cd example && npm install && npm run build", - "deploy": "gh-pages -d example/build" + "deploy": "gh-pages -d example/build", + "eslint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "peerDependencies": { "@craco/craco": "^6.4.3", diff --git a/ui/package.json b/ui/package.json index 096d2b5b8..24834aa4b 100644 --- a/ui/package.json +++ b/ui/package.json @@ -51,11 +51,13 @@ "react-error-overlay": "6.0.9" }, "scripts": { + "prestart": "../devops/ui-common-pack.sh $PWD", "start": "craco start", "start-dev": "./node_modules/.bin/env-cmd -f .env.dev.basic craco start", "build": "./node_modules/.bin/env-cmd -f .env.basic craco build", "test": "craco test", - "eject": "craco eject" + "eject": "craco eject", + "eslint": "eslint . --ext .js,.jsx,.ts,.tsx --max-warnings=0" }, "eslintConfig": { "extends": [