diff --git a/.prettierrc b/.prettierrc index 90155910..5a4c7be4 100644 --- a/.prettierrc +++ b/.prettierrc @@ -11,6 +11,12 @@ "options": { "parser": "markdown" } + }, + { + "files": "*.js", + "options": { + "printWidth": 120 + } } ], "endOfLine": "lf" diff --git a/docs/oev-searchers/in-depth/oev-auctioneer.test.ts b/docs/oev-searchers/in-depth/oev-auctioneer.test.js similarity index 76% rename from docs/oev-searchers/in-depth/oev-auctioneer.test.ts rename to docs/oev-searchers/in-depth/oev-auctioneer.test.js index d2b7b184..e5bc3027 100644 --- a/docs/oev-searchers/in-depth/oev-auctioneer.test.ts +++ b/docs/oev-searchers/in-depth/oev-auctioneer.test.js @@ -6,22 +6,14 @@ import { getChains } from '@api3/dapi-management'; const supportedMainnets = getChains() .filter((chain) => chain.stage === 'active') - .map((chain) => CHAINS.find((api3Chain) => api3Chain.id === chain.id)!) + .map((chain) => CHAINS.find((api3Chain) => api3Chain.id === chain.id)) .filter((chain) => !chain.testnet) .filter((chain) => chain.alias !== 'oev-network') .map((chain) => chain.name) .sort((a, b) => a.localeCompare(b)); test('the auction length section lists all the supported chains', () => { - const docPath = path.join( - process.cwd(), - 'docs', - 'oev-searchers', - 'in-depth', - 'oev-auctioneer.md' - ); - const content = fs.readFileSync(docPath, 'utf8'); - + const content = readMarkdownFile(); const chains = extractContentBetweenMarkers(content, 'chain-auction-length-table') .split('\n') .filter(Boolean) // Get rid of blank lines @@ -31,7 +23,15 @@ test('the auction length section lists all the supported chains', () => { expect(chains).toStrictEqual(supportedMainnets); }); -function extractContentBetweenMarkers(content: string, key: string) { +function readMarkdownFile() { + const docPath = path.join(process.cwd(), 'docs', 'oev-searchers', 'in-depth', 'oev-auctioneer.md'); + if (!fs.existsSync(docPath)) { + throw new Error(`Could not find file "oev-auctioneer.md" at "${docPath}"`); + } + return fs.readFileSync(docPath, 'utf8'); +} + +function extractContentBetweenMarkers(content, key) { const beginMarker = ``; const endMarker = ``; const beginIndex = content.indexOf(beginMarker); diff --git a/libs/link-validator.js b/libs/link-validator.js index bb2deeb5..ca71ea37 100644 --- a/libs/link-validator.js +++ b/libs/link-validator.js @@ -49,9 +49,7 @@ function tempCB(dirPath, dirs, files) { // Load and display ignore list var fs = require('fs'); const { link } = require('fs-extra'); -var ignore = JSON.parse( - fs.readFileSync('./libs/link-validator-ignore.json', 'utf8') -); +var ignore = JSON.parse(fs.readFileSync('./libs/link-validator-ignore.json', 'utf8')); console.log(colors.bold('| > Ignore list')); ignore.forEach((element) => { console.log('|', colors.bold.yellow(element)); @@ -119,14 +117,9 @@ async function testLink(url, filePath, ignoreTimeout) { //console.log('> Target URL:', url); // Look for urlAnchor in response.data. - if ( - urlAnchor && - response.data.indexOf('href="' + urlAnchor + '"') === -1 - ) { + if (urlAnchor && response.data.indexOf('href="' + urlAnchor + '"') === -1) { //console.log(colors.red('> Anchor was NOT found in the response data.')); - throw new Error( - 'Did not find anchor in the response data: ' + urlAnchor - ); + throw new Error('Did not find anchor in the response data: ' + urlAnchor); } // else { //console.log('> Anchor was found in the response data.'); @@ -150,11 +143,7 @@ async function testLink(url, filePath, ignoreTimeout) { return 0; } catch (error) { // If a timeout try one more time - if ( - !ignoreTimeout && - error.code == 'ECONNABORTED' && - error.toString().indexOf('Error: timeout') > -1 - ) { + if (!ignoreTimeout && error.code == 'ECONNABORTED' && error.toString().indexOf('Error: timeout') > -1) { testLink(url, filePath, true); } else { process.stdout.write(colors.bold.red('X')); @@ -165,8 +154,7 @@ async function testLink(url, filePath, ignoreTimeout) { } async function run(task) { - (console.log('Checking (' + task + ')', Object.keys(linksObj).length), - 'links.'); + (console.log('Checking (' + task + ')', Object.keys(linksObj).length), 'links.'); for (var key in linksObj) { if (linksObj.hasOwnProperty(key)) { let fail = await testLink(key, linksObj[key], false); @@ -202,11 +190,7 @@ function loadLinks() { // If the URL starts with an anchor (#) tag // or is to the root (/) // do nothing - } else if ( - url && - url.indexOf('http://') === -1 && - url.indexOf('https://') === -1 - ) { + } else if (url && url.indexOf('http://') === -1 && url.indexOf('https://') === -1) { // These are internal links within the docs url = baseURL + url; diff --git a/package.json b/package.json index c7537443..0e5ecc3b 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,7 @@ "docs:serve": "vitepress serve docs --port 8082", "format": "prettier --write --cache \"./**/*.{js,vue,md,json,yaml}\" --log-level silent", "format:check": "prettier --check --cache \"./**/*.{js,vue,md,json,yaml}\"", - "lint": "pnpm format:check && pnpm lint:tsc", - "lint:tsc": "pnpm tsc", + "lint": "pnpm format:check", "test": "vitest run", "generate-llms-files": "node scripts/generate-llms-files.js", "prepare": "husky", @@ -30,7 +29,6 @@ "medium-zoom": "^1.1.0", "oust": "^2.0.4", "prettier": "^3.6.2", - "typescript": "^5.9.2", "vitepress": "1.6.4", "vitest": "^3.2.4", "walk-sync": "^3.0.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5a18c838..d539acad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,9 +41,6 @@ importers: prettier: specifier: ^3.6.2 version: 3.6.2 - typescript: - specifier: ^5.9.2 - version: 5.9.2 vitepress: specifier: 1.6.4 version: 1.6.4(@algolia/client-search@5.20.4)(@types/node@22.18.0)(axios@1.11.0)(postcss@8.4.49)(search-insights@2.16.2)(typescript@5.9.2) diff --git a/scripts/generate-llms-files.js b/scripts/generate-llms-files.js index 597827d0..7c5cda1d 100644 --- a/scripts/generate-llms-files.js +++ b/scripts/generate-llms-files.js @@ -84,9 +84,7 @@ function generateLlmsFullTxt() { for (const link of links) { const match = link.match(/- \[(.*?)\]\((.*?)\)/); if (match) { - const url = match[2] - .replace('https://docs.api3.org', '') - .replace('.html', '.md'); + const url = match[2].replace('https://docs.api3.org', '').replace('.html', '.md'); const filePath = path.join(docsDir, url); if (fs.existsSync(filePath)) { let fileContent = fs.readFileSync(filePath, 'utf-8'); @@ -103,15 +101,10 @@ function generateLlmsFullTxt() { if (pageHeaderIndex === -1) { throw new Error(`Could not find PageHeader in ${filePath}`); } - fileContent = fileContent.substring( - pageHeaderIndex + pageHeader.length - ); + fileContent = fileContent.substring(pageHeaderIndex + pageHeader.length); const titleMatch = fileContent.match(/# (.*)/); if (titleMatch && pageHeaderValue) { - fileContent = fileContent.replace( - /# (.*)/, - `# ${titleMatch[1]} (${pageHeaderValue})` - ); + fileContent = fileContent.replace(/# (.*)/, `# ${titleMatch[1]} (${pageHeaderValue})`); } fullContent += fileContent + '\n\n'; } diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 70500716..00000000 --- a/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "noEmit": true, - "lib": ["esnext"], - "target": "esnext", - "module": "commonjs", - "moduleResolution": "node", - "moduleDetection": "force", - "isolatedModules": true, - "esModuleInterop": true, - "resolveJsonModule": true, - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noFallthroughCasesInSwitch": true - }, - "exclude": ["node_modules"], - "include": ["**/*.ts"] -} diff --git a/vite.config.js b/vite.config.js index d6b5da8a..ef0ff398 100644 --- a/vite.config.js +++ b/vite.config.js @@ -10,11 +10,7 @@ export default defineConfig({ output: { manualChunks(id) { if (id.includes('node_modules')) { - return id - .toString() - .split('node_modules/')[1] - .split('/')[0] - .toString(); + return id.toString().split('node_modules/')[1].split('/')[0].toString(); } }, },