src: implement standard.js linting

In addition:

* moved module.exports to the bottom
* no single-line if statements
* no if statements without a {
* const for requires
* array declarations get spaces inside [ ]
* 'use strict' in all .js files

PR-URL: https://github.com/nodejs/node-gyp/pull/1794
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: João Reis <reis@janeasystems.com>
This commit is contained in:
Rod Vagg 2019-06-22 13:10:59 +10:00
parent 7e8127068f
commit e40c99e283
No known key found for this signature in database
GPG key ID: C273792F7D83545D
28 changed files with 739 additions and 661 deletions

View file

@ -1,21 +1,21 @@
'use strict'
var test = require('tap').test
var path = require('path')
var gyp = require('../lib/node-gyp')
var requireInject = require('require-inject')
var configure = requireInject('../lib/configure', {
const test = require('tap').test
const path = require('path')
const gyp = require('../lib/node-gyp')
const requireInject = require('require-inject')
const configure = requireInject('../lib/configure', {
'graceful-fs': {
'openSync': function () { return 0; },
'openSync': function () { return 0 },
'closeSync': function () { },
'writeFile': function (file, data, cb) { cb() },
'stat': function (file, cb) { cb(null, {}) }
}
})
var EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib')
var SEPARATOR = process.platform == 'win32' ? ';' : ':'
var SPAWN_RESULT = { on: function () { } }
const EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib')
const SEPARATOR = process.platform === 'win32' ? ';' : ':'
const SPAWN_RESULT = { on: function () { } }
require('npmlog').level = 'warn'
@ -42,11 +42,10 @@ test('configure PYTHONPATH with existing env of one dir', function (t) {
var prog = gyp()
prog.parseArgv([])
prog.spawn = function () {
t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
t.equal(process.env.PYTHONPATH, [ EXPECTED_PYPATH, existingPath ].join(SEPARATOR))
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath])
t.deepEqual(dirs, [ EXPECTED_PYPATH, existingPath ])
return SPAWN_RESULT
}
@ -58,17 +57,16 @@ test('configure PYTHONPATH with existing env of multiple dirs', function (t) {
var pythonDir1 = path.join('a', 'b')
var pythonDir2 = path.join('b', 'c')
var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR)
var existingPath = [ pythonDir1, pythonDir2 ].join(SEPARATOR)
process.env.PYTHONPATH = existingPath
var prog = gyp()
prog.parseArgv([])
prog.spawn = function () {
t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
t.equal(process.env.PYTHONPATH, [ EXPECTED_PYPATH, existingPath ].join(SEPARATOR))
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])
t.deepEqual(dirs, [ EXPECTED_PYPATH, pythonDir1, pythonDir2 ])
return SPAWN_RESULT
}