@email-utils/validator-syntax 0.0.1-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.
- package/.babelrc +8 -0
- package/.eslintignore +5 -0
- package/.nvmrc +1 -0
- package/.nycrc.json +11 -0
- package/@types/index.d.ts +30 -0
- package/Readme.md +102 -0
- package/bin/tag.sh +10 -0
- package/dist/index.js +265 -0
- package/dist/index.js.map +1 -0
- package/package.json +87 -0
- package/src/index.ts +336 -0
- package/test/index.test.ts +1612 -0
- package/tsconfig.json +22 -0
package/.babelrc
ADDED
package/.eslintignore
ADDED
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
16.13.0
|
package/.nycrc.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface EmailValidatorConfig {
|
|
2
|
+
local: LocalValidateConfig
|
|
3
|
+
domain: DomainValidateConfig
|
|
4
|
+
}
|
|
5
|
+
interface EmailValidatorParam {
|
|
6
|
+
local?: LocalValidateConfig
|
|
7
|
+
domain?: DomainValidateConfig
|
|
8
|
+
}
|
|
9
|
+
type LocalValidateConfig = {
|
|
10
|
+
alphaUpper: boolean
|
|
11
|
+
alphaLower: boolean
|
|
12
|
+
numeric: boolean
|
|
13
|
+
period: boolean
|
|
14
|
+
printable: boolean
|
|
15
|
+
quote: boolean
|
|
16
|
+
hyphen: boolean
|
|
17
|
+
spaces: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type DomainValidateConfig = {
|
|
21
|
+
alphaUpper: boolean
|
|
22
|
+
alphaLower: boolean
|
|
23
|
+
numeric: boolean
|
|
24
|
+
period: boolean
|
|
25
|
+
hyphen: boolean
|
|
26
|
+
tld: boolean
|
|
27
|
+
localhost: boolean
|
|
28
|
+
charsBeforeDot: number // -1 means don't check.
|
|
29
|
+
charsAfterDot: number // -1 means don't check.
|
|
30
|
+
}
|
package/Readme.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# ssmith-is-valid-email
|
|
2
|
+
## A Robust Tool for Validating Emails
|
|
3
|
+
|
|
4
|
+
[ ](https://app.codeship.com/projects/297684)
|
|
5
|
+
[](https://codecov.io/gh/ssmith-wombatweb/is-valid-email/branch/master)
|
|
6
|
+
[](https://david-dm.org/ssmith-wombatweb/is-valid-email.svg)
|
|
7
|
+
[](https://badge.fury.io/js/ssmith-is-valid-email)
|
|
8
|
+
|
|
9
|
+
[Project Repo](https://github.com/ssmith-wombatweb/is-valid-email)
|
|
10
|
+
|
|
11
|
+
This script checks the validity of a wide range of email types. It follows most of the rules outlined here: [Email Address - Wikipedia](https://en.wikipedia.org/wiki/Email_address). It was created because of performance issues with RegEx when working with emails in React.
|
|
12
|
+
|
|
13
|
+
### Author
|
|
14
|
+
Written by Simeon Smith.
|
|
15
|
+
|
|
16
|
+
[Portfolio](https://www.simeonsmith.me) | [Resume](https://resume.simeonsmith.me) | [Github](https://github.com/ssmith-wombatweb)
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
npm i -S ssmith-is-valid-email
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Using the Function
|
|
25
|
+
|
|
26
|
+
This function supports all modern browser including IE9+.
|
|
27
|
+
|
|
28
|
+
### Importing
|
|
29
|
+
|
|
30
|
+
#### ES6 JS
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import isValidEmail from 'ssmith-is-valid-email';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
#### Common JS Import
|
|
37
|
+
```javascript
|
|
38
|
+
const isValidEmail = require('ssmith-is-valid-email');
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Calling the Function
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
isValidEmail('test@google.com');
|
|
45
|
+
// Returns true or false.
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Testing
|
|
49
|
+
|
|
50
|
+
The following emails were tested. It follows most of the rules outlined here: [Email Address - Wikipedia](https://en.wikipedia.org/wiki/Email_address).
|
|
51
|
+
|
|
52
|
+
### Valid Emails
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
simple@example.com
|
|
56
|
+
very.common@example.com
|
|
57
|
+
disposable.style.email.with+symbol@example.com
|
|
58
|
+
other.email-with-hyphen@example.com
|
|
59
|
+
user.name+tag+sorting@example.com
|
|
60
|
+
x@example.com
|
|
61
|
+
example-indeed@strange-example.com
|
|
62
|
+
example@s.example
|
|
63
|
+
admin@test.co
|
|
64
|
+
" "@example.org
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Invalid Emails
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
Abc.example.com
|
|
71
|
+
@Abc.example.com
|
|
72
|
+
james@google
|
|
73
|
+
james@google.c
|
|
74
|
+
james richards@google.com
|
|
75
|
+
james" richards@google.com
|
|
76
|
+
james@cb$.com
|
|
77
|
+
A@b@c@example.com
|
|
78
|
+
a"b(c)d,e:f;g<h>i[j\\k]l@example.com
|
|
79
|
+
just"not"right@example.com
|
|
80
|
+
just."not"right@example.com
|
|
81
|
+
1234567890123456789012345678901234567890123456789012345678901234+x@example.com
|
|
82
|
+
john..doe@example.com
|
|
83
|
+
john.doe@example..com
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Not Yet Supported
|
|
87
|
+
|
|
88
|
+
#### Should Be Valid
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### Not Useful to Support
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
admin@mailserver1
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Performance
|
|
101
|
+
|
|
102
|
+
This script will run 1000 times on a valid or invalid email in less than 20 milliseconds.
|
package/bin/tag.sh
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
echo "Creating a $1 verion."
|
|
3
|
+
|
|
4
|
+
npm version $1
|
|
5
|
+
version=`git diff HEAD^..HEAD -- "$(git rev-parse --show-toplevel)"/package.json | grep '^\+.*version' | sed -s 's/[^0-9\.]//g'`
|
|
6
|
+
|
|
7
|
+
echo "Creating version $version."
|
|
8
|
+
|
|
9
|
+
git push --tags
|
|
10
|
+
npm publish
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const tlds = require("tlds/index.json");
|
|
13
|
+
class EmailSyntaxValidator {
|
|
14
|
+
constructor(configParam = {}) {
|
|
15
|
+
this.defaultConfig = {
|
|
16
|
+
local: {
|
|
17
|
+
alphaUpper: true,
|
|
18
|
+
alphaLower: true,
|
|
19
|
+
numeric: true,
|
|
20
|
+
period: true,
|
|
21
|
+
printable: true,
|
|
22
|
+
quote: true,
|
|
23
|
+
hyphen: true,
|
|
24
|
+
spaces: true,
|
|
25
|
+
},
|
|
26
|
+
domain: {
|
|
27
|
+
alphaUpper: true,
|
|
28
|
+
alphaLower: true,
|
|
29
|
+
numeric: true,
|
|
30
|
+
period: true,
|
|
31
|
+
hyphen: true,
|
|
32
|
+
tld: true,
|
|
33
|
+
localhost: false,
|
|
34
|
+
charsBeforeDot: 1,
|
|
35
|
+
charsAfterDot: 2,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
this.config = this.defaultConfig;
|
|
39
|
+
this.chars = {
|
|
40
|
+
alphaLower: 'abcdefghijklmnopqrstuvwxyz',
|
|
41
|
+
alphaUpper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
|
42
|
+
numeric: '0123456789',
|
|
43
|
+
dot: ',',
|
|
44
|
+
printable: "!#$%&'*+/=?^_`{|}~",
|
|
45
|
+
space: ' ',
|
|
46
|
+
quote: '"',
|
|
47
|
+
hyphen: '-',
|
|
48
|
+
period: '.',
|
|
49
|
+
};
|
|
50
|
+
this.email = '';
|
|
51
|
+
this.originalEmail = '';
|
|
52
|
+
let key;
|
|
53
|
+
console.log('validate config');
|
|
54
|
+
for (key in configParam) {
|
|
55
|
+
const configGroup = configParam[key];
|
|
56
|
+
for (const subKey in configGroup) {
|
|
57
|
+
const subKeyType = subKey;
|
|
58
|
+
this.config[key][subKeyType] = configGroup[subKeyType];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
gatherChars(charConfig) {
|
|
63
|
+
let characters = '';
|
|
64
|
+
if (charConfig.alphaUpper === true) {
|
|
65
|
+
characters += this.chars.alphaUpper;
|
|
66
|
+
}
|
|
67
|
+
if (charConfig.alphaLower === true) {
|
|
68
|
+
characters += this.chars.alphaLower;
|
|
69
|
+
}
|
|
70
|
+
if (charConfig.numeric === true) {
|
|
71
|
+
characters += this.chars.numeric;
|
|
72
|
+
}
|
|
73
|
+
if (charConfig.hyphen === true) {
|
|
74
|
+
characters += this.chars.hyphen;
|
|
75
|
+
}
|
|
76
|
+
if ('printable' in charConfig && charConfig.printable === true) {
|
|
77
|
+
characters += this.chars.printable;
|
|
78
|
+
}
|
|
79
|
+
if ('spaces' in charConfig && charConfig.spaces === true) {
|
|
80
|
+
characters += this.chars.space;
|
|
81
|
+
}
|
|
82
|
+
if ('quote' in charConfig && charConfig.quote === true) {
|
|
83
|
+
characters += this.chars.quote;
|
|
84
|
+
}
|
|
85
|
+
if (charConfig.period === true) {
|
|
86
|
+
characters += this.chars.period;
|
|
87
|
+
}
|
|
88
|
+
return characters.split('');
|
|
89
|
+
}
|
|
90
|
+
validateGeneral() {
|
|
91
|
+
const atSymbolIndex = this.email.indexOf('@');
|
|
92
|
+
if (atSymbolIndex < 1) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
validateChars(chars, charsToValidate) {
|
|
98
|
+
let quoteOpen = false;
|
|
99
|
+
for (let l = 0; l < charsToValidate.length; l++) {
|
|
100
|
+
const letter = charsToValidate[l];
|
|
101
|
+
if (this.config.local.quote) {
|
|
102
|
+
if (letter === '"') {
|
|
103
|
+
quoteOpen = !quoteOpen;
|
|
104
|
+
if (l !== 0 && l !== charsToValidate.length - 1) {
|
|
105
|
+
if (quoteOpen && !(charsToValidate[l - 1] === '.')) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
else if (!quoteOpen && !(charsToValidate[l + 1] === '.')) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const letterInAllowed = chars.indexOf(letter) !== -1;
|
|
115
|
+
if (!letterInAllowed) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
validateLocal() {
|
|
122
|
+
const validChars = this.gatherChars(this.config.local);
|
|
123
|
+
let localLetters = this.email.slice(0, this.email.indexOf('@')).split('');
|
|
124
|
+
if (this.config.local.printable) {
|
|
125
|
+
const percentInLocalIndex = localLetters.indexOf('%');
|
|
126
|
+
if (percentInLocalIndex !== -1) {
|
|
127
|
+
localLetters = localLetters.slice(0, percentInLocalIndex);
|
|
128
|
+
}
|
|
129
|
+
const bangInLocalIndex = localLetters.indexOf('!');
|
|
130
|
+
if (bangInLocalIndex !== -1) {
|
|
131
|
+
localLetters = localLetters.slice(bangInLocalIndex);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (localLetters.length > 64) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
const charsValid = this.validateChars(validChars, localLetters);
|
|
138
|
+
if (!charsValid) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
const indexOfDoublePeriods = this.email.indexOf('..');
|
|
142
|
+
if (indexOfDoublePeriods !== -1) {
|
|
143
|
+
const atSymbolIndex = this.email.indexOf('@');
|
|
144
|
+
if (indexOfDoublePeriods > atSymbolIndex) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const indexOfFirstQuoteInLocal = localLetters.indexOf('"');
|
|
148
|
+
const indexOfLastQuoteInLocal = localLetters.length -
|
|
149
|
+
`${localLetters}`.split('').reverse().join('').indexOf('"') -
|
|
150
|
+
1;
|
|
151
|
+
if (indexOfFirstQuoteInLocal < 0 || indexOfLastQuoteInLocal < 0) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (indexOfFirstQuoteInLocal >= indexOfDoublePeriods ||
|
|
155
|
+
indexOfDoublePeriods >= indexOfLastQuoteInLocal) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const indexOfSpace = localLetters.indexOf(' ');
|
|
160
|
+
if (indexOfSpace !== -1 &&
|
|
161
|
+
(localLetters[indexOfSpace + 1] !== '"' ||
|
|
162
|
+
localLetters[indexOfSpace - 1] !== '"')) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
validateDomainParts(domain) {
|
|
168
|
+
const dotIndex = domain.lastIndexOf('.');
|
|
169
|
+
if (dotIndex === -1 && this.config.domain.localhost === false) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
if (dotIndex !== -1) {
|
|
173
|
+
if (this.config.domain.charsBeforeDot !== -1) {
|
|
174
|
+
if (dotIndex <= this.config.domain.charsBeforeDot) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (this.config.domain.charsAfterDot !== -1) {
|
|
179
|
+
if (dotIndex === domain.length - this.config.domain.charsAfterDot) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (this.config.domain.tld) {
|
|
184
|
+
const tld = domain.slice(dotIndex + 1);
|
|
185
|
+
let tldExists = false;
|
|
186
|
+
for (let t = 0; t < tlds.length; t++) {
|
|
187
|
+
const currentTld = tlds[t];
|
|
188
|
+
if (tld.toLowerCase() === currentTld) {
|
|
189
|
+
tldExists = true;
|
|
190
|
+
}
|
|
191
|
+
if (tldExists) {
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (!tldExists) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
validateDomain() {
|
|
203
|
+
const domain = this.email.slice(this.email.indexOf('@') + 1);
|
|
204
|
+
const domainPartsValid = this.validateDomainParts(domain);
|
|
205
|
+
if (!domainPartsValid) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
const validChars = this.gatherChars(this.config.domain);
|
|
209
|
+
const domainLetters = domain.split('');
|
|
210
|
+
if (this.config.local.printable) {
|
|
211
|
+
const localLetters = this.email
|
|
212
|
+
.slice(0, this.email.indexOf('@'))
|
|
213
|
+
.split('');
|
|
214
|
+
const percentInLocalIndex = localLetters.indexOf('%');
|
|
215
|
+
if (percentInLocalIndex !== -1) {
|
|
216
|
+
const relayDomain = localLetters.slice(percentInLocalIndex + 1);
|
|
217
|
+
const relayDomainPartsValid = this.validateDomainParts(relayDomain.join(''));
|
|
218
|
+
if (!relayDomainPartsValid) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
const charsValid = this.validateChars(validChars, relayDomain);
|
|
222
|
+
if (!charsValid) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const bangInLocalIndex = localLetters.indexOf('!');
|
|
227
|
+
if (bangInLocalIndex !== -1) {
|
|
228
|
+
const relayDomain = localLetters.slice(0, bangInLocalIndex);
|
|
229
|
+
const relayDomainPartsValid = this.validateDomainParts(relayDomain.join(''));
|
|
230
|
+
if (!relayDomainPartsValid) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
const charsValid = this.validateChars(validChars, relayDomain);
|
|
234
|
+
if (!charsValid) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const charsValid = this.validateChars(validChars, domainLetters);
|
|
240
|
+
if (!charsValid) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
validate(email) {
|
|
246
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
+
this.email = email;
|
|
248
|
+
const generalValid = this.validateGeneral();
|
|
249
|
+
if (!generalValid) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
const localValid = this.validateLocal();
|
|
253
|
+
if (!localValid) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
const domainValid = this.validateDomain();
|
|
257
|
+
if (!domainValid) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
return true;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
exports.default = EmailSyntaxValidator;
|
|
265
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAGA,wCAAuC;AACvC,MAAM,oBAAoB;IAuCxB,YAAY,c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;gBACjB,OAAO,KAAK,CAAA;aACb;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;YACvC,IAAI,CAAC,UAAU,EAAE;gBACf,OAAO,KAAK,CAAA;aACb;YAED,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;YACzC,IAAI,CAAC,WAAW,EAAE;gBAChB,OAAO,KAAK,CAAA;aACb;YAED,OAAO,IAAI,CAAA;QACb,CAAC;KAAA;CACF;AAED,kBAAe,oBAAoB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@email-utils/validator-syntax",
|
|
3
|
+
"version": "0.0.1-0",
|
|
4
|
+
"description": "Configurable email syntax validator.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"test": "ts-mocha test/**/*.test.ts",
|
|
9
|
+
"report-coverage": "nyc npm test"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/ssmith-wombatweb/is-valid-email.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"email",
|
|
17
|
+
"valid",
|
|
18
|
+
"check"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": "v16.13.0"
|
|
22
|
+
},
|
|
23
|
+
"author": "Simeon Smith <hello@simeonsmith.dev> (https://www.simeonsmith.dev)",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/chai": "^4.2.22",
|
|
27
|
+
"@types/mocha": "^9.0.0",
|
|
28
|
+
"@types/node": "^16.11.7",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^5.3.1",
|
|
30
|
+
"@typescript-eslint/parser": "^5.3.1",
|
|
31
|
+
"chai": "^4.3.4",
|
|
32
|
+
"eslint": "^8.2.0",
|
|
33
|
+
"eslint-config-prettier": "^8.3.0",
|
|
34
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
35
|
+
"nyc": "^15.1.0",
|
|
36
|
+
"prettier": "^2.4.1",
|
|
37
|
+
"ts-mocha": "^8.0.0",
|
|
38
|
+
"typescript": "^4.4.4"
|
|
39
|
+
},
|
|
40
|
+
"eslintConfig": {
|
|
41
|
+
"root": true,
|
|
42
|
+
"env": {
|
|
43
|
+
"mocha": true,
|
|
44
|
+
"browser": true,
|
|
45
|
+
"node": true,
|
|
46
|
+
"es6": true
|
|
47
|
+
},
|
|
48
|
+
"parser": "@typescript-eslint/parser",
|
|
49
|
+
"parserOptions": {
|
|
50
|
+
"ecmaVersion": 2018,
|
|
51
|
+
"sourceType": "module"
|
|
52
|
+
},
|
|
53
|
+
"extends": [
|
|
54
|
+
"prettier",
|
|
55
|
+
"plugin:prettier/recommended",
|
|
56
|
+
"eslint:recommended",
|
|
57
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
58
|
+
"plugin:@typescript-eslint/recommended"
|
|
59
|
+
],
|
|
60
|
+
"plugins": [
|
|
61
|
+
"@typescript-eslint",
|
|
62
|
+
"prettier"
|
|
63
|
+
],
|
|
64
|
+
"rules": {
|
|
65
|
+
"no-unused-vars": "warn",
|
|
66
|
+
"no-prototype-builtins": "warn",
|
|
67
|
+
"curly": "warn"
|
|
68
|
+
},
|
|
69
|
+
"globals": {
|
|
70
|
+
"fetch": true
|
|
71
|
+
},
|
|
72
|
+
"ignorePatterns": [
|
|
73
|
+
"node_modules",
|
|
74
|
+
"dist",
|
|
75
|
+
"coverage",
|
|
76
|
+
".vscode",
|
|
77
|
+
".nyc_output"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"prettier": {
|
|
81
|
+
"semi": false,
|
|
82
|
+
"singleQuote": true
|
|
83
|
+
},
|
|
84
|
+
"dependencies": {
|
|
85
|
+
"tlds": "^1.226.0"
|
|
86
|
+
}
|
|
87
|
+
}
|