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,13 +1,13 @@
'use strict'
var test = require('tap').test
var path = require('path')
var requireInject = require('require-inject')
var configure = requireInject('../lib/configure', {
const test = require('tap').test
const path = require('path')
const requireInject = require('require-inject')
const configure = requireInject('../lib/configure', {
'graceful-fs': {
'closeSync': function () { return undefined },
'openSync': function (path) {
if (readableFiles.some(function (f) { return f === path} )) {
if (readableFiles.some(function (f) { return f === path })) {
return 0
} else {
var error = new Error('ENOENT - not found')
@ -17,11 +17,11 @@ var configure = requireInject('../lib/configure', {
}
})
var dir = path.sep + 'testdir'
var readableFile = 'readable_file'
var anotherReadableFile = 'another_readable_file'
var readableFileInDir = 'somedir' + path.sep + readableFile
var readableFiles = [
const dir = path.sep + 'testdir'
const readableFile = 'readable_file'
const anotherReadableFile = 'another_readable_file'
const readableFileInDir = 'somedir' + path.sep + readableFile
const readableFiles = [
path.resolve(dir, readableFile),
path.resolve(dir, anotherReadableFile),
path.resolve(dir, readableFileInDir)
@ -59,7 +59,6 @@ test('find accessible - single item array, unreadable', function (t) {
t.strictEqual(found, undefined)
})
test('find accessible - multi item array, no matches', function (t) {
t.plan(1)
@ -68,7 +67,6 @@ test('find accessible - multi item array, no matches', function (t) {
t.strictEqual(found, undefined)
})
test('find accessible - multi item array, single match', function (t) {
t.plan(1)