Skip to content

Commit 5dc0113

Browse files
authored
Rollup merge of rust-lang#109052 - GuillaumeGomez:rustdoc-gui-tester-eslint, r=notriddle
Add eslint check for rustdoc-gui tester r? `@notriddle`
2 parents fb4bb16 + cd9759a commit 5dc0113

File tree

3 files changed

+106
-9
lines changed

3 files changed

+106
-9
lines changed

src/ci/docker/host-x86_64/mingw-check/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
5353
# Runs checks to ensure that there are no ES5 issues in our JS code.
5454
es-check es6 ../src/librustdoc/html/static/js/*.js && \
5555
eslint -c ../src/librustdoc/html/static/.eslintrc.js ../src/librustdoc/html/static/js/*.js && \
56-
eslint -c ../src/tools/rustdoc-js/.eslintrc.js ../src/tools/rustdoc-js/tester.js
56+
eslint -c ../src/tools/rustdoc-js/.eslintrc.js ../src/tools/rustdoc-js/tester.js && \
57+
eslint -c ../src/tools/rustdoc-gui/.eslintrc.js ../src/tools/rustdoc-gui/tester.js

src/tools/rustdoc-gui/.eslintrc.js

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"node": true,
5+
"es6": true
6+
},
7+
"extends": "eslint:recommended",
8+
"parserOptions": {
9+
"ecmaVersion": 2018,
10+
"sourceType": "module"
11+
},
12+
"rules": {
13+
"linebreak-style": [
14+
"error",
15+
"unix"
16+
],
17+
"semi": [
18+
"error",
19+
"always"
20+
],
21+
"quotes": [
22+
"error",
23+
"double"
24+
],
25+
"linebreak-style": [
26+
"error",
27+
"unix"
28+
],
29+
"no-trailing-spaces": "error",
30+
"no-var": ["error"],
31+
"prefer-const": ["error"],
32+
"prefer-arrow-callback": ["error"],
33+
"brace-style": [
34+
"error",
35+
"1tbs",
36+
{ "allowSingleLine": false }
37+
],
38+
"keyword-spacing": [
39+
"error",
40+
{ "before": true, "after": true }
41+
],
42+
"arrow-spacing": [
43+
"error",
44+
{ "before": true, "after": true }
45+
],
46+
"key-spacing": [
47+
"error",
48+
{ "beforeColon": false, "afterColon": true, "mode": "strict" }
49+
],
50+
"func-call-spacing": ["error", "never"],
51+
"space-infix-ops": "error",
52+
"space-before-function-paren": ["error", "never"],
53+
"space-before-blocks": "error",
54+
"comma-dangle": ["error", "always-multiline"],
55+
"comma-style": ["error", "last"],
56+
"max-len": ["error", { "code": 100, "tabWidth": 4 }],
57+
"eol-last": ["error", "always"],
58+
"arrow-parens": ["error", "as-needed"],
59+
"no-unused-vars": [
60+
"error",
61+
{
62+
"argsIgnorePattern": "^_",
63+
"varsIgnorePattern": "^_"
64+
}
65+
],
66+
"eqeqeq": "error",
67+
"no-const-assign": "error",
68+
"no-debugger": "error",
69+
"no-dupe-args": "error",
70+
"no-dupe-else-if": "error",
71+
"no-dupe-keys": "error",
72+
"no-duplicate-case": "error",
73+
"no-ex-assign": "error",
74+
"no-fallthrough": "error",
75+
"no-invalid-regexp": "error",
76+
"no-import-assign": "error",
77+
"no-self-compare": "error",
78+
"no-template-curly-in-string": "error",
79+
"block-scoped-var": "error",
80+
"guard-for-in": "error",
81+
"no-alert": "error",
82+
"no-confusing-arrow": "error",
83+
"no-div-regex": "error",
84+
"no-floating-decimal": "error",
85+
"no-implicit-globals": "error",
86+
"no-implied-eval": "error",
87+
"no-label-var": "error",
88+
"no-lonely-if": "error",
89+
"no-mixed-operators": "error",
90+
"no-multi-assign": "error",
91+
"no-return-assign": "error",
92+
"no-script-url": "error",
93+
"no-sequences": "error",
94+
"no-div-regex": "error",
95+
}
96+
};

src/tools/rustdoc-gui/tester.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
const fs = require("fs");
88
const path = require("path");
9-
const os = require('os');
10-
const {Options, runTest} = require('browser-ui-test');
9+
const os = require("os");
10+
const {Options, runTest} = require("browser-ui-test");
1111

1212
// If a test fails or errors, we will retry it two more times in case it was a flaky failure.
1313
const NB_RETRY = 3;
@@ -200,7 +200,7 @@ async function main(argv) {
200200
const framework_options = new Options();
201201
try {
202202
// This is more convenient that setting fields one by one.
203-
let args = [
203+
const args = [
204204
"--variable", "DOC_PATH", opts["doc_folder"], "--enable-fail-on-js-error",
205205
"--allow-file-access-from-files",
206206
];
@@ -234,7 +234,7 @@ async function main(argv) {
234234
} else {
235235
files = opts["files"];
236236
}
237-
files = files.filter(file => path.extname(file) == ".goml");
237+
files = files.filter(file => path.extname(file) === ".goml");
238238
if (files.length === 0) {
239239
console.error("rustdoc-gui: No test selected");
240240
process.exit(2);
@@ -259,7 +259,7 @@ async function main(argv) {
259259

260260
// We catch this "event" to display a nicer message in case of unexpected exit (because of a
261261
// missing `--no-sandbox`).
262-
const exitHandling = (code) => {
262+
const exitHandling = () => {
263263
if (!opts["no_sandbox"]) {
264264
console.log("");
265265
console.log(
@@ -268,10 +268,10 @@ async function main(argv) {
268268
console.log("");
269269
}
270270
};
271-
process.on('exit', exitHandling);
271+
process.on("exit", exitHandling);
272272

273273
const originalFilesLen = files.length;
274-
let results = createEmptyResults();
274+
const results = createEmptyResults();
275275
const status_bar = char_printer(files.length);
276276

277277
let new_results;
@@ -281,7 +281,7 @@ async function main(argv) {
281281
Array.prototype.push.apply(results.successful, new_results.successful);
282282
// We generate the new list of files with the previously failing tests.
283283
files = Array.prototype.concat(new_results.failed, new_results.errored).map(
284-
f => f['file_name']);
284+
f => f["file_name"]);
285285
if (files.length > originalFilesLen / 2) {
286286
// If we have too many failing tests, it's very likely not flaky failures anymore so
287287
// no need to retry.

0 commit comments

Comments
 (0)