mongodb-atlas-api-client 3.20.0 → 4.0.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.
@@ -1,9 +1,9 @@
1
- const {describe, it} = exports.lab = require("@hapi/lab").script();
2
- const {expect} = require("@hapi/code");
3
- const nock = require("nock");
4
- const getClient = require("../src");
1
+ const {describe, it, afterEach, before, beforeEach} = exports.lab = require("@hapi/lab").script();
2
+ const {expect} = require('@hapi/code');
3
+ const getClient = require('../src/index.js');
4
+ const {MockAgent, setGlobalDispatcher} = require('urllib');
5
5
 
6
- const baseUrl = "http://dummyBaseUrl";
6
+ const baseUrl = "http://localhost:7001";
7
7
  const projectId = "dummyProjectId";
8
8
 
9
9
  const client = getClient({
@@ -15,6 +15,21 @@ const client = getClient({
15
15
 
16
16
  describe("Mongo Atlas Api Client - Project Accesslist", () => {
17
17
 
18
+ let mockAgent;
19
+ let mockPool;
20
+ before(() => {
21
+ mockAgent = new MockAgent();
22
+ setGlobalDispatcher(mockAgent);
23
+ });
24
+
25
+ beforeEach(() => {
26
+ mockPool = mockAgent.get(baseUrl);
27
+ });
28
+
29
+ afterEach(() => {
30
+ mockAgent.assertNoPendingInterceptors();
31
+ });
32
+
18
33
  describe("When projectAccesslist is exported from index", () => {
19
34
  it("should export projectAccesslist functions", async () => {
20
35
  expect(client.projectAccesslist.get).to.be.function();
@@ -27,56 +42,68 @@ describe("Mongo Atlas Api Client - Project Accesslist", () => {
27
42
 
28
43
  describe("When get is called with querystring parameters", () => {
29
44
  it("should return response", async () => {
30
- const expectedRequest = nock(baseUrl)
31
- .get(`/groups/${projectId}/accessList/myAccesslistEntry?key1=value1&key2=value2`)
45
+ mockPool.intercept({
46
+ "path": `/groups/${projectId}/accessList/myAccesslistEntry?key1=value1&key2=value2`,
47
+ "method": "get"
48
+ })
32
49
  .reply(200, {"projectAccesslist": "name"});
33
50
  const result = await client.projectAccesslist.get("myAccesslistEntry", {"key1": "value1", "key2": "value2"});
34
51
  expect(result).to.equal({"projectAccesslist": "name"});
35
- expect(expectedRequest.isDone()).to.be.true();
52
+
36
53
  });
37
54
  });
38
55
 
39
56
  describe("When getAll is called with querystring parameters", () => {
40
57
  it("should return response", async () => {
41
- const expectedRequest = nock(baseUrl)
42
- .get(`/groups/${projectId}/accessList?key1=value1&key2=value2`)
58
+ mockPool.intercept({
59
+ "path": `/groups/${projectId}/accessList?key1=value1&key2=value2`,
60
+ "method": "get"
61
+ })
43
62
  .reply(200, [{"projectAccesslist": "name"}]);
44
63
  const result = await client.projectAccesslist.getAll({"key1": "value1", "key2": "value2"});
45
64
  expect(result).to.equal([{"projectAccesslist": "name"}]);
46
- expect(expectedRequest.isDone()).to.be.true();
65
+
47
66
  });
48
67
  });
49
68
 
50
69
  describe("When update is called with querystring parameters", () => {
51
70
  it("should return response", async () => {
52
- const expectedRequest = nock(baseUrl)
53
- .post(`/groups/${projectId}/accessList?key1=value1&key2=value2`)
71
+ mockPool.intercept({
72
+ "path": `/groups/${projectId}/accessList?key1=value1&key2=value2`,
73
+ "method": "POST",
74
+ "data": {"body": "value"}
75
+ })
54
76
  .reply(200, [{"projectAccesslist": "name"}]);
55
77
  const result = await client.projectAccesslist.update({"body": "value"}, {"key1": "value1", "key2": "value2"});
56
78
  expect(result).to.equal([{"projectAccesslist": "name"}]);
57
- expect(expectedRequest.isDone()).to.be.true();
79
+
58
80
  });
59
81
  });
60
82
 
61
83
  describe("When create is called with querystring parameters", () => {
62
84
  it("should return response", async () => {
63
- const expectedRequest = nock(baseUrl)
64
- .post(`/groups/${projectId}/accessList?key1=value1&key2=value2`)
85
+ mockPool.intercept({
86
+ "path": `/groups/${projectId}/accessList?key1=value1&key2=value2`,
87
+ "method": "POST",
88
+ "data": {"body": "value"}
89
+ })
65
90
  .reply(200, [{"projectAccesslist": "name"}]);
66
91
  const result = await client.projectAccesslist.create({"body": "value"}, {"key1": "value1", "key2": "value2"});
67
92
  expect(result).to.equal([{"projectAccesslist": "name"}]);
68
- expect(expectedRequest.isDone()).to.be.true();
93
+
69
94
  });
70
95
  });
71
96
 
72
97
  describe("When delete is called with querystring parameters", () => {
73
98
  it("should return response", async () => {
74
- const expectedRequest = nock(baseUrl)
75
- .delete(`/groups/${projectId}/accessList/myAccesslistEntry?key1=value1&key2=value2`)
99
+ mockPool.intercept({
100
+ "path": `/groups/${projectId}/accessList/myAccesslistEntry?key1=value1&key2=value2`,
101
+ "method": "DELETE"
102
+ })
76
103
  .reply(200, true);
77
104
  const result = await client.projectAccesslist.delete("myAccesslistEntry", {"key1": "value1", "key2": "value2"});
78
105
  expect(result).to.be.true();
79
- expect(expectedRequest.isDone()).to.be.true();
106
+
80
107
  });
81
108
  });
82
109
  });
@@ -1,9 +1,9 @@
1
- const {describe, it} = exports.lab = require("@hapi/lab").script();
2
- const {expect} = require("@hapi/code");
3
- const nock = require("nock");
4
- const getClient = require("../src");
1
+ const {describe, it, afterEach, before, beforeEach} = exports.lab = require("@hapi/lab").script();
2
+ const {expect} = require('@hapi/code');
3
+ const getClient = require('../src/index.js');
4
+ const {MockAgent, setGlobalDispatcher} = require('urllib');
5
5
 
6
- const baseUrl = "http://dummyBaseUrl";
6
+ const baseUrl = "http://localhost:7001";
7
7
  const projectId = "dummyProjectId";
8
8
 
9
9
  const client = getClient({
@@ -15,6 +15,21 @@ const client = getClient({
15
15
 
16
16
  describe("Mongo Atlas Api Client - Project Whitelist", () => {
17
17
 
18
+ let mockAgent;
19
+ let mockPool;
20
+ before(() => {
21
+ mockAgent = new MockAgent();
22
+ setGlobalDispatcher(mockAgent);
23
+ });
24
+
25
+ beforeEach(() => {
26
+ mockPool = mockAgent.get(baseUrl);
27
+ });
28
+
29
+ afterEach(() => {
30
+ mockAgent.assertNoPendingInterceptors();
31
+ });
32
+
18
33
  describe("When projectWhitelist is exported from index", () => {
19
34
  it("should export projectWhitelist functions", async () => {
20
35
  expect(client.projectWhitelist.get).to.be.function();
@@ -27,56 +42,68 @@ describe("Mongo Atlas Api Client - Project Whitelist", () => {
27
42
 
28
43
  describe("When get is called with querystring parameters", () => {
29
44
  it("should return response", async () => {
30
- const expectedRequest = nock(baseUrl)
31
- .get(`/groups/${projectId}/whitelist/myWhitelistEntry?key1=value1&key2=value2`)
45
+ mockPool.intercept({
46
+ "path": `/groups/${projectId}/whitelist/myWhitelistEntry?key1=value1&key2=value2`,
47
+ "method": "get"
48
+ })
32
49
  .reply(200, {"projectWhitelist": "name"});
33
50
  const result = await client.projectWhitelist.get("myWhitelistEntry", {"key1": "value1", "key2": "value2"});
34
51
  expect(result).to.equal({"projectWhitelist": "name"});
35
- expect(expectedRequest.isDone()).to.be.true();
52
+
36
53
  });
37
54
  });
38
55
 
39
56
  describe("When getAll is called with querystring parameters", () => {
40
57
  it("should return response", async () => {
41
- const expectedRequest = nock(baseUrl)
42
- .get(`/groups/${projectId}/whitelist?key1=value1&key2=value2`)
58
+ mockPool.intercept({
59
+ "path": `/groups/${projectId}/whitelist?key1=value1&key2=value2`,
60
+ "method": "get"
61
+ })
43
62
  .reply(200, [{"projectWhitelist": "name"}]);
44
63
  const result = await client.projectWhitelist.getAll({"key1": "value1", "key2": "value2"});
45
64
  expect(result).to.equal([{"projectWhitelist": "name"}]);
46
- expect(expectedRequest.isDone()).to.be.true();
65
+
47
66
  });
48
67
  });
49
68
 
50
69
  describe("When update is called with querystring parameters", () => {
51
70
  it("should return response", async () => {
52
- const expectedRequest = nock(baseUrl)
53
- .post(`/groups/${projectId}/whitelist?key1=value1&key2=value2`)
71
+ mockPool.intercept({
72
+ "path": `/groups/${projectId}/whitelist?key1=value1&key2=value2`,
73
+ "method": "POST",
74
+ "data": {"body": "value"}
75
+ })
54
76
  .reply(200, [{"projectWhitelist": "name"}]);
55
77
  const result = await client.projectWhitelist.update({"body": "value"}, {"key1": "value1", "key2": "value2"});
56
78
  expect(result).to.equal([{"projectWhitelist": "name"}]);
57
- expect(expectedRequest.isDone()).to.be.true();
79
+
58
80
  });
59
81
  });
60
82
 
61
83
  describe("When create is called with querystring parameters", () => {
62
84
  it("should return response", async () => {
63
- const expectedRequest = nock(baseUrl)
64
- .post(`/groups/${projectId}/whitelist?key1=value1&key2=value2`)
85
+ mockPool.intercept({
86
+ "path": `/groups/${projectId}/whitelist?key1=value1&key2=value2`,
87
+ "method": "POST",
88
+ "data": {"body": "value"}
89
+ })
65
90
  .reply(200, [{"projectWhitelist": "name"}]);
66
91
  const result = await client.projectWhitelist.create({"body": "value"}, {"key1": "value1", "key2": "value2"});
67
92
  expect(result).to.equal([{"projectWhitelist": "name"}]);
68
- expect(expectedRequest.isDone()).to.be.true();
93
+
69
94
  });
70
95
  });
71
96
 
72
97
  describe("When delete is called with querystring parameters", () => {
73
98
  it("should return response", async () => {
74
- const expectedRequest = nock(baseUrl)
75
- .delete(`/groups/${projectId}/whitelist/myWhitelistEntry?key1=value1&key2=value2`)
99
+ mockPool.intercept({
100
+ "path": `/groups/${projectId}/whitelist/myWhitelistEntry?key1=value1&key2=value2`,
101
+ "method": "delete"
102
+ })
76
103
  .reply(200, true);
77
104
  const result = await client.projectWhitelist.delete("myWhitelistEntry", {"key1": "value1", "key2": "value2"});
78
105
  expect(result).to.be.true();
79
- expect(expectedRequest.isDone()).to.be.true();
106
+
80
107
  });
81
108
  });
82
109
  });
package/test/user.test.js CHANGED
@@ -1,9 +1,9 @@
1
- const {describe, it} = exports.lab = require("@hapi/lab").script();
2
- const {expect} = require("@hapi/code");
3
- const nock = require("nock");
4
- const getClient = require("../src");
1
+ const {describe, it, afterEach, before, beforeEach} = exports.lab = require("@hapi/lab").script();
2
+ const {expect} = require('@hapi/code');
3
+ const getClient = require('../src/index.js');
4
+ const {MockAgent, setGlobalDispatcher} = require('urllib');
5
5
 
6
- const baseUrl = "http://dummyBaseUrl";
6
+ const baseUrl = "http://localhost:7001";
7
7
  const projectId = "dummyProjectId";
8
8
 
9
9
  const client = getClient({
@@ -15,6 +15,21 @@ const client = getClient({
15
15
 
16
16
  describe("Mongo Atlas Api Client - User", () => {
17
17
 
18
+ let mockAgent;
19
+ let mockPool;
20
+ before(() => {
21
+ mockAgent = new MockAgent();
22
+ setGlobalDispatcher(mockAgent);
23
+ });
24
+
25
+ beforeEach(() => {
26
+ mockPool = mockAgent.get(baseUrl);
27
+ });
28
+
29
+ afterEach(() => {
30
+ mockAgent.assertNoPendingInterceptors();
31
+ });
32
+
18
33
  describe("When user is exported from index", () => {
19
34
  it("should export user functions", async () => {
20
35
  expect(client.user.get).to.be.function();
@@ -27,56 +42,68 @@ describe("Mongo Atlas Api Client - User", () => {
27
42
 
28
43
  describe("When get is called with querystring parameters", () => {
29
44
  it("should return response", async () => {
30
- const expectedRequest = nock(baseUrl)
31
- .get(`/groups/${projectId}/databaseUsers/admin/myUsername?key1=value1&key2=value2`)
45
+ mockPool.intercept({
46
+ "path": `/groups/${projectId}/databaseUsers/admin/myUsername?key1=value1&key2=value2`,
47
+ "method": "get"
48
+ })
32
49
  .reply(200, {"projectWhitelist": "name"});
33
50
  const result = await client.user.get("myUsername", {"key1": "value1", "key2": "value2"});
34
51
  expect(result).to.equal({"projectWhitelist": "name"});
35
- expect(expectedRequest.isDone()).to.be.true();
52
+
36
53
  });
37
54
  });
38
55
 
39
56
  describe("When getAll is called with querystring parameters", () => {
40
57
  it("should return response", async () => {
41
- const expectedRequest = nock(baseUrl)
42
- .get(`/groups/${projectId}/databaseUsers?key1=value1&key2=value2`)
58
+ mockPool.intercept({
59
+ "path": `/groups/${projectId}/databaseUsers?key1=value1&key2=value2`,
60
+ "method": "get"
61
+ })
43
62
  .reply(200, [{"projectWhitelist": "name"}]);
44
63
  const result = await client.user.getAll({"key1": "value1", "key2": "value2"});
45
64
  expect(result).to.equal([{"projectWhitelist": "name"}]);
46
- expect(expectedRequest.isDone()).to.be.true();
65
+
47
66
  });
48
67
  });
49
68
 
50
69
  describe("When update is called with querystring parameters", () => {
51
70
  it("should return response", async () => {
52
- const expectedRequest = nock(baseUrl)
53
- .patch(`/groups/${projectId}/databaseUsers/admin/myUsername?key1=value1&key2=value2`)
71
+ mockPool.intercept({
72
+ "path": `/groups/${projectId}/databaseUsers/admin/myUsername?key1=value1&key2=value2`,
73
+ "method": "PATCH",
74
+ "data": {"body": "value"}
75
+ })
54
76
  .reply(200, [{"projectWhitelist": "name"}]);
55
77
  const result = await client.user.update("myUsername", {"body": "value"}, {"key1": "value1", "key2": "value2"});
56
78
  expect(result).to.equal([{"projectWhitelist": "name"}]);
57
- expect(expectedRequest.isDone()).to.be.true();
79
+
58
80
  });
59
81
  });
60
82
 
61
83
  describe("When create is called with querystring parameters", () => {
62
84
  it("should return response", async () => {
63
- const expectedRequest = nock(baseUrl)
64
- .post(`/groups/${projectId}/databaseUsers?key1=value1&key2=value2`)
85
+ mockPool.intercept({
86
+ "path": `/groups/${projectId}/databaseUsers?key1=value1&key2=value2`,
87
+ "method": "POST",
88
+ "data": {"body": "value"}
89
+ })
65
90
  .reply(200, [{"projectWhitelist": "name"}]);
66
91
  const result = await client.user.create({"body": "value"}, {"key1": "value1", "key2": "value2"});
67
92
  expect(result).to.equal([{"projectWhitelist": "name"}]);
68
- expect(expectedRequest.isDone()).to.be.true();
93
+
69
94
  });
70
95
  });
71
96
 
72
97
  describe("When delete is called with querystring parameters", () => {
73
98
  it("should return response", async () => {
74
- const expectedRequest = nock(baseUrl)
75
- .delete(`/groups/${projectId}/databaseUsers/admin/myUsername?key1=value1&key2=value2`)
99
+ mockPool.intercept({
100
+ "path": `/groups/${projectId}/databaseUsers/admin/myUsername?key1=value1&key2=value2`,
101
+ "method": "DELETE"
102
+ })
76
103
  .reply(200, true);
77
104
  const result = await client.user.delete("myUsername", {"key1": "value1", "key2": "value2"});
78
105
  expect(result).to.be.true();
79
- expect(expectedRequest.isDone()).to.be.true();
106
+
80
107
  });
81
108
  });
82
109
  });
package/.eslintrc DELETED
@@ -1,254 +0,0 @@
1
- {
2
- "env": {
3
- "node": true,
4
- "es6": true
5
- },
6
- "parserOptions": {
7
- "ecmaVersion": 2018,
8
- "sourceType": "module"
9
- },
10
- "rules": {
11
- // Possible Errors
12
- // The following rules point out areas where you might have made mistakes.
13
-
14
- "comma-dangle": [2, "never"], // - disallow or enforce trailing commas (recommended)
15
- "getter-return": 2, // - enforces that a return statement is present in property getters
16
- "no-async-promise-executor": 2, // - disallow using an async function as a Promise executor
17
- "no-await-in-loop": 2, // - disallow await inside of loops
18
- "no-compare-neg-zero": 2, // - disallow checking for equality against negative zero
19
- "no-cond-assign": 2, // - disallow assignment in conditional expressions (recommended)
20
- "no-console": 2, // - disallow use of console in the node environment (recommended)
21
- "no-constant-condition": 2, // - disallow use of constant expressions in conditions (recommended)
22
- "no-control-regex": 2, // - disallow control characters in regular expressions (recommended)
23
- "no-debugger": 2, // - disallow use of debugger (recommended)
24
- "no-dupe-args": 2, // - disallow duplicate arguments in functions (recommended)
25
- "no-dupe-keys": 2, // - disallow duplicate keys when creating object literals (recommended)
26
- "no-duplicate-case": 2, // - disallow a duplicate case label. (recommended)
27
- "no-empty-character-class": 2, // - disallow the use of empty character classes in regular expressions (recommended)
28
- "no-empty": 2, // - disallow empty statements (recommended)
29
- "no-ex-assign": 2, // - disallow assigning to the exception in a catch block (recommended)
30
- "no-extra-boolean-cast": 2, // - disallow double-negation boolean casts in a boolean context (recommended)
31
- "no-extra-parens": 0, // - disallow unnecessary parentheses
32
- "no-extra-semi": 2, // - disallow unnecessary semicolons (recommended)
33
- "no-func-assign": 2, // - disallow overwriting functions written as function declarations (recommended)
34
- "no-inner-declarations": [2, "functions"], // - disallow function or variable declarations in nested blocks (recommended)
35
- "no-invalid-regexp": 2, // - disallow invalid regular expression strings in the RegExp constructor (recommended)
36
- "no-irregular-whitespace": 2, // - disallow irregular whitespace outside of strings and comments (recommended)
37
- "no-negated-in-lhs": 2, // - disallow negation of the left operand of an in expression (recommended)
38
- "no-obj-calls": 2, // - disallow the use of object properties of the global object (Math and JSON) as functions (recommended)
39
- "no-regex-spaces": 2, // - disallow multiple spaces in a regular expression literal (recommended)
40
- "no-sparse-arrays": 0, // - disallow sparse arrays (recommended) Note: set to false because array destructuring in ES6
41
- "no-unreachable": 2, // - disallow unreachable statements after a return, throw, continue, or break statement (recommended)
42
- "use-isnan": 2, // - disallow comparisons with the value NaN (recommended)
43
- "valid-jsdoc": 2, // - Ensure JSDoc comments are valid
44
- "valid-typeof": 2, // - Ensure that the results of typeof are compared against a valid string (recommended)
45
- "no-unexpected-multiline": 2, // - Avoid code that looks like two expressions but is actually one
46
-
47
- // Best Practices
48
- // These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns.
49
-
50
- "accessor-pairs": 2, // - Enforces getter/setter pairs in objects
51
- "block-scoped-var": 0, // - treat var statements as if they were block scoped
52
- "complexity": [1, 9], // - specify the maximum cyclomatic complexity allowed in a program
53
- "consistent-return": 1, // - require return statements to either always or never specify values
54
- "curly": [2, "all"], // - specify curly brace conventions for all control statements
55
- "default-case": 0, // - require default case in switch statements
56
- "dot-notation": 2, // - encourages use of dot notation whenever possible
57
- "dot-location": [2, "property"], // - enforces consistent newlines before or after dots
58
- "eqeqeq": 2, // - require the use of === and !==
59
- "guard-for-in": 2, // - make sure for-in loops have an if statement
60
- "no-alert": 2, // - disallow the use of alert, confirm, and prompt
61
- "no-caller": 2, // - disallow use of arguments.caller or arguments.callee
62
- "no-div-regex": 2, // - disallow division operators explicitly at beginning of regular expression
63
- "no-else-return": 2, // - disallow else after a return in an if
64
- "no-eq-null": 2, // - disallow comparisons to null without a type-checking operator
65
- "no-eval": 2, // - disallow use of eval()
66
- "no-extend-native": 2, // - disallow adding to native types
67
- "no-extra-bind": 2, // - disallow unnecessary function binding
68
- "no-fallthrough": 2, // - disallow fallthrough of case statements (recommended)
69
- "no-floating-decimal": 2, // - disallow the use of leading or trailing decimal points in numeric literals
70
- "no-implicit-coercion": 2, // - disallow the type conversions with shorter notations
71
- "no-implied-eval": 2, // - disallow use of eval()-like methods
72
- "no-invalid-this": 2, // - disallow this keywords outside of classes or class-like objects
73
- "no-iterator": 2, // - disallow usage of __iterator__ property
74
- "no-labels": 2, // - disallow use of labeled statements
75
- "no-lone-blocks": 2, // - disallow unnecessary nested blocks
76
- "no-loop-func": 2, // - disallow creation of functions within loops
77
- "no-multi-spaces": [
78
- 2,
79
- {
80
- "ignoreEOLComments": true
81
- }
82
- ], // - disallow use of multiple spaces
83
- "no-multi-str": 2, // - disallow use of multiline strings
84
- "no-native-reassign": 2, // - disallow reassignments of native objects
85
- "no-new-func": 2, // - disallow use of new operator for Function object
86
- "no-new-wrappers": 2, // - disallows creating new instances of String,Number, and Boolean
87
- "no-new": 2, // - disallow use of the new operator when not part of an assignment or comparison
88
- "no-octal-escape": 2, // - disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
89
- "no-octal": 2, // - disallow use of octal literals (recommended)
90
- "no-param-reassign": 2, // - disallow reassignment of function parameters
91
- "no-process-env": 2, // - disallow use of process.env
92
- "no-proto": 2, // - disallow usage of __proto__ property
93
- "no-redeclare": 2, // - disallow declaring the same variable more than once (recommended)
94
- "no-return-assign": 2, // - disallow use of assignment in return statement
95
- "no-return-await": 2, // - disallows unnecessary return await
96
- "no-script-url": 2, // - disallow use of javascript: urls.
97
- "no-self-assign": 2, // - disallow Self Assignment
98
- "no-self-compare": 2, // - disallow comparisons where both sides are exactly the same
99
- "no-sequences": 2, // - disallow use of the comma operator
100
- "no-throw-literal": 2, // - restrict what can be thrown as an exception
101
- "no-unused-expressions": 0, // - disallow usage of expressions in statement position
102
- "no-useless-call": 2, // - disallow unnecessary .call() and .apply()
103
- "no-void": 2, // - disallow use of the void operator
104
- "no-warning-comments": 0, // - disallow usage of configurable warning terms in comments - e.g. TODO or FIXME
105
- "no-with": 2, // - disallow use of the with statement
106
- "radix": 2, // - require use of the second argument for parseInt()
107
- "vars-on-top": 2, // - require declaration of all vars at the top of their containing scope
108
- "wrap-iife": 2, // - require immediate function invocation to be wrapped in parentheses
109
- "yoda": 2, // - require or disallow Yoda conditions
110
-
111
- // Strict Mode
112
- // These rules relate to using strict mode.
113
-
114
- "strict": [2, "global"], // - controls location of Use Strict Directives
115
-
116
- // Variables
117
- // These rules have to do with variable declarations.
118
-
119
- "init-declarations": 0, // - enforce or disallow variable initializations at definition
120
- "no-catch-shadow": 2, // - disallow the catch clause parameter name being the same as a variable in the outer scope
121
- "no-delete-var": 2, // - disallow deletion of variables (recommended)
122
- "no-label-var": 2, // - disallow labels that share a name with a variable
123
- "no-shadow-restricted-names": 2, // - disallow shadowing of names such as arguments
124
- "no-shadow": 2, // - disallow declaration of variables already declared in the outer scope
125
- "no-undef-init": 2, // - disallow use of undefined when initializing variables
126
- "no-undef": 2, // - disallow use of undeclared variables unless mentioned in a /*global */ block (recommended)
127
- "no-undefined": 0, // - disallow use of undefined variable
128
- "no-unused-vars": 2, // - disallow declaration of variables that are not used in the code (recommended)
129
- "no-use-before-define": 2, // - disallow use of variables before they are defined
130
-
131
- // Node.js
132
- // These rules are specific to JavaScript running on Node.js.
133
-
134
- "callback-return": 2, // - enforce return after a callback
135
- "global-require": 2, // - enforce require() on the top-level module scope
136
- "handle-callback-err": 2, // - enforce error handling in callbacks
137
- "no-mixed-requires": 2, // - disallow mixing regular variable and require declarations
138
- "no-new-require": 2, // - disallow use of new operator with the require function
139
- "no-path-concat": 2, // - disallow string concatenation with __dirname and __filename
140
- "no-process-exit": 2, // - disallow process.exit()
141
- "no-restricted-modules": 2, // - restrict usage of specified node modules
142
- "no-sync": 2, // - disallow use of synchronous methods
143
- "no-buffer-constructor": 2, // - disallow use of the deprecated Buffer() constructor
144
-
145
- // Stylistic Issues
146
- // These rules are purely matters of style and are quite subjective.
147
-
148
- "array-bracket-spacing": 2, // - enforce spacing inside array brackets
149
- "brace-style": 2, // - enforce one true brace style
150
- "camelcase": 2, // - require camel case names
151
- "comma-spacing": 2, // - enforce spacing before and after comma
152
- "comma-style": 2, // - enforce one true comma style
153
- "computed-property-spacing": 2, // - require or disallow padding inside computed properties
154
- "consistent-this": 2, // - enforce consistent naming when capturing the current execution context
155
- "eol-last": 2, // - enforce newline at the end of file, with no multiple empty lines
156
- "func-names": 0, // - require function expressions to have a name
157
- "func-style": [2, "declaration"], // - enforce use of function declarations or expressions
158
- "id-length": [2,
159
- {
160
- "min": 2,
161
- "max": 70,
162
- "exceptions": ["i", "j", "k", "n", "Q", "_"]
163
- }
164
- ], // - this option enforces minimum and maximum identifier lengths (variable names, property names etc.) (off by default)
165
- "id-match": 0, // - require identifiers to match the provided regular expression
166
- "indent": [2, 2, // - specify tab or space width for your code
167
- {
168
- "SwitchCase": 1
169
- }
170
- ],
171
- "key-spacing": 2, // - enforce spacing between keys and values in object literal properties
172
- "lines-around-comment": [2,
173
- {
174
- "beforeBlockComment": true,
175
- "afterBlockComment": false,
176
- "beforeLineComment": false,
177
- "afterLineComment": false,
178
- "allowBlockStart": true,
179
- "allowBlockEnd": true
180
- }
181
- ], // - enforce empty lines around comments
182
- "linebreak-style": 2, // - disallow mixed 'LF' and 'CRLF' as linebreaks
183
- "max-nested-callbacks": [2, 6], // - specify the maximum depth callbacks can be nested
184
- "max-statements-per-line": [
185
- 2,
186
- {
187
- "max": 1
188
- }
189
- ], // - enforce a maximum number of statements per line
190
- "new-cap": 0, // - require a capital letter for constructors
191
- "new-parens": 2, // - disallow the omission of parentheses when invoking a constructor with no arguments
192
- "newline-after-var": 0, // - require or disallow an empty newline after variable declarations
193
- "no-array-constructor": 2, // - disallow use of the Array constructor
194
- "no-continue": 2, // - disallow use of the continue statement
195
- "no-inline-comments": 0, // - disallow comments inline after code
196
- "no-lonely-if": 2, // - disallow if as the only statement in an else block
197
- "no-mixed-spaces-and-tabs": 2, // - disallow mixed spaces and tabs for indentation (recommended)
198
- "no-multiple-empty-lines": [
199
- 2,
200
- {
201
- "max": 2,
202
- "maxEOF": 1,
203
- "maxBOF": 0
204
- }
205
- ], // - disallow multiple empty lines
206
- "no-nested-ternary": 2, // - disallow nested ternary expressions
207
- "no-new-object": 2, // - disallow the use of the Object constructor
208
- "no-spaced-func": 2, // - disallow space between function identifier and application
209
- "no-ternary": 0, // - disallow the use of ternary operators
210
- "no-trailing-spaces": 2, // - disallow trailing whitespace at the end of lines
211
- "no-underscore-dangle": 0, // - disallow dangling underscores in identifiers
212
- "no-unneeded-ternary": 2, // - disallow the use of Boolean literals in conditional expressions
213
- "object-curly-spacing": 2, // - require or disallow padding inside curly braces
214
- "one-var": [1, "never"], // - require or disallow one variable declaration per function
215
- "operator-assignment": [2, "always"], // - require assignment operator shorthand where possible or prohibit it entirely
216
- "operator-linebreak": 2, // - enforce operators to be placed before or after line breaks
217
- "padded-blocks": 0, // - enforce padding within blocks
218
- "quote-props": 2, // - require quotes around object literal property names
219
- "quotes": [2, "double"], // - specify whether backticks, double or single quotes should be used
220
- "semi-spacing": 2, // - enforce spacing before and after semicolons
221
- "semi": 2, // - require or disallow use of semicolons instead of ASI
222
- "sort-vars": 0, // - sort variables within the same declaration block
223
- "keyword-spacing": 2, // - require a space after certain keywords
224
- "space-before-blocks": 2, // - require or disallow a space before blocks
225
- "space-before-function-paren": [2,
226
- {
227
- "anonymous": "always",
228
- "named": "never"
229
- }
230
- ], // - require or disallow a space before function opening parenthesis
231
- "space-in-parens": 2, // - require or disallow spaces inside parentheses
232
- "space-infix-ops": 2, // - require spaces around operators
233
- "space-unary-ops": 2, // - require or disallow spaces before/after unary operators
234
- "spaced-comment": 2, // - require or disallow a space immediately following the // or /* in a comment
235
- "wrap-regex": 2, // - require regex literals to be wrapped in parentheses
236
-
237
- // ECMAScript 6
238
- // These rules are only relevant to ES6 environments.
239
-
240
- "arrow-parens": [2, "as-needed"], // - require parens in arrow function arguments
241
- "arrow-spacing": 2, // - require space before/after arrow function's arrow
242
- "constructor-super": 2, // - verify calls of super() in constructors
243
- "generator-star-spacing": 2, // - enforce spacing around the * in generator functions
244
- "no-class-assign": 2, // - disallow modifying variables of class declarations
245
- "no-const-assign": 2, // - disallow modifying variables that are declared using const
246
- "no-this-before-super": 2, // - disallow use of this/super before calling super() in constructors.
247
- "no-var": 2, // - require let or const instead of var
248
- "object-shorthand": [2, "methods"], // - require method and property shorthand syntax for object literals
249
- "prefer-const": 2, // - suggest using const declaration for variables that are never modified after declared
250
- "prefer-spread": 2, // - suggest using the spread operator instead of .apply().
251
- "require-yield": 2, // - disallow generator functions that do not have yield
252
- "prefer-template": 2
253
- }
254
- }