Skip to content

Commit ed7cc42

Browse files
committed
Add GitHub Action for Code Linting
This pull request introduces a GitHub Action workflow to automate the linting of various code types in the repo on each push and pull request. It add: - lint.yml to define the workflow - eslint.config.js to manage the rules for the js linting The workflow runs the following linters: - JavaScript: Uses ESLint to check for issues in JavaScript files. - HTML: Uses HTMLHint to lint HTML files. - CSS: Uses Stylelint to ensure proper CSS formatting. - Shell scripts: Uses ShellCheck to lint shell scripts. - C++: Uses Clang-Tidy to check C++ code for style and potential errors. By adding this workflow, we ensure consistent code quality and formatting across multiple languages in the repository.
1 parent 6199f5e commit ed7cc42

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.github/workflows/lint.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Lint Code
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v2
12+
13+
- name: Install ESLint globally
14+
run: |
15+
sudo apt-get update
16+
sudo apt-get install -y eslint # Install ESLint globally
17+
18+
- name: Install ShellCheck
19+
run: |
20+
sudo apt-get install -y shellcheck
21+
22+
- name: Install Clang-Tidy
23+
run: |
24+
sudo apt-get install -y clang-tidy
25+
26+
# - name: Install Perl and cpanm
27+
# run: |
28+
# sudo apt-get install -y perl
29+
# sudo apt-get install -y cpanminus # Install cpanm tool
30+
31+
# - name: Install missing Perl dependencies
32+
# run: |
33+
# sudo cpanm Module::Pluggable # Install the missing dependency
34+
# sudo cpanm --installdeps Perl::Critic # Install all dependencies for Perl::Critic
35+
36+
# - name: Install Perl::Critic
37+
# run: |
38+
# sudo cpanm Perl::Critic # Install Perl::Critic module
39+
40+
- name: Lint JavaScript
41+
run: npx eslint .
42+
43+
- name: Lint HTML
44+
run: npx htmlhint .
45+
46+
- name: Lint CSS
47+
run: npx stylelint "**/*.css"
48+
49+
- name: Lint Shell scripts
50+
run: shellcheck **/*.sh
51+
52+
- name: Lint C++ code
53+
run: clang-tidy **/*.cpp
54+
55+
# - name: Lint Perl
56+
# run: perlcritic **/*.pl

eslint.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// eslint.config.js
2+
module.exports = [
3+
{
4+
languageOptions: {
5+
globals: {
6+
// Define any global variables here (e.g., for browsers)
7+
window: 'readonly',
8+
document: 'readonly',
9+
},
10+
parserOptions: {
11+
ecmaVersion: 12, // ES2021
12+
sourceType: 'module', // Enable ES6 modules
13+
},
14+
},
15+
rules: {
16+
'no-console': 'warn', // Warn on console statements
17+
'semi': ['error', 'always'], // Enforce semicolons
18+
'quotes': ['error', 'single'], // Enforce single quotes
19+
'eqeqeq': 'error', // Enforce strict equality (===)
20+
'curly': 'error', // Enforce curly braces for control statements
21+
'no-unused-vars': 'warn', // Warn about unused variables
22+
'no-magic-numbers': 'off', // Optional: disable rule for magic numbers if you want
23+
},
24+
},
25+
];

0 commit comments

Comments
 (0)