daviscodesbugs / gamepiece-json

A collection of json files describing the pieces of board games
GNU General Public License v3.0
11 stars 32 forks source link

Add linting to game json files #93

Closed wachunga closed 7 years ago

wachunga commented 7 years ago

With so many contributors, style is getting very inconsistent (eg tabs instead of 4 spaces). I added npm run lint to resolve this. I'll leave it up to you whether you want this to run along with npm test but I would recommend doing so.

This required changing the jsonlint library to a more popular one that has more features.

daviscodesbugs commented 7 years ago

This is something that I've been meaning to tackle, but have been moderately overwhelmed with the recent response to the project.

This PR looks good. :+1: Just for clarification, running npm run lint lints all json files in project. Correct? Then does the change in unit test ensure that the files mirror what it should when linted?

wachunga commented 7 years ago

npm run lint lints all json files in the game directory. If there were json files elsewhere, they wouldn't be linted currently.

The unit tests operate exactly the same as before. The only changes I made were to DRY them up a little and replace the json-lint dep with the jsonlint one. I tested to ensure that the new version fails as expected if there's a syntax error.

daviscodesbugs commented 7 years ago

Okay, that's great. I'd only want to list json in games.

I noticed that, I just wasn't sure if the new lint test would fail if the file wasn't correctly linted already (e.g. the file was tabbed rather than 4-spaced).

wachunga commented 7 years ago

Oh, I understand now. No, it won't fail for stylistic issues. But if you change scripts.text to be ./lint.sh; mocha then they'll always get fixed anyway instead of the build breaking and requiring an extra commit.

daviscodesbugs commented 7 years ago

However, they won't be committed to the repo as linted, unless the user runs the test target before they submit their PR, correct? I think that's the primary issue with PRs is the inattention to formatting and other contribution specs.

I'm unaware of a way to have Travis lint and commit as part of it's build process; Do you know of one?