Skip to content

Commit 9fee73b

Browse files
committed
add support for eslint (closes #1)
1 parent 1659ae1 commit 9fee73b

File tree

5 files changed

+1214
-9
lines changed

5 files changed

+1214
-9
lines changed

.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "airbnb-base",
3+
"rules": {
4+
"no-extend-native": 0
5+
}
6+
}

.gitignore

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

forEach.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/**
1+
/**
22
*
3-
forEach() calls a provided callback function once for each element in an array in ascending order.
4-
It is not invoked for index properties that have been deleted or are uninitialized
3+
forEach() calls a provided callback function once for each element in an array in ascending order.
4+
It is not invoked for index properties that have been deleted or are uninitialized
55
(i.e. on sparse arrays, see example below).
66
77
Callback is invoked with three arguments:
@@ -11,14 +11,14 @@
1111
- the Array object being traversed
1212
1313
** Imp
14-
There is no way to stop or break a forEach() loop other than by throwing an exception. If you need such behavior, the forEach() method is the wrong tool.
15-
16-
*
14+
There is no way to stop or break a forEach() loop other than by throwing an exception.
15+
If you need such behavior, the forEach() method is the wrong tool.
16+
*
1717
*/
1818

19-
Array.prototype.myEach = function(callback) {
20-
for (var i = 0; i < this.length; i++) {
21-
if (this.hasOwnProperty(i)) {
19+
Array.prototype.myEach = function myEach(callback) {
20+
for (let i = 0; i < this.length; i += 1) {
21+
if (Object.hasOwnProperty.call(this, i)) {
2222
callback(this[i], i, this);
2323
}
2424
}

package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "native-javascript",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"repository": "[email protected]:kaxus/native-javascript.git",
6+
"license": "MIT",
7+
"devDependencies": {
8+
"eslint": "^6.1.0",
9+
"eslint-config-airbnb-base": "^14.0.0",
10+
"eslint-plugin-import": "^2.18.2"
11+
}
12+
}

0 commit comments

Comments
 (0)