Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 62 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { RuleTester } from 'eslint'; |
||
2 | import { rules } from '../entry'; |
||
3 | |||
4 | const rule = rules['no-swear']; |
||
5 | const ruleTester = new RuleTester({ |
||
6 | 'parserOptions' : { |
||
7 | 'ecmaVersion' : 2017 |
||
8 | } |
||
9 | }); |
||
10 | |||
11 | suite('Rule no-swear'); |
||
12 | |||
13 | test('Swear in function name [FunctionDeclaration] [Identifier]', function () { |
||
14 | ruleTester.run('no-swear', rule, { |
||
15 | valid : [ ` |
||
16 | function factorial(n) { |
||
17 | // do some stuff |
||
18 | return n + 1; |
||
19 | } |
||
20 | ` ], |
||
21 | invalid : [ |
||
22 | { |
||
23 | code : ` |
||
24 | function fuck(n) { |
||
25 | // do some stuff |
||
26 | return n + 1; |
||
27 | } |
||
28 | `, |
||
29 | errors : [ { message: 'Identifier fuck is considered as swear word [fuck]' } ] |
||
30 | } |
||
31 | ] |
||
32 | }); |
||
33 | }); |
||
34 | |||
35 | test('Swear in variable name [VariableDeclaration] [Identifier]', function () { |
||
36 | ruleTester.run('no-swear', rule, { |
||
37 | valid : [ |
||
38 | 'const n = 5;', |
||
39 | 'const password = "jkdslfj";' |
||
40 | ], |
||
41 | invalid : [ |
||
42 | { |
||
43 | code : 'let asshole = 0', |
||
44 | errors : [ { message: 'Identifier asshole is considered as swear word [ass]' } ] |
||
45 | } |
||
46 | ] |
||
47 | }); |
||
48 | }); |
||
49 | |||
50 | test('Swear in variable value [VariableDeclaration] [Literal]', function () { |
||
51 | ruleTester.run('no-swear', rule, { |
||
52 | valid : [ |
||
53 | 'let n = "top good";' |
||
54 | ], |
||
55 | invalid : [ |
||
56 | { |
||
57 | code : 'let x = "yellowShowered"', |
||
58 | errors : [ { message: 'Literal yellowShowered is considered as swear word [yellow_shower]' } ] |
||
59 | } |
||
60 | ] |
||
61 | }); |
||
62 | }); |
||
63 | |||
64 |