Skip to content

Commit 070ae08

Browse files
authored
chore: fixed linter settings (#180)
1 parent 7c0c275 commit 070ae08

File tree

2 files changed

+48
-48
lines changed

2 files changed

+48
-48
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"scripts": {
1313
"build": "tsc",
1414
"prepack": "yarn build",
15-
"lint": "yarn eslint --ext .ts,.js,.mjs src",
15+
"lint": "yarn eslint --ext .ts,.js,.mjs src test",
1616
"test": "ava",
1717
"dev": "netlify dev"
1818
},

test/utils.test.ts

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import test from 'ava'
2-
import {parseURL} from 'ufo'
3-
import {decodeBase64Params, doPatternsMatchUrl, RemotePattern} from '../src/utils'
2+
import { parseURL } from 'ufo'
3+
import { decodeBase64Params, doPatternsMatchUrl, RemotePattern } from '../src/utils'
44

5-
const encodeUrlAndTransforms = (url: string = '', transforms: string = '', extension: string = '') : string => {
5+
const encodeUrlAndTransforms = (url = '', transforms = '', extension = ''): string => {
66
const encodedUrl = Buffer.from(url).toString('base64')
77
const encodedTransforms = Buffer.from(transforms).toString('base64')
88
return `${encodedUrl}/${encodedTransforms}${extension}`
@@ -12,9 +12,9 @@ test('decodeBase64Params: returns expected response if no url is present', (t) =
1212
const expectedResponse = {
1313
error: 'Bad Request'
1414
}
15-
15+
1616
const response = decodeBase64Params('')
17-
17+
1818
t.deepEqual(response, expectedResponse)
1919
})
2020

@@ -24,173 +24,173 @@ test('decodeBase64Params: returns expected response if no transform exists in pa
2424
}
2525

2626
const encodedUrl = encodeUrlAndTransforms('/images/image.jpg', '')
27-
27+
2828
const response = decodeBase64Params(encodedUrl)
29-
29+
3030
t.deepEqual(response, expectedResponse)
3131
})
3232

3333
test("decodeBase64Params: returns expected response if transform doesn't contain any transforms", (t) => {
34-
const expectedId = '/images/';
34+
const expectedId = '/images/'
3535
const expectedResponse = {
3636
error: 'Bad Request'
3737
}
38-
38+
3939
const encodedUrl = encodeUrlAndTransforms(expectedId, '', '.ext')
40-
40+
4141
const response = decodeBase64Params(encodedUrl)
42-
42+
4343
t.deepEqual(response, expectedResponse)
4444
})
4545

4646
test('decodeBase64Params: returns expected response if transform contains w and h', (t) => {
47-
const expectedId = '/images/image.jpg';
47+
const expectedId = '/images/image.jpg'
4848
const expectedResponse = {
4949
id: expectedId,
5050
modifiers: 's_100x200'
5151
}
5252

5353
const encodedUrl = encodeUrlAndTransforms(expectedId, 'w=100&h=200', '.jpg')
54-
54+
5555
const response = decodeBase64Params(encodedUrl)
56-
56+
5757
t.deepEqual(response, expectedResponse)
5858
})
5959

6060
test('decodeBase64Params: returns expected response if transform contains w but no h', (t) => {
61-
const expectedId = '/images/image.jpg';
61+
const expectedId = '/images/image.jpg'
6262
const expectedResponse = {
6363
id: expectedId,
6464
modifiers: 'w_100'
6565
}
6666

6767
const encodedUrl = encodeUrlAndTransforms(expectedId, 'w=100', '.jpg')
68-
68+
6969
const response = decodeBase64Params(encodedUrl)
70-
70+
7171
t.deepEqual(response, expectedResponse)
7272
})
7373

7474
test('decodeBase64Params: returns expected response if transform contains h but no w', (t) => {
75-
const expectedId = '/images/image.jpg';
75+
const expectedId = '/images/image.jpg'
7676
const expectedResponse = {
7777
id: expectedId,
7878
modifiers: 'h_200'
7979
}
8080

8181
const encodedUrl = encodeUrlAndTransforms(expectedId, 'h=200', '.jpg')
82-
82+
8383
const response = decodeBase64Params(encodedUrl)
84-
84+
8585
t.deepEqual(response, expectedResponse)
8686
})
8787

8888
test('decodeBase64Params: returns expected response if transform contains fm', (t) => {
89-
const expectedId = '/images/image.jpg';
89+
const expectedId = '/images/image.jpg'
9090
const expectedResponse = {
9191
id: expectedId,
9292
modifiers: 'f_10'
9393
}
9494

9595
const encodedUrl = encodeUrlAndTransforms(expectedId, 'fm=10', '.jpg')
96-
96+
9797
const response = decodeBase64Params(encodedUrl)
98-
98+
9999
t.deepEqual(response, expectedResponse)
100100
})
101101

102102
test('decodeBase64Params: returns expected response if transform contains q', (t) => {
103-
const expectedId = '/images/image.jpg';
103+
const expectedId = '/images/image.jpg'
104104
const expectedResponse = {
105105
id: expectedId,
106106
modifiers: 'q_101'
107107
}
108108

109109
const encodedUrl = encodeUrlAndTransforms(expectedId, 'q=101', '.jpg')
110-
110+
111111
const response = decodeBase64Params(encodedUrl)
112-
112+
113113
t.deepEqual(response, expectedResponse)
114114
})
115115

