From 640e6a72663a3b7bb1b2435da1a66421de30541e Mon Sep 17 00:00:00 2001 From: Adithyan Dinesh Date: Thu, 4 Jun 2026 16:23:53 +0530 Subject: [PATCH 1/2] Created Lint check CI action --- .eslintrc.json | 31 ++++++++++++++++ .github/workflows/lint.yml | 75 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 .eslintrc.json create mode 100644 .github/workflows/lint.yml diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..cad3b14 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,31 @@ +{ + "plugins": ["import", "eslint-plugin-tsdoc", "prettier"], + "extends": [ + "react-app", + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended" + ], + "parser": "@typescript-eslint/parser", + "env": { + "jest": true + }, + "settings": { + "react": { + "version": "detect" + } + }, + "rules": { + // Enforce consistent brace style for all control statements for readability + "curly": "error", + "import/no-anonymous-default-export": "off" + }, + "globals": { + "cy": true, + "before": true, + "context": true, + "Cypress": true, + "assert": true + } +} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..5577123 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,75 @@ +name: Lint Check + +on: + push: + branches: ["**"] + pull_request: + branches: + - nightly + - production + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + timeout-minutes: 15 + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: 20 + + - name: Install Linting Libraries + # Installs packages directly into node_modules without requiring package.json + run: > + npm install --no-save + eslint@8 eslint-plugin-diff + prettier eslint-plugin-prettier eslint-config-prettier + eslint-config-react-app eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y eslint-plugin-import + @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-tsdoc + @babel/core @babel/eslint-parser + eslint-plugin-jest eslint-plugin-testing-library eslint-plugin-flowtype + + - name: Deduplicate TypeScript Plugin + # Forces ESLint to only use the root-level plugin by deleting the nested one + run: rm -rf node_modules/eslint-config-react-app/node_modules/@typescript-eslint + + - name: Run ESLint strictly on Changed Lines (Blocking) + run: | + # 1. Create a temporary config that inherits your copied base config + # but applies the 'diff/ci' mode to filter output to changed lines only + echo '{ "extends": ["./.eslintrc.json", "plugin:diff/ci"] }' > .eslintrc.diff.json + + # 2. Determine the target commit for the git diff comparison + if [ "${{ github.event_name }}" = "pull_request" ]; then + export ESLINT_PLUGIN_DIFF_COMMIT="${{ github.event.pull_request.base.sha }}" + else + BEFORE_COMMIT="${{ github.event.before }}" + + if [ "$BEFORE_COMMIT" = "0000000000000000000000000000000000000000" ]; then + # Pushing a brand new branch + export ESLINT_PLUGIN_DIFF_COMMIT="HEAD~1" + else + # Verify if the 'before' commit actually exists in the local checkout + if git rev-parse --verify --quiet "$BEFORE_COMMIT" > /dev/null; then + export ESLINT_PLUGIN_DIFF_COMMIT="$BEFORE_COMMIT" + else + # Fallback for force pushes or rebases where the old commit is gone + echo "Warning: Commit $BEFORE_COMMIT not found locally. Falling back to HEAD~1" + export ESLINT_PLUGIN_DIFF_COMMIT="HEAD~1" + fi + fi + fi + + # 3. Execute ESLint across the codebase using the temporary diff config via npx + npx eslint --max-warnings=0 --config .eslintrc.diff.json --ext .js,.jsx,.ts,.tsx . From 544794d554e0c4552145d712c3b506f5b8028e12 Mon Sep 17 00:00:00 2001 From: Adithyan Dinesh Date: Thu, 4 Jun 2026 16:29:07 +0530 Subject: [PATCH 2/2] Added a function with intentional lint errors --- .../utils/addAutoSegmentationSavingHandler.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts b/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts index 17ed44f..8f0a017 100644 --- a/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts +++ b/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts @@ -87,3 +87,20 @@ export default function addAutoSegmentationSavingHandler( } ); } + +function Calculate_Total( items:any[],tax ) { + var Total = 0; + + for (let i = 0; i < items.length; i++) { + let Item = items[i]; + var price = Item.price; + Total = Total + price; + } + + if (tax == null) { + let tax = 0.05; + } + + return Total * (1 + tax) +} +