This repository was archived by the owner on Mar 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrecommended.js
127 lines (103 loc) · 4.67 KB
/
recommended.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
/**
* Js-coding-standards
*
* @author Robert Rossmann <[email protected]>
* @copyright 2016 STRV
* @license http://choosealicense.com/licenses/bsd-3-clause BSD-3-Clause License
*/
'use strict'
const globs = require('../../globs')
module.exports = {
extends: '../shared/recommended.js',
parserOptions: {
ecmaVersion: 2015,
},
env: {
es6: true,
node: true,
},
plugins: [
'node',
],
rules: {
// Enforce `require()` on the top-level module scope
// It's arguably harder to identify dependencies when they are deeply nested inside of functions
// and other statements. Since require() does a synchronous load, it can cause performance
// problems when used in other locations.
'global-require': 'warn',
// Disallow use of the deprecated Buffer() constructor
// In Node.js, the behavior of the Buffer constructor is different depending on the type of its
// argument. Passing an argument from user input to Buffer() without validating its type can
// lead to security vulnerabilities such as remote memory disclosure and denial of service.
'no-buffer-constructor': 2,
// Disallow new require
// This rule aims to eliminate use of the `new require` expression.
'no-new-require': 'error',
// Disallow string concatenation when using _dirname and _filename
// This rule aims to prevent string concatenation of directory paths in Node.js to make sure
// developers use a platform-independent way of creating paths (we feel you, Windows).
'no-path-concat': 'error',
// Disallow process.env
// This rule is aimed at discouraging use of process.env to avoid global dependencies throughout
// the project's codebase.
//
// Note: Env vars are a great way of managing configuration options. This rule can be safely
// turned off for a particular file/folder where project configuration is gathered and stored in
// custom configuration objects which you then use throughout your app, but the use of
// process.env outside of preparing configuration data should be discouraged.
'no-process-env': 'warn',
// Disallow `process.exit()`
// It's better to throw an error and allow the application to handle it appropriately. Unhandled
// errors always exit the process, but contrary to `process.exit()` they also print a stack
// trace.
'no-process-exit': 'error',
// Disallow Synchronous Methods
// This rule is aimed at preventing synchronous methods from being called in Node.js. It looks
// specifically for the method suffix "Sync" (as is the convention with Node.js operations).
'no-sync': ['warn', {
allowAtRootLevel: true,
}],
// Disallow unsupported ECMAScript features on the specified version
// This rule reports unsupported ECMAScript built-in variables on the configured Node.js version
// as lint errors. This rule reads the engines field of package.json to detect which Node.js
// versions your module is supporting.
'node/no-unsupported-features/es-builtins': 'error',
// Disallow unsupported ECMAScript syntax on the specified version
// This rule reports unsupported ECMAScript syntax on the configured Node.js version as lint
// errors. This rule reads the engines field of package.json to detect which Node.js versions
// your module is supporting.
'node/no-unsupported-features/es-syntax': 'error',
// Disallow unsupported Node.js built-in APIs on the specified version
// This rule reports unsupported Node.js built-in APIs on the configured Node.js version as lint
// errors. This rule reads the engines field of package.json to detect which Node.js versions
// your module is supporting.
'node/no-unsupported-features/node-builtins': 'error',
// Treat process.exit() the same code path as throw
// If you turn this rule on, ESLint comes to address process.exit() as throw in code path
// analysis.
'node/process-exit-as-throw': 'error',
// Suggest correct usage of shebang
// This rule checks bin field of package.json, then if a target file matches one of bin files,
// it checks whether or not there is a correct shebang. Otherwise it checks whether or not there
// is not a shebang.
'node/shebang': 'warn',
// Disallow deprecated API
// Node has many deprecated API. The community is going to remove those API from Node in future,
// so we should not use those.
'node/no-deprecated-api': 'warn',
},
overrides: [{
files: globs.javascripts,
parserOptions: {
sourceType: 'script',
},
}, {
files: globs.esmodules,
parserOptions: {
sourceType: 'module',
},
env: {
es6: true,
},
}],
}