Skip to content

js: Format helpers.js#205

Merged
captncraig merged 2 commits intoStackExchange:masterfrom
whs:master
Sep 15, 2017
Merged

js: Format helpers.js#205
captncraig merged 2 commits intoStackExchange:masterfrom
whs:master

Conversation

@whs
Copy link
Copy Markdown
Contributor

@whs whs commented Sep 15, 2017

Last time I worked with helpers.js, that file was a completely mess with so many coding standards mixed together.

This pull request use Prettier to cleanup the file. It should work similar to gofmt, although there is no one true style in JavaScript so I take some liberty in defining the prettierrc.

Integration test files are not ran though prettier, as it doesn't understand our DSL and will put all arguments on its own line.

If we want this to last, I'd suggest we should add a check on pull requests similar to gofmt.

I have a plan for another pull request which add eslint to perform static analysis (like warn on unused variables) plus some style guide check (for the ones I skipped like integration tests). I'll see the response from this pull request first.

var d = dot.split('.');
return ((((((+d[0])*256)+(+d[1]))*256)+(+d[2]))*256)+(+d[3]);
// prettier-ignore
return ((((((+d[0]) * 256) + (+d[1])) * 256) + (+d[2])) * 256) + (+d[3]);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without prettier-ignore, this line turns to

return ((+d[0] * 256 + +d[1]) * 256 + +d[2]) * 256 + +d[3];

I'm not sure which is better, so I put spaces around the operands in the original line instead.

@captncraig
Copy link
Copy Markdown
Contributor

The other thing I'd like to check is documentation. If possible we should probably wrap that all in a function and explicitly export things to the global context that we expect to use. Then we can inspect the exports and make sure they all have a file in the docs folder.

That just seems like a bit of work I haven't buckled down to attack yet.

@captncraig captncraig merged commit 4bffc37 into StackExchange:master Sep 15, 2017
@captncraig captncraig changed the title Format helpers.js js: Format helpers.js Sep 15, 2017
rblenkinsopp pushed a commit to rblenkinsopp/dnscontrol that referenced this pull request Aug 21, 2020
* Format helpers.js with prettier

* Adding docs on how to run prettier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants