Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to format and validate the style #73

Closed
kylebarron opened this issue Jan 13, 2020 · 4 comments · Fixed by #74
Closed

Add script to format and validate the style #73

kylebarron opened this issue Jan 13, 2020 · 4 comments · Fixed by #74

Comments

@kylebarron
Copy link
Contributor

As a possible workaround to the JSON formatting issues mentioned in #66 and maplibre/maputnik#591, it might be easiest to just add gl-style-format in place as a Git pre-commit hook. It should be as simple as adding an NPM package.json with a couple dev dependencies, e.g. nst-guide@75b0657#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R24-R32
(for now, that only validates, not formats in place)

Before writing up a PR, just wanted to check if this is of interest.

@pathmapper
Copy link
Member

Thanks for your suggestion @kylebarron

In general I'm up for adding a package.json with @mapbox/mapbox-gl-style-spec as dev dependency to have gl-style-format available.

If we would use a Git pre-commit hook, than the style would only be formatted when doining a commit, right?

I think it would be useful to be able to format/validate the style any time while working on it.

What do you think about using a script instead which could be execute with e.g. npm run test to format/validate the style?

Later we could also add functionality to remove not needed default values which are bloating the style like "visibility": "visible" as this is a recurring request to remove them from PRs (see #61, #72 (comment), #71 (review)).

@kylebarron
Copy link
Contributor Author

Correct, the style would only be formatted on commit.

I agree that format/validation at any time is good, however most of the time people will be making edits using Maputnik, which probably enforces a valid style, and with the online editor forces formatting correctly. I mostly see this as a workaround/second check while the Maputnik issue is being sorted out.

@pathmapper
Copy link
Member

pathmapper commented Jan 14, 2020

OK thanks, so let's implement this with a npm run ... script which could be executed at any time.

Yeah, this is a good workaround for people using Maputnik Desktop, but also generally useful (e.g. when modifying the style with a text editor).

Is this something you are interested to work on and submit a PR?

@pathmapper pathmapper changed the title Add gl-style-format pre-commit hook Add script to format and validate the style Jan 14, 2020
@pathmapper
Copy link
Member

ref: #59 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants