@sideid/id-profanity-filter 1.9.6 → 1.10.2
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/.eslintrc.js +44 -16
- package/.github/workflows/release.yml +62 -0
- package/CONTRIBUTING.md +150 -150
- package/LICENSE +21 -21
- package/README.md +548 -506
- package/dist/config/options.d.ts +24 -0
- package/dist/constants/categories/blasphemy.d.ts +4 -0
- package/dist/constants/categories/disgusting.d.ts +4 -0
- package/dist/constants/categories/drugs.d.ts +4 -0
- package/dist/constants/categories/profanity.d.ts +4 -0
- package/dist/constants/categories/slur.d.ts +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +923 -94
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +924 -93
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/utils/ahoCorasick.d.ts +36 -0
- package/dist/utils/similarityUtils.d.ts +35 -0
- package/eslint.config.mjs +40 -0
- package/examples/advanced.ts +120 -120
- package/examples/basic.ts +71 -71
- package/examples/custom-list.ts +140 -140
- package/jest.config.mjs +10 -10
- package/package.json +3 -2
- package/prettierrc +6 -6
- package/rollup.config.mjs +35 -35
- package/src/config/options.ts +2 -0
- package/src/constants/categories/blasphemy.ts +25 -0
- package/src/constants/categories/disgusting.ts +82 -0
- package/src/constants/categories/drugs.ts +72 -0
- package/src/constants/categories/profanity.ts +139 -0
- package/src/constants/categories/slur.ts +102 -0
- package/src/constants/regions/general.ts +111 -2
- package/src/constants/regions/jawa.ts +257 -3
- package/src/constants/wordList.ts +15 -8
- package/src/core/analyzer.ts +28 -13
- package/src/core/filter.ts +178 -37
- package/src/core/matcher.ts +146 -69
- package/src/index.ts +21 -2
- package/src/types/index.ts +4 -2
- package/src/utils/ahoCorasick.ts +179 -0
- package/src/utils/regexUtils.ts +0 -1
- package/src/utils/similarityUtils.ts +239 -7
- package/tsconfig.json +115 -115
- package/.github/workflows/ci.yml +0 -0
- package/dist/constants/categories/index.d.ts +0 -9
- package/dist/constants/regions/index.d.ts +0 -8
- package/src/constants/categories/index.ts +0 -31
- package/src/constants/regions/index.ts +0 -62
|
@@ -91,6 +91,48 @@ export function findMostSimilar(
|
|
|
91
91
|
return mostSimilar;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Mencari string yang paling mirip dari array menggunakan Levenshtein distance
|
|
96
|
+
*
|
|
97
|
+
* @param target String target
|
|
98
|
+
* @param candidates Array string kandidat
|
|
99
|
+
* @param threshold Minimum kesamaan yang diterima (0-1)
|
|
100
|
+
* @param maxDistance Jarak Levenshtein maksimal yang diterima (default: 3)
|
|
101
|
+
* @returns String yang paling mirip atau null jika tidak ada yang di atas threshold
|
|
102
|
+
*/
|
|
103
|
+
export function findMostSimilarWithLevenshtein(
|
|
104
|
+
target: string,
|
|
105
|
+
candidates: string[],
|
|
106
|
+
threshold: number = 0.7,
|
|
107
|
+
maxDistance: number = 3,
|
|
108
|
+
): string | null {
|
|
109
|
+
if (!candidates.length) return null;
|
|
110
|
+
|
|
111
|
+
let maxSimilarity = 0;
|
|
112
|
+
let minDistance = Infinity;
|
|
113
|
+
let mostSimilar: string | null = null;
|
|
114
|
+
|
|
115
|
+
for (const candidate of candidates) {
|
|
116
|
+
if (Math.abs(target.length - candidate.length) > maxDistance) continue;
|
|
117
|
+
|
|
118
|
+
const distance = levenshteinDistance(target, candidate);
|
|
119
|
+
const similarity = stringSimilarity(target, candidate);
|
|
120
|
+
|
|
121
|
+
if (
|
|
122
|
+
(similarity > maxSimilarity && similarity >= threshold) ||
|
|
123
|
+
(similarity >= threshold && distance < minDistance)
|
|
124
|
+
) {
|
|
125
|
+
maxSimilarity = similarity;
|
|
126
|
+
minDistance = distance;
|
|
127
|
+
mostSimilar = candidate;
|
|
128
|
+
|
|
129
|
+
if (distance <= 1 || similarity > 0.95) break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return mostSimilar;
|
|
134
|
+
}
|
|
135
|
+
|
|
94
136
|
/**
|
|
95
137
|
* Cek apakah string mungkin merupakan variasi dari kata kotor
|
|
96
138
|
* menggunakan kesamaan string
|
|
@@ -156,12 +198,22 @@ export function clusterSimilarWords(
|
|
|
156
198
|
|
|
157
199
|
/**
|
|
158
200
|
* Cari kata-kata kotor yang mungkin dari teks menggunakan kesamaan string
|
|
201
|
+
* dengan optimasi untuk mengurangi kompleksitas
|
|
159
202
|
*
|
|
160
203
|
* @param text Teks yang akan diperiksa
|
|
161
204
|
* @param profanityWords Daftar kata kotor
|
|
162
205
|
* @param threshold Batas minimum kesamaan (default: 0.8)
|
|
163
206
|
* @returns Array kata yang mungkin merupakan kata kotor
|
|
164
207
|
*/
|
|
208
|
+
/**
|
|
209
|
+
* Cari kata-kata kotor yang mungkin dari teks berdasarkan kemiripan string
|
|
210
|
+
* dengan optimasi biar prosesnya nggak terlalu berat
|
|
211
|
+
*
|
|
212
|
+
* @param text Teks yang mau dicek
|
|
213
|
+
* @param profanityWords Daftar kata-kata kotor/kasar
|
|
214
|
+
* @param threshold Batas minimal kemiripan (default: 0.8)
|
|
215
|
+
* @returns Array kata yang kemungkinan kata kotor/kasar
|
|
216
|
+
*/
|
|
165
217
|
export function findPossibleProfanityBySimiliarity(
|
|
166
218
|
text: string,
|
|
167
219
|
profanityWords: string[],
|
|
@@ -170,26 +222,206 @@ export function findPossibleProfanityBySimiliarity(
|
|
|
170
222
|
const result: Array<{ word: string; original: string; similarity: number }> =
|
|
171
223
|
[];
|
|
172
224
|
|
|
173
|
-
//
|
|
225
|
+
// Optimasi dengan bikin map kata-kata kotor berdasarkan huruf pertama
|
|
226
|
+
const profanityMap = new Map<string, string[]>();
|
|
227
|
+
|
|
228
|
+
// Kelompokkan kata-kata kotor berdasarkan huruf pertama biar pencariannya lebih cepat
|
|
229
|
+
for (const word of profanityWords) {
|
|
230
|
+
if (word.length < 1) continue;
|
|
231
|
+
|
|
232
|
+
const firstChar = word[0].toLowerCase();
|
|
233
|
+
if (!profanityMap.has(firstChar)) {
|
|
234
|
+
profanityMap.set(firstChar, []);
|
|
235
|
+
}
|
|
236
|
+
profanityMap.get(firstChar)!.push(word);
|
|
237
|
+
}
|
|
238
|
+
|
|
174
239
|
const words = text.toLowerCase().split(/\s+/);
|
|
175
240
|
|
|
176
241
|
for (const word of words) {
|
|
177
|
-
// Lewati kata-kata yang terlalu pendek
|
|
178
242
|
if (word.length < 3) continue;
|
|
179
243
|
|
|
180
|
-
|
|
244
|
+
// Cuma bandingin dengan kata-kata kotor yang huruf pertamanya sama
|
|
245
|
+
// atau yang perbedaan panjangnya masih masuk akal
|
|
246
|
+
const firstChar = word[0];
|
|
247
|
+
const candidateWords = profanityMap.get(firstChar) || [];
|
|
248
|
+
|
|
249
|
+
// Cek juga huruf-huruf yang berdekatan (buat antisipasi typo di huruf pertama)
|
|
250
|
+
// Ini opsional tapi bikin deteksinya lebih bagus
|
|
251
|
+
const charCode = firstChar.charCodeAt(0);
|
|
252
|
+
const prevChar = String.fromCharCode(charCode - 1);
|
|
253
|
+
const nextChar = String.fromCharCode(charCode + 1);
|
|
254
|
+
|
|
255
|
+
const adjacentCandidates = [
|
|
256
|
+
...(profanityMap.get(prevChar) || []),
|
|
257
|
+
...(profanityMap.get(nextChar) || []),
|
|
258
|
+
];
|
|
259
|
+
|
|
260
|
+
// Gabungin kandidat-kandidatnya, prioritasin yang huruf pertamanya sama persis
|
|
261
|
+
const allCandidates = [...candidateWords, ...adjacentCandidates];
|
|
262
|
+
|
|
263
|
+
// Filter kandidat berdasarkan perbedaan panjang sebelum ngitung kemiripannya
|
|
264
|
+
const lengthFilteredCandidates = allCandidates.filter(
|
|
265
|
+
(candidate) => Math.abs(candidate.length - word.length) <= 2,
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
// Cari yang paling cocok
|
|
269
|
+
let bestMatch: {
|
|
270
|
+
word: string;
|
|
271
|
+
original: string;
|
|
272
|
+
similarity: number;
|
|
273
|
+
} | null = null;
|
|
274
|
+
|
|
275
|
+
for (const profanity of lengthFilteredCandidates) {
|
|
181
276
|
const similarity = stringSimilarity(word, profanity);
|
|
182
277
|
|
|
183
|
-
if (
|
|
184
|
-
|
|
278
|
+
if (
|
|
279
|
+
similarity >= threshold &&
|
|
280
|
+
(!bestMatch || similarity > bestMatch.similarity)
|
|
281
|
+
) {
|
|
282
|
+
bestMatch = {
|
|
185
283
|
word,
|
|
186
284
|
original: profanity,
|
|
187
285
|
similarity,
|
|
188
|
-
}
|
|
189
|
-
break;
|
|
286
|
+
};
|
|
190
287
|
}
|
|
191
288
|
}
|
|
289
|
+
|
|
290
|
+
if (bestMatch) {
|
|
291
|
+
result.push(bestMatch);
|
|
292
|
+
}
|
|
192
293
|
}
|
|
193
294
|
|
|
194
295
|
return result;
|
|
195
296
|
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Cari kata-kata kotor yang mungkin dari teks menggunakan Levenshtein distance
|
|
300
|
+
*
|
|
301
|
+
* @param text Teks yang akan diperiksa
|
|
302
|
+
* @param profanityWords Daftar kata kotor
|
|
303
|
+
* @param threshold Batas minimum kesamaan (default: 0.8)
|
|
304
|
+
* @param maxDistance Jarak Levenshtein maksimal (default: 2)
|
|
305
|
+
* @returns Array kata yang mungkin merupakan kata kotor
|
|
306
|
+
*/
|
|
307
|
+
export function findProfanityByLevenshteinDistance(
|
|
308
|
+
text: string,
|
|
309
|
+
profanityWords: string[],
|
|
310
|
+
threshold: number = 0.8,
|
|
311
|
+
maxDistance: number = 2,
|
|
312
|
+
): Array<{
|
|
313
|
+
word: string;
|
|
314
|
+
original: string;
|
|
315
|
+
similarity: number;
|
|
316
|
+
distance: number;
|
|
317
|
+
}> {
|
|
318
|
+
const result: Array<{
|
|
319
|
+
word: string;
|
|
320
|
+
original: string;
|
|
321
|
+
similarity: number;
|
|
322
|
+
distance: number;
|
|
323
|
+
}> = [];
|
|
324
|
+
|
|
325
|
+
// map kata-kata kotor dikelompokkan sesuai panjangnya
|
|
326
|
+
const profanityByLength = new Map<number, string[]>();
|
|
327
|
+
|
|
328
|
+
// Kelompokkin kata-kata kotor berdasarkan panjangnya biar pencarian lebih cepat
|
|
329
|
+
for (const word of profanityWords) {
|
|
330
|
+
const length = word.length;
|
|
331
|
+
if (!profanityByLength.has(length)) {
|
|
332
|
+
profanityByLength.set(length, []);
|
|
333
|
+
}
|
|
334
|
+
profanityByLength.get(length)!.push(word);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const words = text.toLowerCase().split(/\s+/);
|
|
338
|
+
|
|
339
|
+
for (const word of words) {
|
|
340
|
+
if (word.length < 3) continue;
|
|
341
|
+
|
|
342
|
+
let bestMatch: {
|
|
343
|
+
word: string;
|
|
344
|
+
original: string;
|
|
345
|
+
similarity: number;
|
|
346
|
+
distance: number;
|
|
347
|
+
} | null = null;
|
|
348
|
+
|
|
349
|
+
for (
|
|
350
|
+
let len = Math.max(3, word.length - maxDistance);
|
|
351
|
+
len <= word.length + maxDistance;
|
|
352
|
+
len++
|
|
353
|
+
) {
|
|
354
|
+
const candidates = profanityByLength.get(len) || [];
|
|
355
|
+
|
|
356
|
+
for (const profanity of candidates) {
|
|
357
|
+
if (!isCharacterCountSimilar(word, profanity, maxDistance)) {
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const distance = levenshteinDistance(word, profanity);
|
|
362
|
+
|
|
363
|
+
if (distance <= maxDistance) {
|
|
364
|
+
const similarity =
|
|
365
|
+
1 - distance / Math.max(word.length, profanity.length);
|
|
366
|
+
|
|
367
|
+
if (
|
|
368
|
+
similarity >= threshold &&
|
|
369
|
+
(!bestMatch || similarity > bestMatch.similarity)
|
|
370
|
+
) {
|
|
371
|
+
bestMatch = {
|
|
372
|
+
word,
|
|
373
|
+
original: profanity,
|
|
374
|
+
similarity,
|
|
375
|
+
distance,
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
if (distance === 0 || similarity > 0.95) {
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (bestMatch) {
|
|
387
|
+
result.push(bestMatch);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Helper function to efficiently check if character counts between two strings
|
|
396
|
+
* are similar enough to warrant a full Levenshtein calculation
|
|
397
|
+
*/
|
|
398
|
+
function isCharacterCountSimilar(
|
|
399
|
+
str1: string,
|
|
400
|
+
str2: string,
|
|
401
|
+
maxDifference: number,
|
|
402
|
+
): boolean {
|
|
403
|
+
const charCount1: Record<string, number> = {};
|
|
404
|
+
const charCount2: Record<string, number> = {};
|
|
405
|
+
|
|
406
|
+
for (const char of str1) {
|
|
407
|
+
charCount1[char] = (charCount1[char] || 0) + 1;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
for (const char of str2) {
|
|
411
|
+
charCount2[char] = (charCount2[char] || 0) + 1;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
let diffCount = 0;
|
|
415
|
+
|
|
416
|
+
for (const char in charCount1) {
|
|
417
|
+
diffCount += Math.abs((charCount1[char] || 0) - (charCount2[char] || 0));
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
for (const char in charCount2) {
|
|
421
|
+
if (!charCount1[char]) {
|
|
422
|
+
diffCount += charCount2[char];
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return diffCount <= maxDifference * 2;
|
|
427
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Projects */
|
|
6
|
-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
-
|
|
13
|
-
/* Language and Environment */
|
|
14
|
-
"target": "es2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
-
// "libReplacement": true, /* Enable lib replacement. */
|
|
18
|
-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
19
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
20
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
21
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
22
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
23
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
24
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
25
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
26
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
27
|
-
|
|
28
|
-
/* Modules */
|
|
29
|
-
"module": "ESNext" /* Specify what module code is generated. */,
|
|
30
|
-
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
31
|
-
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
|
32
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
33
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
34
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
35
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
36
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
37
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
38
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
39
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
40
|
-
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
|
|
41
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
42
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
43
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
44
|
-
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
|
45
|
-
"resolveJsonModule": true /* Enable importing .json files. */,
|
|
46
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
47
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
48
|
-
|
|
49
|
-
/* JavaScript Support */
|
|
50
|
-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
51
|
-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
52
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
53
|
-
|
|
54
|
-
/* Emit */
|
|
55
|
-
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
56
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
57
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
58
|
-
"sourceMap": true /* Create source map files for emitted JavaScript files. */,
|
|
59
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
60
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
62
|
-
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
|
63
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
64
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
65
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
66
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
67
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
68
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
69
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
70
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
71
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
72
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
73
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
74
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
75
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
76
|
-
|
|
77
|
-
/* Interop Constraints */
|
|
78
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
79
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
80
|
-
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
|
81
|
-
// "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
|
|
82
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
83
|
-
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
84
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
85
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
86
|
-
|
|
87
|
-
/* Type Checking */
|
|
88
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
89
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
90
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
91
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
92
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
93
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
94
|
-
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
|
95
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
96
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
97
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
98
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
99
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
100
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
101
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
102
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
103
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
104
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
105
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
106
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
107
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
108
|
-
|
|
109
|
-
/* Completeness */
|
|
110
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
111
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
112
|
-
},
|
|
113
|
-
"include": ["./src/**/*"],
|
|
114
|
-
"exclude": ["node_modules", "dist", "test"]
|
|
115
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
+
// "libReplacement": true, /* Enable lib replacement. */
|
|
18
|
+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
19
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
20
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
21
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
22
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
23
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
24
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
25
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
26
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
27
|
+
|
|
28
|
+
/* Modules */
|
|
29
|
+
"module": "ESNext" /* Specify what module code is generated. */,
|
|
30
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
31
|
+
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
|
32
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
33
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
34
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
35
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
36
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
37
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
38
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
39
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
40
|
+
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
|
|
41
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
42
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
43
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
44
|
+
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
|
45
|
+
"resolveJsonModule": true /* Enable importing .json files. */,
|
|
46
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
47
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
48
|
+
|
|
49
|
+
/* JavaScript Support */
|
|
50
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
51
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
52
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
53
|
+
|
|
54
|
+
/* Emit */
|
|
55
|
+
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
56
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
57
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
58
|
+
"sourceMap": true /* Create source map files for emitted JavaScript files. */,
|
|
59
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
60
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
62
|
+
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
|
63
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
64
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
65
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
66
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
67
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
68
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
69
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
70
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
71
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
72
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
73
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
74
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
75
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
76
|
+
|
|
77
|
+
/* Interop Constraints */
|
|
78
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
79
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
80
|
+
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
|
81
|
+
// "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
|
|
82
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
83
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
84
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
85
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
86
|
+
|
|
87
|
+
/* Type Checking */
|
|
88
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
89
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
90
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
91
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
92
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
93
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
94
|
+
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
|
95
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
96
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
97
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
98
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
99
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
100
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
101
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
102
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
103
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
104
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
105
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
106
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
107
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
108
|
+
|
|
109
|
+
/* Completeness */
|
|
110
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
111
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
112
|
+
},
|
|
113
|
+
"include": ["./src/**/*"],
|
|
114
|
+
"exclude": ["node_modules", "dist", "test"]
|
|
115
|
+
}
|
package/.github/workflows/ci.yml
DELETED
|
File without changes
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { sexual } from './sexual';
|
|
2
|
-
import { insult } from './insult';
|
|
3
|
-
export declare const categories: {
|
|
4
|
-
sexual: import("../..").ProfanityWord[];
|
|
5
|
-
insult: import("../..").ProfanityWord[];
|
|
6
|
-
};
|
|
7
|
-
export { sexual, insult };
|
|
8
|
-
export declare const allCategoryWords: import("../..").ProfanityWord[];
|
|
9
|
-
export default allCategoryWords;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { general } from './general';
|
|
2
|
-
import { jawa } from './jawa';
|
|
3
|
-
import { sunda } from './sunda';
|
|
4
|
-
import { betawi } from './betawi';
|
|
5
|
-
import { batak } from './batak';
|
|
6
|
-
export { general, jawa, sunda, betawi, batak, };
|
|
7
|
-
export declare const allRegionWords: import("../..").ProfanityWord[];
|
|
8
|
-
export default allRegionWords;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { sexual } from './sexual';
|
|
2
|
-
import { insult } from './insult';
|
|
3
|
-
// import { profanity } from './profanity';
|
|
4
|
-
// import { slur } from './slur';
|
|
5
|
-
// import { drugs } from './drugs';
|
|
6
|
-
// import { disgusting } from './disgusting';
|
|
7
|
-
// import { blasphemy } from './blasphemy';
|
|
8
|
-
|
|
9
|
-
export const categories = {
|
|
10
|
-
sexual, // Kata-kata berbau seksual
|
|
11
|
-
insult, // Kata-kata penghinaan
|
|
12
|
-
// profanity, // Umpatan umum
|
|
13
|
-
// slur, // Perkataan merendahkan berdasarkan identitas
|
|
14
|
-
// drugs, // Terkait narkoba
|
|
15
|
-
// disgusting, // Kata-kata menjijikkan
|
|
16
|
-
// blasphemy, // Penistaan agama
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { sexual, insult };
|
|
20
|
-
|
|
21
|
-
export const allCategoryWords = [
|
|
22
|
-
...sexual,
|
|
23
|
-
...insult,
|
|
24
|
-
// ...profanity,
|
|
25
|
-
// ...slur,
|
|
26
|
-
// ...drugs,
|
|
27
|
-
// ...disgusting,
|
|
28
|
-
// ...blasphemy,
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
export default allCategoryWords;
|