Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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/"]
}
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions src/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This file demonstrates proper linting compliance

function exampleFunction() {
const usedVariable = 'This variable is properly used';

Check failure on line 4 in src/example.js

View workflow job for this annotation

GitHub Actions / lint

'usedVariable' is assigned a value but never used

Check failure on line 4 in src/example.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4

// Note: console.log is allowed but will show as a warning

Check failure on line 6 in src/example.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
console.log('This uses single quotes as required');

Check warning on line 7 in src/example.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check failure on line 7 in src/example.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4

let properVariable = 'This line has a semicolon';

Check failure on line 9 in src/example.js

View workflow job for this annotation

GitHub Actions / lint

'properVariable' is never reassigned. Use 'const' instead

Check failure on line 9 in src/example.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4

return properVariable;

Check failure on line 11 in src/example.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
}

exampleFunction();
Loading