validation-br 1.4.4 → 1.5.1

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.
Files changed (65) hide show
  1. package/.github/workflows/test.yml +6 -6
  2. package/.prettierrc.js +1 -1
  3. package/dist/cnh.d.ts +91 -91
  4. package/dist/cnh.js +138 -133
  5. package/dist/cnh.js.map +1 -1
  6. package/dist/cnh.test.d.ts +1 -1
  7. package/dist/cnpj.d.ts +87 -82
  8. package/dist/cnpj.js +150 -124
  9. package/dist/cnpj.js.map +1 -1
  10. package/dist/cnpj.test.d.ts +1 -1
  11. package/dist/cpf.d.ts +99 -99
  12. package/dist/cpf.js +146 -141
  13. package/dist/cpf.js.map +1 -1
  14. package/dist/cpf.test.d.ts +1 -1
  15. package/dist/data/ValidationBRError.d.ts +6 -6
  16. package/dist/data/ValidationBRError.js +9 -9
  17. package/dist/data/ValidationBRError.js.map +1 -1
  18. package/dist/index.d.ts +21 -21
  19. package/dist/index.js +41 -32
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.test.d.ts +1 -1
  22. package/dist/judicialProcess.d.ts +126 -126
  23. package/dist/judicialProcess.js +189 -184
  24. package/dist/judicialProcess.js.map +1 -1
  25. package/dist/judicialProcess.test.d.ts +1 -1
  26. package/dist/nup17.d.ts +102 -102
  27. package/dist/nup17.js +154 -149
  28. package/dist/nup17.js.map +1 -1
  29. package/dist/nup17.test.d.ts +1 -1
  30. package/dist/pisPasep.d.ts +81 -81
  31. package/dist/pisPasep.js +125 -120
  32. package/dist/pisPasep.js.map +1 -1
  33. package/dist/pisPasep.test.d.ts +1 -1
  34. package/dist/postalCode.d.ts +83 -83
  35. package/dist/postalCode.js +135 -130
  36. package/dist/postalCode.js.map +1 -1
  37. package/dist/postalCode.test.d.ts +1 -1
  38. package/dist/renavam.d.ts +75 -75
  39. package/dist/renavam.js +121 -116
  40. package/dist/renavam.js.map +1 -1
  41. package/dist/renavam.test.d.ts +1 -1
  42. package/dist/tituloEleitor.d.ts +93 -93
  43. package/dist/tituloEleitor.js +142 -137
  44. package/dist/tituloEleitor.js.map +1 -1
  45. package/dist/tituloEleitor.test.d.ts +1 -1
  46. package/dist/utils-applyMask.test.d.ts +1 -1
  47. package/dist/utils-checkRepeatedSequence.test.d.ts +1 -0
  48. package/dist/utils-clearValue.test.d.ts +1 -1
  49. package/dist/utils-fakeNumber.test.d.ts +1 -1
  50. package/dist/utils-insertAtPosition.test.d.ts +1 -1
  51. package/dist/utils-invalidListGenerator.test.d.ts +1 -1
  52. package/dist/utils-randomLetter.test.d.ts +1 -1
  53. package/dist/utils-removeFromPosition.test.d.ts +1 -1
  54. package/dist/utils-sumElementsByMultipliers.test.d.ts +1 -1
  55. package/dist/utils-sumToDV.test.d.ts +1 -1
  56. package/dist/utils.d.ts +131 -133
  57. package/dist/utils.js +188 -190
  58. package/dist/utils.js.map +1 -1
  59. package/docs/Nota.COCAD.SUARA.2024.05.49.CNPJ.Alfanumerico-1.pdf +0 -0
  60. package/{.eslintrc.js → eslint.config.js} +39 -39
  61. package/jest.config.js +1 -6
  62. package/package.json +6 -27
  63. package/readme.md +42 -27
  64. package/.eslintcache +0 -1
  65. package/.eslintignore +0 -2
