Skip to content

Commit b47d1cf

Browse files
authored
Merge pull request #2554 from GuillaumeGomez/eslint
Fix eslint warnings and add eslint check in CI
2 parents 780daa7 + 9114905 commit b47d1cf

File tree

8 files changed

+636
-417
lines changed

8 files changed

+636
-417
lines changed

.eslintrc.json

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"node": true,
5+
"es6": true
6+
},
7+
"extends": "eslint:recommended",
8+
"globals": {
9+
"module": "readonly",
10+
"require": "readonly"
11+
},
12+
"parserOptions": {
13+
"ecmaVersion": 2018,
14+
"requireConfigFile": false,
15+
"sourceType": "module"
16+
},
17+
"ignorePatterns": ["**min.js", "**/highlight.js", "**/playground_editor/*"],
18+
"rules": {
19+
"indent": [
20+
"error",
21+
4
22+
],
23+
"linebreak-style": [
24+
"error",
25+
"unix"
26+
],
27+
"quotes": [
28+
"error",
29+
"single"
30+
],
31+
"semi": [
32+
"error",
33+
"always"
34+
],
35+
"brace-style": [
36+
"error",
37+
"1tbs",
38+
{ "allowSingleLine": false }
39+
],
40+
"curly": "error",
41+
"no-trailing-spaces": "error",
42+
"no-multi-spaces": "error",
43+
"keyword-spacing": [
44+
"error",
45+
{ "before": true, "after": true }
46+
],
47+
"comma-spacing": [
48+
"error",
49+
{ "before": false, "after": true }
50+
],
51+
"arrow-spacing": [
52+
"error",
53+
{ "before": true, "after": true }
54+
],
55+
"key-spacing": [
56+
"error",
57+
{ "beforeColon": false, "afterColon": true, "mode": "strict" }
58+
],
59+
"func-call-spacing": ["error", "never"],
60+
"space-infix-ops": "error",
61+
"space-before-function-paren": ["error", "never"],
62+
"space-before-blocks": "error",
63+
"no-console": [
64+
"error",
65+
{ "allow": ["warn", "error"] }
66+
],
67+
"comma-dangle": ["error", "always-multiline"],
68+
"comma-style": ["error", "last"],
69+
"max-len": ["error", { "code": 100, "tabWidth": 2 }],
70+
"eol-last": ["error", "always"],
71+
"no-extra-parens": "error",
72+
"arrow-parens": ["error", "as-needed"],
73+
"no-unused-vars": [
74+
"error",
75+
{
76+
"argsIgnorePattern": "^_",
77+
"varsIgnorePattern": "^_"
78+
}
79+
],
80+
"prefer-const": ["error"],
81+
"no-var": "error",
82+
"eqeqeq": "error"
83+
},
84+
"overrides": [
85+
{
86+
"files": [
87+
"tests/**/*.js"
88+
],
89+
"env": {
90+
"jest": true,
91+
"node": true
92+
}
93+
}
94+
]
95+
}

.github/workflows/main.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ on:
33
pull_request:
44
merge_group:
55

6-
env:
7-
BROWSER_UI_TEST_VERSION: '0.19.0'
8-
96
jobs:
107
test:
118
runs-on: ${{ matrix.os }}
@@ -85,7 +82,9 @@ jobs:
8582
with:
8683
node-version: 20
8784
- name: Install browser-ui-test
88-
run: npm install browser-ui-test@"${BROWSER_UI_TEST_VERSION}"
85+
run: npm install
86+
- name: Run eslint
87+
run: npm run lint
8988
- name: Build and run tests (+ GUI)
9089
run: cargo test --locked --target x86_64-unknown-linux-gnu --test gui
9190

CONTRIBUTING.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ If you want to only run some tests, you can filter them by passing (part of) the
150150
cargo test --test gui -- search
151151
```
152152
153-
The first time, it'll fail and ask you to install the `browser-ui-test` package. Install it then re-run the tests.
153+
The first time, it'll fail and ask you to install the `browser-ui-test` package. Install it with the provided
154+
command then re-run the tests.
154155
155156
If you want to disable the headless mode, use the `--disable-headless-test` option:
156157
@@ -162,6 +163,21 @@ The GUI tests are in the directory `tests/gui` in text files with the `.goml` ex
162163
using a `node.js` framework called `browser-ui-test`. You can find documentation for this language on its
163164
[repository](https://github.com/GuillaumeGomez/browser-UI-test/blob/master/goml-script.md).
164165
166+
### Checking changes in `.js` files
167+
168+
The `.js` files source code is checked using [`eslint`](https://eslint.org/). This is a linter (just like `clippy` in Rust)
169+
for the Javascript language. You can install it with `npm` by running the following command:
170+
171+
```
172+
npm install
173+
```
174+
175+
Then you can run it using:
176+
177+
```
178+
npm run lint
179+
```
180+
165181
## Updating highlight.js
166182
167183
The following are instructions for updating [highlight.js](https://highlightjs.org/).

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"dependencies": {
3+
"browser-ui-test": "0.19.0",
4+
"eslint": "^8.57.1"
5+
},
6+
"scripts": {
7+
"lint": "eslint src/theme/*js src/theme/**/*js",
8+
"lint-fix": "eslint --fix src/theme/*js src/theme/**/*js"
9+
}
10+
}

0 commit comments

Comments
 (0)