-
Notifications
You must be signed in to change notification settings - Fork 5
Add JS Standard linting an run in Travis #26
Conversation
Hey @geymed, Thanks for starting this work. Here are some things I would like you to do:
/* eslint-disable no-multi-spaces */
const program = require('commander')
const package = require('../package.json')
const pkg = require('../package.json')
const config = require('../lib/config')
/* eslint-enable no-multi-spaces */ I'll also add inline comments as a formal review. |
FYI, I just added the |
f644e9e
to
eb03a59
Compare
Hey @joelwallis , |
Hey @geymed, I just cloned your fork and ran
|
@joelwallis that's weird, did you checkout the feature branch ( |
@geymed My bad! I ran standard on master branch 😂 |
.gitignore
Outdated
registry.json | ||
npm-debug.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these entries. We can add them later.
.travis.yml
Outdated
@@ -4,3 +4,9 @@ node_js: | |||
cache: | |||
directories: | |||
- "node_modules" | |||
install: | |||
- "npm install" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm install
is the default command to install dependencies on Travis. No need to have it on .travis.yml
@@ -16,7 +16,6 @@ if (!['get', 'set'].includes(operation)) { | |||
} | |||
|
|||
switch (operation) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is standard
complaining about padded blocks? If that's so, you should fix all padded blocks (CLI, libs and tests).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geymed 👆
@@ -60,7 +58,7 @@ function loadFromApi () { | |||
}) | |||
.then(JSON.parse) | |||
.then(payload => payload.content) | |||
.then(raw => new Buffer(raw, 'base64').toString()) | |||
.then(raw => Buffer.from(raw, 'base64').toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need of it for this PR. Again: focus on the problem you're solving now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geymed 👆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, just saw the standard
error. new Buffer()
was deprecated. Nevermind.
./lib/registry.js:63:18: 'new Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead. (node/no-deprecated-api)
package.json
Outdated
@@ -7,7 +7,8 @@ | |||
}, | |||
"scripts": { | |||
"test": "mocha -b --recursive", | |||
"test:watch": "mocha -bw --recursive" | |||
"test:watch": "mocha -bw --recursive", | |||
"lint": "./node_modules/.bin/standard" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to use the full path of standard
, the node_modules/.bin
folder is included in the module path when you're using npm scripts. See: I'm using just mocha
on test
, not ./node_modules/.bin/mocha
. 🙂 It's safe on npm scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, remember to include *all CLI, libs and tests .js files:
"lint": "standard ./bin/*.js ./lib/*.js ./test/*/*.js"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geymed 👆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joelwallis when I just run standard
it scans all files recursively. I can specify paths if there some we want to skip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @geymed, you can ignore this comment. I saw that standard
searches *.js
files recursively while ignoring paths like node_modules
and ones declared in .gitignore
. 🙂
|
||
chai.use(require('chai-as-promised')) | ||
const expect = chai.expect | ||
|
||
/* eslint-env mocha */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind moving it to the top of the file (first line)?
test/lib/registry.test.js
Outdated
const registry = require('../../lib/registry') | ||
|
||
const expect = chai.expect | ||
|
||
/* eslint-env mocha */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one needs to move to the top too.
test/lib/config.test.js
Outdated
@@ -78,14 +75,13 @@ describe('lib/config', function () { | |||
return promise | |||
}) | |||
|
|||
/* eslint no-unused-expressions:0 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you use this one here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geymed 👆
@geymed I just saw that I didn't submit my review. That's why it wasn't showing for you. My bad! |
@geymed I changed the code directly to streamline this PR on my fork, branch Here are the commands that you'll need to run:
|
I made the changes on my fork - https://github.com/joelwallis/dsafio/tree/wip-pr-26
@geymed I made just a final change request for this PR. It's all good. |
@joelwallis just cherry-picked your commit, LMK if it's OK. |
Great work @geymed! Feel free to proceed with the dsafio/challenges#3 one 😊 |
Fixes #15