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..25ba5c5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +name: Lint Code + +on: + push: + branches: + - main + pull_request: + branches: + - main + +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/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 diff --git a/package.json b/package.json new file mode 100644 index 0000000..3f02d29 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "scripts": { + "lint": "eslint .", + "lint:fix": "eslint . --fix" + }, + "devDependencies": { + "@eslint/js": "^9.13.0", + "eslint": "^8.57.1", + "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){ 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