Skip to content

Commit

Permalink
Merge pull request #289 from salesforce/enable-remaining-eslints
Browse files Browse the repository at this point in the history
Changes to support full eslint rule configurations
  • Loading branch information
colincasey authored Sep 1, 2023
2 parents e07f193 + bc07ba7 commit 6486eec
Show file tree
Hide file tree
Showing 15 changed files with 565 additions and 354 deletions.
14 changes: 2 additions & 12 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
//"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
Expand All @@ -16,16 +16,6 @@
// this is only needed because `createPromiseCallback` uses arguments to support the callback-style api
// we should strongly consider dropping the callback and sync api variants (in say v6) to reduce the
// surface area and complexity of tough-cookie
"prefer-rest-params": "warn",
"@typescript-eslint/no-unused-vars": "warn",

// used by callSync which needs to use Function because it's used by several apis
"@typescript-eslint/ban-types": "warn",

// there are several areas that still have ts-ignore comments, let's try to eliminate those
"@typescript-eslint/ban-ts-comment": "warn",

// i'd like to clean up all usages of any but the current api is just too loose
"@typescript-eslint/no-explicit-any": "warn"
"prefer-rest-params": "warn"
}
}
2 changes: 1 addition & 1 deletion lib/__tests__/cookieJar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ it('should fix issue #197 - CookieJar().setCookie throws an error when empty coo
).rejects.toThrowError('Cookie failed to parse')
})

it('should fix issue #282 - Prototype pollution when setting a cookie with the domain __proto__', async () => {
it('should fix issue #282 - Prototype pollution when setting a cookie with the domain __proto__', () => {
const jar = new CookieJar(undefined, {
rejectPublicSuffixes: false,
})
Expand Down
7 changes: 4 additions & 3 deletions lib/__tests__/jarSerialization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ describe('cookieJar serialization', () => {
hostOnly: true,
domain: 'www.example.org',
},
]
] as const

for await (const cornerCase of cornerCases) {
const domain = cornerCase.domain ?? 'example.org'
for (const cornerCase of cornerCases) {
const domain =
'domain' in cornerCase ? cornerCase.domain : 'example.org'
const path = '/'
const cookie = new Cookie({ ...cornerCase, domain, path })
await jar.setCookie(cookie, 'https://www.example.org/', {
Expand Down
15 changes: 3 additions & 12 deletions lib/__tests__/nodeUtilFallback.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,13 @@ describe('Node util module fallback for non-node environments', () => {
)
})

it('should not be null in a node environment when custom inspect symbol cannot be retrieved (< node v10.12.0', () => {
it('should not be null in a non-node environment since we create the symbol if it does not exist', () => {
expect(
getCustomInspectSymbol({
lookupCustomInspectSymbol: () => null,
requireUtil: () => undefined,
}),
).toEqual(Symbol.for('nodejs.util.inspect.custom') || util.inspect.custom)
})

it('should be null in a non-node environment since `util` features cannot be relied on', () => {
expect(
getCustomInspectSymbol({
lookupCustomInspectSymbol: () => null,
requireUtil: () => null,
}),
).toBeNull()
})
})

describe('getUtilInspect', () => {
Expand All @@ -39,7 +30,7 @@ describe('Node util module fallback for non-node environments', () => {

it('should use fallback inspect function in a non-node environment', () => {
const inspect = getUtilInspect(() => 'fallback', {
requireUtil: () => null,
requireUtil: () => undefined,
})
expect(inspect('util.inspect')).toEqual('fallback')
})
Expand Down
Loading

0 comments on commit 6486eec

Please sign in to comment.