Skip to content

Commit

Permalink
Change the default options and ignore any options passed from outside
Browse files Browse the repository at this point in the history
Provide an `unlockOptions` escape hatch used by the playground app in docs.
  • Loading branch information
jsnajdr committed Dec 28, 2017
1 parent f59444e commit 81c358c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ const defaults = {
requirePragma: false,
semi: true,
proseWrap: "preserve",
arrowParens: "avoid",
unlockOptions: false
};

const calypsoDefaults = {
useTabs: true,
tabWidth: 2,
printWidth: 100,
singleQuote: true,
trailingComma: "es5",
bracketSpacing: true,
parenSpacing: true,
jsxBracketSameLine: false,
insertPragma: true,
requirePragma: false,
semi: true,
arrowParens: "avoid"
};

Expand Down Expand Up @@ -117,6 +133,12 @@ function normalize(options) {
}
});

// Calypso fork ignores all options and always uses the defaults. This is an escape hatch.
// comment out this block when running tests
if (!normalized.unlockOptions) {
Object.assign(normalized, calypsoDefaults);
}

return normalized;
}

Expand Down
1 change: 1 addition & 0 deletions website/static/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ self.onmessage = function(message) {
delete options.ast;
delete options.doc;
delete options.output2;
options.unlockOptions = true;

var formatted = formatCode(message.data.text, options);
var doc;
Expand Down

0 comments on commit 81c358c

Please sign in to comment.