116116
test('decodeBase64Params: returns expected response if transform contains pos', (t) => {
117-
const expectedId = '/images/image.jpg';
117+
const expectedId = '/images/image.jpg'
118118
const expectedResponse = {
119119
id: expectedId,
120120
modifiers: 'crop_10 20'
121121
}
122122

123123
const encodedUrl = encodeUrlAndTransforms(expectedId, 'pos=10,20', '.jpg')
124-
124+
125125
const response = decodeBase64Params(encodedUrl)
126-
126+
127127
t.deepEqual(response, expectedResponse)
128128
})
129129

130130
test('decodeBase64Params: returns expected response if transform contains multiple valid props', (t) => {
131-
const expectedId = '/images/image.jpg';
131+
const expectedId = '/images/image.jpg'
132132
const expectedResponse = {
133133
id: expectedId,
134134
modifiers: 's_100x200,f_101,crop_10 20,q_1234'
135135
}
136136

137137
const encodedUrl = encodeUrlAndTransforms(expectedId, 'pos=10,20&w=100&h=200&fm=101&q=1234', '.jpg')
138-
138+
139139
const response = decodeBase64Params(encodedUrl)
140-
140+
141141
t.deepEqual(response, expectedResponse)
142142
})
143143

144144
test("doPatternsMatchUrl: returns false if protocol exists in remote pattern and it doesn't match", (t) => {
145-
const remotePattern : RemotePattern = {
145+
const remotePattern: RemotePattern = {
146146
protocol: 'http',
147147
hostname: 'fail.com'
148148
}
149149
const parsedUrl = parseURL('https://fake.url/images?w=100&h=200&fm=1234', 'https://')
150150

151151
const matches = doPatternsMatchUrl(remotePattern, parsedUrl)
152-
152+
153153
t.false(matches)
154154
})
155155

156156
test("doPatternsMatchUrl: returns false if port exists in remote pattern and the full host doesn't match", (t) => {
157-
const remotePattern : RemotePattern = {
157+
const remotePattern: RemotePattern = {
158158
hostname: 'fail.com',
159159
port: '3000'
160160
}
161161
const parsedUrl = parseURL('https://fake.url/images?w=100&h=200&fm=1234', 'https://')
162162

163163
const matches = doPatternsMatchUrl(remotePattern, parsedUrl)
164-
164+
165165
t.false(matches)
166166
})
167167

168168
test("doPatternsMatchUrl: returns false if port doesn't exists in remote pattern and the host doesn't match", (t) => {
169-
const remotePattern : RemotePattern = {
170-
hostname: 'fail.com',
169+
const remotePattern: RemotePattern = {
170+
hostname: 'fail.com'
171171
}
172172
const parsedUrl = parseURL('https://fake.url/images?w=100&h=200&fm=1234', 'https://')
173173

174174
const matches = doPatternsMatchUrl(remotePattern, parsedUrl)
175-
175+
176176
t.false(matches)
177177
})
178178

179179
test("doPatternsMatchUrl: returns false if the pathname doesn't match", (t) => {
180-
const remotePattern : RemotePattern = {
180+
const remotePattern: RemotePattern = {
181181
protocol: 'https',
182182
hostname: 'fake.url',
183183
pathname: '/failpath'
184184
}
185185
const parsedUrl = parseURL('https://fake.url/images?w=100&h=200&fm=1234', 'https://')
186186

187187
const matches = doPatternsMatchUrl(remotePattern, parsedUrl)
188-
188+
189189
t.false(matches)
190190
})
191191

192-
test("doPatternsMatchUrl: returns true if remote pattern fully matches", (t) => {
193-
const remotePattern : RemotePattern = {
192+
test('doPatternsMatchUrl: returns true if remote pattern fully matches', (t) => {
193+
const remotePattern: RemotePattern = {
194194
protocol: 'https',
195195
hostname: 'fake.url',
196196
port: '3000',
@@ -199,19 +199,19 @@ test("doPatternsMatchUrl: returns true if remote pattern fully matches", (t) =>
199199
const parsedUrl = parseURL('https://fake.url:3000/images?w=100&h=200&fm=1234', 'https://')
200200

201201
const matches = doPatternsMatchUrl(remotePattern, parsedUrl)
202-
202+
203203
t.true(matches)
204204
})
205205

206-
test("doPatternsMatchUrl: returns true if remote pattern fully matches without pathname", (t) => {
207-
const remotePattern : RemotePattern = {
206+
test('doPatternsMatchUrl: returns true if remote pattern fully matches without pathname', (t) => {
207+
const remotePattern: RemotePattern = {
208208
protocol: 'https',
209209
hostname: 'fake.url',
210210
port: '3000'
211211
}
212212
const parsedUrl = parseURL('https://fake.url:3000/images?w=100&h=200&fm=1234', 'https://')
213213

214214
const matches = doPatternsMatchUrl(remotePattern, parsedUrl)
215-
215+
216216
t.true(matches)
217217
})

0 commit comments

Comments
 (0)