Skip to content

Commit 22e9897

Browse files
committed
chore(eslint): add eslint and configuration)
1 parent 131101c commit 22e9897

22 files changed

+2032
-153
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
*.json

.eslintrc.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
extends: "standard",
3+
env: { es6: true },
4+
rules: {
5+
"indent": ["error", 2],
6+
"quotes": ["error", "double"],
7+
"semi": ["error", "always"],
8+
"eol-last": ["error", "never"],
9+
"no-multiple-empty-lines": ["error", { max: 1 }]
10+
}
11+
};

JavaScript_Advance/defaultValues.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const helpGST = (name, age) => {
2-
console.log(name,age);
3-
}
2+
console.log(name, age);
3+
};
44

55
helpGST(); // Output will be undefined undefined
66

7-
const helpGSTWithDefaultValues = (name, age=19) => {
8-
console.log(name,age);
9-
}
7+
const helpGSTWithDefaultValues = (name, age = 19) => {
8+
console.log(name, age);
9+
};
1010

1111
helpGSTWithDefaultValues("Swapnil"); // Output Swapnil 19
1212

13-
helpGSTWithDefaultValues("Vishal",23); // Output Vishal 23
13+
helpGSTWithDefaultValues("Vishal", 23); // Output Vishal 23

JavaScript_Advance/destructuring.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
// As data coming from the server is very big then there is better way of getting the data out of object
2-
let a = { // Suppose this is the object coming from server then
3-
name : "Swapnil",
4-
age : 19,
5-
college : "SIES"
6-
}
2+
const a = { // Suppose this is the object coming from server then
3+
name: "Swapnil",
4+
age: 19,
5+
college: "SIES"
6+
};
77

88
// By using Destructuring we can get the data of specific keys out into variables
99

10-
let { name, age, college } = a; // This way name variable gets "Swapnil" this is possible because the object also has same key
10+
const { name, age, college } = a; // This way name variable gets "Swapnil" this is possible because the object also has same key
1111

1212
console.log(name); // Output Swapnil
1313

14-
let {name:Myname} = a // This way Myname variable get assigned the value of name key in from object a
14+
const { name: Myname } = a; // This way Myname variable get assigned the value of name key in from object a
1515

1616
console.log(Myname); // Output Swapnil
1717

18-
array = [1, 2, 3, 4] // Array Declaration
18+
array = [1, 2, 3, 4]; // Array Declaration
1919

20-
let [ first, second, ,fourth ] = array // Array Destructuring
20+
const [first, second, , fourth] = array; // Array Destructuring
2121
// In this the Order of variables matters the most as arrays don't have keys
2222

2323
// For skipping some values we can do that using as shown here we have skiped the third value
2424
console.log(fourth); // Output 4
2525

26-
newArray = ["Swapnil", 19, "Shinde"] // New array
26+
newArray = ["Swapnil", 19, "Shinde"]; // New array
2727

28-
let [firstName , , lastName] = newArray; // Destructured the firstName and lastName
28+
const [firstName, , lastName] = newArray; // Destructured the firstName and lastName
2929

3030
console.log(`My name is ${firstName} ${lastName}`);// Output My name is Swapnil Shinde

