express-rate-limit 5.4.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,239 @@
1
+ import Express from 'express';
2
+ /**
3
+ * Callback that fires when a client's hit counter is incremented.
4
+ *
5
+ * @param error {Error | undefined} - The error that occurred, if any
6
+ * @param totalHits {number} - The number of hits for that client so far
7
+ * @param resetTime {Date | undefined} - The time when the counter resets
8
+ */
9
+ export declare type IncrementCallback = (error: Error | undefined, totalHits: number, resetTime: Date | undefined) => void;
10
+ /**
11
+ * Method (in the form of middleware) to generate/retrieve a value based on the
12
+ * incoming request
13
+ *
14
+ * @param request {Express.Request} - The Express request object
15
+ * @param response {Express.Response} - The Express response object
16
+ *
17
+ * @returns {T} - The value needed
18
+ */
19
+ export declare type ValueDeterminingMiddleware<T> = (request: Express.Request, response: Express.Response) => T | Promise<T>;
20
+ /**
21
+ * Express request handler that sends back a response when a client is
22
+ * rate-limited.
23
+ *
24
+ * @param request {Express.Request} - The Express request object
25
+ * @param response {Express.Response} - The Express response object
26
+ * @param next {Express.NextFunction} - The Express `next` function, can be called to skip responding
27
+ * @param optionsUsed {Options} - The options used to set up the middleware
28
+ */
29
+ export declare type RateLimitExceededEventHandler = (request: Express.Request, response: Express.Response, next: Express.NextFunction, optionsUsed: Options) => void;
30
+ /**
31
+ * Event callback that is triggered on a client's first request that exceeds the limit
32
+ * but not for subsequent requests. May be used for logging, etc. Should *not*
33
+ * send a response.
34
+ *
35
+ * @param request {Express.Request} - The Express request object
36
+ * @param response {Express.Response} - The Express response object
37
+ * @param optionsUsed {Options} - The options used to set up the middleware
38
+ */
39
+ export declare type RateLimitReachedEventHandler = (request: Express.Request, response: Express.Response, optionsUsed: Options) => void;
40
+ /**
41
+ * Data returned from the `Store` when a client's hit counter is incremented.
42
+ *
43
+ * @property totalHits {number} - The number of hits for that client so far
44
+ * @property resetTime {Date | undefined} - The time when the counter resets
45
+ */
46
+ export declare type IncrementResponse = {
47
+ totalHits: number;
48
+ resetTime: Date | undefined;
49
+ };
50
+ /**
51
+ * A modified Express request handler with the rate limit functions.
52
+ */
53
+ export declare type RateLimitRequestHandler = Express.RequestHandler & {
54
+ /**
55
+ * Method to reset a client's hit counter.
56
+ *
57
+ * @param key {string} - The identifier for a client
58
+ */
59
+ resetKey: (key: string) => void;
60
+ };
61
+ /**
62
+ * An interface that all hit counter stores must implement.
63
+ *
64
+ * @deprecated 6.x - Implement the `Store` interface instead.
65
+ */
66
+ export interface LegacyStore {
67
+ /**
68
+ * Method to increment a client's hit counter.
69
+ *
70
+ * @param key {string} - The identifier for a client
71
+ * @param callback {IncrementCallback} - The callback to call once the counter is incremented
72
+ */
73
+ incr: (key: string, callback: IncrementCallback) => void;
74
+ /**
75
+ * Method to decrement a client's hit counter.
76
+ *
77
+ * @param key {string} - The identifier for a client
78
+ */
79
+ decrement: (key: string) => void;
80
+ /**
81
+ * Method to reset a client's hit counter.
82
+ *
83
+ * @param key {string} - The identifier for a client
84
+ */
85
+ resetKey: (key: string) => void;
86
+ /**
87
+ * Method to reset everyone's hit counter.
88
+ */
89
+ resetAll?: () => void;
90
+ }
91
+ /**
92
+ * An interface that all hit counter stores must implement.
93
+ */
94
+ export interface Store {
95
+ /**
96
+ * Method that initializes the store, and has access to the options passed to
97
+ * the middleware too.
98
+ *
99
+ * @param options {Options} - The options used to setup the middleware
100
+ */
101
+ init?: (options: Options) => void;
102
+ /**
103
+ * Method to increment a client's hit counter.
104
+ *
105
+ * @param key {string} - The identifier for a client
106
+ *
107
+ * @returns {IncrementResponse} - The number of hits and reset time for that client
108
+ */
109
+ increment: (key: string) => Promise<IncrementResponse> | IncrementResponse;
110
+ /**
111
+ * Method to decrement a client's hit counter.
112
+ *
113
+ * @param key {string} - The identifier for a client
114
+ */
115
+ decrement: (key: string) => Promise<void> | void;
116
+ /**
117
+ * Method to reset a client's hit counter.
118
+ *
119
+ * @param key {string} - The identifier for a client
120
+ */
121
+ resetKey: (key: string) => Promise<void> | void;
122
+ /**
123
+ * Method to reset everyone's hit counter.
124
+ */
125
+ resetAll?: () => Promise<void> | void;
126
+ }
127
+ /**
128
+ * The configuration options for the rate limiter.
129
+ */
130
+ export interface Options {
131
+ /**
132
+ * How long we should remember the requests.
133
+ */
134
+ readonly windowMs: number;
135
+ /**
136
+ * The maximum number of connection to allow during the `window` before
137
+ * rate limiting the client.
138
+ *
139
+ * Can be the limit itself as a number or express middleware that parses
140
+ * the request and then figures out the limit.
141
+ */
142
+ readonly max: number | ValueDeterminingMiddleware<number>;
143
+ /**
144
+ * The response body to send back when a client is rate limited.
145
+ */
146
+ readonly message: any;
147
+ /**
148
+ * The HTTP status code to send back when a client is rate limited.
149
+ *
150
+ * Defaults to `HTTP 429 Too Many Requests` (RFC 6585).
151
+ */
152
+ readonly statusCode: number;
153
+ /**
154
+ * Whether to send `X-RateLimit-*` headers with the rate limit and the number
155
+ * of requests.
156
+ */
157
+ readonly legacyHeaders: boolean;
158
+ /**
159
+ * Whether to enable support for the rate limit standardization headers (`RateLimit-*`).
160
+ */
161
+ readonly standardHeaders: boolean;
162
+ /**
163
+ * The name of the property on the request object to store the rate limit info.
164
+ *
165
+ * Defaults to `rateLimit`.
166
+ */
167
+ readonly requestPropertyName: string;
168
+ /**
169
+ * If `true`, the library will (by default) skip all requests that have a 4XX
170
+ * or 5XX status.
171
+ */
172
+ readonly skipFailedRequests: boolean;
173
+ /**
174
+ * If `true`, the library will (by default) skip all requests that have a
175
+ * status code less than 400.
176
+ */
177
+ readonly skipSuccessfulRequests: boolean;
178
+ /**
179
+ * Method to determine whether or not the request counts as 'succesful'. Used
180
+ * when either `skipSuccessfulRequests` or `skipFailedRequests` is set to true.
181
+ */
182
+ readonly requestWasSuccessful: ValueDeterminingMiddleware<boolean>;
183
+ /**
184
+ * Method to generate custom identifiers for clients.
185
+ *
186
+ * By default, the client's IP address is used.
187
+ */
188
+ readonly keyGenerator: ValueDeterminingMiddleware<string>;
189
+ /**
190
+ * Method (in the form of middleware) to determine whether or not this request
191
+ * counts towards a client's quota.
192
+ */
193
+ readonly skip: ValueDeterminingMiddleware<boolean>;
194
+ /**
195
+ * Express request handler that sends back a response when a client is
196
+ * rate-limited.
197
+ */
198
+ readonly handler: RateLimitExceededEventHandler;
199
+ /**
200
+ * Express request handler that sends back a response when a client has
201
+ * reached their rate limit, and will be rate limited on their next request.
202
+ */
203
+ readonly onLimitReached: RateLimitReachedEventHandler;
204
+ /**
205
+ * The {@link Store} to use to store the hit count for each client.
206
+ */
207
+ store: Store;
208
+ /**
209
+ * Whether to send `X-RateLimit-*` headers with the rate limit and the number
210
+ * of requests.
211
+ *
212
+ * @deprecated 6.x - This option was renamed to `legacyHeaders`.
213
+ */
214
+ headers?: boolean;
215
+ /**
216
+ * Whether to send `RateLimit-*` headers with the rate limit and the number
217
+ * of requests.
218
+ *
219
+ * @deprecated 6.x - This option was renamed to `standardHeaders`.
220
+ */
221
+ draft_polli_ratelimit_headers?: boolean;
222
+ }
223
+ /**
224
+ * The extended request object that includes information about the client's
225
+ * rate limit.
226
+ */
227
+ export declare type AugmentedRequest = Express.Request & {
228
+ [key: string]: RateLimitInfo;
229
+ };
230
+ /**
231
+ * The rate limit related information for each client included in the
232
+ * Express request object.
233
+ */
234
+ export interface RateLimitInfo {
235
+ readonly limit: number;
236
+ readonly current: number;
237
+ readonly remaining: number;
238
+ readonly resetTime: Date | undefined;
239
+ }
@@ -0,0 +1,4 @@
1
+ // /source/types.ts
2
+ // All the types used by this package
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../source/types.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,qCAAqC","sourcesContent":["// /source/types.ts\n// All the types used by this package\n\nimport Express from 'express'\n\n/**\n * Callback that fires when a client's hit counter is incremented.\n *\n * @param error {Error | undefined} - The error that occurred, if any\n * @param totalHits {number} - The number of hits for that client so far\n * @param resetTime {Date | undefined} - The time when the counter resets\n */\nexport type IncrementCallback = (\n\terror: Error | undefined,\n\ttotalHits: number,\n\tresetTime: Date | undefined,\n) => void\n\n/**\n * Method (in the form of middleware) to generate/retrieve a value based on the\n * incoming request\n *\n * @param request {Express.Request} - The Express request object\n * @param response {Express.Response} - The Express response object\n *\n * @returns {T} - The value needed\n */\nexport type ValueDeterminingMiddleware<T> = (\n\trequest: Express.Request,\n\tresponse: Express.Response,\n) => T | Promise<T>\n\n/**\n * Express request handler that sends back a response when a client is\n * rate-limited.\n *\n * @param request {Express.Request} - The Express request object\n * @param response {Express.Response} - The Express response object\n * @param next {Express.NextFunction} - The Express `next` function, can be called to skip responding\n * @param optionsUsed {Options} - The options used to set up the middleware\n */\nexport type RateLimitExceededEventHandler = (\n\trequest: Express.Request,\n\tresponse: Express.Response,\n\tnext: Express.NextFunction,\n\toptionsUsed: Options,\n) => void\n\n/**\n * Event callback that is triggered on a client's first request that exceeds the limit\n * but not for subsequent requests. May be used for logging, etc. Should *not*\n * send a response.\n *\n * @param request {Express.Request} - The Express request object\n * @param response {Express.Response} - The Express response object\n * @param optionsUsed {Options} - The options used to set up the middleware\n */\nexport type RateLimitReachedEventHandler = (\n\trequest: Express.Request,\n\tresponse: Express.Response,\n\toptionsUsed: Options,\n) => void\n\n/**\n * Data returned from the `Store` when a client's hit counter is incremented.\n *\n * @property totalHits {number} - The number of hits for that client so far\n * @property resetTime {Date | undefined} - The time when the counter resets\n */\nexport type IncrementResponse = {\n\ttotalHits: number\n\tresetTime: Date | undefined\n}\n\n/**\n * A modified Express request handler with the rate limit functions.\n */\nexport type RateLimitRequestHandler = Express.RequestHandler & {\n\t/**\n\t * Method to reset a client's hit counter.\n\t *\n\t * @param key {string} - The identifier for a client\n\t */\n\tresetKey: (key: string) => void\n}\n\n/**\n * An interface that all hit counter stores must implement.\n *\n * @deprecated 6.x - Implement the `Store` interface instead.\n */\nexport interface LegacyStore {\n\t/**\n\t * Method to increment a client's hit counter.\n\t *\n\t * @param key {string} - The identifier for a client\n\t * @param callback {IncrementCallback} - The callback to call once the counter is incremented\n\t */\n\tincr: (key: string, callback: IncrementCallback) => void\n\n\t/**\n\t * Method to decrement a client's hit counter.\n\t *\n\t * @param key {string} - The identifier for a client\n\t */\n\tdecrement: (key: string) => void\n\n\t/**\n\t * Method to reset a client's hit counter.\n\t *\n\t * @param key {string} - The identifier for a client\n\t */\n\tresetKey: (key: string) => void\n\n\t/**\n\t * Method to reset everyone's hit counter.\n\t */\n\tresetAll?: () => void\n}\n\n/**\n * An interface that all hit counter stores must implement.\n */\nexport interface Store {\n\t/**\n\t * Method that initializes the store, and has access to the options passed to\n\t * the middleware too.\n\t *\n\t * @param options {Options} - The options used to setup the middleware\n\t */\n\tinit?: (options: Options) => void\n\n\t/**\n\t * Method to increment a client's hit counter.\n\t *\n\t * @param key {string} - The identifier for a client\n\t *\n\t * @returns {IncrementResponse} - The number of hits and reset time for that client\n\t */\n\tincrement: (key: string) => Promise<IncrementResponse> | IncrementResponse\n\n\t/**\n\t * Method to decrement a client's hit counter.\n\t *\n\t * @param key {string} - The identifier for a client\n\t */\n\tdecrement: (key: string) => Promise<void> | void\n\n\t/**\n\t * Method to reset a client's hit counter.\n\t *\n\t * @param key {string} - The identifier for a client\n\t */\n\tresetKey: (key: string) => Promise<void> | void\n\n\t/**\n\t * Method to reset everyone's hit counter.\n\t */\n\tresetAll?: () => Promise<void> | void\n}\n\n/**\n * The configuration options for the rate limiter.\n */\nexport interface Options {\n\t/**\n\t * How long we should remember the requests.\n\t */\n\treadonly windowMs: number\n\n\t/**\n\t * The maximum number of connection to allow during the `window` before\n\t * rate limiting the client.\n\t *\n\t * Can be the limit itself as a number or express middleware that parses\n\t * the request and then figures out the limit.\n\t */\n\treadonly max: number | ValueDeterminingMiddleware<number>\n\n\t/**\n\t * The response body to send back when a client is rate limited.\n\t */\n\treadonly message: any\n\n\t/**\n\t * The HTTP status code to send back when a client is rate limited.\n\t *\n\t * Defaults to `HTTP 429 Too Many Requests` (RFC 6585).\n\t */\n\treadonly statusCode: number\n\n\t/**\n\t * Whether to send `X-RateLimit-*` headers with the rate limit and the number\n\t * of requests.\n\t */\n\treadonly legacyHeaders: boolean\n\n\t/**\n\t * Whether to enable support for the rate limit standardization headers (`RateLimit-*`).\n\t */\n\treadonly standardHeaders: boolean\n\n\t/**\n\t * The name of the property on the request object to store the rate limit info.\n\t *\n\t * Defaults to `rateLimit`.\n\t */\n\treadonly requestPropertyName: string\n\n\t/**\n\t * If `true`, the library will (by default) skip all requests that have a 4XX\n\t * or 5XX status.\n\t */\n\treadonly skipFailedRequests: boolean\n\n\t/**\n\t * If `true`, the library will (by default) skip all requests that have a\n\t * status code less than 400.\n\t */\n\treadonly skipSuccessfulRequests: boolean\n\n\t/**\n\t * Method to determine whether or not the request counts as 'succesful'. Used\n\t * when either `skipSuccessfulRequests` or `skipFailedRequests` is set to true.\n\t */\n\treadonly requestWasSuccessful: ValueDeterminingMiddleware<boolean>\n\n\t/**\n\t * Method to generate custom identifiers for clients.\n\t *\n\t * By default, the client's IP address is used.\n\t */\n\treadonly keyGenerator: ValueDeterminingMiddleware<string>\n\n\t/**\n\t * Method (in the form of middleware) to determine whether or not this request\n\t * counts towards a client's quota.\n\t */\n\treadonly skip: ValueDeterminingMiddleware<boolean>\n\n\t/**\n\t * Express request handler that sends back a response when a client is\n\t * rate-limited.\n\t */\n\treadonly handler: RateLimitExceededEventHandler\n\n\t/**\n\t * Express request handler that sends back a response when a client has\n\t * reached their rate limit, and will be rate limited on their next request.\n\t */\n\treadonly onLimitReached: RateLimitReachedEventHandler\n\n\t/**\n\t * The {@link Store} to use to store the hit count for each client.\n\t */\n\tstore: Store\n\n\t/**\n\t * Whether to send `X-RateLimit-*` headers with the rate limit and the number\n\t * of requests.\n\t *\n\t * @deprecated 6.x - This option was renamed to `legacyHeaders`.\n\t */\n\theaders?: boolean\n\n\t/**\n\t * Whether to send `RateLimit-*` headers with the rate limit and the number\n\t * of requests.\n\t *\n\t * @deprecated 6.x - This option was renamed to `standardHeaders`.\n\t */\n\tdraft_polli_ratelimit_headers?: boolean\n}\n\n/**\n * The extended request object that includes information about the client's\n * rate limit.\n */\nexport type AugmentedRequest = Express.Request & {\n\t[key: string]: RateLimitInfo\n}\n\n/**\n * The rate limit related information for each client included in the\n * Express request object.\n */\nexport interface RateLimitInfo {\n\treadonly limit: number\n\treadonly current: number\n\treadonly remaining: number\n\treadonly resetTime: Date | undefined\n}\n"]}
package/license.md ADDED
@@ -0,0 +1,20 @@
1
+ # MIT License
2
+
3
+ Copyright 2021 Nathan Friedly
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json CHANGED
@@ -1,53 +1,154 @@
1
1
  {
2
- "name": "express-rate-limit",
3
- "version": "5.4.0",
4
- "description": "Basic IP rate-limiting middleware for Express. Use to limit repeated requests to public APIs and/or endpoints such as password reset.",
5
- "homepage": "https://github.com/nfriedly/express-rate-limit",
6
- "author": {
7
- "name": "Nathan Friedly",
8
- "url": "http://nfriedly.com/"
9
- },
10
- "repository": "nfriedly/express-rate-limit",
11
- "license": "MIT",
12
- "main": "lib/express-rate-limit.js",
13
- "files": [
14
- "lib/"
15
- ],
16
- "keywords": [
17
- "express-rate-limit",
18
- "express",
19
- "rate",
20
- "limit",
21
- "ratelimit",
22
- "rate-limit",
23
- "middleware",
24
- "ip",
25
- "auth",
26
- "authorization",
27
- "security",
28
- "brute",
29
- "force",
30
- "bruteforce",
31
- "brute-force",
32
- "attack"
33
- ],
34
- "devDependencies": {
35
- "bluebird": "^3.7.2",
36
- "eslint": "^7.32.0",
37
- "eslint-config-prettier": "^8.3.0",
38
- "eslint-plugin-prettier": "^4.0.0",
39
- "express": "^4.17.1",
40
- "husky": "^7.0.2",
41
- "mocha": "^9.1.2",
42
- "prettier": "^2.4.1",
43
- "pretty-quick": "^3.1.1",
44
- "sinon": "^11.1.2",
45
- "supertest": "^6.1.6"
46
- },
47
- "scripts": {
48
- "lint": "eslint .",
49
- "autofix": "npm run lint -- --fix",
50
- "test": "npm run lint && mocha",
51
- "precommit": "pretty-quick --staged"
52
- }
2
+ "name": "express-rate-limit",
3
+ "version": "6.0.0",
4
+ "description": "Basic IP rate-limiting middleware for Express. Use to limit repeated requests to public APIs and/or endpoints such as password reset.",
5
+ "author": {
6
+ "name": "Nathan Friedly",
7
+ "url": "http://nfriedly.com/"
8
+ },
9
+ "license": "MIT",
10
+ "homepage": "https://github.com/nfriedly/express-rate-limit",
11
+ "repository": "https://github.com/nfriedly/express-rate-limit",
12
+ "keywords": [
13
+ "express-rate-limit",
14
+ "express",
15
+ "rate",
16
+ "limit",
17
+ "ratelimit",
18
+ "rate-limit",
19
+ "middleware",
20
+ "ip",
21
+ "auth",
22
+ "authorization",
23
+ "security",
24
+ "brute",
25
+ "force",
26
+ "bruteforce",
27
+ "brute-force",
28
+ "attack"
29
+ ],
30
+ "type": "module",
31
+ "module": "dist/esm/index.js",
32
+ "main": "dist/cjs/index.js",
33
+ "exports": {
34
+ ".": {
35
+ "import": "./dist/esm/index.js",
36
+ "require": "./dist/cjs/index.js"
37
+ },
38
+ "./memory-store": {
39
+ "import": "./dist/esm/memory-store.js",
40
+ "require": "./dist/cjs/memory-store.js"
41
+ }
42
+ },
43
+ "typesVersions": {
44
+ "*": {
45
+ ".": [
46
+ "./dist/esm/index.d.ts"
47
+ ],
48
+ "./memory-store": [
49
+ "./dist/esm/memory-store.d.ts"
50
+ ]
51
+ }
52
+ },
53
+ "files": [
54
+ "dist/",
55
+ "tsconfig.json",
56
+ "package.json",
57
+ "package-lock.json",
58
+ "readme.md",
59
+ "license.md",
60
+ "changelog.md"
61
+ ],
62
+ "engines": {
63
+ "node": ">= 12.9.0"
64
+ },
65
+ "scripts": {
66
+ "clean": "del-cli dist/ coverage/ *.log *.tmp *.bak *.tgz",
67
+ "build:cjs": "tsc --project config/typescript/cjs.json",
68
+ "build:esm": "tsc --project config/typescript/esm.json",
69
+ "build": "run-p build:*",
70
+ "compile": "run-s clean build",
71
+ "lint": "xo",
72
+ "autofix": "xo --fix",
73
+ "test-lib": "cross-env TS_NODE_PROJECT=config/typescript/test.json NODE_OPTIONS=--experimental-vm-modules jest",
74
+ "test": "run-s compile lint test-lib",
75
+ "view-coverage": "npx serve coverage/lcov-report",
76
+ "pre-commit": "lint-staged",
77
+ "prepare": "npm run compile && husky install config/husky"
78
+ },
79
+ "peerDependencies": {
80
+ "express": "^4"
81
+ },
82
+ "devDependencies": {
83
+ "@jest/globals": "^27.4.2",
84
+ "@types/express": "^4.17.13",
85
+ "@types/jest": "^27.0.3",
86
+ "@types/node": "^16.11.17",
87
+ "@types/supertest": "^2.0.11",
88
+ "cross-env": "^7.0.3",
89
+ "del-cli": "^4.0.1",
90
+ "express": "^4.17.1",
91
+ "husky": "^7.0.4",
92
+ "jest": "^27.4.3",
93
+ "lint-staged": "^12.1.2",
94
+ "npm-run-all": "^4.1.5",
95
+ "supertest": "^6.1.6",
96
+ "ts-jest": "^27.1.1",
97
+ "ts-node": "^10.4.0",
98
+ "typescript": "^4.5.2",
99
+ "xo": "^0.47.0"
100
+ },
101
+ "xo": {
102
+ "prettier": true,
103
+ "rules": {
104
+ "@typescript-eslint/no-empty-function": 0,
105
+ "@typescript-eslint/no-dynamic-delete": 0,
106
+ "@typescript-eslint/no-confusing-void-expression": 0,
107
+ "@typescript-eslint/consistent-indexed-object-style": [
108
+ "error",
109
+ "index-signature"
110
+ ],
111
+ "import/no-named-as-default-member": 0,
112
+ "import/no-cycle": 0
113
+ }
114
+ },
115
+ "prettier": {
116
+ "semi": false,
117
+ "useTabs": true,
118
+ "singleQuote": true,
119
+ "bracketSpacing": true,
120
+ "trailingComma": "all",
121
+ "proseWrap": "always"
122
+ },
123
+ "jest": {
124
+ "preset": "ts-jest/presets/default-esm",
125
+ "globals": {
126
+ "ts-jest": {
127
+ "useESM": true
128
+ }
129
+ },
130
+ "verbose": true,
131
+ "collectCoverage": true,
132
+ "collectCoverageFrom": [
133
+ "source/**/*.ts"
134
+ ],
135
+ "testTimeout": 30000,
136
+ "testMatch": [
137
+ "**/test/**/*-test.[jt]s?(x)"
138
+ ],
139
+ "moduleFileExtensions": [
140
+ "js",
141
+ "jsx",
142
+ "json",
143
+ "ts",
144
+ "tsx"
145
+ ],
146
+ "moduleNameMapper": {
147
+ "^(\\.{1,2}/.*)\\.js$": "$1"
148
+ }
149
+ },
150
+ "lint-staged": {
151
+ "{source,test}/**/*.ts": "xo --fix",
152
+ "**/*.{json,yaml,md}": "prettier --write"
153
+ }
53
154
  }