Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,25 @@ export default [
],
},
},
{
files: ["lib/**/*.js"],
rules: {
"no-console": "error",
"no-restricted-syntax": [
"error",
{
selector: ":function ImportExpression",
message: "Import at the top of the module.",
},
{
selector: ":function CallExpression[callee.name='require']",
message: "Require at the top of the module.",
},
{
selector: ":function :matches(ClassDeclaration, ClassExpression)",
message: "Define classes at the top level of the module.",
},
],
},
},
];
1 change: 1 addition & 0 deletions lib/axios-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export async function createProxyAxios(options) {

let axios;
try {
// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
axios = (await import('axios')).default;
} catch {
throw new Error('axios is required. Install it with: npm install axios');
Expand Down
1 change: 1 addition & 0 deletions lib/got-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export async function createProxyGot(options) {

let got;
try {
// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
got = (await import('got')).default;
} catch {
throw new Error('got is required. Install it with: npm install got');
Expand Down
1 change: 1 addition & 0 deletions lib/ky-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export async function createProxyKy(options) {

let ky;
try {
// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
ky = (await import('ky')).default;
} catch {
throw new Error('ky is required. Install it with: npm install ky');
Expand Down
2 changes: 2 additions & 0 deletions lib/needle-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export async function proxyNeedleGet(url, options = {}) {
throw new Error('proxy option is required');
}

// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
const needle = require('needle');

const agent = new ProxyHeadersAgent(proxy, {
Expand Down Expand Up @@ -75,6 +76,7 @@ export function createProxyNeedle(options) {
proxyTlsOptions,
});

// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
const needle = require('needle');

return {
Expand Down
1 change: 1 addition & 0 deletions lib/node-fetch-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export async function proxyFetch(url, options = {}) {

let fetch;
try {
// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
fetch = (await import('node-fetch')).default;
} catch {
throw new Error('node-fetch is required. Install it with: npm install node-fetch');
Expand Down
1 change: 1 addition & 0 deletions lib/superagent-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export function proxyPlugin(options) {
export async function createProxySuperagent(options) {
let superagent;
try {
// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
superagent = (await import('superagent')).default;
} catch {
throw new Error('superagent is required. Install it with: npm install superagent');
Expand Down
4 changes: 4 additions & 0 deletions lib/typed-rest-client-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function attachRestProxyHeaders(processed, res) {
* @param {import('typed-rest-client/HttpClient').HttpClient} Base
*/
function createProxyHeadersHttpClientClass(HttpClient) {
// eslint-disable-next-line no-restricted-syntax -- extends an optional peer dependency class
return class ProxyHeadersHttpClient extends HttpClient {
/**
* @param {string} userAgent
Expand Down Expand Up @@ -90,6 +91,7 @@ function createProxyHeadersHttpClientClass(HttpClient) {
* @param {ReturnType<createProxyHeadersHttpClientClass>} ProxyHeadersHttpClient
*/
function createProxyHeadersRestClientClass(RestClient, ProxyHeadersHttpClient) {
// eslint-disable-next-line no-restricted-syntax -- extends an optional peer dependency class
return class ProxyHeadersRestClient extends RestClient {
/**
* @param {string} userAgent
Expand Down Expand Up @@ -151,7 +153,9 @@ export function createProxyRestClient(options) {
throw new Error('proxy option is required');
}

// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
const { RestClient } = require('typed-rest-client/RestClient');
// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
const { HttpClient } = require('typed-rest-client/HttpClient');

const PHC = createProxyHeadersHttpClientClass(HttpClient);
Expand Down
1 change: 1 addition & 0 deletions lib/undici-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export async function request(url, options = {}) {

let undici;
try {
// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
undici = await import('undici');
} catch {
throw new Error('undici is required. Install it with: npm install undici');
Expand Down
1 change: 1 addition & 0 deletions lib/wretch-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function createProxyWretch(options) {

let rawWretch;
try {
// eslint-disable-next-line no-restricted-syntax -- optional peer dependency, loaded on first use
rawWretch = (await import('wretch')).default;
} catch {
throw new Error('wretch is required. Install it with: npm install wretch');
Expand Down