-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
77 lines (76 loc) · 2.47 KB
/
Copy patheslint.config.js
File metadata and controls
77 lines (76 loc) · 2.47 KB
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
module.exports = [
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
console: 'readonly',
process: 'readonly',
require: 'readonly',
module: 'readonly',
exports: 'readonly',
__dirname: 'readonly',
Buffer: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
fetch: 'readonly',
URL: 'readonly',
AbortController: 'readonly',
Uint8Array: 'readonly'
}
},
plugins: {
local: {
rules: {
'no-process-exit': {
meta: {
type: 'suggestion',
docs: { description: 'Enforce process.exitCode instead of process.exit()' },
schema: []
},
create(context) {
return {
CallExpression(node) {
if (
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
node.callee.object.name === 'process' &&
node.callee.property.type === 'Identifier' &&
node.callee.property.name === 'exit'
) {
// Allow signal handler exits (130 = SIGINT, 143 = SIGTERM)
if (
node.arguments.length === 1 &&
node.arguments[0].type === 'Literal' &&
(node.arguments[0].value === 130 || node.arguments[0].value === 143)
) {
return;
}
context.report({
node,
message: 'Use process.exitCode = <code>; return; instead of process.exit(<code>). This allows cleanup hooks (process.on("exit", ...), beforeExit) to run. Use /* eslint-disable-next-line local/no-process-exit */ for intentional uses (Commander event handlers, TUI quit).',
});
}
}
};
}
}
}
}
},
rules: {
'no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}],
'no-console': 'off',
'prefer-const': 'warn',
'no-var': 'error',
'eqeqeq': ['error', 'always', { null: 'ignore' }],
'no-throw-literal': 'error',
'no-shadow': 'warn',
'local/no-process-exit': 'error'
}
}
];