diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..5ddcc0d --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,34 @@ +// Purpose: This file configures ESLint, a static code analysis tool for identifying problematic patterns in JavaScript and TypeScript code. + +{ + "env": { + "browser": true, + "es2021": true, + "node": true + }, + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended", + "plugin:@typescript-eslint/recommended", + "prettier" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": 12, + "sourceType": "module" + }, + "plugins": [ + "react", + "react-hooks", + "@typescript-eslint" + ], + "rules": { + "react/react-in-jsx-scope": "off", + "@typescript-eslint/no-unused-vars": ["error"] + } + } + \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7957a3e..2984792 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,40 +8,32 @@ # 6. Deployment Test (automated deployment upon successful tests) -name: CI Workflow +name: Node.js CI -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: - lint: + build: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm install - - run: npm run lint - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm install - - run: npm run test + strategy: + matrix: + node-version: [14, 16, 18] - build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: 16 + node-version: ${{ matrix.node-version }} - run: npm install + - run: npm run lint + - run: npm run test - run: npm run build + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46a99b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Purpose: This file specifies which files and directories should be ignored by Git version control. + +node_modules/ +dist/ +coverage/ +.env diff --git a/package.json b/package.json new file mode 100644 index 0000000..a463124 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "version": "1.0.0", + "description": "A sample project for CI testing", + "main": "index.js", + "scripts": { + "lint": "eslint .", + "test": "vitest run", + "build": "echo 'Build successful'" + }, + "author": "Your Name", + "license": "MIT", + "devDependencies": { + "eslint": "^8.50.0", + "eslint-plugin-react": "^7.32.0", + "eslint-plugin-react-hooks": "^4.6.0", + "vitest": "^0.32.0" + } + } + \ No newline at end of file diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..dad0c5c --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,15 @@ +// Purpose: This file configures Vitest, a modern testing framework for JavaScript and TypeScript applications. + +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + globals: true, + environment: 'jsdom', + coverage: { + reporter: ['text', 'json', 'html'], + include: ['src/**/*.ts', 'src/**/*.tsx'], + exclude: ['**/*.spec.ts', '**/*.test.ts'], + }, + }, +}); \ No newline at end of file