Add basic linting rules
This commit is contained in:
parent
bfb0220fe1
commit
ca10d0eaf8
17 changed files with 28 additions and 27 deletions
2
.eslintignore
Normal file
2
.eslintignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
usage.js
|
8
.eslintrc.json
Normal file
8
.eslintrc.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"no-unused-vars": "error"
|
||||||
|
}
|
||||||
|
}
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -9,4 +9,5 @@ test/fixtures/*.json
|
||||||
node_modules/
|
node_modules/
|
||||||
node_modules/*
|
node_modules/*
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
coverage
|
coverage
|
||||||
|
package-lock.json
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var async = require('async'),
|
var common = require('./nconf/common'),
|
||||||
common = require('./nconf/common'),
|
|
||||||
Provider = require('./nconf/provider').Provider;
|
Provider = require('./nconf/provider').Provider;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -91,7 +91,6 @@ Provider.prototype.file = function (key, options) {
|
||||||
//
|
//
|
||||||
Provider.prototype.use = function (name, options) {
|
Provider.prototype.use = function (name, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var type = options.type || name;
|
|
||||||
|
|
||||||
function sameOptions (store) {
|
function sameOptions (store) {
|
||||||
return Object.keys(options).every(function (key) {
|
return Object.keys(options).every(function (key) {
|
||||||
|
|
|
@ -10,8 +10,9 @@ var fs = require('fs'),
|
||||||
util = require('util'),
|
util = require('util'),
|
||||||
Secure = require('secure-keys'),
|
Secure = require('secure-keys'),
|
||||||
formats = require('../formats'),
|
formats = require('../formats'),
|
||||||
Memory = require('./memory').Memory,
|
Memory = require('./memory').Memory;
|
||||||
exists = fs.exists || path.exists,
|
|
||||||
|
var exists = fs.exists || path.exists,
|
||||||
existsSync = fs.existsSync || path.existsSync;
|
existsSync = fs.existsSync || path.existsSync;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -22,7 +23,7 @@ var fs = require('fs'),
|
||||||
//
|
//
|
||||||
var File = exports.File = function (options) {
|
var File = exports.File = function (options) {
|
||||||
if (!options || !options.file) {
|
if (!options || !options.file) {
|
||||||
throw new Error ('Missing required option `file`');
|
throw new Error('Missing required option `file`');
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory.call(this, options);
|
Memory.call(this, options);
|
||||||
|
@ -83,12 +84,10 @@ File.prototype.save = function (value, callback) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// ### function saveSync (value, callback)
|
// ### function saveSync (value, callback)
|
||||||
// #### @value {Object} _Ignored_ Left here for consistency
|
|
||||||
// #### @callback {function} **Optional** Continuation to respond to when complete.
|
|
||||||
// Saves the current configuration object to disk at `this.file`
|
// Saves the current configuration object to disk at `this.file`
|
||||||
// using the format specified by `this.format` synchronously.
|
// using the format specified by `this.format` synchronously.
|
||||||
//
|
//
|
||||||
File.prototype.saveSync = function (value) {
|
File.prototype.saveSync = function () {
|
||||||
fs.writeFileSync(this.file, this.stringify());
|
fs.writeFileSync(this.file, this.stringify());
|
||||||
return this.store;
|
return this.store;
|
||||||
};
|
};
|
||||||
|
@ -168,8 +167,7 @@ File.prototype.loadSync = function () {
|
||||||
// `this.secure` is enabled
|
// `this.secure` is enabled
|
||||||
//
|
//
|
||||||
File.prototype.stringify = function () {
|
File.prototype.stringify = function () {
|
||||||
var data = this.store,
|
var data = this.store;
|
||||||
self = this;
|
|
||||||
|
|
||||||
if (this.secure) {
|
if (this.secure) {
|
||||||
data = this.keys.encrypt(data);
|
data = this.keys.encrypt(data);
|
||||||
|
@ -184,8 +182,7 @@ File.prototype.stringify = function () {
|
||||||
// `this.secure` is enabled.
|
// `this.secure` is enabled.
|
||||||
//
|
//
|
||||||
File.prototype.parse = function (contents) {
|
File.prototype.parse = function (contents) {
|
||||||
var parsed = this.format.parse(contents),
|
var parsed = this.format.parse(contents);
|
||||||
self = this;
|
|
||||||
|
|
||||||
if (!this.secure) {
|
if (!this.secure) {
|
||||||
return parsed;
|
return parsed;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"coveralls": "^2.11.4",
|
"coveralls": "^2.11.4",
|
||||||
|
"eslint": "^4.9.0",
|
||||||
"istanbul": "^0.4.1",
|
"istanbul": "^0.4.1",
|
||||||
"vows": "0.8.x"
|
"vows": "0.8.x"
|
||||||
},
|
},
|
||||||
|
@ -27,7 +28,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vows test/*-test.js test/**/*-test.js --spec",
|
"test": "vows test/*-test.js test/**/*-test.js --spec",
|
||||||
"cover": "istanbul cover vows -- test/*-test.js test/**/*-test.js --spec",
|
"cover": "istanbul cover vows -- test/*-test.js test/**/*-test.js --spec",
|
||||||
"coveralls": "cat coverage/lcov.info | coveralls"
|
"coveralls": "cat coverage/lcov.info | coveralls",
|
||||||
|
"lint": "eslint ."
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4.0"
|
"node": ">= 0.4.0"
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
vows = require('vows'),
|
vows = require('vows'),
|
||||||
assert = require('assert'),
|
|
||||||
helpers = require('./helpers'),
|
helpers = require('./helpers'),
|
||||||
nconf = require('../lib/nconf');
|
nconf = require('../lib/nconf');
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
path = require('path'),
|
|
||||||
vows = require('vows'),
|
vows = require('vows'),
|
||||||
assert = require('assert'),
|
assert = require('assert'),
|
||||||
nconf = require('../lib/nconf'),
|
nconf = require('../lib/nconf'),
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var fs = require('fs'),
|
var path = require('path'),
|
||||||
path = require('path'),
|
|
||||||
nconf = require('../../../lib/nconf');
|
nconf = require('../../../lib/nconf');
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
var assert = require('assert'),
|
var assert = require('assert'),
|
||||||
spawn = require('child_process').spawn,
|
spawn = require('child_process').spawn,
|
||||||
util = require('util'),
|
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
nconf = require('../lib/nconf');
|
nconf = require('../lib/nconf');
|
||||||
|
|
|
@ -54,7 +54,9 @@ vows.describe('nconf/hierarchy').addBatch({
|
||||||
child;
|
child;
|
||||||
|
|
||||||
try { fs.unlinkSync(configFile) }
|
try { fs.unlinkSync(configFile) }
|
||||||
catch (ex) { }
|
catch (ex) {
|
||||||
|
// No-op
|
||||||
|
}
|
||||||
|
|
||||||
child = spawn('node', [script].concat(argv));
|
child = spawn('node', [script].concat(argv));
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,7 @@ var fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
vows = require('vows'),
|
vows = require('vows'),
|
||||||
assert = require('assert'),
|
assert = require('assert'),
|
||||||
nconf = require('../lib/nconf'),
|
nconf = require('../lib/nconf')
|
||||||
data = require('./fixtures/data').data;
|
|
||||||
|
|
||||||
vows.describe('nconf').addBatch({
|
vows.describe('nconf').addBatch({
|
||||||
"When using the nconf": {
|
"When using the nconf": {
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
var assert = require('assert'),
|
var assert = require('assert'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
spawn = require('child_process').spawn,
|
|
||||||
vows = require('vows'),
|
vows = require('vows'),
|
||||||
helpers = require('./helpers'),
|
helpers = require('./helpers'),
|
||||||
nconf = require('../lib/nconf');
|
nconf = require('../lib/nconf');
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
var vows = require('vows'),
|
var vows = require('vows'),
|
||||||
assert = require('assert'),
|
assert = require('assert'),
|
||||||
helpers = require('../helpers'),
|
|
||||||
nconf = require('../../lib/nconf');
|
nconf = require('../../lib/nconf');
|
||||||
|
|
||||||
vows.describe('nconf/stores/argv').addBatch({
|
vows.describe('nconf/stores/argv').addBatch({
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
var vows = require('vows'),
|
var vows = require('vows'),
|
||||||
assert = require('assert'),
|
assert = require('assert'),
|
||||||
helpers = require('../helpers'),
|
|
||||||
nconf = require('../../lib/nconf');
|
nconf = require('../../lib/nconf');
|
||||||
|
|
||||||
vows.describe('nconf/stores/env').addBatch({
|
vows.describe('nconf/stores/env').addBatch({
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
var vows = require('vows'),
|
var vows = require('vows'),
|
||||||
assert = require('assert'),
|
assert = require('assert'),
|
||||||
helpers = require('../helpers'),
|
|
||||||
nconf = require('../../lib/nconf');
|
nconf = require('../../lib/nconf');
|
||||||
|
|
||||||
vows.describe('nconf/stores/literal').addBatch({
|
vows.describe('nconf/stores/literal').addBatch({
|
||||||
|
|
Loading…
Reference in a new issue