Skip to content

Commit f62afcc

Browse files
Add JavaScript linting
1 parent c95827d commit f62afcc

File tree

4 files changed

+77
-5
lines changed

4 files changed

+77
-5
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.

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ 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).
1314

1415
## [2.4.0] - 2024-10-08
1516

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;

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Magic-Mirror-Module-Remote-Control",
33
"version": "2.4.0",
4-
"description": "This module for the Magic Mirror allows you to shutdown and configure your mirror through a web browser.",
4+
"description": "This module for the MagicMirror allows you to shutdown and configure your mirror through a web browser.",
55
"repository": {
66
"type": "git",
77
"url": "git+https://github.com/jopyth/MMM-Remote-Control"
@@ -28,9 +28,16 @@
2828
"uuid": "^3.3.2"
2929
},
3030
"devDependencies": {
31-
"cspell": "^8.15.7"
31+
"@eslint/js": "^9.15.0",
32+
"cspell": "^8.16.0",
33+
"eslint": "^9.15.0",
34+
"eslint-plugin-import": "^2.31.0",
35+
"globals": "^15.12.0"
3236
},
3337
"scripts": {
34-
"test": "cspell ."
38+
"lint": "eslint .",
39+
"lint:fix": "eslint . --fix",
40+
"test": "npm run lint && npm run test:spelling",
41+
"test:spelling": "cspell ."
3542
}
3643
}

0 commit comments

Comments
 (0)