diff --git a/.eslintrc.json b/.eslintrc.json
index 22e0bc736..c4a67231b 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -81,7 +81,7 @@
{
"files": [
"bin/**",
- "build/**",
+ "build/**/*.js",
"src/cli/**",
"Gruntfile.js",
"rollup.config.js"
@@ -99,6 +99,7 @@
"node": true
},
"rules": {
+ "strict": "error",
"compat/compat": "off",
"no-console": "off",
"no-process-exit": "off",
diff --git a/Gruntfile.js b/Gruntfile.js
index 173841ece..fc0831331 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,4 +1,5 @@
/* eslint-env node */
+'use strict';
const fs = require('fs');
const path = require('path');
diff --git a/build/dev.js b/build/dev.js
index b5c4ef40c..6b80ff9d7 100644
--- a/build/dev.js
+++ b/build/dev.js
@@ -1,3 +1,5 @@
+'use strict';
+
const fs = require('fs');
const http = require('http');
const path = require('path');
diff --git a/build/dist-replace.js b/build/dist-replace.js
index 7ba45764b..21da5d27b 100644
--- a/build/dist-replace.js
+++ b/build/dist-replace.js
@@ -5,6 +5,7 @@
// If a date or timestamp is used, then honour SOURCE_DATE_EPOCH
// and update RELEASE.md as needed.
// .
+'use strict';
let distVersion = require('../package.json').version;
diff --git a/build/npm-search.js b/build/npm-search.js
index 8290166eb..95c8aaf96 100644
--- a/build/npm-search.js
+++ b/build/npm-search.js
@@ -1,27 +1,20 @@
+'use strict';
+
+const NPM_REGISTRY_URL = 'https://registry.npmjs.org/';
+
/**
- * npm-search.js is based on npm-keyword v6.1.0 by @sindresorhus,
+ * This is based on npm-keyword v6.1.0 by @sindresorhus,
* but simplified to not have 32 needless dependencies.
*
* -
* -
+ *
+ * @param {string} keyword
+ * @return {Object[]} List of package objects
*/
-'use strict';
-const https = require('https');
-const registryUrl = 'https://registry.npmjs.org/';
-
-function fetch (url) {
- return new Promise((resolve, reject) => {
- const req = https.get(url, (resp) => {
- let data = '';
- resp.on('data', (chunk) => {
- data += chunk;
- });
- resp.on('end', () => {
- resolve(data);
- });
- });
- req.on('error', reject);
- });
+async function keyword (keyword) {
+ const { objects } = await search('keywords:' + keyword, { size: 250 });
+ return objects.map(element => element.package);
}
async function search (phrase, options) {
@@ -32,17 +25,9 @@ async function search (phrase, options) {
}
phrase = encodeURIComponent(phrase).replace('%2C', '+');
- const url = `${registryUrl}-/v1/search?text=${phrase}&size=${options.size}`;
- return JSON.parse(await fetch(url));
-}
-
-/**
- * @param {string} keyword
- * @return {Object[]} List of package objects
- */
-async function keyword (keyword) {
- const { objects } = await search('keywords:' + keyword, { size: 250 });
- return objects.map(element => element.package);
+ const url = `${NPM_REGISTRY_URL}-/v1/search?text=${phrase}&size=${options.size}`;
+ const resp = await fetch(url);
+ return await resp.json();
}
module.exports = { search, keyword };
diff --git a/build/prep-release.js b/build/prep-release.js
index 6795f4c80..e9bfa6176 100644
--- a/build/prep-release.js
+++ b/build/prep-release.js
@@ -7,6 +7,7 @@
// See also RELEASE.md.
//
// Inspired by .
+'use strict';
const fs = require('fs');
const path = require('path');
diff --git a/build/q4000-template.js b/build/q4000-template.js
index bb0a0e96c..ead3380a9 100644
--- a/build/q4000-template.js
+++ b/build/q4000-template.js
@@ -1,3 +1,5 @@
+'use strict';
+
const fs = require('fs');
const path = require('path');
diff --git a/build/reproducible-builds.js b/build/reproducible-builds.js
index 0665a73b6..ae720a561 100644
--- a/build/reproducible-builds.js
+++ b/build/reproducible-builds.js
@@ -4,6 +4,7 @@
// * Node.js 18+, npm 10+
// * Git 2.11+
// * tar, shasum, gunzip (preinstalled on Linux/macOS)
+'use strict';
const cp = require('child_process');
const fs = require('fs');
diff --git a/build/review-package.js b/build/review-package.js
index 1cd868f56..422bc2557 100644
--- a/build/review-package.js
+++ b/build/review-package.js
@@ -1,8 +1,8 @@
// Helper for reviewing build artefacts against a past release.
//
// See also RELEASE.md.
-
/* eslint-env node */
+'use strict';
const cp = require('child_process');
const fs = require('fs');
diff --git a/build/site-set-version.js b/build/site-set-version.js
index 9a33a3669..a5528e7cd 100644
--- a/build/site-set-version.js
+++ b/build/site-set-version.js
@@ -1,3 +1,5 @@
+'use strict';
+
const fs = require('fs');
const { CommandError, isValidVersion, versionAnywhereRegPattern } = require('./utils.js');
diff --git a/build/site-update-plugins.js b/build/site-update-plugins.js
index 8627649ce..e4aa87877 100644
--- a/build/site-update-plugins.js
+++ b/build/site-update-plugins.js
@@ -1,3 +1,5 @@
+'use strict';
+
const fs = require('fs');
const { keyword } = require('./npm-search.js');
diff --git a/build/utils.js b/build/utils.js
index 77b104031..70f5b39d8 100644
--- a/build/utils.js
+++ b/build/utils.js
@@ -1,3 +1,5 @@
+'use strict';
+
const cp = require('child_process');
const fs = require('fs');
const https = require('https');
diff --git a/demos/bundlers/Gruntfile.js b/demos/bundlers/Gruntfile.js
index e679d83bc..701a37087 100644
--- a/demos/bundlers/Gruntfile.js
+++ b/demos/bundlers/Gruntfile.js
@@ -1,4 +1,5 @@
/* eslint-env node */
+'use strict';
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-qunit');
diff --git a/demos/grunt-contrib-qunit/Gruntfile.js b/demos/grunt-contrib-qunit/Gruntfile.js
index 03834c01b..52b90db74 100644
--- a/demos/grunt-contrib-qunit/Gruntfile.js
+++ b/demos/grunt-contrib-qunit/Gruntfile.js
@@ -1,4 +1,5 @@
/* eslint-env node */
+'use strict';
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-qunit');
diff --git a/rollup.config.js b/rollup.config.js
index 3ae0b3a20..4fe734e69 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -1,4 +1,5 @@
/* eslint-env node */
+'use strict';
const { babel } = require('@rollup/plugin-babel');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
diff --git a/src/cli/require-from-cwd.js b/src/cli/require-from-cwd.js
index 335bb96c8..22fbad018 100644
--- a/src/cli/require-from-cwd.js
+++ b/src/cli/require-from-cwd.js
@@ -1,3 +1,5 @@
+'use strict';
+
module.exports = function requireFromCWD (mod) {
const resolvedPath = require.resolve(mod, { paths: [process.cwd()] });
return require(resolvedPath);
diff --git a/src/cli/require-qunit.js b/src/cli/require-qunit.js
index 9e4823152..9a71e2c64 100644
--- a/src/cli/require-qunit.js
+++ b/src/cli/require-qunit.js
@@ -1,5 +1,9 @@
-// Depending on the exact usage, QUnit could be in one of several places, this
-// function handles finding it.
+'use strict';
+
+/**
+ * Depending on the exact usage, QUnit could be in one of several places, this
+ * function handles finding it.
+ */
module.exports = function requireQUnit (resolve = require.resolve) {
try {
// For: