forked from restify/node-restify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
149 lines (137 loc) · 5.16 KB
/
.eslintrc.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
146
147
148
149
'use strict';
var OFF = 0;
var ERROR = 2;
var config = {
extends: [],
plugins: ['jsdoc'],
env: {
browser: false,
node: true,
es6: true
},
parserOptions: {
ecmaVersion: 2018
},
rules: {}
};
if (!process.env.NO_LINT) {
// possible errors
config.rules['no-cond-assign'] = ERROR;
config.rules['no-console'] = OFF;
config.rules['no-constant-condition'] = ERROR;
config.rules['no-control-regex'] = ERROR;
config.rules['no-debugger'] = ERROR;
config.rules['no-dupe-args'] = ERROR;
config.rules['no-dupe-keys'] = ERROR;
config.rules['no-duplicate-case'] = ERROR;
config.rules['no-empty'] = ERROR;
config.rules['no-empty-character-class'] = ERROR;
config.rules['no-ex-assign'] = ERROR;
config.rules['no-extra-boolean-cast'] = ERROR;
config.rules['no-extra-semi'] = ERROR;
config.rules['no-func-assign'] = ERROR;
// config.rules['one-var'] = [ERROR, 'always']; // TODO: var overlapping
// this is for variable hoisting, not necessary if we use block scoped declarations
// config.rules['no-inner-declarations'] = [ ERROR, 'both' ];
config.rules['no-invalid-regexp'] = ERROR;
config.rules['no-irregular-whitespace'] = ERROR;
config.rules['no-negated-in-lhs'] = ERROR;
config.rules['no-reserved-keys'] = OFF;
config.rules['no-regex-spaces'] = ERROR;
config.rules['no-sparse-arrays'] = ERROR;
config.rules['no-unreachable'] = ERROR;
config.rules['use-isnan'] = ERROR;
config.rules['valid-jsdoc'] = [
ERROR,
{
requireReturnDescription: false,
prefer: {
return: 'returns'
}
}
];
config.rules['valid-typeof'] = ERROR;
// best practices
config.rules['func-names'] = ERROR;
config.rules['block-scoped-var'] = ERROR;
config.rules['consistent-return'] = ERROR;
config.rules['curly'] = OFF;
config.rules['default-case'] = ERROR;
config.rules['dot-notation'] = [ERROR, { allowKeywords: true }];
config.rules['eqeqeq'] = ERROR;
config.rules['guard-for-in'] = ERROR;
config.rules['no-alert'] = ERROR;
config.rules['no-caller'] = ERROR;
config.rules['no-div-regex'] = ERROR;
config.rules['no-eq-null'] = ERROR;
config.rules['no-eval'] = ERROR;
config.rules['no-extend-native'] = ERROR;
config.rules['no-extra-bind'] = ERROR;
config.rules['no-fallthrough'] = ERROR;
config.rules['no-floating-decimal'] = ERROR;
config.rules['no-implied-eval'] = ERROR;
config.rules['no-iterator'] = ERROR;
config.rules['no-labels'] = ERROR;
config.rules['no-lone-blocks'] = ERROR;
config.rules['no-loop-func'] = OFF;
config.rules['no-multi-spaces'] = OFF;
config.rules['no-multi-str'] = OFF;
config.rules['no-native-reassign'] = ERROR;
config.rules['no-new'] = OFF;
config.rules['no-new-func'] = ERROR;
config.rules['no-new-wrappers'] = ERROR;
config.rules['no-octal'] = ERROR;
config.rules['no-octal-escape'] = ERROR;
config.rules['no-param-reassign'] = OFF;
config.rules['no-proto'] = ERROR;
config.rules['no-process-env'] = OFF;
config.rules['no-redeclare'] = ERROR;
config.rules['no-return-assign'] = ERROR;
config.rules['no-script-url'] = ERROR;
config.rules['no-self-compare'] = ERROR;
config.rules['no-sequences'] = ERROR;
config.rules['no-throw-literal'] = ERROR;
config.rules['no-unused-expressions'] = ERROR;
config.rules['no-warning-comments'] = [1];
config.rules['no-with'] = ERROR;
config.rules['radix'] = ERROR;
config.rules['wrap-iife'] = ERROR;
// strict mode
config.rules['strict'] = [ERROR, 'global'];
// variables
config.rules['no-catch-shadow'] = ERROR;
config.rules['no-delete-var'] = ERROR;
config.rules['no-shadow'] = ERROR;
config.rules['no-shadow-restricted-names'] = ERROR;
config.rules['no-undef'] = ERROR;
config.rules['no-undef-init'] = ERROR;
config.rules['no-undefined'] = OFF;
config.rules['no-unused-vars'] = [ERROR, { vars: 'all', args: 'none' }];
config.rules['no-use-before-define'] = [ERROR, 'nofunc'];
// node.js
config.rules['handle-callback-err'] = [ERROR, '^.*(e|E)rr'];
config.rules['no-mixed-requires'] = ERROR;
config.rules['no-new-require'] = ERROR;
config.rules['no-path-concat'] = OFF;
config.rules['no-process-exit'] = OFF;
}
// stylistic.
if (!process.env.NO_STYLE) {
// Global
config.rules['max-len'] = [ERROR, { code: 80, ignoreComments: true }];
// Prettier
config.extends.push('prettier');
config.plugins.push('prettier');
config.rules['prettier/prettier'] = ERROR;
// JSDoc
config.rules['jsdoc/check-param-names'] = ERROR;
config.rules['jsdoc/check-tag-names'] = ERROR;
config.rules['jsdoc/newline-after-description'] = ERROR;
config.rules['jsdoc/require-hyphen-before-param-description'] = ERROR;
config.rules['jsdoc/require-param'] = ERROR;
config.rules['jsdoc/require-param-description'] = ERROR;
config.rules['jsdoc/require-param-type'] = ERROR;
config.rules['jsdoc/require-returns-description'] = ERROR;
config.rules['jsdoc/require-returns-type'] = ERROR;
}
module.exports = config;