diff --git a/cli.ts b/cli.ts index 6eead10..aaee99d 100755 --- a/cli.ts +++ b/cli.ts @@ -13,8 +13,7 @@ import { SitemapAndIndexStream } from './lib/sitemap-index-stream'; import { URL } from 'url'; import { createGzip, Gzip } from 'zlib'; import { ErrorLevel } from './lib/types'; -/* eslint-disable-next-line @typescript-eslint/no-var-requires */ -const arg = require('arg'); +import arg from 'arg'; const pickStreamOrArg = (argv: { _: string[] }): Readable => { if (!argv._.length) { @@ -50,9 +49,9 @@ function getStream(): Readable { } } if (argv['--version']) { - /* eslint-disable-next-line @typescript-eslint/no-var-requires */ - const packagejson = require('../package.json'); - console.log(packagejson.version); + import('./package.json').then(({ default: packagejson }) => { + console.log(packagejson.version); + }); } else if (argv['--help']) { console.log(` Turn a list of urls into a sitemap xml. @@ -104,8 +103,8 @@ Use XMLLib to validate your sitemap (requires xmllib) } }); } else if (argv['--index']) { - const limit: number = argv['--limit']; - const baseURL: string = argv['--index-base-url']; + const limit: number | undefined = argv['--limit']; + const baseURL: string | undefined = argv['--index-base-url']; if (!baseURL) { throw new Error( "You must specify where the sitemaps will be hosted. use --index-base-url 'https://example.com/path'" diff --git a/lib/errors.ts b/lib/errors.ts index dd3702c..bea45ff 100644 --- a/lib/errors.ts +++ b/lib/errors.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/no-explicit-any */ /*! * Sitemap diff --git a/lib/sitemap-item-stream.ts b/lib/sitemap-item-stream.ts index 92ec40a..8e9440d 100644 --- a/lib/sitemap-item-stream.ts +++ b/lib/sitemap-item-stream.ts @@ -17,7 +17,6 @@ function attrBuilder( const iv: StringObj = {}; return keys.reduce((attrs, key): StringObj => { - // eslint-disable-next-line if (conf[key] !== undefined) { const keyAr = key.split(':'); if (keyAr.length !== 2) { diff --git a/lib/utils.ts b/lib/utils.ts index df86ad2..94c0634 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -324,7 +324,6 @@ export function lineSeparatedURLsToSitemapOptions( return new ReadlineStream({ input: stream }).pipe( new Transform({ objectMode: true, - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types transform: (line, encoding, cb): void => { if (isJSON || (isJSON === undefined && line[0] === '{')) { cb(null, JSON.parse(line)); diff --git a/package.json b/package.json index bd7d941..d58c008 100644 --- a/package.json +++ b/package.json @@ -80,4 +80,4 @@ "node": ">=18.20.3", "npm": ">=10.5.0" } -} +} \ No newline at end of file diff --git a/tests/sitemap-index-parser.test.ts b/tests/sitemap-index-parser.test.ts index 71a5a9f..0c15ff5 100644 --- a/tests/sitemap-index-parser.test.ts +++ b/tests/sitemap-index-parser.test.ts @@ -9,8 +9,8 @@ import { } from '../lib/sitemap-index-parser'; import { ErrorLevel, IndexItem } from '../lib/types'; const pipeline = promisify(pipe); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const normalizedSample = require('./mocks/sampleconfig-index.normalized.json'); +import normalizedSample from './mocks/sampleconfig-index.normalized.json'; + describe('parseSitemapIndex', () => { it('parses xml into index-items', async () => { const urls = await parseSitemapIndex( diff --git a/tests/sitemap-parser.test.ts b/tests/sitemap-parser.test.ts index ee39373..d05b624 100644 --- a/tests/sitemap-parser.test.ts +++ b/tests/sitemap-parser.test.ts @@ -10,8 +10,8 @@ import { import { SitemapStreamOptions } from '../lib/sitemap-stream'; import { ErrorLevel, SitemapItem } from '../lib/types'; const pipeline = promisify(pipe); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const normalizedSample = require('./mocks/sampleconfig.normalized.json'); +import normalizedSample from './mocks/sampleconfig.normalized.json'; + describe('parseSitemap', () => { it('parses xml into sitemap-items', async () => { const urls = await parseSitemap( diff --git a/tests/xmllint.test.ts b/tests/xmllint.test.ts index 78664d8..8d01077 100644 --- a/tests/xmllint.test.ts +++ b/tests/xmllint.test.ts @@ -1,6 +1,6 @@ import { xmlLint } from '../lib/xmllint'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const execFileSync = require('child_process').execFileSync; +import { execFileSync } from 'child_process'; + let hasXMLLint = true; try { execFileSync('which', ['xmllint']); diff --git a/tsconfig.json b/tsconfig.json index f2cdf5c..8182c0f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,8 @@ "esModuleInterop": true, "moduleResolution": "node", "lib": ["es2022"], - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true }, "include": ["index.ts", "cli.ts"], "exclude": ["node_modules"]