From 33a8264c07051d953e951dae96050f312840beb9 Mon Sep 17 00:00:00 2001 From: Sam007 <122424295+sam14243@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:09:02 +0530 Subject: [PATCH 1/5] Implemented CI pipeline for Linting --- .github/pull_request_template.md | 3 ++- .github/workflows/lint.yml | 25 +++++++++++++++++++++++++ README.md | 3 +++ package.json | 12 ++++++++++++ script.js | 16 +++++++++------- 5 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 package.json diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 796b6eb..dc45e05 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,7 +6,8 @@ Please include a concise summary of the change and any relevant details. ## PR Checklist -- [ ] My submission follows the guidelines in [Contribution.md](/Contribution.md). +- [ ] My submission follows the guidelines in [Contribution.md](https://github.com/DhanushNehru/breakout-game/blob/main/Contribution.md). +- [ ] I have tested `npm run lint` locally. - [ ] All new and existing tests pass. - [ ] The description of changes is clear and concise. - [ ] I have documented any necessary changes to the codebase. \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..0db0abd --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: Lint Code + +on: + push: + branches: + - main + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Install Dependencies + run: npm install + + - name: Run Lint + run: npm run lint \ No newline at end of file diff --git a/README.md b/README.md index 1f7d28c..e9631d1 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,9 @@ You can use Gitpod in the cloud [![Gitpod Ready-to-Code](https://img.shields.io/ ## Controls - Move mouse to control the paddle, or use 'A'and the left arrow key or 'D' and the right arrow key for left and right movement respectively. +## Linting Status +![Linting Status](https://github.com/DhanushNehru/breakout-game/actions/workflows/lint.yml/badge.svg) + Created with diff --git a/package.json b/package.json new file mode 100644 index 0000000..765aa82 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "scripts": { + "lint": "eslint .", + "lint:fix": "eslint . --fix" + }, + "devDependencies": { + "@eslint/js": "^9.13.0", + "eslint": "^9.13.0", + "globals": "^15.11.0" + } +} + diff --git a/script.js b/script.js index df8ab39..c654ed7 100644 --- a/script.js +++ b/script.js @@ -1,3 +1,5 @@ +import { utilsColor } from './utils/utilsColor.js'; + var canvas = document.getElementById('myCanvas'); var ctx = canvas.getContext('2d'); @@ -73,9 +75,9 @@ sizeSlider.addEventListener("input", () => { changeBrickColumnCountAndOffsetLeft() let bricks = []; -for (c=0; c b.x && x-ballRadius < b.x+brickWidth && y+ballRadius > b.y && y-ballRadius < b.y+brickHeight) { if(y > b.y && y < b.y+brickHeight){ if(x < b.x || x > b.x+brickWidth){ From da205463b02c504d26d5c9bfc9cb9efd180e960b Mon Sep 17 00:00:00 2001 From: Sam007 <122424295+sam14243@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:12:36 +0530 Subject: [PATCH 2/5] Added ESlint config file --- eslint.config.mjs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 eslint.config.mjs diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..2edbef8 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,8 @@ +import globals from "globals"; +import pluginJs from "@eslint/js"; + + +export default [ + {languageOptions: { globals: globals.browser }}, + pluginJs.configs.recommended, +]; \ No newline at end of file From bb8a2459f014f658061d0891688e9c4525f1ae54 Mon Sep 17 00:00:00 2001 From: Sam007 <122424295+sam14243@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:35:59 +0530 Subject: [PATCH 3/5] Modified package.json file --- package.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 765aa82..3f02d29 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,11 @@ { "scripts": { - "lint": "eslint .", - "lint:fix": "eslint . --fix" + "lint": "eslint .", + "lint:fix": "eslint . --fix" }, "devDependencies": { "@eslint/js": "^9.13.0", - "eslint": "^9.13.0", + "eslint": "^8.57.1", "globals": "^15.11.0" } } - From e08d386f3d696ad834589ca0a6338cea5bdeb22f Mon Sep 17 00:00:00 2001 From: Sam007 <122424295+sam14243@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:39:08 +0530 Subject: [PATCH 4/5] Fixed lint errors --- utils/utilsColor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/utilsColor.js b/utils/utilsColor.js index 5de7690..191237d 100644 --- a/utils/utilsColor.js +++ b/utils/utilsColor.js @@ -29,4 +29,6 @@ function useColor(modeColor, X, Y){ return arrayColor[Y] return arrayColor[0] -} \ No newline at end of file +} + +export { utilsColor } \ No newline at end of file From 33d3e99615cdb443bd959fad0cd57168b82f82b6 Mon Sep 17 00:00:00 2001 From: Sam007 <122424295+sam14243@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:51:23 +0530 Subject: [PATCH 5/5] Modified lint.yml file --- .github/workflows/lint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0db0abd..25ba5c5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,6 +5,8 @@ on: branches: - main pull_request: + branches: + - main jobs: lint: