diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..1c558d5 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,21 @@ +{ + "env": { + "browser": true, + "es2021": true, + "node": true + }, + "extends": [ + "eslint:recommended" + ], + "parserOptions": { + "ecmaVersion": 12, + "sourceType": "module" + }, + "rules": { + "no-unused-vars": "error", + "no-console": "warn", + "semi": ["error", "always"], + "quotes": ["error", "single"] + }, + "ignorePatterns": ["node_modules/", "dist/", "build/"] +} \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c53f5a0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,30 @@ +name: Code Linting + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Install ESLint globally + run: npm install -g eslint + + - name: Run ESLint + run: eslint src/ --ext .js \ No newline at end of file diff --git a/src/example.js b/src/example.js new file mode 100644 index 0000000..b3ca138 --- /dev/null +++ b/src/example.js @@ -0,0 +1,14 @@ +// This file demonstrates proper linting compliance + +function exampleFunction() { + const usedVariable = 'This variable is properly used'; + + // Note: console.log is allowed but will show as a warning + console.log('This uses single quotes as required'); + + let properVariable = 'This line has a semicolon'; + + return properVariable; +} + +exampleFunction(); \ No newline at end of file