UNPKG

5.2 kBJavaScriptView Raw
1'use strict';
2
3var OFF = 0;
4var ERROR = 2;
5
6var config = {
7 extends: [],
8 plugins: ['jsdoc'],
9 env: {
10 browser: false,
11 node: true,
12 es6: false
13 },
14 rules: {}
15};
16
17if (!process.env.NO_LINT) {
18 // possible errors
19 config.rules['no-cond-assign'] = ERROR;
20 config.rules['no-console'] = OFF;
21 config.rules['no-constant-condition'] = ERROR;
22 config.rules['no-control-regex'] = ERROR;
23 config.rules['no-debugger'] = ERROR;
24 config.rules['no-dupe-args'] = ERROR;
25 config.rules['no-dupe-keys'] = ERROR;
26 config.rules['no-duplicate-case'] = ERROR;
27 config.rules['no-empty'] = ERROR;
28 config.rules['no-empty-character-class'] = ERROR;
29 config.rules['no-ex-assign'] = ERROR;
30 config.rules['no-extra-boolean-cast'] = ERROR;
31 config.rules['no-extra-semi'] = ERROR;
32 config.rules['no-func-assign'] = ERROR;
33 // config.rules['one-var'] = [ERROR, 'always']; // TODO: var overlapping
34 // this is for variable hoisting, not necessary if we use block scoped declarations
35 // config.rules['no-inner-declarations'] = [ ERROR, 'both' ];
36 config.rules['no-invalid-regexp'] = ERROR;
37 config.rules['no-irregular-whitespace'] = ERROR;
38 config.rules['no-negated-in-lhs'] = ERROR;
39 config.rules['no-reserved-keys'] = OFF;
40 config.rules['no-regex-spaces'] = ERROR;
41 config.rules['no-sparse-arrays'] = ERROR;
42 config.rules['no-unreachable'] = ERROR;
43 config.rules['use-isnan'] = ERROR;
44 config.rules['valid-jsdoc'] = [
45 ERROR,
46 {
47 requireReturnDescription: false,
48 prefer: {
49 return: 'returns'
50 }
51 }
52 ];
53 config.rules['valid-typeof'] = ERROR;
54
55 // best practices
56 config.rules['func-names'] = ERROR;
57 config.rules['block-scoped-var'] = ERROR;
58 config.rules['consistent-return'] = ERROR;
59 config.rules['curly'] = OFF;
60 config.rules['default-case'] = ERROR;
61 config.rules['dot-notation'] = [ERROR, { allowKeywords: true }];
62 config.rules['eqeqeq'] = ERROR;
63 config.rules['guard-for-in'] = ERROR;
64 config.rules['no-alert'] = ERROR;
65 config.rules['no-caller'] = ERROR;
66 config.rules['no-div-regex'] = ERROR;
67 config.rules['no-eq-null'] = ERROR;
68 config.rules['no-eval'] = ERROR;
69 config.rules['no-extend-native'] = ERROR;
70 config.rules['no-extra-bind'] = ERROR;
71 config.rules['no-fallthrough'] = ERROR;
72 config.rules['no-floating-decimal'] = ERROR;
73 config.rules['no-implied-eval'] = ERROR;
74 config.rules['no-iterator'] = ERROR;
75 config.rules['no-labels'] = ERROR;
76 config.rules['no-lone-blocks'] = ERROR;
77 config.rules['no-loop-func'] = OFF;
78 config.rules['no-multi-spaces'] = OFF;
79 config.rules['no-multi-str'] = OFF;
80 config.rules['no-native-reassign'] = ERROR;
81 config.rules['no-new'] = OFF;
82 config.rules['no-new-func'] = ERROR;
83 config.rules['no-new-wrappers'] = ERROR;
84 config.rules['no-octal'] = ERROR;
85 config.rules['no-octal-escape'] = ERROR;
86 config.rules['no-param-reassign'] = OFF;
87 config.rules['no-proto'] = ERROR;
88 config.rules['no-process-env'] = OFF;
89 config.rules['no-redeclare'] = ERROR;
90 config.rules['no-return-assign'] = ERROR;
91 config.rules['no-script-url'] = ERROR;
92 config.rules['no-self-compare'] = ERROR;
93 config.rules['no-sequences'] = ERROR;
94 config.rules['no-throw-literal'] = ERROR;
95 config.rules['no-unused-expressions'] = ERROR;
96
97 config.rules['no-warning-comments'] = [1];
98 config.rules['no-with'] = ERROR;
99 config.rules['radix'] = ERROR;
100 config.rules['wrap-iife'] = ERROR;
101
102 // strict mode
103 config.rules['strict'] = [ERROR, 'global'];
104
105 // variables
106 config.rules['no-catch-shadow'] = ERROR;
107 config.rules['no-delete-var'] = ERROR;
108 config.rules['no-shadow'] = ERROR;
109 config.rules['no-shadow-restricted-names'] = ERROR;
110 config.rules['no-undef'] = ERROR;
111 config.rules['no-undef-init'] = ERROR;
112 config.rules['no-undefined'] = OFF;
113 config.rules['no-unused-vars'] = [ERROR, { vars: 'all', args: 'none' }];
114 config.rules['no-use-before-define'] = [ERROR, 'nofunc'];
115
116 // node.js
117 config.rules['handle-callback-err'] = [ERROR, '^.*(e|E)rr'];
118 config.rules['no-mixed-requires'] = ERROR;
119 config.rules['no-new-require'] = ERROR;
120 config.rules['no-path-concat'] = OFF;
121 config.rules['no-process-exit'] = OFF;
122}
123
124// stylistic.
125if (!process.env.NO_STYLE) {
126 // Global
127 config.rules['max-len'] = [ERROR, { code: 80 }];
128
129 // Prettier
130 config.extends.push('prettier');
131 config.plugins.push('prettier');
132 config.rules['prettier/prettier'] = ERROR;
133
134 // JSDoc
135 config.rules['jsdoc/check-param-names'] = ERROR;
136 config.rules['jsdoc/check-tag-names'] = ERROR;
137 config.rules['jsdoc/newline-after-description'] = ERROR;
138 config.rules['jsdoc/require-hyphen-before-param-description'] = ERROR;
139 config.rules['jsdoc/require-param'] = ERROR;
140 config.rules['jsdoc/require-param-description'] = ERROR;
141 config.rules['jsdoc/require-param-type'] = ERROR;
142 config.rules['jsdoc/require-returns-description'] = ERROR;
143 config.rules['jsdoc/require-returns-type'] = ERROR;
144}
145
146module.exports = config;