Skip to content

Commit

Permalink
Add basic linting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Hamann committed Oct 21, 2017
1 parent bfb0220 commit ca10d0e
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
node_modules
usage.js
8 changes: 8 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,8 @@
{
"env": {
"node": true
},
"rules": {
"no-unused-vars": "error"
}
}
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -9,4 +9,5 @@ test/fixtures/*.json
node_modules/
node_modules/*
npm-debug.log
coverage
coverage
package-lock.json
3 changes: 1 addition & 2 deletions lib/nconf.js
Expand Up @@ -5,8 +5,7 @@
*
*/

var async = require('async'),
common = require('./nconf/common'),
var common = require('./nconf/common'),
Provider = require('./nconf/provider').Provider;

//
Expand Down
1 change: 0 additions & 1 deletion lib/nconf/provider.js
Expand Up @@ -91,7 +91,6 @@ Provider.prototype.file = function (key, options) {
//
Provider.prototype.use = function (name, options) {
options = options || {};
var type = options.type || name;

function sameOptions (store) {
return Object.keys(options).every(function (key) {
Expand Down
17 changes: 7 additions & 10 deletions lib/nconf/stores/file.js
Expand Up @@ -10,8 +10,9 @@ var fs = require('fs'),
util = require('util'),
Secure = require('secure-keys'),
formats = require('../formats'),
Memory = require('./memory').Memory,
exists = fs.exists || path.exists,
Memory = require('./memory').Memory;

var exists = fs.exists || path.exists,
existsSync = fs.existsSync || path.existsSync;

//
Expand All @@ -22,7 +23,7 @@ var fs = require('fs'),
//
var File = exports.File = function (options) {
if (!options || !options.file) {
throw new Error ('Missing required option `file`');
throw new Error('Missing required option `file`');
}

Memory.call(this, options);
Expand Down Expand Up @@ -83,12 +84,10 @@ File.prototype.save = function (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`
// using the format specified by `this.format` synchronously.
//
File.prototype.saveSync = function (value) {
File.prototype.saveSync = function () {
fs.writeFileSync(this.file, this.stringify());
return this.store;
};
Expand Down Expand Up @@ -168,8 +167,7 @@ File.prototype.loadSync = function () {
// `this.secure` is enabled
//
File.prototype.stringify = function () {
var data = this.store,
self = this;
var data = this.store;

if (this.secure) {
data = this.keys.encrypt(data);
Expand All @@ -184,8 +182,7 @@ File.prototype.stringify = function () {
// `this.secure` is enabled.
//
File.prototype.parse = function (contents) {
var parsed = this.format.parse(contents),
self = this;
var parsed = this.format.parse(contents);

if (!this.secure) {
return parsed;
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -20,14 +20,16 @@
},
"devDependencies": {
"coveralls": "^2.11.4",
"eslint": "^4.9.0",
"istanbul": "^0.4.1",
"vows": "0.8.x"
},
"main": "./lib/nconf",
"scripts": {
"test": "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": {
"node": ">= 0.4.0"
Expand Down
1 change: 0 additions & 1 deletion test/common-test.js
Expand Up @@ -8,7 +8,6 @@
var fs = require('fs'),
path = require('path'),
vows = require('vows'),
assert = require('assert'),
helpers = require('./helpers'),
nconf = require('../lib/nconf');

Expand Down
1 change: 0 additions & 1 deletion test/complete-test.js
Expand Up @@ -6,7 +6,6 @@
*/

var fs = require('fs'),
path = require('path'),
vows = require('vows'),
assert = require('assert'),
nconf = require('../lib/nconf'),
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/scripts/nconf-hierarchical-load-save.js
Expand Up @@ -5,8 +5,7 @@
*
*/

var fs = require('fs'),
path = require('path'),
var path = require('path'),
nconf = require('../../../lib/nconf');

//
Expand Down
1 change: 0 additions & 1 deletion test/helpers.js
Expand Up @@ -7,7 +7,6 @@

var assert = require('assert'),
spawn = require('child_process').spawn,
util = require('util'),
fs = require('fs'),
path = require('path'),
nconf = require('../lib/nconf');
Expand Down
4 changes: 3 additions & 1 deletion test/hierarchy-test.js
Expand Up @@ -54,7 +54,9 @@ vows.describe('nconf/hierarchy').addBatch({
child;

try { fs.unlinkSync(configFile) }
catch (ex) { }
catch (ex) {
// No-op
}

child = spawn('node', [script].concat(argv));

Expand Down
3 changes: 1 addition & 2 deletions test/nconf-test.js
Expand Up @@ -9,8 +9,7 @@ var fs = require('fs'),
path = require('path'),
vows = require('vows'),
assert = require('assert'),
nconf = require('../lib/nconf'),
data = require('./fixtures/data').data;
nconf = require('../lib/nconf')

vows.describe('nconf').addBatch({
"When using the nconf": {
Expand Down
1 change: 0 additions & 1 deletion test/provider-test.js
Expand Up @@ -8,7 +8,6 @@
var assert = require('assert'),
fs = require('fs'),
path = require('path'),
spawn = require('child_process').spawn,
vows = require('vows'),
helpers = require('./helpers'),
nconf = require('../lib/nconf');
Expand Down
1 change: 0 additions & 1 deletion test/stores/argv-test.js
Expand Up @@ -7,7 +7,6 @@

var vows = require('vows'),
assert = require('assert'),
helpers = require('../helpers'),
nconf = require('../../lib/nconf');

vows.describe('nconf/stores/argv').addBatch({
Expand Down
1 change: 0 additions & 1 deletion test/stores/env-test.js
Expand Up @@ -7,7 +7,6 @@

var vows = require('vows'),
assert = require('assert'),
helpers = require('../helpers'),
nconf = require('../../lib/nconf');

vows.describe('nconf/stores/env').addBatch({
Expand Down
1 change: 0 additions & 1 deletion test/stores/literal-test.js
Expand Up @@ -7,7 +7,6 @@

var vows = require('vows'),
assert = require('assert'),
helpers = require('../helpers'),
nconf = require('../../lib/nconf');

vows.describe('nconf/stores/literal').addBatch({
Expand Down

0 comments on commit ca10d0e

Please sign in to comment.