Skip to content

Commit 01d8e79

Browse files
authored
Merge pull request Jopyth#310 from KristjanESPERANTO/linter
Add JavaScript linting and GitHub workflow for testing
2 parents c95827d + c9ebbad commit 01d8e79

File tree

8 files changed

+4220
-8
lines changed

8 files changed

+4220
-8
lines changed

.github/CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ We ask you to keep contributing, and feel free to open as many issues and PR as
99

1010
## Developer commands
1111

12-
- `npm run test` - Run spelling check.
12+
- `npm run lint` - Run linting checks.
13+
- `npm run lint:fix` - Fix linting issues.
14+
- `npm run test` - Run linting and formatter checks + Run spelling check.
15+
- `npm run test:spelling` - Run spelling check.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Automated Tests
2+
on:
3+
push:
4+
branches: [master, develop]
5+
pull_request:
6+
branches: [master, develop]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
run-lint:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 30
15+
steps:
16+
- run: echo "Starting automated tests for ${{ github.repository }} on ${{ github.ref }}"
17+
- name: Check out repository code
18+
uses: actions/checkout@v4
19+
- name: Use Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 22
23+
cache: npm
24+
- name: Install dependencies
25+
run: npm ci
26+
- name: Check spelling
27+
run: npm run test:spelling
28+
- name: Check linting
29+
run: npm run lint
30+
- run: echo "Test job status is ${{ job.status }}."

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,4 @@ node_modules
3535
# Default settings
3636
settings.json
3737

38-
# Package Lock File
39-
package-lock.json
4038

API/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ module.exports = {
290290
actionName = req.body.monitor.toUpperCase();
291291
}
292292
} else {
293-
var actionName = req.params.action ? req.params.action.toUpperCase() : "STATUS";
293+
actionName = req.params.action ? req.params.action.toUpperCase() : "STATUS";
294294
}
295295
this.executeQuery(this.checkDelay({ action: `MONITOR${actionName}` }, req), res);
296296
});

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
99

1010
### Added
1111

12-
- Added a spell checker and fixed problems that were found.
12+
- Added a spell checker and fixed problems that were found (#308).
13+
- Added JavaScript linting (for the start with soft rules).
14+
- Added GitHub workflow for linting and spell checking on every push and pull request.
1315

1416
## [2.4.0] - 2024-10-08
1517

eslint.config.mjs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import eslintPluginImport from "eslint-plugin-import";
2+
import eslintPluginJs from "@eslint/js";
3+
import globals from "globals";
4+
5+
const config = [
6+
eslintPluginImport.flatConfigs.recommended,
7+
eslintPluginJs.configs.recommended,
8+
{
9+
"ignores": ["**/*.min.js"]
10+
},
11+
{
12+
"files": ["**/*.js"],
13+
"languageOptions": {
14+
"globals": {
15+
...globals.browser,
16+
...globals.node
17+
},
18+
"sourceType": "commonjs"
19+
},
20+
"rules": {
21+
"capitalized-comments": "off",
22+
"consistent-this": "off",
23+
"line-comment-position": "off",
24+
"max-lines-per-function": ["warn", 200],
25+
"max-statements": ["warn", 60],
26+
"multiline-comment-style": "off",
27+
"no-await-in-loop": "off",
28+
"no-constant-binary-expression": "warn",
29+
"no-inline-comments": "off",
30+
"no-magic-numbers": "off",
31+
"no-plusplus": "off",
32+
"no-prototype-builtins": "warn",
33+
"no-undef": "warn",
34+
"no-unused-vars": "warn",
35+
"no-useless-escape": "warn",
36+
"no-var": "warn",
37+
"one-var": "off",
38+
"sort-keys": "off",
39+
"strict": "off"
40+
}
41+
},
42+
{
43+
"files": ["**/*.mjs"],
44+
"languageOptions": {
45+
"ecmaVersion": "latest",
46+
"globals": {
47+
...globals.node
48+
},
49+
"sourceType": "module"
50+
},
51+
"rules": {
52+
"func-style": "off",
53+
"max-lines-per-function": ["error", 100],
54+
"no-magic-numbers": "off",
55+
"one-var": "off",
56+
"prefer-destructuring": "off"
57+
}
58+
}
59+
];
60+
61+
export default config;

0 commit comments

Comments
 (0)