Skip to content

Add quoteProps: es3 #6936

@ExE-Boss

Description

@ExE-Boss

When contributing new polyfills to ES‑Shims, which have to use ES3, I still want to use Prettier for ES‑Shim packages that I own.

Since Prettier strips the quotes required by ES3 for object properties named with keywords, I have to run eslint ‑‑fix after running prettier --write, which is annoying.

Prettier 1.19.1
Playground link

Input:

function __generator(thisArg, body) {
    var g;
    return g = { next: verb(0), "throw": verb(1), return: verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        // …
    }
}

Output:

function __generator(thisArg, body) {
	var g;
	return (
		(g = { next: verb(0), throw: verb(1), return: verb(2) }),
		typeof Symbol === "function" &&
			(g[Symbol.iterator] = function() {
				return this;
			}),
		g
	);
	function verb(n) {
		return function(v) {
			return step([n, v]);
		};
	}
}

Expected behavior:

function __generator(thisArg, body) {
	var g;
	return (
		// `throw` and `return` are quoted,
		// as they're invalid property names in ES3.
		(g = { next: verb(0), "throw": verb(1), "return": verb(2) }),
		typeof Symbol === "function" &&
			(g[Symbol.iterator] = function() {
				return this;
			}),
		g
	);
	function verb(n) {
		return function(v) {
			return step([n, v]);
		};
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions