Clasp: Code formatter

Created on 23 Mar 2018  路  3Comments  路  Source: google/clasp

Expected Behavior

Developers write readable code that conforms to a style.

Actual Behavior

Developers write code that is poorly formatted.

Solution

  • Give an example of how we can use an example like prettier.io to format Apps Script code.
  • Integrate it with clasp? (Do we need .rc files to specify style?) No
docs

Most helpful comment

Adding my two cents to the discussion.

I'm using prettier personally with some of my AppsScripts projects and it works really great, especially for some things that appsscript considers errors such as semicolons. I make a npm package, and have the clasp-specific stuff all under a src directory. Prettier is configured through my package.json file.

I think it'd be frustrating, though, if using clasp meant I had to adopt a specific style. I could see myself disagreeing with the defaults that are picked--i.e. single vs double quotes, line-length, spaces around brackets.

If the behavior was able to be overridden, or if it only did the steps necessary for a sucessful push (adding semicolons, changing arrow functions to normal function definitions, changing const/let to var) I would really like this feature.

All 3 comments

Adding my two cents to the discussion.

I'm using prettier personally with some of my AppsScripts projects and it works really great, especially for some things that appsscript considers errors such as semicolons. I make a npm package, and have the clasp-specific stuff all under a src directory. Prettier is configured through my package.json file.

I think it'd be frustrating, though, if using clasp meant I had to adopt a specific style. I could see myself disagreeing with the defaults that are picked--i.e. single vs double quotes, line-length, spaces around brackets.

If the behavior was able to be overridden, or if it only did the steps necessary for a sucessful push (adding semicolons, changing arrow functions to normal function definitions, changing const/let to var) I would really like this feature.

I agree. I don't think clasp should pick a style at all, there's lots of tools to do that. Apps Script is different than Go.

I removed: _"Should we enforce a certain style like Go?"_

But I think we should tell people how to use some of the existing tools.

Formatting should be done in clasp.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dustinmichels picture dustinmichels  路  4Comments

PopGoesTheWza picture PopGoesTheWza  路  4Comments

grant picture grant  路  8Comments

Haris-Jamil picture Haris-Jamil  路  6Comments

OleksandrRakovets picture OleksandrRakovets  路  3Comments