JavaScript_Advance/eventloop.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ setTimeout(() => {
44

55
console.log("Last statment"); // This statement gets printed first
66

7-
// This enables the non blocking using event based management
7+
// This enables the non blocking using event based management

JavaScript_Advance/fsModule.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
// Fs is a inbuilt function in nodejs to perform operations on files
22

3-
4-
// There are always two ways to do fs operation as sync and async
3+
// There are always two ways to do fs operation as sync and async
54

65
// Fs library sends data event continuously in this case event emitter comes into picture
76

87
// For importing the fs module we have following syntax
9-
const fs = require('fs');
8+
const fs = require("fs");
109

11-
// Here we created a read stream will give output as a object into string
12-
const content = fs.createReadStream('./Order.txt');
10+
// Here we created a read stream will give output as a object into string
11+
const content = fs.createReadStream("./Order.txt");
1312

1413
/* If we don't use the encoding as utf8 then it will print data in the form of buffer only
1514
<Buffer 61 72 72 6f 77 46 75 6e 63 74 69 6f 6e 0a 64 65 73 74 72 75 63 74 75 72 69 6e 67 0a 73 70 72 65 61 64 20 61 6e 64 20 72 65 73 74 0a 74 69 6d 65 72 46 ... 35 more bytes>
1615
*/
17-
content.setEncoding('UTF8');// This encodes the data into our desired type
16+
content.setEncoding("UTF8");// This encodes the data into our desired type
1817

1918
// Here we are listing to the event of closing of a file
20-
content.on('open',() => {
19+
content.on("open", () => {
2120
console.log("File opened for reading");
2221
});
2322

2423
// Here we are listening to the event called data which will be called when data is present
25-
content.on('data', (data) => {
24+
content.on("data", (data) => {
2625
console.log(data);
2726
});
2827

2928
// Here we are listing to the event of closing of a file
30-
content.on('close',() => {
29+
content.on("close", () => {
3130
console.log("File ends");
3231
});
3332

34-
// Output is going to be
33+
// Output is going to be
3534
/*
3635
File opened for reading
3736
arrowFunction

JavaScript_Advance/promises.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// promises promise the nodejs main thread that i'm going to come after doing a particular task
22

3-
let a = new Promise ((resolve, reject) => { // This is a empty promise
3+
const a = new Promise((resolve, reject) => { // This is a empty promise
44
// resolve will only be called if there is data to return like resolve(data);
5-
// resolve will reject the promise and send the error back
5+
// resolve will reject the promise and send the error back
66
});
77

8-
let b = new Promise((resolve, reject) => {
8+
const b = new Promise((resolve, reject) => {
99
reject("Hii");
1010
});
1111

12-
b.then((value)=> {
12+
b.then((value) => {
1313
console.log(value);
1414
})
15-
.catch((value) => {
16-
console.log(value);
17-
});
15+
.catch((value) => {
16+
console.log(value);
17+
});

JavaScript_Advance/spread&rest.js

+21-22
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,51 @@
1-
let marks = [1,2,3,4,5,6,7,8,9]; // Array Declaration
1+
const marks = [1, 2, 3, 4, 5, 6, 7, 8, 9]; // Array Declaration
22

33
// If we want 1 to 3 as different variables and 4 to 9 as full array then in such cases we use "rest" operator
44

5-
let [first, second, third, ...remaining] = marks;
5+
const [first, second, third, ...remaining] = marks;
66

77
console.log(first, second, third); // Output 1 2 3
88

99
console.log(remaining); // Output [ 4, 5, 6, 7, 8, 9 ]
1010

11-
let a = {
12-
name : "Swapnil",
13-
branch : "Comps",
14-
age : 19,
15-
college : "SIES"
11+
const a = {
12+
name: "Swapnil",
13+
branch: "Comps",
14+
age: 19,
15+
college: "SIES"
1616
};
1717

18-
let {name ,age, ...unwanted} = a; // Here in unwanted all key and values expect the name and age will come this is different than arrays
18+
const { name, age, ...unwanted } = a; // Here in unwanted all key and values expect the name and age will come this is different than arrays
1919

2020
console.log(unwanted);// Output { branch: 'Comps', college: 'SIES' }
2121

22-
2322
// "spread" operator can also be used for merging the arrays
2423

25-
let array1 = [1,2,3,4,5,6];
24+
const array1 = [1, 2, 3, 4, 5, 6];
2625

27-
let array2 = [6,7,8,9,10];
26+
const array2 = [6, 7, 8, 9, 10];
2827

29-
let combinedArray = [...array1, ...array2]; // Here "..." are considered as spread operation we are spreading the two arrays into one
28+
const combinedArray = [...array1, ...array2]; // Here "..." are considered as spread operation we are spreading the two arrays into one
3029

31-
console.log(combinedArray);
32-
/* Output
30+
console.log(combinedArray);
31+
/* Output
3332
[
3433
1, 2, 3,
3534
4, 5, 6,
3635
6, 7, 8,
3736
9, 10
3837
] */
3938

40-
let obj1 = { // First Object
41-
name : "Swapnil",
42-
branch : "Comps"
39+
const obj1 = { // First Object
40+
name: "Swapnil",
41+
branch: "Comps"
4342
};
4443

45-
let obj2 = { // Second Object
46-
age : 19,
47-
college : "SIES",
48-
}
44+
const obj2 = { // Second Object
45+
age: 19,
46+
college: "SIES"
47+
};
4948

50-
let finalObj = {...obj1, ...obj2}; // Using Spread operator we are combining two objects into one
49+
const finalObj = { ...obj1, ...obj2 }; // Using Spread operator we are combining two objects into one
5150

5251
console.log(finalObj); // Output { name: 'Swapnil', branch: 'Comps', age: 19, college: 'SIES' }

JavaScript_Advance/timerFunctions.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
// setTimeout This runs a code after given time starting form calling this method in program.
44

5-
setTimeout( () => {
6-
console.log("SetTimeout is Called")
5+
setTimeout(() => {
6+
console.log("SetTimeout is Called");
77
}, 5000); // This will print SetTimeout is Called after 5sec after calling it
88

99
// For stopping this we can use ClearTimeout
1010

1111
// setInterval This runs a code after specific interval of time till we stop the timer.
1212

13-
starting = setInterval( () => {
14-
console.log("SetInterval is Called")
15-
}, 3000); // This will print setInterval is Called after every 3sec
13+
starting = setInterval(() => {
14+
console.log("SetInterval is Called");
15+
}, 3000); // This will print setInterval is Called after every 3sec
1616

1717
// We can stop the interval and timeout using clearTimeout and clearInterval
18-
setTimeout(()=>{
18+
setTimeout(() => {
1919
clearInterval(starting);
2020
}, 7000);
2121

22-
// Output of this whole program is
22+
// Output of this whole program is
2323
/*
2424
SetInterval is Called
2525
SetTimeout is Called

JavaScript_Basics/arrays.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Javascript arrays can take any values in the same array
22
// We don't have to specify the size
3-
let a = ['hii', 26 , "Swapnil"];
3+
const a = ["hii", 26, "Swapnil"];
44

5-
console.log(a);
5+
console.log(a);
66
// Output [ 'hii', 26, 'Swapnil' ]
77
console.log(a.length); // This will print the size of array
88
// Output 3
99

10-
let Student = []; // Created Empty array
10+
const Student = []; // Created Empty array
1111

1212
// Here we are pushing one by one element
13-
Student.push("Swapnil Satish Shinde"); // Pushed the Name
13+
Student.push("Swapnil Satish Shinde"); // Pushed the Name
1414

1515
Student.push(76); // Pushed rollno
1616

@@ -19,9 +19,9 @@ Student.push(true); // Pushed true
1919
console.log(Student); // Print Whole array
2020
// Output [ 'Swapnil Satish Shinde', 76, true ]
2121

22-
let easyMethod = []; // Created Empty array
22+
const easyMethod = []; // Created Empty array
2323

24-
easyMethod.push("Swapnil Satish Shinde", 76 , true); // This way you can push Multiple Values at once.
24+
easyMethod.push("Swapnil Satish Shinde", 76, true); // This way you can push Multiple Values at once.
2525

2626
console.log(easyMethod);
2727
// Output [ 'Swapnil Satish Shinde', 76, true ]

JavaScript_Basics/classes.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
class Student {
22
// onlyname; // This should not have let or const only in classes
3-
constructor (name, age){ // name and age are arguments given to object at the time of creation of object
3+
constructor (name, age) { // name and age are arguments given to object at the time of creation of object
44
this.name = name; // This initializes the local variable as name passed in argument
55
this.age = age; // This initializes the local variable as age passed in argument
66
}
77
}
88

9-
let Swapnil = new Student("Swapnil", 19); // This way we can create new objects with arguments
9+
const Swapnil = new Student("Swapnil", 19); // This way we can create new objects with arguments
1010

1111
console.log(Swapnil.name);// Output Swapnil
1212

1313
console.log(Swapnil.age);// Output 19
1414

1515
class StudentInfo {
1616
// college = "SIES"; // This is allowed above ES7, ES8
17-
constructor (name){ // name and age are arguments given to object at the time of creation of object
17+
constructor (name) { // name and age are arguments given to object at the time of creation of object
1818
this.name = name; // This initializes the local variable as name passed in argument
1919
this.college = "SIES"; // We want the College to be same for all students that's why it is declared outside of constructor
2020
}
21-
getNameAndCollege (){ // This is a methon in Stdent
21+
22+
getNameAndCollege () { // This is a methon in Stdent
2223
console.log(`${this.name} ${this.college}`);
2324
}
2425
}
2526

26-
let SwapnilInfo = new StudentInfo("Swapnil Bio");
27+
const SwapnilInfo = new StudentInfo("Swapnil Bio");
2728
SwapnilInfo.getNameAndCollege();
+12-12
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
class Student {
22
// Created the constructor for student
3-
constructor (firstName,lastName,age,college,bio){
4-
this.firstName = firstName;
5-
this.lastName = lastName;
3+
constructor (firstName, lastName, age, college, bio) {
4+
this.firstName = firstName;
5+
this.lastName = lastName;
66
this.age = age;
77
this.college = college;
88
this.bio = bio;
99
}
1010

1111
// This method returns combined firstname and lastname
12-
getFullName() {
13-
return(`${this.firstName} ${this.lastName}`);
12+
getFullName () {
13+
return (`${this.firstName} ${this.lastName}`);
1414
}
1515

1616
// This method returns bio
17-
getBio() {
18-
return(`${this.bio}`);
17+
getBio () {
18+
return (`${this.bio}`);
1919
}
2020

2121
// This method returns All details
22-
getAllDetails() {
23-
return(`My name is ${this.firstName} ${this.lastName} \nMy age is ${this.age} \nMy college is ${this.college}, I am ${this.bio}.`)
22+
getAllDetails () {
23+
return (`My name is ${this.firstName} ${this.lastName} \nMy age is ${this.age} \nMy college is ${this.college}, I am ${this.bio}.`);
2424
}
2525
}
2626

27-
let Swapnil = new Student('Swapnil','Shinde',19,"SIES","Web Developer"); // Created object with arguments
27+
const Swapnil = new Student("Swapnil", "Shinde", 19, "SIES", "Web Developer"); // Created object with arguments
2828

2929
console.log(Swapnil.getFullName()); // Output Swapnil Shinde
3030

3131
console.log(Swapnil.getBio()); // Output Web Developer
3232

3333
console.log(Swapnil.getAllDetails()); // Output My name is Swapnil Shinde. My age is 19. My college is SIES, I am Web Developer.
3434

35-
console.log(Swapnil); // This returns the object only
35+
console.log(Swapnil); // This returns the object only
3636
/*
3737
Output
3838
@@ -41,6 +41,6 @@ Student {
4141
lastName: 'Shinde',
4242
age: 19,
4343
college: 'SIES',
44-
bio: 'Web Developer'
44+
bio: 'Web Developer'
4545
}
4646
*/

0 commit comments

Comments
 (0)