From 8c4304da5b57d8fcd3d92941c5974e668184e669 Mon Sep 17 00:00:00 2001 From: Nate Wessel Date: Fri, 23 Jun 2023 11:30:53 -0400 Subject: [PATCH] Set up basic linting action (#58) * trying to configure basic eslint * remove unused workflow, try basic linting workflow * set working directory * simplify node versioning * trying a thing * indent * define branches * unset wd * trying again * remove empty step * try printing * simplify * reorder * introduce syntax error * fix syntax error --- .github/workflows/backend_test.yml | 93 ------------------------------ .github/workflows/lint-js.yml | 21 +++++++ frontend/.eslintrc.js | 8 +-- frontend/src/App/Map/index.jsx | 12 ++-- frontend/src/App/index.jsx | 1 - 5 files changed, 30 insertions(+), 105 deletions(-) delete mode 100644 .github/workflows/backend_test.yml create mode 100644 .github/workflows/lint-js.yml diff --git a/.github/workflows/backend_test.yml b/.github/workflows/backend_test.yml deleted file mode 100644 index f3db33f0..00000000 --- a/.github/workflows/backend_test.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: backend test deployment -env: - EB_PACKAGE_S3_BUCKET_NAME: "backend-s3-test" - EB_APPLICATION_NAME: "backend-test" - EB_ENVIRONMENT_NAME: "BackendTest-env" - DEPLOY_PACKAGE_NAME: "backend_test_${{ github.sha }}.zip" - AWS_REGION_NAME: "ca-central-1" - -on: - pull_request: - branches: [ dev ] - push: - branches: [ dev ] - -jobs: - build-pytest: - defaults: - run: - working-directory: backend - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [ 3.6, 3.7, 3.8 ] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest - build-to-s3: - defaults: - run: - working-directory: backend - - runs-on: ubuntu-latest - needs: [ build-pytest ] - - steps: - - name: Git clone repo - uses: actions/checkout@v1 - - name: create zip deploy package - run: zip -r -D ${{ env.DEPLOY_PACKAGE_NAME }} * -x *.git* - - - name: AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS }} - aws-secret-access-key: ${{ secrets.AWS_SECRET }} - aws-region: ${{ env.AWS_REGION_NAME }} - - - name: Copy dev package to S3 bucket - run: aws s3 cp ${{ env.DEPLOY_PACKAGE_NAME }} s3://${{ env.EB_PACKAGE_S3_BUCKET_NAME }}/ - - deploy-to-elasticbeanstalk: - runs-on: ubuntu-latest - needs: [ build-to-s3 ] - - steps: - - name: AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS }} - aws-secret-access-key: ${{ secrets.AWS_SECRET }} - aws-region: ${{ env.AWS_REGION_NAME }} - - - name: create ElasticBeanstalk App - run: | - aws elasticbeanstalk create-application-version \ - --application-name ${{ env.EB_APPLICATION_NAME }} \ - --source-bundle S3Bucket="${{ env.EB_PACKAGE_S3_BUCKET_NAME }}",S3Key="${{ env.DEPLOY_PACKAGE_NAME }}" \ - --version-label "Ver-${{ github.sha }}" \ - --description "CommitSHA-${{ github.sha }}" - - name: deploy ElasticBeanstalk App - run: | - aws elasticbeanstalk update-environment \ - --environment-name ${{ env.EB_ENVIRONMENT_NAME }} \ - --version-label "Ver-${{ github.sha }}" diff --git a/.github/workflows/lint-js.yml b/.github/workflows/lint-js.yml new file mode 100644 index 00000000..0665289e --- /dev/null +++ b/.github/workflows/lint-js.yml @@ -0,0 +1,21 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: JS linting +on: + pull_request: + branches: [ deploy ] + +jobs: + linting: + runs-on: ubuntu-latest + defaults: + run: + working-directory: frontend + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 14.x + - run: npm install + - run: npm run lint \ No newline at end of file diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index cd2c408d..00a92097 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -20,15 +20,11 @@ module.exports = { plugins: ["react",'css-modules'], rules: { "react/prop-types": 'off', - "react/display-name": 'off', - "react/no-unescaped-entities": 'warn', - "css-modules/no-unused-class": 'off' - + "dot-notation": 'warn' }, settings: { react: { - version: "detect", - //"pragma": "React", + version: "detect" } } } diff --git a/frontend/src/App/Map/index.jsx b/frontend/src/App/Map/index.jsx index 58aee699..abbfe16f 100644 --- a/frontend/src/App/Map/index.jsx +++ b/frontend/src/App/Map/index.jsx @@ -121,7 +121,7 @@ export default class Map extends Component { this.disableInteractions(); this.removeAllLinkSources(); this.props.getLinks(this); - }; + } /* this function is called only by action.js after full link data is fetch */ displayLinks(linkDataArr, sequence) { @@ -135,7 +135,8 @@ export default class Map extends Component { () => this.enableInteractions() // re-enables buttons ) this.props.onLinkUpdate(linkDataArr) - }; + } + // check if there is already a link drawn in the reverse direction checkIfLinkDirDrawn(checkCoor, bidirection, other) { let holdCoorArr = []; @@ -175,6 +176,7 @@ export default class Map extends Component { } return false; } + // draw the links on the map drawLinks(linkDataArr, sequence) { let linkSources = []; @@ -317,7 +319,7 @@ export default class Map extends Component { linkMouseEnter: tempLinkMouseEnter, linkMouseLeave: tempLinkMouseLeave }); - }; + } //remove all the drawn links on the map removeAllLinkSources() { this.props.removeAllLinks(); @@ -496,7 +498,7 @@ export default class Map extends Component { if (nodeCandidateClose) { nodeCandidateClose(); } - }; + } //removes the last node placed on the map removeNodes() { @@ -655,5 +657,5 @@ export default class Map extends Component { ); - }; + } } \ No newline at end of file diff --git a/frontend/src/App/index.jsx b/frontend/src/App/index.jsx index fbc28c86..82477da5 100644 --- a/frontend/src/App/index.jsx +++ b/frontend/src/App/index.jsx @@ -7,7 +7,6 @@ import Map from "./Map" import { SpatialData } from '../spatialData.js' import RangeFactory from "./Datetime/Range" -import parseTimePeriods from "./Datetime/TimeRangeParser" import { getLinksBetweenNodes, getDateBoundaries } from "../actions.js" import FileSettingsFactory from "./Settings/FileSettings" import { NotificationContainer, NotificationManager } from 'react-notifications'