Enable the no-var linting rule in test/testutils.js

This is done automatically with the `gulp lint --fix` command with the
only exception of the `parts` variable.
This commit is contained in:
Tim van der Meij 2021-12-18 15:58:47 +01:00
parent a24982a733
commit 71326c6a1c
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

@ -13,13 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-var */
"use strict";
var fs = require("fs");
var path = require("path");
var rimrafSync = require("rimraf").sync;
const fs = require("fs");
const path = require("path");
const rimrafSync = require("rimraf").sync;
exports.removeDirSync = function removeDirSync(dir) {
fs.readdirSync(dir); // Will throw if dir is not a directory
@ -29,14 +28,14 @@ exports.removeDirSync = function removeDirSync(dir) {
};
exports.copySubtreeSync = function copySubtreeSync(src, dest) {
var files = fs.readdirSync(src);
const files = fs.readdirSync(src);
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
}
files.forEach(function (filename) {
var srcFile = path.join(src, filename);
var file = path.join(dest, filename);
var stats = fs.statSync(srcFile);
const srcFile = path.join(src, filename);
const file = path.join(dest, filename);
const stats = fs.statSync(srcFile);
if (stats.isDirectory()) {
copySubtreeSync(srcFile, file);
} else {
@ -49,8 +48,8 @@ exports.ensureDirSync = function ensureDirSync(dir) {
if (fs.existsSync(dir)) {
return;
}
var parts = dir.split(path.sep),
i = parts.length;
const parts = dir.split(path.sep);
let i = parts.length;
while (i > 1 && !fs.existsSync(parts.slice(0, i - 1).join(path.sep))) {
i--;
}