Browse Source

Add ts-check to build script

SukkaW 2 years ago
parent
commit
9a307709a5

+ 1 - 0
Build/lib/fetch-retry.js

@@ -1,3 +1,4 @@
+// @ts-check
 const { fetch } = require('undici');
 const fetchWithRetry = require('@vercel/fetch-retry')(fetch);
 module.exports.fetchWithRetry = fetchWithRetry;

+ 7 - 1
Build/lib/is-domain-loose.js

@@ -1,10 +1,16 @@
+// @ts-check
 const { parse } = require('tldts');
 
+/**
+ * @param {string} domain
+ */
 module.exports.isDomainLoose = (domain) => {
   const { isIcann, isPrivate, isIp } = parse(domain, { allowPrivateDomains: true });
   return !!(!isIp && (isIcann || isPrivate));
 };
-
+/**
+ * @param {string} domain
+ */
 module.exports.normalizeDomain = (domain) => {
   if (domain == null) {
     return null;

+ 1 - 0
Build/lib/parse-filter.js

@@ -1,3 +1,4 @@
+// @ts-check
 const { fetchWithRetry } = require('./fetch-retry');
 const { NetworkFilter } = require('@cliqz/adblocker');
 const { normalizeDomain } = require('./is-domain-loose');

+ 1 - 0
Build/lib/reject-data-source.js

@@ -1,3 +1,4 @@
+// @ts-check
 /** @type {[string, boolean][]} */
 const HOSTS = [
   ['https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext', true],

+ 9 - 0
Build/lib/string-array-compare.js

@@ -1,5 +1,10 @@
+// @ts-check
 const { promises: fsPromises } = require('fs');
 
+/**
+ * @param {string[]} linesA
+ * @param {string} filePath
+ */
 async function compareAndWriteFile(linesA, filePath) {
   const linesB = (await fsPromises.readFile(filePath, { encoding: 'utf-8' })).split('\n');
 
@@ -14,6 +19,10 @@ async function compareAndWriteFile(linesA, filePath) {
   }
 }
 
+/**
+ * @param {string[]} linesA
+ * @param {string[]} linesB
+ */
 function stringArrayCompare (linesA, linesB) {
   if (linesA.length !== linesB.length) return false;
 

+ 2 - 0
Build/lib/with-banner.js

@@ -1,3 +1,5 @@
+// @ts-check
+
 /**
  * @param {string} title
  * @param {string[]} description

+ 4 - 1
Build/worker/build-reject-domainset-worker.js

@@ -1,3 +1,4 @@
+// @ts-check
 const Piscina = require('piscina');
 // const { isCI } = require('ci-info');
 
@@ -5,7 +6,9 @@ const fullsetDomainStartsWithADot = Piscina.workerData
 const totalLen = fullsetDomainStartsWithADot.length;
 
 // const log = isCI ? () => { } : console.log.bind(console);
-
+/**
+ * @param {{ chunk: string[] }} param0
+ */
 module.exports = ({ chunk }) => {
   const chunkLength = chunk.length;
   const outputToBeRemoved = new Int8Array(chunkLength);