Skip to content

Commit 0c1da9a

Browse files
Rearranged the modules and split some modules into smaller parts
1 parent 103e1de commit 0c1da9a

File tree

17 files changed

+173
-128
lines changed

17 files changed

+173
-128
lines changed

Diff for: best-practices.js renamed to best-practices/bugs.js

+12-58
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,12 @@ module.exports = {
1717
// make sure for-in loops have an if statement
1818
"guard-for-in": "error",
1919

20-
// require a capital letter for constructors
21-
"new-cap": "error",
22-
23-
// disallow the omission of parentheses when invoking a constructor with no arguments
24-
"new-parens": "error",
25-
2620
// disallow use of the Array constructor
2721
"no-array-constructor": "error",
2822

2923
// disallow use of bitwise operators
3024
"no-bitwise": "error",
3125

32-
// disallow use of arguments.caller or arguments.callee
33-
"no-caller": "error",
34-
35-
// disallow the catch clause parameter name being the same as a variable in the outer scope
36-
"no-catch-shadow": "warn",
37-
3826
// disallow assignment in conditional expressions
3927
"no-cond-assign": "error",
4028

@@ -68,9 +56,6 @@ module.exports = {
6856
// disallow comparisons to null without a type-checking operator
6957
"no-eq-null": "error",
7058

71-
// disallow use of eval()
72-
"no-eval": "error",
73-
7459
// disallow adding to native types
7560
"no-extend-native": "error",
7661

@@ -92,9 +77,6 @@ module.exports = {
9277
// disallow overwriting functions written as function declarations
9378
"no-func-assign": "error",
9479

95-
// disallow use of eval()-like methods
96-
"no-implied-eval": "error",
97-
9880
// disallow function or variable declarations in nested blocks
9981
"no-inner-declarations": "error",
10082

@@ -107,18 +89,12 @@ module.exports = {
10789
// disallow labels that share a name with a variable
10890
"no-label-var": "error",
10991

110-
// disallow use of labeled statements
111-
"no-labels": "error",
112-
11392
// disallow unnecessary nested blocks
11493
"no-lone-blocks": "warn",
11594

11695
// disallow creation of functions within loops
11796
"no-loop-func": "warn",
11897

119-
// disallow use of multiline strings
120-
"no-multi-str": "error",
121-
12298
// disallow reassignments of native objects
12399
"no-native-reassign": "error",
124100

@@ -146,36 +122,33 @@ module.exports = {
146122
// disallow use of octal escape sequences in string literals, such as var foo = "Copyright \050";
147123
"no-octal-escape": "error",
148124

149-
// disallow usage of __proto__ property
150-
"no-proto": "error",
151-
152125
// disallow declaring the same variable more then once
153126
"no-redeclare": "error",
154127

155-
// disallow use of javascript: urls.
156-
"no-script-url": "error",
157-
158128
// disallow comparisons where both sides are exactly the same
159129
"no-self-compare": "error",
160130

161-
// disallow use of comma operator
162-
"no-sequences": "error",
163-
164131
// disallow declaration of variables already declared in the outer scope
165132
"no-shadow": "warn",
166133

167-
// disallow shadowing of names such as arguments
168-
"no-shadow-restricted-names": "error",
169-
170134
// disallow sparse arrays
171135
"no-sparse-arrays": "error",
172136

173-
// disallow throwing non-Error objects
174-
"no-throw-literal": "error",
175-
176137
// disallow use of undeclared variables unless mentioned in a /*global */ block
177138
"no-undef": "error",
178139

140+
// disallow unreachable statements after a return, throw, continue, or break statement
141+
"no-unreachable": "warn",
142+
143+
// disallow usage of expressions in statement position
144+
"no-unused-expressions": [
145+
"error",
146+
{
147+
allowShortCircuit: true, // allow short-circuited expressions (e.g. foo && bar())
148+
allowTernary: true, // allow ternary expressions (e.g. foo ? bar() : baz())
149+
},
150+
],
151+
179152
// disallow declaration of variables that are not used in the code
180153
"no-unused-vars": [
181154
"error",
@@ -185,22 +158,6 @@ module.exports = {
185158
},
186159
],
187160

188-
// disallow use of void operator
189-
"no-void": "error",
190-
191-
// disallow use of the with statement
192-
"no-with": "error",
193-
194-
// require assignment operator shorthand where possible
195-
"operator-assignment": "error",
196-
197-
// Require the "use strict" pragma, either at the global level or function level,
198-
// depending on whether CommonJS is being used or not
199-
strict: [
200-
"error",
201-
"safe",
202-
],
203-
204161
// disallow comparisons with the value NaN
205162
"use-isnan": "error",
206163

@@ -210,8 +167,5 @@ module.exports = {
210167
// require immediate function invocation to be wrapped in parentheses
211168
"wrap-iife": "error",
212169

213-
// disallow Yoda conditions
214-
yoda: "error",
215-
216170
}
217171
};

Diff for: best-practices/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
3+
const bugs = require("./bugs");
4+
const security = require("./security");
5+
6+
module.exports = {
7+
extends: [
8+
"modular/best-practices/bugs",
9+
"modular/best-practices/security",
10+
],
11+
};

Diff for: best-practices/security.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use strict";
2+
3+
module.exports = {
4+
rules: {
5+
// disallow use of eval()
6+
"no-eval": "error",
7+
8+
// disallow use of eval()-like methods
9+
"no-implied-eval": "error",
10+
11+
// disallow use of javascript: urls.
12+
"no-script-url": "error",
13+
14+
// Require the "use strict" pragma, either at the global level or function level,
15+
// depending on whether CommonJS is being used or not
16+
strict: [
17+
"error",
18+
"safe",
19+
],
20+
21+
}
22+
};

Diff for: browser.js renamed to browser/index.js

File renamed without changes.

Diff for: jsx.js renamed to browser/jsx.js

File renamed without changes.

Diff for: es5.js renamed to es5/index.js

File renamed without changes.

Diff for: es6.js renamed to es6/index.js

File renamed without changes.

Diff for: common-js.js renamed to modules/cjs.js

File renamed without changes.

Diff for: es6-modules.js renamed to modules/esm.js

File renamed without changes.

Diff for: node.js renamed to node/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22

33
module.exports = {
4-
extends: "modular/common-js",
4+
extends: "modular/modules/cjs",
55

66
env: {
77
node: true,

Diff for: package.json

+9-11
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,15 @@
3939
"license": "MIT",
4040
"main": "index.js",
4141
"files": [
42-
"best-practices.js",
43-
"browser.js",
44-
"common-js.js",
45-
"es5.js",
46-
"es6.js",
47-
"es6-modules.js",
48-
"index.js",
49-
"jsx.js",
50-
"node.js",
51-
"style.js",
52-
"test.js"
42+
"best-practices",
43+
"browser",
44+
"es5",
45+
"es6",
46+
"modules",
47+
"node",
48+
"style",
49+
"test/index.js",
50+
"index.js"
5351
],
5452
"scripts": {
5553
"lint": "eslint .",

Diff for: style/conventions.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"use strict";
2+
3+
module.exports = {
4+
rules: {
5+
// specify curly brace conventions for all control statements
6+
curly: "error",
7+
8+
// enforce use of function declarations
9+
"func-style": [
10+
"error",
11+
"declaration",
12+
],
13+
14+
// disallow throwing non-Error objects
15+
"no-throw-literal": "error",
16+
17+
// disallow quotes around object literal property names
18+
"quote-props": [
19+
"warn",
20+
"as-needed",
21+
],
22+
23+
// require single quotes for all strings
24+
quotes: [
25+
"error",
26+
"double",
27+
"avoid-escape",
28+
],
29+
30+
// require use of semicolons instead of ASI
31+
semi: "error",
32+
33+
}
34+
};

Diff for: style/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use strict";
2+
3+
const conventions = require("./conventions");
4+
const naming = require("./naming");
5+
const syntax = require("./syntax");
6+
const whitespace = require("./whitespace");
7+
8+
module.exports = {
9+
extends: [
10+
"modular/style/conventions",
11+
"modular/style/naming",
12+
"modular/style/syntax",
13+
"modular/style/whitespace",
14+
],
15+
};

Diff for: style/naming.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"use strict";
2+
3+
module.exports = {
4+
rules: {
5+
// require camel case names
6+
camelcase: "error",
7+
8+
// require a capital letter for constructors
9+
"new-cap": "error",
10+
11+
}
12+
};

Diff for: style/syntax.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"use strict";
2+
3+
module.exports = {
4+
rules: {
5+
// encourages use of dot notation whenever possible
6+
"dot-notation": "error",
7+
8+
// disallow the omission of parentheses when invoking a constructor with no arguments
9+
"new-parens": "error",
10+
11+
// disallow use of arguments.caller or arguments.callee
12+
"no-caller": "error",
13+
14+
// disallow use of labeled statements
15+
"no-labels": "error",
16+
17+
// disallow use of multiline strings
18+
"no-multi-str": "error",
19+
20+
// disallow usage of __proto__ property
21+
"no-proto": "error",
22+
23+
// disallow use of comma operator
24+
"no-sequences": "error",
25+
26+
// disallow shadowing of names such as arguments
27+
"no-shadow-restricted-names": "error",
28+
29+
// disallow use of undefined when initializing variables
30+
"no-undef-init": "error",
31+
32+
// disallow multi-line statements that could be confused for separte ASI statements
33+
"no-unexpected-multiline": "error",
34+
35+
// disallow the use of ternary operators when a simpler alternative exists
36+
"no-unneeded-ternary": "error",
37+
38+
// disallow unnecessary .call() and .apply()
39+
"no-useless-call": "error",
40+
41+
// disallow unnecessary concatenation of string literals
42+
"no-useless-concat": "error",
43+
44+
// disallow use of void operator
45+
"no-void": "error",
46+
47+
// disallow use of the with statement
48+
"no-with": "error",
49+
50+
// require assignment operator shorthand where possible
51+
"operator-assignment": "error",
52+
53+
// disallow Yoda conditions
54+
yoda: "error",
55+
56+
}
57+
};

0 commit comments

Comments
 (0)