lib: remove env: node in eslint config for lib files · nodejs/node@de23055 (original) (raw)

12 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
1 1 'use strict';
2 2
3 +/* eslint-env node */
4 +
3 5 const Module = require('module');
4 6 const path = require('path');
5 7
@@ -31,7 +33,6 @@ Module._findPath = (request, paths, isMain) => {
31 33 module.exports = {
32 34 root: true,
33 35 plugins: ['markdown', 'node-core'],
34 -env: { node: true, es6: true },
35 36 parser: 'babel-eslint',
36 37 parserOptions: { sourceType: 'script' },
37 38 overrides: [
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
1 1 ## Benchmark-specific linter rules
2 2
3 +env:
4 +node: true
5 +es6: true
6 +
3 7 rules:
4 8 comma-dangle:
5 9 - error
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1 +env:
2 +es6: true
3 +
1 4 rules:
2 5 prefer-object-spread: error
3 6 no-buffer-constructor: error
@@ -19,10 +22,11 @@ rules:
19 22 - selector: "CallExpression[callee.object.name='Error'][callee.property.name='captureStackTrace']"
20 23 message: "Please use `require('internal/errors').hideStackFrames()` instead."
21 24 # Custom rules in tools/eslint-rules
22 -node-core/require-globals: error
23 25 node-core/lowercase-name-for-primitive: error
24 26 node-core/non-ascii-character: error
25 27 globals:
28 +Intl: false
29 +# Assertions
26 30 CHECK: false
27 31 CHECK_EQ: false
28 32 CHECK_GE: false
@@ -37,5 +41,21 @@ globals:
37 41 DCHECK_LE: false
38 42 DCHECK_LT: false
39 43 DCHECK_NE: false
44 +# Parameters passed to internal modules
45 +global: false
46 +require: false
47 +process: false
48 +exports: false
49 +module: false
40 50 internalBinding: false
41 51 primordials: false
52 +# Globals
53 +# TODO(joyeecheung): if possible, get these in native modules
54 +# through `require` instead of grabbing them from the global proxy.
55 +clearTimeout: false
56 +setTimeout: false
57 +clearInterval: false
58 +setInterval: false
59 +setImmediate: false
60 +clearImmediate: false
61 +console: false
Original file line number Diff line number Diff line change
@@ -654,9 +654,10 @@ Buffer.prototype.equals = function equals(otherBuffer) {
654 654 return _compare(this, otherBuffer) === 0;
655 655 };
656 656
657 +let INSPECT_MAX_BYTES = 50;
657 658 // Override how buffers are presented by util.inspect().
658 659 Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
659 -const max = exports.INSPECT_MAX_BYTES;
660 +const max = INSPECT_MAX_BYTES;
660 661 const actualMax = Math.min(max, this.length);
661 662 const remaining = this.length - max;
662 663 let str = this.hexSlice(0, actualMax).replace(/(.{2})/g, '$1 ').trim();
@@ -1089,19 +1090,25 @@ if (internalBinding('config').hasIntl) {
1089 1090 };
1090 1091 }
1091 1092
1092 -module.exports = exports = {
1093 +module.exports = {
1093 1094 Buffer,
1094 1095 SlowBuffer,
1095 1096 transcode,
1096 -INSPECT_MAX_BYTES: 50,
1097 -
1098 1097 // Legacy
1099 1098 kMaxLength,
1100 1099 kStringMaxLength
1101 1100 };
1102 1101
1103 -Object.defineProperty(exports, 'constants', {
1104 -configurable: false,
1105 -enumerable: true,
1106 -value: constants
1102 +Object.defineProperties(module.exports, {
1103 +constants: {
1104 +configurable: false,
1105 +enumerable: true,
1106 +value: constants
1107 +},
1108 +INSPECT_MAX_BYTES: {
1109 +configurable: true,
1110 +enumerable: true,
1111 +get() { return INSPECT_MAX_BYTES; },
1112 +set(val) { INSPECT_MAX_BYTES = val; }
1113 +}
1107 1114 });
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ function createVerify(algorithm, options) {
145 145 return new Verify(algorithm, options);
146 146 }
147 147
148 -module.exports = exports = {
148 +module.exports = {
149 149 // Methods
150 150 createCipheriv,
151 151 createDecipheriv,
@@ -218,7 +218,7 @@ function getFipsForced() {
218 218 return 1;
219 219 }
220 220
221 -Object.defineProperties(exports, {
221 +Object.defineProperties(module.exports, {
222 222 createCipher: {
223 223 enumerable: false,
224 224 value: deprecate(createCipher,
Original file line number Diff line number Diff line change
@@ -124,6 +124,7 @@ const internalBindingWhitelist = new SafeSet([
124 124 let internalBinding;
125 125 {
126 126 const bindingObj = Object.create(null);
127 +// eslint-disable-next-line no-global-assign
127 128 internalBinding = function internalBinding(module) {
128 129 let mod = bindingObj[module];
129 130 if (typeof mod !== 'object') {
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ function normalizeReferrerURL(referrer) {
129 129 return new URL(referrer).href;
130 130 }
131 131
132 -module.exports = exports = {
132 +module.exports = {
133 133 addBuiltinLibsToObject,
134 134 builtinLibs,
135 135 makeRequireFunction,
Original file line number Diff line number Diff line change
@@ -113,8 +113,8 @@ function timestamp() {
113 113 }
114 114
115 115 // Log is just a thin wrapper to console.log that prepends a timestamp
116 -function log() {
117 -console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
116 +function log(...args) {
117 +console.log('%s - %s', timestamp(), format(...args));
118 118 }
119 119
120 120 /**
@@ -218,7 +218,7 @@ function getSystemErrorName(err) {
218 218 }
219 219
220 220 // Keep the `exports =` so that various functions can still be monkeypatched
221 -module.exports = exports = {
221 +module.exports = {
222 222 _errnoException: errnoException,
223 223 _exceptionWithHostPort: exceptionWithHostPort,
224 224 _extend,
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
1 1 ## Test-specific linter rules
2 2
3 +env:
4 +node: true
5 +es6: true
6 +
3 7 rules:
4 8 # ECMAScript 6
5 9 # http://eslint.org/docs/rules/#ecmascript-6
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1 +env:
2 +node: true
3 +es6: true
4 +
1 5 rules:
2 6 comma-dangle:
3 7 - error