package/dist/utils.js CHANGED
@@ -1,191 +1,189 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.randomLetter = exports.applyMask = exports.removeFromPosition = exports.insertAtPosition = exports.clearValue = exports.fakeNumber = exports.sumElementsByMultipliers = exports.invalidListGenerator = exports.sumToDV = void 0;
7
- const ValidationBRError_1 = __importDefault(require("./data/ValidationBRError"));
8
- /**
9
- * Calcula o DV verificador a partir das regras do MOD11:
10
- * O valor da soma é dividido por 11. O resultado é o resto da divisão. Caso o resto seja
11
- * menor que 2, ou seja, o valor da divisão seja 10 ou 11, o resultado é 0.
12
- *
13
- * @param {Integer} sum Soma
14
- * @returns {Integer}
15
- */
16
- function sumToDV(sum) {
17
- return sum % 11 < 2 ? 0 : 11 - (sum % 11);
18
- }
19
- exports.sumToDV = sumToDV;
20
- /**
21
- * Cria uma lista de valores repetidos no tamanho do documento para eliminar
22
- * valores que já conhecemos como inválidos
23
- *
24
- * @example
25
- * invalidListGenerator(10, 11)
26
- * //-> [00000000000, 11111111111, ....., 99999999999]
27
- *
28
- * @param {Integer} length Número de itens do array
29
- * @param {Integer} size Tamanho da string gerada
30
- * @returns {Array} Lista de valores
31
- */
32
- function invalidListGenerator(size) {
33
- return [...Array(10).keys()].map((f) => String(f).repeat(size));
34
- }
35
- exports.invalidListGenerator = invalidListGenerator;
36
- /**
37
- * Multiplica os elementos de uma string com os elementos de outra, ou de um array
38
- * e soma o resultado ao final
39
- *
40
- * @example
41
- * sumElementsByMultipliers('123', '987') //-> 46
42
- * sumElementsByMultipliers('123', [9, 8, 7]) //-> 46
43
- *
44
- * @param {String} value
45
- * @param {String|Array} multiplier
46
- * @returns {Integer} Somatório
47
- */
48
- function sumElementsByMultipliers(value, multiplier) {
49
- if (typeof multiplier === 'string')
50
- multiplier = multiplier.split('').map((n) => Number(n));
51
- return multiplier.reduce((accu, curr, i) => accu + curr * Number(value.charAt(i)), 0);
52
- }
53
- exports.sumElementsByMultipliers = sumElementsByMultipliers;
54
- /**
55
- * fakeNumber()
56
- * Cria um número aleatório com o número de caracteres
57
- *
58
- * @example
59
- * fakeNumber(8, true) // -> 00083159
60
- * fakeNumber(4) // -> 831
61
- *
62
- * @param {Integer} length
63
- * @param {Boolean} forceLength Adiciona zeros à esquerda para ter os números de caractes exatos
64
- * @returns {String}
65
- */
66
- function fakeNumber(length, forceLength = false) {
67
- const value = Math.floor(Math.random() * 10 ** length);
68
- if (forceLength)
69
- return String(value).padStart(length, '0');
70
- return +value;
71
- }
72
- exports.fakeNumber = fakeNumber;
73
- /**
74
- * Limpa um número informado, retirando caracteres diferentes de números,
75
- * preenchendo com zeros à esquerda se for menor que o tamanho exato e
76
- * removendo uma parte do número se for maior que tamanho definido.
77
- *
78
- * 1) Retira caracteres não-numéricos
79
- * 2) Preenche com zeros à esquerda se 'value' for menor que 'length'
80
- * 3) Remove caracteres à direita se 'value' for maior que 'length'
81
- *
82
- * @example
83
- * clearValue(12345-6, 6) // -> 123456
84
- * clearValue(12345678, 3) // -> 123
85
- * clearValue(12345, 10) // -> 0000001234
86
- *
87
- * @param {Number|String} value
88
- * @param {Number} length Tamanho exato. Se for null, retira os caracteres não-numéricos
89
- * @returns {String} Número com o tamanho exato
90
- */
91
- function clearValue(value, length = null, options) {
92
- let clearedValue = String(value).replace(/([/.-]+)/gi, '');
93
- if (options) {
94
- if (options.rejectEmpty === true && clearedValue.length === 0) {
95
- throw ValidationBRError_1.default.EMPTY_VALUE;
96
- }
97
- if (options.rejectHigherLength === true && length && clearedValue.length > length) {
98
- throw ValidationBRError_1.default.MAX_LEN_EXCEDEED;
99
- }
100
- if (options.rejectEqualSequence === true && length) {
101
- const invalidList = invalidListGenerator(length);
102
- if (invalidList.includes(clearedValue)) {
103
- throw ValidationBRError_1.default.SEQUENCE_REPEATED;
104
- }
105
- }
106
- // if (!length || clearedValue.length === length) return clearedValue
107
- if (length && options.fillZerosAtLeft)
108
- clearedValue = clearedValue.padStart(length, '0');
109
- if (length && options.trimAtRight)
110
- clearedValue = clearedValue.substring(0, length);
111
- }
112
- return clearedValue;
113
- }
114
- exports.clearValue = clearValue;
115
- /**
116
- * insertAtPosition()
117
- * Insere um conjunto de caracteres em um local específico de uma string
118
- *
119
- * @example
120
- * insertAtPosition('AAABBB', 'C', 3) // -> AAACBBB
121
- * insertAtPosition('000011122223445555', 99, 7) // -> 00001119922223445555
122
- *
123
- * @param {String|Number} value Valor original
124
- * @param {String|Number} insertValue Valor que será inserido
125
- * @param {String|Number} position Posição que receberá o novo valor
126
- * @returns {String}
127
- *
128
- */
129
- function insertAtPosition(value, insertValue, position) {
130
- return `${value.substring(0, position)}${insertValue}${value.substring(position)}`;
131
- }
132
- exports.insertAtPosition = insertAtPosition;
133
- /**
134
- * removeFromPosition()
135
- * Retira um conjunto de caracteres de um local específico de uma string
136
- *
137
- * @example
138
- * removeFromPosition('00001119922223445555', 7,9) // -> 000011122223445555
139
- * removeFromPosition('AAACBBB', 3,4) // -> AAABBB
140
- *
141
- * @param {String|Number} value Valor original
142
- * @param {String|Number} startPosition
143
- * @param {String|Number} endPosition
144
- * @returns {String}
145
- *
146
- */
147
- function removeFromPosition(value, startPosition, endPosition) {
148
- return [value.slice(0, startPosition), value.slice(endPosition)].join('');
149
- }
150
- exports.removeFromPosition = removeFromPosition;
151
- /**
152
- * applyMask()
153
- * Aplica uma máscara a uma string
154
- *
155
- * @example
156
- * applyMask('59650000', '00.000-000') // -> 59.650-000
157
- * applyMask('99877665544', '(00) 0 0000-0000') // -> (99) 8 7766-5544
158
- *
159
- * @param {String|Number} value Valor original
160
- * @param {String} mask
161
- * @returns {String}
162
- *
163
- */
164
- function applyMask(value, mask) {
165
- const maskLen = clearValue(mask).length;
166
- let masked = clearValue(value, maskLen, { fillZerosAtLeft: true, trimAtRight: true });
167
- const specialChars = ['/', '-', '.', '(', ')', ' '];
168
- for (let position = 0; position < mask.length; position += 1) {
169
- const current = mask[position];
170
- if (specialChars.includes(current))
171
- masked = insertAtPosition(masked, current, position);
172
- }
173
- return masked;
174
- }
175
- exports.applyMask = applyMask;
176
- /**
177
- * randomLetter()
178
- * Pega uma letra maiúscula aleatoriamente
179
- *
180
- * @example
181
- * randomLetter() // -> A
182
- * randomLetter() // -> S
183
- *
184
- * @returns {String}
185
- */
186
- function randomLetter() {
187
- const idx = Math.floor(1 + Math.random() * 26);
188
- return String.fromCharCode(idx + 64);
189
- }
190
- exports.randomLetter = randomLetter;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.sumToDV = sumToDV;
7
+ exports.checkRepeatedSequence = checkRepeatedSequence;
8
+ exports.sumElementsByMultipliers = sumElementsByMultipliers;
9
+ exports.fakeNumber = fakeNumber;
10
+ exports.clearValue = clearValue;
11
+ exports.insertAtPosition = insertAtPosition;
12
+ exports.removeFromPosition = removeFromPosition;
13
+ exports.applyMask = applyMask;
14
+ exports.randomLetter = randomLetter;
15
+ const ValidationBRError_1 = __importDefault(require("./data/ValidationBRError"));
16
+ /**
17
+ * Calcula o DV verificador a partir das regras do MOD11:
18
+ * O valor da soma é dividido por 11. O resultado é o resto da divisão. Caso o resto seja
19
+ * menor que 2, ou seja, o valor da divisão seja 10 ou 11, o resultado é 0.
20
+ *
21
+ * @param {Integer} sum Soma
22
+ * @returns {Integer}
23
+ */
24
+ function sumToDV(sum) {
25
+ return sum % 11 < 2 ? 0 : 11 - (sum % 11);
26
+ }
27
+ /**
28
+ * Checa se o número repassado possui todos os digitos iguais
29
+ *
30
+ * @example
31
+ * checkRepeatedSequence(12345678)
32
+ * // -> false
33
+ * checkRepeatedSequence(11111111)
34
+ * // -> true
35
+ *
36
+ */
37
+ function checkRepeatedSequence(value) {
38
+ return [...value].every(digit => digit === value[0]);
39
+ }
40
+ /**
41
+ * Multiplica os elementos de uma string com os elementos de outra, ou de um array
42
+ * e soma o resultado ao final
43
+ *
44
+ * @example
45
+ * sumElementsByMultipliers('123', '987') //-> 46
46
+ * sumElementsByMultipliers('123', [9, 8, 7]) //-> 46
47
+ *
48
+ * @param {String} value
49
+ * @param {String|Array} multiplier
50
+ * @returns {Integer} Somatório
51
+ */
52
+ function sumElementsByMultipliers(value, multiplier) {
53
+ if (!Array.isArray(multiplier)) {
54
+ multiplier = [...multiplier].map((n) => Number(n));
55
+ }
56
+ return multiplier.reduce((accu, curr, i) => accu + curr * Number(value[i]), 0);
57
+ }
58
+ /**
59
+ * fakeNumber()
60
+ * Cria um número aleatório com o número de caracteres
61
+ *
62
+ * @example
63
+ * fakeNumber(8, true) // -> 00083159
64
+ * fakeNumber(4) // -> 831
65
+ *
66
+ * @param {Integer} length
67
+ * @param {Boolean} forceLength Adiciona zeros à esquerda para ter os números de caractes exatos
68
+ * @returns {String}
69
+ */
70
+ function fakeNumber(length, forceLength = false) {
71
+ const value = Math.floor(Math.random() * 10 ** length);
72
+ if (forceLength)
73
+ return String(value).padStart(length, '0');
74
+ return +value;
75
+ }
76
+ /**
77
+ * Limpa um número informado, retirando caracteres diferentes de números,
78
+ * preenchendo com zeros à esquerda se for menor que o tamanho exato e
79
+ * removendo uma parte do número se for maior que tamanho definido.
80
+ *
81
+ * 1) Retira caracteres não-numéricos
82
+ * 2) Preenche com zeros à esquerda se 'value' for menor que 'length'
83
+ * 3) Remove caracteres à direita se 'value' for maior que 'length'
84
+ *
85
+ * @example
86
+ * clearValue(12345-6, 6) // -> 123456
87
+ * clearValue(12345678, 3) // -> 123
88
+ * clearValue(12345, 10) // -> 0000001234
89
+ *
90
+ * @param {Number|String} value
91
+ * @param {Number} length Tamanho exato. Se for null, retira os caracteres não-numéricos
92
+ * @returns {String} Número com o tamanho exato
93
+ */
94
+ function clearValue(value, length = null, options) {
95
+ let clearedValue = String(value).replace(/([/.-]+)/gi, '');
96
+ if (options) {
97
+ const shouldRejectEmpty = options.rejectEmpty === true && clearedValue.length === 0;
98
+ if (shouldRejectEmpty) {
99
+ throw ValidationBRError_1.default.EMPTY_VALUE;
100
+ }
101
+ const shouldRejectHigherLength = options.rejectHigherLength === true && length && clearedValue.length > length;
102
+ if (shouldRejectHigherLength) {
103
+ throw ValidationBRError_1.default.MAX_LEN_EXCEDEED;
104
+ }
105
+ const shouldRejectEqualSequence = options.rejectEqualSequence === true && length;
106
+ if (shouldRejectEqualSequence) {
107
+ if (checkRepeatedSequence(clearedValue))
108
+ throw ValidationBRError_1.default.REPEATED_SEQUENCE;
109
+ }
110
+ if (length && options.fillZerosAtLeft)
111
+ clearedValue = clearedValue.padStart(length, '0');
112
+ if (length && options.trimAtRight)
113
+ clearedValue = clearedValue.substring(0, length);
114
+ }
115
+ return clearedValue;
116
+ }
117
+ /**
118
+ * insertAtPosition()
119
+ * Insere um conjunto de caracteres em um local específico de uma string
120
+ *
121
+ * @example
122
+ * insertAtPosition('AAABBB', 'C', 3) // -> AAACBBB
123
+ * insertAtPosition('000011122223445555', 99, 7) // -> 00001119922223445555
124
+ *
125
+ * @param {String|Number} value Valor original
126
+ * @param {String|Number} insertValue Valor que será inserido
127
+ * @param {String|Number} position Posição que receberá o novo valor
128
+ * @returns {String}
129
+ *
130
+ */
131
+ function insertAtPosition(value, insertValue, position) {
132
+ return `${value.substring(0, position)}${insertValue}${value.substring(position)}`;
133
+ }
134
+ /**
135
+ * removeFromPosition()
136
+ * Retira um conjunto de caracteres de um local específico de uma string
137
+ *
138
+ * @example
139
+ * removeFromPosition('00001119922223445555', 7,9) // -> 000011122223445555
140
+ * removeFromPosition('AAACBBB', 3,4) // -> AAABBB
141
+ *
142
+ * @param {String|Number} value Valor original
143
+ * @param {String|Number} startPosition
144
+ * @param {String|Number} endPosition
145
+ * @returns {String}
146
+ *
147
+ */
148
+ function removeFromPosition(value, startPosition, endPosition) {
149
+ return [value.slice(0, startPosition), value.slice(endPosition)].join('');
150
+ }
151
+ /**
152
+ * applyMask()
153
+ * Aplica uma máscara a uma string
154
+ *
155
+ * @example
156
+ * applyMask('59650000', '00.000-000') // -> 59.650-000
157
+ * applyMask('99877665544', '(00) 0 0000-0000') // -> (99) 8 7766-5544
158
+ *
159
+ * @param {String|Number} value Valor original
160
+ * @param {String} mask
161
+ * @returns {String}
162
+ *
163
+ */
164
+ function applyMask(value, mask) {
165
+ const maskLen = clearValue(mask).length;
166
+ let masked = clearValue(value, maskLen, { fillZerosAtLeft: true, trimAtRight: true });
167
+ const specialChars = ['/', '-', '.', '(', ')', ' '];
168
+ for (let position = 0; position < mask.length; position += 1) {
169
+ const current = mask[position];
170
+ if (specialChars.includes(current))
171
+ masked = insertAtPosition(masked, current, position);
172
+ }
173
+ return masked;
174
+ }
175
+ /**
176
+ * randomLetter()
177
+ * Pega uma letra maiúscula aleatoriamente
178
+ *
179
+ * @example
180
+ * randomLetter() // -> A
181
+ * randomLetter() // -> S
182
+ *
183
+ * @returns {String}
184
+ */
185
+ function randomLetter() {
186
+ const idx = Math.floor(1 + Math.random() * 26);
187
+ return String.fromCharCode(idx + 64);
188
+ }
191
189
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,iFAAwD;AAExD;;;;;;;GAOG;AACH,SAAgB,OAAO,CAAC,GAAW;IACjC,OAAO,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAA;AAC3C,CAAC;AAFD,0BAEC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;AACjE,CAAC;AAFD,oDAEC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,wBAAwB,CAAC,KAAa,EAAE,UAA6B;IACnF,IAAI,OAAO,UAAU,KAAK,QAAQ;QAAE,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3F,OAAO,UAAU,CAAC,MAAM,CACtB,CAAC,IAAY,EAAE,IAAS,EAAE,CAAS,EAAE,EAAE,CAAC,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAA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AAG,EAAE,GAAG,CAAC,CAAA;IAEnD,KAAK,IAAI,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,IAAI,CAAC,EAAE,CAAC;QAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC9B,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC1F,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,YAAY;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IAC9C,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,GAAG,EAAE,CAAC,CAAA;AACtC,CAAC"}
@@ -1,15 +1,14 @@
1
1
  module.exports = {
2
- root: true,
3
- extends: ['airbnb-base', 'prettier'],
4
- parser: '@typescript-eslint/parser',
5
- parserOptions: {
6
- ecmaVersion: 2018,
7
- sourceType: 'module',
8
- },
9
- env: {
10
- node: true,
11
- jest: true,
12
- },
2
+ // root: true,
3
+ // extends: ['airbnb-base', 'prettier'],
4
+ // parserOptions: {
5
+ // ecmaVersion: 2018,
6
+ // sourceType: 'module',
7
+ // },
8
+ // env: {
9
+ // node: true,
10
+ // jest: true,
11
+ // },
13
12
  settings: {
14
13
  'import/resolver': {
15
14
  node: {
@@ -18,19 +17,19 @@ module.exports = {
18
17
  },
19
18
  },
20
19
  rules: {
21
- '@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^_', args: 'none' }],
20
+ // '@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^_', args: 'none' }],
22
21
  'array-callback-return': 'off',
23
22
  'arrow-body-style': 'off',
24
23
  curly: ['error', 'multi-line', 'consistent'],
25
24
  'class-methods-use-this': 'off',
26
25
  'consistent-return': 'warn',
27
26
  'default-case': 'off',
28
- 'import/extensions': ['error', 'never'],
29
- 'import/first': 'warn',
30
- 'import/no-named-as-default': 'warn',
31
- 'import/no-named-as-default-member': 'warn',
32
- 'import/no-unresolved': 'warn',
33
- 'import/prefer-default-export': 'off',
27
+ // 'import/extensions': ['error', 'never'],
28
+ // 'import/first': 'warn',
29
+ // 'import/no-named-as-default': 'warn',
30
+ // 'import/no-named-as-default-member': 'warn',
31
+ // 'import/no-unresolved': 'warn',
32
+ // 'import/prefer-default-export': 'off',
34
33
  'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
35
34
  'max-classes-per-file': 'off',
36
35
  'max-len': ['error', 120, 2, { ignoreUrls: true, ignoreTemplateLiterals: true }],
@@ -43,7 +42,7 @@ module.exports = {
43
42
  'no-loop-func': 'off',
44
43
  'no-mixed-operators': 'off',
45
44
  'no-nested-ternary': 'off',
46
- 'no-only-tests/no-only-tests': 'error',
45
+ // 'no-only-tests/no-only-tests': 'error',
47
46
  'no-param-reassign': 'off',
48
47
  'no-plusplus': 'off',
49
48
  'no-prototype-builtins': 'off',
@@ -56,27 +55,28 @@ module.exports = {
56
55
  'no-unused-vars': 'off',
57
56
  'no-use-before-define': ['warn', { functions: false, classes: false }],
58
57
  'prefer-destructuring': 'off',
59
- semi: ['error', 'never'],
58
+ semi: ['error', 'always'],
60
59
  'sort-imports': 'off',
61
60
  'no-unused-expressions': 'off',
62
61
  quotes: ['error', 'single', { avoidEscape: true }],
63
- '@typescript-eslint/ban-types': 'error',
62
+ // '@typescript-eslint/ban-types': 'error',
64
63
  },
65
- overrides: [
66
- {
67
- files: ['*.ts'],
68
- rules: {
69
- 'no-dupe-class-members': 'off',
70
- 'no-undef': 'off',
71
- '@typescript-eslint/explicit-function-return-type': 'error',
72
- },
73
- },
74
- {
75
- files: ['*.d.ts'],
76
- rules: {
77
- 'no-useless-constructor': 'off', // crashes on constructor declaration in .d.ts files
78
- },
79
- },
80
- ],
81
- plugins: ['no-only-tests', '@typescript-eslint'],
82
- }
64
+ // overrides: [
65
+ // {
66
+ // files: ['*.ts'],
67
+ // rules: {
68
+ // 'no-dupe-class-members': 'off',
69
+ // 'no-undef': 'off',
70
+ // '@typescript-eslint/explicit-function-return-type': 'error',
71
+ // },
72
+ // },
73
+ // {
74
+ // files: ['*.d.ts'],
75
+ // rules: {
76
+ // 'no-useless-constructor': 'off', // crashes on constructor declaration in .d.ts files
77
+ // },
78
+ // },
79
+ // ],
80
+ // plugins: ['no-only-tests', '@typescript-eslint'],
81
+ ignores: ['dist/*', '/node_modules/**'],
82
+ };
package/jest.config.js CHANGED
@@ -1,12 +1,7 @@
1
1
  module.exports = {
2
- globals: {
3
- 'ts-jest': {
4
- tsconfig: 'tsconfig.json',
5
- },
6
- },
7
2
  moduleFileExtensions: ['ts', 'js'],
8
3
  transform: {
9
- '^.+\\.(ts|tsx)$': 'ts-jest',
4
+ '^.+\\.(ts|tsx)$': ['ts-jest', { /* ts-jest config goes here in Jest */ }],
10
5
  },
11
6
  testRegex: '(/src/.*\\.(test|spec))\\.(jsx?|tsx?)$',
12
7
  testEnvironment: 'node',
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "validation-br",
3
3
  "description": "Brazilian personal documents validation - cpf, cnpj, titulo, pis/pasep, cnh, renavam, processos judiciais, protocolo federal, código de rastreamento dos correios",
4
- "version": "1.4.4",
4
+ "version": "1.5.1",
5
5
  "main": "dist/index.js",
6
- "types": "./dist/types.d.ts",
6
+ "types": "./dist/index.d.ts",
7
7
  "author": "Cláudio Medeiros <klawdyo@gmail.com>",
8
8
  "license": "MIT",
9
9
  "scripts": {
@@ -11,15 +11,7 @@
11
11
  "test": "jest",
12
12
  "test:watch": "jest --watch",
13
13
  "test:coverage": "jest --collectCoverageFrom=src/**/*.ts --coverage",
14
- "lint:list": "eslint */**/*.js --fix",
15
- "format": "prettier --write \"./**/*.{js,ts,json}\"",
16
- "prepublish": "yarn build",
17
- "prepare": "husky install"
18
- },
19
- "husky": {
20
- "hooks": {
21
- "pre-commit": "tsc --noEmit && lint-staged"
22
- }
14
+ "format": "prettier --write \"./**/*.{js,ts,json}\""
23
15
  },
24
16
  "lint-staged": {
25
17
  "*.{js,ts}": [
@@ -30,23 +22,10 @@
30
22
  "devDependencies": {
31
23
  "@types/jest": "^27.4.0",
32
24
  "@types/node": "^14.14.2",
33
- "@typescript-eslint/eslint-plugin": "^4.0.0",
34
- "@typescript-eslint/parser": "^3.10.1",
35
- "eslint": "^7.11.0",
36
- "eslint-config-airbnb-base": "^14.2.0",
37
- "eslint-config-prettier": "^6.14.0",
38
- "eslint-import-resolver-node": "^0.3.4",
39
- "eslint-import-resolver-typescript": "^2.3.0",
40
- "eslint-plugin-import": "^2.22.1",
41
- "eslint-plugin-no-only-tests": "^2.4.0",
42
- "eslint-plugin-prettier": "^3.1.4",
43
- "husky": "^7.0.4",
44
- "jest": "^27.4.7",
45
- "lint-staged": "^10.4.2",
46
- "prettier": "^2.1.2",
47
- "ts-jest": "^27.1.2",
25
+ "jest": "^29.7.0",
26
+ "ts-jest": "^29.2.5",
48
27
  "ts-node": "^9.0.0",
49
- "typescript": "^4.0.3"
28
+ "typescript": "^5.6.2"
50
29
  },
51
30
  "repository": {
52
31
  "url": "https://github.com/klawdyo/validation-br"