-
Notifications
You must be signed in to change notification settings - Fork 0
/
not-recommendeds.js
145 lines (117 loc) · 2.89 KB
/
not-recommendeds.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
JavaScript Coding Standard Example Project
- There exist rules for the list in "Kentkart Mobile Javascript Coding Standards Document"
- This file is created to show possible incorrect coding practices.
- Date Created: Aug 4, 2022
- Last Edited: Aug 5, 2020 (9:28 AM)
Usage:
For the selected rule;
- Remove the eslint disable command
- Remove the eslint enable command
- Run "eslint not-recommendeds.js"
Rules:
- Please leave 2 newlines after each example.
- Please wrap your examples in scopes. Avoid creating global variables.
- Please edit the file with understandable format. Try to keep it simple.
- No example with more than 10 rows should be accepted.
*/
/*
2.2: use lower camel case for function naming:
*/
/* eslint-disable */
function say_Hello(){ }
/* eslint-enable */
/*
2.2: use lower camel case for function naming:
*/
/* exceptionally accepted - still not recommended */
function SayHello(){ }
/*
2.3: There should be no space between function name and the function parameters
and also no space between parameters and curl-brackets.
*/
/* eslint-disable */
function sayHello() {
console.log("hello");
}
/* eslint-enable */
/*
2.4: Put spacing on long parameter pass and bundle primitives into objects.
*/
function respond(recipient, userMessage, userId, userName){ }
/*
3.1: Put spacing on long parameter pass and bundle primitives into objects.
*/
/* eslint-disable */
{
const q = 10;
let status = (q >= 5)
? "x"
: "y";
}
/* eslint-enable */
/*
3.2: There should be a spacing before and after of each operator.
*/
/* eslint-disable */
{
const isOk = "yes";
let count = 1;
if(isOk === "no"&&count === 1){
console.log('fail case');
}
}
/* eslint-enable */
/*
3.3: Use strict equality or inequality.
*/
/* eslint-disable */
{
let name = "Fatih";
if(name == "Fatih"){
console.log("You are the chosen one");
}
}
/* eslint-enable */
/*
5.1: Don't handle errors in try-catch blocks or create if-else statements in the following format.
*/
/* eslint-disable */
try{
console.log("meow");
}catch(error){
console.log(error);
}
/* eslint-enable */
/*
5.1: Don't handle errors in try-catch blocks or create if-else statements in the following format.
*/
/* eslint-disable */
try{
console.log("meow");
} catch(error){
console.log(error);
}
/* eslint-enable */
/*
6.1: Use literals on initializing arrays. Do not use constructors on initializing arrays.
*/
{
/* exceptionally accepted - still not recommended */
let productList = new Array(10);
/* eslint-disable */
let favoritesList = new Array(
0,
1,
2
);
/* eslint-enable */
}
/*
6.2: Use literals on initializing objects. Do not use constructors on initializing objects.
*/
{
/* eslint-disable */
let product = new Object();
/* eslint-enable */
}