Skip to content

Commit

Permalink
[chore]: cleanup requires and unnecessary eslint-disables
Browse files Browse the repository at this point in the history
  • Loading branch information
derduher committed May 30, 2024
1 parent b9cc06c commit fbf5393
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 18 deletions.
13 changes: 6 additions & 7 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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'"
Expand Down
1 change: 0 additions & 1 deletion lib/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/*!
* Sitemap
Expand Down
1 change: 0 additions & 1 deletion lib/sitemap-item-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@
"node": ">=18.20.3",
"npm": ">=10.5.0"
}
}
}
4 changes: 2 additions & 2 deletions tests/sitemap-index-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/sitemap-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/xmllint.test.ts
Original file line number Diff line number Diff line change
@@ -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']);
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"esModuleInterop": true,
"moduleResolution": "node",
"lib": ["es2022"],
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"include": ["index.ts", "cli.ts"],
"exclude": ["node_modules"]
Expand Down

0 comments on commit fbf5393

Please sign in to comment.