Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prettier in eslint config #274

Merged
merged 2 commits into from
Apr 18, 2023
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
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
//"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier"
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand Down
30 changes: 20 additions & 10 deletions lib/__tests__/cookieJar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

import { Cookie, CookieJar, MemoryCookieStore, ParameterError, SerializedCookieJar, Store } from "../cookie";
import {
Cookie,
CookieJar,
MemoryCookieStore,
ParameterError,
SerializedCookieJar,
Store,
} from '../cookie'

jest.useFakeTimers()

Expand Down Expand Up @@ -66,7 +73,10 @@ describe('CookieJar', () => {
cookie = await cookieJar.setCookie('foo=bar', 'http://example.com')
},
syncStyle() {
const result = cookieJar.setCookieSync('foo=bar', 'http://example.com')
const result = cookieJar.setCookieSync(
'foo=bar',
'http://example.com',
)
if (result == null) {
throw new Error('Result should not have been undefined')
}
Expand Down Expand Up @@ -368,7 +378,7 @@ describe('CookieJar', () => {
cookies = cookieJar.getCookiesSync('http://example.com')
},
},
()=> {
() => {
expect(cookies).toEqual([
expect.objectContaining({
key: 'foo',
Expand Down Expand Up @@ -947,7 +957,7 @@ describe('CookieJar', () => {
syncStyle() {
const result = cookieJar.serializeSync()
if (!result) {
throw new Error("This should have been undefined")
throw new Error('This should have been undefined')
}
data = result
},
Expand Down Expand Up @@ -1118,7 +1128,7 @@ describe('loose mode', () => {
const cookieJar = new CookieJar(null, { looseMode: true })
const cookieJarAsJson = cookieJar.toJSON()
if (!cookieJarAsJson) {
throw new Error("This should not have been undefined")
throw new Error('This should not have been undefined')
}
const clonedCookieJar = CookieJar.fromJSON(cookieJarAsJson)
await clonedCookieJar.setCookie('FooBar', 'http://www.foonet.net')
Expand Down Expand Up @@ -1249,7 +1259,7 @@ describe.each(['local', 'example', 'invalid', 'localhost', 'test'])(
)
} catch (e) {
if (!(e instanceof Error)) {
throw new Error("This should be an error instance")
throw new Error('This should be an error instance')
}
expect(e.message).toBe(
`Cookie has domain set to the public suffix "${specialUseDomain}" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.`,
Expand Down Expand Up @@ -1300,7 +1310,7 @@ describe.each(['local', 'example', 'invalid', 'localhost', 'test'])(
)
} catch (e) {
if (!(e instanceof Error)) {
throw new Error("This should be an error instance")
throw new Error('This should be an error instance')
}
expect(e.message).toBe(
`Cookie has domain set to the public suffix "${specialUseDomain}" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.`,
Expand Down Expand Up @@ -1348,7 +1358,7 @@ describe.each(['local', 'example', 'invalid', 'localhost', 'test'])(
)
} catch (e) {
if (!(e instanceof Error)) {
throw new Error("This should be an error instance")
throw new Error('This should be an error instance')
}
expect(e.message).toBe(
`Cookie has domain set to the public suffix "${specialUseDomain}" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.`,
Expand All @@ -1370,7 +1380,7 @@ describe.each(['local', 'example', 'invalid', 'localhost', 'test'])(
)
} catch (e) {
if (!(e instanceof Error)) {
throw new Error("This should be an error instance")
throw new Error('This should be an error instance')
}
expect(e.message).toBe(
`Cookie has domain set to the public suffix "${specialUseDomain}" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.`,
Expand Down Expand Up @@ -1424,7 +1434,7 @@ function createCookie(
): Cookie {
const cookie = Cookie.parse(cookieString)
if (!cookie) {
throw new Error("This should not be undefined")
throw new Error('This should not be undefined')
}
if (options?.hostOnly) {
cookie.hostOnly = options.hostOnly
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/cookiePrefixes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CookieJar, PrefixSecurityEnum } from "../cookie";
import { CookieJar, PrefixSecurityEnum } from '../cookie'

let cookieJar: CookieJar
const insecureUrl = 'http://www.example.com'
Expand Down
8 changes: 6 additions & 2 deletions lib/__tests__/cookieSorting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ describe('Cookie sorting', () => {
const cookie2 = new Cookie()
expect(typeof cookie1.creationIndex).toBe('number')
expect(typeof cookie2.creationIndex).toBe('number')
expect(cookie1.creationIndex).toBeLessThan(cookie2.creationIndex as number)
expect(cookie1.creationIndex).toBeLessThan(
cookie2.creationIndex as number,
)
})

it('should set the creation index during construction when creation time is provided', () => {
Expand All @@ -19,7 +21,9 @@ describe('Cookie sorting', () => {
expect(cookie1.creation).toEqual(cookie2.creation)
expect(typeof cookie1.creationIndex).toBe('number')
expect(typeof cookie2.creationIndex).toBe('number')
expect(cookie1.creationIndex).toBeLessThan(cookie2.creationIndex as number)
expect(cookie1.creationIndex).toBeLessThan(
cookie2.creationIndex as number,
)
})

it('should leave the creation index alone during setCookie', async () => {
Expand Down
10 changes: 5 additions & 5 deletions lib/__tests__/cookieToAndFromJson.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cookie } from "../cookie";
import { Cookie } from '../cookie'

jest.useFakeTimers()

Expand All @@ -8,7 +8,7 @@ describe('Cookie.toJSON()', () => {
'alpha=beta; Domain=example.com; Path=/foo; Expires=Tue, 19 Jan 2038 03:14:07 GMT; HttpOnly',
)
if (!cookie) {
throw new Error("This should not be undefined")
throw new Error('This should not be undefined')
}
expect(cookie.toJSON()).toEqual({
creation: new Date().toISOString(),
Expand Down Expand Up @@ -44,8 +44,8 @@ describe('Cookie.fromJSON()', () => {
path: '/foo',
value: 'beta',
lastAccessed: new Date(2000000000123),
},
))
}),
)
})

it('should be able to handle a null value deserialization', () => {
Expand All @@ -60,7 +60,7 @@ describe('Cookie.fromJSON()', () => {
})
const cookie = Cookie.fromJSON(json)
if (!cookie) {
throw new Error("This should not be null")
throw new Error('This should not be null')
}
expect(cookie.expires).toBe('Infinity')
expect(cookie.creation).toBe('Infinity')
Expand Down
4 changes: 2 additions & 2 deletions lib/__tests__/cookieToString.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Cookie } from "../cookie";
import { Cookie } from '../cookie'

describe('Cookie.toString()', () => {
const parse = (cookieString: string): Cookie => {
const cookie = Cookie.parse(cookieString)
if (!cookie) {
throw new Error("This should have parsed")
throw new Error('This should have parsed')
}
return cookie
}
Expand Down
Loading