Skip to content

Commit

Permalink
Merge pull request #310 from KristjanESPERANTO/linter
Browse files Browse the repository at this point in the history
Add JavaScript linting and GitHub workflow for testing
  • Loading branch information
ezeholz authored Nov 20, 2024
2 parents c95827d + c9ebbad commit 01d8e79
Show file tree
Hide file tree
Showing 8 changed files with 4,220 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ We ask you to keep contributing, and feel free to open as many issues and PR as

## Developer commands

- `npm run test` - Run spelling check.
- `npm run lint` - Run linting checks.
- `npm run lint:fix` - Fix linting issues.
- `npm run test` - Run linting and formatter checks + Run spelling check.
- `npm run test:spelling` - Run spelling check.
30 changes: 30 additions & 0 deletions .github/workflows/automated-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Automated Tests
on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]

permissions:
contents: read

jobs:
run-lint:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- run: echo "Starting automated tests for ${{ github.repository }} on ${{ github.ref }}"
- name: Check out repository code
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Check spelling
run: npm run test:spelling
- name: Check linting
run: npm run lint
- run: echo "Test job status is ${{ job.status }}."
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ node_modules
# Default settings
settings.json

# Package Lock File
package-lock.json

2 changes: 1 addition & 1 deletion API/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ module.exports = {
actionName = req.body.monitor.toUpperCase();
}
} else {
var actionName = req.params.action ? req.params.action.toUpperCase() : "STATUS";
actionName = req.params.action ? req.params.action.toUpperCase() : "STATUS";
}
this.executeQuery(this.checkDelay({ action: `MONITOR${actionName}` }, req), res);
});
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

### Added

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

## [2.4.0] - 2024-10-08

Expand Down
61 changes: 61 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import eslintPluginImport from "eslint-plugin-import";
import eslintPluginJs from "@eslint/js";
import globals from "globals";

const config = [
eslintPluginImport.flatConfigs.recommended,
eslintPluginJs.configs.recommended,
{
"ignores": ["**/*.min.js"]
},
{
"files": ["**/*.js"],
"languageOptions": {
"globals": {
...globals.browser,
...globals.node
},
"sourceType": "commonjs"
},
"rules": {
"capitalized-comments": "off",
"consistent-this": "off",
"line-comment-position": "off",
"max-lines-per-function": ["warn", 200],
"max-statements": ["warn", 60],
"multiline-comment-style": "off",
"no-await-in-loop": "off",
"no-constant-binary-expression": "warn",
"no-inline-comments": "off",
"no-magic-numbers": "off",
"no-plusplus": "off",
"no-prototype-builtins": "warn",
"no-undef": "warn",
"no-unused-vars": "warn",
"no-useless-escape": "warn",
"no-var": "warn",
"one-var": "off",
"sort-keys": "off",
"strict": "off"
}
},
{
"files": ["**/*.mjs"],
"languageOptions": {
"ecmaVersion": "latest",
"globals": {
...globals.node
},
"sourceType": "module"
},
"rules": {
"func-style": "off",
"max-lines-per-function": ["error", 100],
"no-magic-numbers": "off",
"one-var": "off",
"prefer-destructuring": "off"
}
}
];

export default config;
Loading

0 comments on commit 01d8e79

Please sign in to comment.