From 640e6a72663a3b7bb1b2435da1a66421de30541e Mon Sep 17 00:00:00 2001 From: Adithyan Dinesh Date: Thu, 4 Jun 2026 16:23:53 +0530 Subject: [PATCH 1/6] 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/6] 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) +} + From 564cfcc9b015bfc87a8e13a9b9c00fefa3611779 Mon Sep 17 00:00:00 2001 From: Adithyan Dinesh Date: Thu, 4 Jun 2026 16:43:47 +0530 Subject: [PATCH 3/6] Fixed some of the lint errors --- .../src/utils/addAutoSegmentationSavingHandler.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts b/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts index 8f0a017..243ebaa 100644 --- a/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts +++ b/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts @@ -88,9 +88,9 @@ export default function addAutoSegmentationSavingHandler( ); } -function Calculate_Total( items:any[],tax ) { +function Calculate_Total(items: any[], tax: number | null) { var Total = 0; - + for (let i = 0; i < items.length; i++) { let Item = items[i]; var price = Item.price; @@ -103,4 +103,3 @@ function Calculate_Total( items:any[],tax ) { return Total * (1 + tax) } - From de4c081a9ab81f7e55910bca56195f51a1278876 Mon Sep 17 00:00:00 2001 From: Adithyan Dinesh Date: Thu, 4 Jun 2026 16:48:19 +0530 Subject: [PATCH 4/6] Fixed all lint errors --- .../src/utils/addAutoSegmentationSavingHandler.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts b/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts index 243ebaa..a10ad0e 100644 --- a/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts +++ b/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts @@ -88,18 +88,18 @@ export default function addAutoSegmentationSavingHandler( ); } -function Calculate_Total(items: any[], tax: number | null) { - var Total = 0; +export function calculateTotal(items: { price: number }[], tax: number | null) { + let total = 0; for (let i = 0; i < items.length; i++) { - let Item = items[i]; - var price = Item.price; - Total = Total + price; + const item = items[i]; + const price = item.price; + total = total + price; } if (tax == null) { - let tax = 0.05; + tax = 0.05; } - return Total * (1 + tax) + return total * (1 + tax); } From 6cd1d00e07d9df38fcfda9b56ad660b4c51f3dca Mon Sep 17 00:00:00 2001 From: Adithyan Dinesh Date: Thu, 4 Jun 2026 17:16:22 +0530 Subject: [PATCH 5/6] Updated lint check CI action forced push handling --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5577123..72553bf 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -60,8 +60,8 @@ jobs: # 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 + # Verify if the 'before' commit actually exists and is accessible as a commit object + if git cat-file -e "${BEFORE_COMMIT}^{commit}" 2>/dev/null; then export ESLINT_PLUGIN_DIFF_COMMIT="$BEFORE_COMMIT" else # Fallback for force pushes or rebases where the old commit is gone From d59d3a1e81f85ff30fbe66868f42d96a47b37e48 Mon Sep 17 00:00:00 2001 From: Adithyan Dinesh Date: Thu, 4 Jun 2026 17:18:41 +0530 Subject: [PATCH 6/6] A forced commit --- .../src/utils/addAutoSegmentationSavingHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts b/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts index a10ad0e..c83ad62 100644 --- a/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts +++ b/extensions/ohif-gradienthealth-extension/src/utils/addAutoSegmentationSavingHandler.ts @@ -88,7 +88,7 @@ export default function addAutoSegmentationSavingHandler( ); } -export function calculateTotal(items: { price: number }[], tax: number | null) { +export function calculateTotalName(items: { price: number }[], tax?: number) { let total = 0; for (let i = 0; i < items.length; i++) { @@ -97,7 +97,7 @@ export function calculateTotal(items: { price: number }[], tax: number | null) { total = total + price; } - if (tax == null) { + if (!tax) { tax = 0.05; }