@sideid/id-profanity-filter 1.12.0 → 1.13.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.
@@ -66,6 +66,24 @@ describe('Matcher Core', () => {
66
66
  expect(resultsWithGeneral).toContain('anjing');
67
67
  expect(resultsWithGeneral).not.toContain('jancok');
68
68
  });
69
+
70
+ test('should not trigger false positives on innocent words with substring matches by default', () => {
71
+ expect(findProfanity('saya mau masuk ke rumah')).toEqual([]);
72
+ expect(findProfanity('saya tidur di kasur')).toEqual([]);
73
+ expect(findProfanity('kunjungi website kami')).toEqual([]);
74
+ expect(findProfanity('barang ini asli')).toEqual([]);
75
+ expect(findProfanity('agama islam')).toEqual([]);
76
+ expect(findProfanity('saya sudah makan')).toEqual([]);
77
+ });
78
+
79
+ test('should detect custom wordList without built-in leakage', () => {
80
+ const results = findProfanity('film ini jelek dan payah anjing', {
81
+ wordList: ['jelek', 'payah'],
82
+ });
83
+ expect(results).toContain('jelek');
84
+ expect(results).toContain('payah');
85
+ expect(results).not.toContain('anjing');
86
+ });
69
87
  });
70
88
 
71
89
  describe('findProfanityWithMetadata function', () => {
@@ -49,6 +49,21 @@ describe('IDProfanityFilter', () => {
49
49
  expect(result.filtered).not.toContain('anjing');
50
50
  expect(result.filtered).not.toEqual('Dasar anjing kamu!');
51
51
  });
52
+
53
+ test('should reset options to default with resetOptions', () => {
54
+ filter.setOptions({ replaceWith: '#' });
55
+ expect(filter.filter('anjing').filtered).toBe('######');
56
+ filter.resetOptions();
57
+ expect(filter.filter('anjing').filtered).toBe('******');
58
+ });
59
+
60
+ test('should censor custom wordList correctly', () => {
61
+ filter.resetOptions();
62
+ filter.setWordList(['jelek', 'payah']);
63
+ const result = filter.filter('Film itu sangat jelek dan payah!');
64
+ expect(result.filtered).toBe('Film itu sangat ***** dan *****!');
65
+ expect(result.censored).toBe(2);
66
+ });
52
67
  });
53
68
 
54
69
  describe('preset functionality', () => {
package/.eslintrc.js DELETED
@@ -1,44 +0,0 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- parserOptions: {
4
- ecmaVersion: 2020,
5
- sourceType: 'module',
6
- project: './tsconfig.json',
7
- },
8
- extends: [
9
- 'eslint:recommended',
10
- 'plugin:@typescript-eslint/recommended',
11
- 'prettier', // Disables ESLint rules that might conflict with Prettier
12
- ],
13
- plugins: ['@typescript-eslint'],
14
- env: {
15
- node: true,
16
- jest: true,
17
- },
18
- rules: {
19
- // Enforce consistent code style
20
- '@typescript-eslint/explicit-function-return-type': 'off',
21
- '@typescript-eslint/no-explicit-any': 'warn',
22
- '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
23
-
24
- // Allow certain TypeScript patterns
25
- '@typescript-eslint/no-non-null-assertion': 'off',
26
-
27
- // General ESLint rules
28
- 'no-console': ['warn', { allow: ['warn', 'error'] }],
29
- 'prefer-const': 'warn',
30
- 'no-var': 'error',
31
-
32
- // Make sure imports are properly sorted
33
- 'sort-imports': [
34
- 'off',
35
- {
36
- ignoreCase: false,
37
- ignoreDeclarationSort: true,
38
- ignoreMemberSort: false,
39
- memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
40
- },
41
- ],
42
- },
43
- ignorePatterns: ['dist/', 'node_modules/', '*.js', '*.d.ts'],
44
- };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes