+```
+
+
+
+
test
+
+
+
+ hi
+ {hello}
+ {/* another comment */}
+
+
+
+````
diff --git a/docs/options.md b/docs/options.md
index 00f647107..bc5521774 100644
--- a/docs/options.md
+++ b/docs/options.md
@@ -97,13 +97,13 @@ Print trailing commas wherever possible when multi-line. (A single-line array, f
Valid options:
-- `"none"` - No trailing commas.
- `"es5"` - Trailing commas where valid in ES5 (objects, arrays, etc.)
+- `"none"` - No trailing commas.
- `"all"` - Trailing commas wherever possible (including function arguments). This requires node 8 or a [transform](https://babeljs.io/docs/plugins/syntax-trailing-function-commas/).
-| Default | CLI Override | API Override |
-| -------- | ------------------------------------------------------ | ------------------------------------------------------ |
-| `"none"` |
--trailing-comma |
trailingComma: "" |
+| Default | CLI Override | API Override |
+| ------- | ------------------------------------------------------ | ------------------------------------------------------ |
+| `"es5"` |
--trailing-comma |
trailingComma: "" |
## Bracket Spacing
diff --git a/package.json b/package.json
index 7536c355f..d7a289602 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
"license": "MIT",
"main": "./index.js",
"engines": {
- "node": ">=8"
+ "node": ">=10"
},
"dependencies": {
"@angular/compiler": "8.2.13",
@@ -89,8 +89,9 @@
"eslint-plugin-import": "2.18.2",
"eslint-plugin-prettier": "3.1.1",
"eslint-plugin-react": "7.16.0",
+ "eslint-plugin-unicorn": "13.0.0",
"execa": "3.2.0",
- "jest": "23.3.0",
+ "jest": "24.9.0",
"jest-junit": "9.0.0",
"jest-snapshot-serializer-ansi": "1.0.0",
"jest-snapshot-serializer-raw": "1.1.0",
@@ -107,7 +108,7 @@
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-terser": "5.1.2",
"shelljs": "0.8.3",
- "snapshot-diff": "0.4.0",
+ "snapshot-diff": "0.6.1",
"strip-ansi": "5.2.0",
"synchronous-promise": "2.0.10",
"tempy": "0.2.1",
diff --git a/scripts/build/babel-plugins/replace-array-includes-with-indexof.js b/scripts/build/babel-plugins/replace-array-includes-with-indexof.js
deleted file mode 100644
index 18514344b..000000000
--- a/scripts/build/babel-plugins/replace-array-includes-with-indexof.js
+++ /dev/null
@@ -1,32 +0,0 @@
-"use strict";
-
-//
-// BEFORE:
-// [__something__].includes(__something__)
-// CONSTANT_CASE.includes(__something__)
-//
-// AFTER:
-// [__something__].indexOf(__something__) !== -1
-// CONSTANT_CASE.indexOf(__something__) !== -1
-//
-
-module.exports = ({ types: t }) => ({
- visitor: {
- CallExpression(path) {
- const node = path.node;
- const callee = node.callee;
- if (
- t.isMemberExpression(callee, { computed: false }) &&
- (t.isArrayExpression(callee.object) ||
- (t.isIdentifier(callee.object) &&
- (/^[A-Z_]+$/.test(callee.object.name) ||
- // https://github.com/eemeli/yaml/blob/1005d01/src/Anchors.js#L45
- callee.object.name === "names"))) &&
- t.isIdentifier(callee.property, { name: "includes" })
- ) {
- callee.property.name = "indexOf";
- path.replaceWith(t.binaryExpression("!==", node, t.numericLiteral(-1)));
- }
- }
- }
-});
diff --git a/scripts/build/build.js b/scripts/build/build.js
index ad5c9fca8..e99f2ef9f 100644
--- a/scripts/build/build.js
+++ b/scripts/build/build.js
@@ -29,7 +29,7 @@ function fitTerminal(input) {
const columns = Math.min(process.stdout.columns || 40, 80);
const WIDTH = columns - stringWidth(OK) + 1;
if (input.length < WIDTH) {
- input += Array(WIDTH - input.length).join(chalk.dim("."));
+ input += new Array(WIDTH - input.length).join(chalk.dim("."));
}
return input;
}
@@ -77,7 +77,6 @@ async function cacheFiles() {
async function preparePackage() {
const pkg = await util.readJson("package.json");
pkg.bin = "./bin-prettier.js";
- pkg.engines.node = ">=4";
delete pkg.dependencies;
delete pkg.devDependencies;
pkg.scripts = {
@@ -99,7 +98,7 @@ async function run(params) {
await execa("rm", ["-rf", ".cache"]);
}
- const bundleCache = new Cache(".cache/", "v19");
+ const bundleCache = new Cache(".cache/", "v20");
await bundleCache.load();
console.log(chalk.inverse(" Building packages "));
diff --git a/scripts/build/bundler.js b/scripts/build/bundler.js
index 7cdc86387..8af0ef60e 100644
--- a/scripts/build/bundler.js
+++ b/scripts/build/bundler.js
@@ -47,7 +47,7 @@ function getBabelConfig(bundle) {
require.resolve("./babel-plugins/transform-custom-require")
);
}
- const targets = { node: 4 };
+ const targets = { node: "10" };
if (bundle.target === "universal") {
// From https://jamie.build/last-2-versions
targets.browsers = [">0.25%", "not ie 11", "not op_mini all"];
diff --git a/scripts/build/config.js b/scripts/build/config.js
index 1a00fd073..acfc0ef22 100644
--- a/scripts/build/config.js
+++ b/scripts/build/config.js
@@ -2,9 +2,6 @@
const path = require("path");
const PROJECT_ROOT = path.resolve(__dirname, "../..");
-const babelReplaceArrayIncludesWithIndexof = require.resolve(
- "./babel-plugins/replace-array-includes-with-indexof"
-);
/**
* @typedef {Object} Bundle
@@ -29,8 +26,7 @@ const babelReplaceArrayIncludesWithIndexof = require.resolve(
const parsers = [
{
input: "src/language-js/parser-babylon.js",
- target: "universal",
- babelPlugins: [babelReplaceArrayIncludesWithIndexof]
+ target: "universal"
},
{
input: "src/language-js/parser-flow.js",
@@ -40,7 +36,6 @@ const parsers = [
{
input: "src/language-js/parser-typescript.js",
target: "universal",
- babelPlugins: [babelReplaceArrayIncludesWithIndexof],
replace: {
'require("@microsoft/typescript-etw")': "undefined"
}
@@ -130,8 +125,7 @@ const parsers = [
replacement: require.resolve("lines-and-columns")
}
]
- },
- babelPlugins: [babelReplaceArrayIncludesWithIndexof]
+ }
}
].map(parser => {
const name = getFileOutput(parser)
diff --git a/scripts/release/steps/check-git-status.js b/scripts/release/steps/check-git-status.js
index 779addb83..94f27da3c 100644
--- a/scripts/release/steps/check-git-status.js
+++ b/scripts/release/steps/check-git-status.js
@@ -6,7 +6,7 @@ module.exports = async function() {
const status = await execa.stdout("git", ["status", "--porcelain"]);
if (status) {
- throw Error(
+ throw new Error(
"Uncommitted local changes. " +
"Please revert or commit all local changes before making a release."
);
diff --git a/scripts/release/steps/generate-bundles.js b/scripts/release/steps/generate-bundles.js
index 2b96073b7..16051f512 100644
--- a/scripts/release/steps/generate-bundles.js
+++ b/scripts/release/steps/generate-bundles.js
@@ -8,7 +8,7 @@ module.exports = async function({ version }) {
const builtPkg = await readJson("dist/package.json");
if (builtPkg.version !== version) {
- throw Error(
+ throw new Error(
`Expected ${version} in dist/package.json but found ${builtPkg.version}`
);
}
diff --git a/scripts/release/steps/install-dependencies.js b/scripts/release/steps/install-dependencies.js
index 07c5be28d..89453c081 100644
--- a/scripts/release/steps/install-dependencies.js
+++ b/scripts/release/steps/install-dependencies.js
@@ -9,7 +9,7 @@ async function install() {
const status = await execa.stdout("git", ["ls-files", "-m"]);
if (status) {
- throw Error(
+ throw new Error(
"The lockfile needs to be updated, commit it before making the release."
);
}
diff --git a/scripts/release/steps/update-changelog.js b/scripts/release/steps/update-changelog.js
index d45d5b1b1..b0a61210e 100644
--- a/scripts/release/steps/update-changelog.js
+++ b/scripts/release/steps/update-changelog.js
@@ -10,8 +10,8 @@ const { waitForEnter } = require("../utils");
function getBlogPostInfo(version) {
const date = new Date();
const year = date.getFullYear();
- const month = new String(date.getMonth() + 1).padStart(2, "0");
- const day = new String(date.getDate()).padStart(2, "0");
+ const month = String(date.getMonth() + 1).padStart(2, "0");
+ const day = String(date.getDate()).padStart(2, "0");
return {
file: `website/blog/${year}-${month}-${day}-${version}.md`,
diff --git a/scripts/release/steps/validate-new-version.js b/scripts/release/steps/validate-new-version.js
index 3f529c0be..65b5323bf 100644
--- a/scripts/release/steps/validate-new-version.js
+++ b/scripts/release/steps/validate-new-version.js
@@ -5,10 +5,12 @@ const semver = require("semver");
module.exports = async function({ version, previousVersion }) {
if (!semver.valid(version)) {
- throw Error(`Invalid version specified`);
+ throw new Error(`Invalid version specified`);
}
if (!semver.gt(version, previousVersion)) {
- throw Error(`Version ${chalk.yellow(version)} has already been published`);
+ throw new Error(
+ `Version ${chalk.yellow(version)} has already been published`
+ );
}
};
diff --git a/scripts/release/utils.js b/scripts/release/utils.js
index 55a7d940d..833c4aa90 100644
--- a/scripts/release/utils.js
+++ b/scripts/release/utils.js
@@ -14,7 +14,7 @@ function fitTerminal(input) {
const columns = Math.min(process.stdout.columns, 80);
const WIDTH = columns - stringWidth(OK) + 1;
if (input.length < WIDTH) {
- input += Array(WIDTH - input.length).join(chalk.dim("."));
+ input += new Array(WIDTH - input.length).join(chalk.dim("."));
}
return input;
}
@@ -38,7 +38,7 @@ function runYarn(script) {
script = [script];
}
return execa("yarn", ["--silent"].concat(script)).catch(error => {
- throw Error(`\`yarn ${script}\` failed\n${error.stdout}`);
+ throw new Error(`\`yarn ${script}\` failed\n${error.stdout}`);
});
}
@@ -56,7 +56,7 @@ function waitForEnter() {
process.stdin.pause();
resolve();
} else if (key.ctrl && key.name === "c") {
- reject(Error("Process terminated by the user"));
+ reject(new Error("Process terminated by the user"));
}
}
});
diff --git a/src/cli/util.js b/src/cli/util.js
index e419a11ec..86da87ac0 100644
--- a/src/cli/util.js
+++ b/src/cli/util.js
@@ -600,8 +600,7 @@ function createUsage(context) {
const lastCategories = constant.categoryOrder.slice(-1);
const restCategories = Object.keys(groupedOptions).filter(
category =>
- firstCategories.indexOf(category) === -1 &&
- lastCategories.indexOf(category) === -1
+ !firstCategories.includes(category) && !lastCategories.includes(category)
);
const allCategories = firstCategories.concat(restCategories, lastCategories);
@@ -659,8 +658,7 @@ function createOptionUsageType(option) {
return null;
case "choice":
return `<${option.choices
- .filter(choice => choice.since !== null)
- .filter(choice => !choice.deprecated)
+ .filter(choice => !choice.deprecated && choice.since !== null)
.map(choice => choice.value)
.join("|")}>`;
default:
@@ -853,14 +851,14 @@ function createMinimistOptions(detailedOptions) {
.map(option => [option.name].concat(option.alias || []))
.reduce((a, b) => a.concat(b)),
default: detailedOptions
- .filter(option => !option.deprecated)
.filter(
option =>
- !option.forwardToApi ||
- option.name === "plugin" ||
- option.name === "plugin-search-dir"
+ !option.deprecated &&
+ (!option.forwardToApi ||
+ option.name === "plugin" ||
+ option.name === "plugin-search-dir") &&
+ option.default !== undefined
)
- .filter(option => option.default !== undefined)
.reduce(
(current, option) =>
Object.assign({ [option.name]: option.default }, current),
@@ -990,9 +988,7 @@ function updateContextArgv(context, plugins, pluginSearchDirs) {
function normalizeContextArgv(context, keys) {
const detailedOptions = !keys
? context.detailedOptions
- : context.detailedOptions.filter(
- option => keys.indexOf(option.name) !== -1
- );
+ : context.detailedOptions.filter(option => keys.includes(option.name));
const argv = !keys ? context.argv : pick(context.argv, keys);
context.argv = optionsNormalizer.normalizeCliOptions(argv, detailedOptions, {
diff --git a/src/common/create-ignorer.js b/src/common/create-ignorer.js
index 705e1c60d..8996b71d9 100644
--- a/src/common/create-ignorer.js
+++ b/src/common/create-ignorer.js
@@ -8,11 +8,12 @@ const getFileContentOrNull = require("../utils/get-file-content-or-null");
* @param {undefined | string} ignorePath
* @param {undefined | boolean} withNodeModules
*/
-function createIgnorer(ignorePath, withNodeModules) {
- return (!ignorePath
- ? Promise.resolve(null)
- : getFileContentOrNull(path.resolve(ignorePath))
- ).then(ignoreContent => _createIgnorer(ignoreContent, withNodeModules));
+async function createIgnorer(ignorePath, withNodeModules) {
+ const ignoreContent = ignorePath
+ ? await getFileContentOrNull(path.resolve(ignorePath))
+ : null;
+
+ return _createIgnorer(ignoreContent, withNodeModules);
}
/**
diff --git a/src/common/get-file-info.js b/src/common/get-file-info.js
index ca7b9f0cd..688a98252 100644
--- a/src/common/get-file-info.js
+++ b/src/common/get-file-info.js
@@ -19,24 +19,21 @@ const path = require("path");
* not an object. A transformation from this array to an object is automatically done
* internally by the method wrapper. See withPlugins() in index.js.
*/
-function getFileInfo(filePath, opts) {
+async function getFileInfo(filePath, opts) {
if (typeof filePath !== "string") {
- return Promise.reject(
- new TypeError(
- `expect \`filePath\` to be a string, got \`${typeof filePath}\``
- )
+ throw new TypeError(
+ `expect \`filePath\` to be a string, got \`${typeof filePath}\``
);
}
- return createIgnorer(opts.ignorePath, opts.withNodeModules).then(ignorer =>
- _getFileInfo({
- ignorer,
- filePath: normalizeFilePath(filePath, opts.ignorePath),
- plugins: opts.plugins,
- resolveConfig: opts.resolveConfig,
- sync: false
- })
- );
+ const ignorer = await createIgnorer(opts.ignorePath, opts.withNodeModules);
+ return _getFileInfo({
+ ignorer,
+ filePath: normalizeFilePath(filePath, opts.ignorePath),
+ plugins: opts.plugins,
+ resolveConfig: opts.resolveConfig,
+ sync: false
+ });
}
/**
diff --git a/src/common/util.js b/src/common/util.js
index 9f13f83c6..4a5667bda 100644
--- a/src/common/util.js
+++ b/src/common/util.js
@@ -64,7 +64,7 @@ function skip(chars) {
if (!chars.test(c)) {
return cursor;
}
- } else if (chars.indexOf(c) === -1) {
+ } else if (!chars.includes(c)) {
return cursor;
}
diff --git a/src/config/resolve-config.js b/src/config/resolve-config.js
index 0c27eed05..a1c47eabf 100644
--- a/src/config/resolve-config.js
+++ b/src/config/resolve-config.js
@@ -117,11 +117,10 @@ function clearCache() {
resolveEditorConfig.clearCache();
}
-function resolveConfigFile(filePath) {
+async function resolveConfigFile(filePath) {
const load = getLoadFunction({ sync: false });
- return load(filePath).then(result => {
- return result ? result.filepath : null;
- });
+ const result = await load(filePath);
+ return result ? result.filepath : null;
}
resolveConfigFile.sync = filePath => {
diff --git a/src/language-css/clean.js b/src/language-css/clean.js
index 054428ce7..fcfee341b 100644
--- a/src/language-css/clean.js
+++ b/src/language-css/clean.js
@@ -63,9 +63,9 @@ function clean(ast, newObj, parent) {
if (
(ast.type === "value-word" &&
((ast.isColor && ast.isHex) ||
- ["initial", "inherit", "unset", "revert"].indexOf(
+ ["initial", "inherit", "unset", "revert"].includes(
newObj.value.replace().toLowerCase()
- ) !== -1)) ||
+ ))) ||
ast.type === "media-feature" ||
ast.type === "selector-root-invalid" ||
ast.type === "selector-pseudo"
@@ -140,7 +140,7 @@ function clean(ast, newObj, parent) {
if (ast.type === "selector-tag") {
const lowercasedValue = ast.value.toLowerCase();
- if (["from", "to"].indexOf(lowercasedValue) !== -1) {
+ if (["from", "to"].includes(lowercasedValue)) {
newObj.value = lowercasedValue;
}
}
diff --git a/src/language-css/parser-postcss.js b/src/language-css/parser-postcss.js
index 447a8593e..d0e2287c4 100644
--- a/src/language-css/parser-postcss.js
+++ b/src/language-css/parser-postcss.js
@@ -442,7 +442,7 @@ function parseNestedCSS(node, options) {
"return",
"define-mixin",
"add-mixin"
- ].indexOf(name) !== -1
+ ].includes(name)
) {
// Remove unnecessary spaces in SCSS variable arguments
params = params.replace(/(\$\S+?)\s+?\.\.\./, "$1...");
@@ -465,7 +465,7 @@ function parseNestedCSS(node, options) {
return node;
}
- if (["media", "custom-media"].indexOf(lowercasedName) !== -1) {
+ if (["media", "custom-media"].includes(lowercasedName)) {
if (params.includes("#{")) {
// Workaround for media at rule with scss interpolation
return {
diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js
index b2b57ab00..8b3f7f7c0 100644
--- a/src/language-css/printer-postcss.js
+++ b/src/language-css/printer-postcss.js
@@ -118,7 +118,7 @@ function genericPrint(path, options, print) {
const rawText = node.raws.text || node.text;
// Workaround a bug where the location is off.
// https://github.com/postcss/postcss-scss/issues/63
- if (text.indexOf(rawText) === -1) {
+ if (!text.includes(rawText)) {
if (node.raws.inline) {
return concat(["// ", rawText]);
}
@@ -512,7 +512,7 @@ function genericPrint(path, options, print) {
// Ignore escape `\`
if (
iNode.value &&
- iNode.value.indexOf("\\") !== -1 &&
+ iNode.value.includes("\\") &&
iNextNode &&
iNextNode.type !== "value-comment"
) {
@@ -907,7 +907,7 @@ const STRING_REGEX = /(['"])(?:(?!\1)[^\\]|\\[\s\S])*\1/g;
const NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g;
const STANDARD_UNIT_REGEX = /[a-zA-Z]+/g;
const WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g;
-const ADJUST_NUMBERS_REGEX = RegExp(
+const ADJUST_NUMBERS_REGEX = new RegExp(
STRING_REGEX.source +
`|` +
`(${WORD_PART_REGEX.source})?` +
diff --git a/src/language-css/utils.js b/src/language-css/utils.js
index a45e666ca..cb8583448 100644
--- a/src/language-css/utils.js
+++ b/src/language-css/utils.js
@@ -35,7 +35,7 @@ function getAncestorCounter(path, typeOrTypes) {
let ancestorNode;
while ((ancestorNode = path.getParentNode(++counter))) {
- if (types.indexOf(ancestorNode.type) !== -1) {
+ if (types.includes(ancestorNode.type)) {
return counter;
}
}
@@ -67,9 +67,8 @@ function isSCSS(parser, text) {
}
function isWideKeywords(value) {
- return (
- ["initial", "inherit", "unset", "revert"].indexOf(value.toLowerCase()) !==
- -1
+ return ["initial", "inherit", "unset", "revert"].includes(
+ value.toLowerCase()
);
}
@@ -79,7 +78,7 @@ function isKeyframeAtRuleKeywords(path, value) {
atRuleAncestorNode &&
atRuleAncestorNode.name &&
atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") &&
- ["from", "to"].indexOf(value.toLowerCase()) !== -1
+ ["from", "to"].includes(value.toLowerCase())
);
}
@@ -122,7 +121,7 @@ function insideAtRuleNode(path, atRuleNameOrAtRuleNames) {
return (
atRuleAncestorNode &&
- atRuleNames.indexOf(atRuleAncestorNode.name.toLowerCase()) !== -1
+ atRuleNames.includes(atRuleAncestorNode.name.toLowerCase())
);
}
@@ -168,14 +167,13 @@ function isDetachedRulesetDeclarationNode(node) {
function isForKeywordNode(node) {
return (
node.type === "value-word" &&
- ["from", "through", "end"].indexOf(node.value) !== -1
+ ["from", "through", "end"].includes(node.value)
);
}
function isIfElseKeywordNode(node) {
return (
- node.type === "value-word" &&
- ["and", "or", "not"].indexOf(node.value) !== -1
+ node.type === "value-word" && ["and", "or", "not"].includes(node.value)
);
}
@@ -214,20 +212,19 @@ function isMathOperatorNode(node) {
}
function isEqualityOperatorNode(node) {
- return node.type === "value-word" && ["==", "!="].indexOf(node.value) !== -1;
+ return node.type === "value-word" && ["==", "!="].includes(node.value);
}
function isRelationalOperatorNode(node) {
return (
- node.type === "value-word" &&
- ["<", ">", "<=", ">="].indexOf(node.value) !== -1
+ node.type === "value-word" && ["<", ">", "<=", ">="].includes(node.value)
);
}
function isSCSSControlDirectiveNode(node) {
return (
node.type === "css-atrule" &&
- ["if", "else", "for", "each", "while"].indexOf(node.name) !== -1
+ ["if", "else", "for", "each", "while"].includes(node.name)
);
}
@@ -363,7 +360,7 @@ function isRightCurlyBraceNode(node) {
}
function isWordNode(node) {
- return ["value-word", "value-atword"].indexOf(node.type) !== -1;
+ return ["value-word", "value-atword"].includes(node.type);
}
function isColonNode(node) {
@@ -371,9 +368,7 @@ function isColonNode(node) {
}
function isMediaAndSupportsKeywords(node) {
- return (
- node.value && ["not", "and", "or"].indexOf(node.value.toLowerCase()) !== -1
- );
+ return node.value && ["not", "and", "or"].includes(node.value.toLowerCase());
}
function isColorAdjusterFuncNode(node) {
@@ -381,7 +376,7 @@ function isColorAdjusterFuncNode(node) {
return false;
}
- return colorAdjusterFunctions.indexOf(node.value.toLowerCase()) !== -1;
+ return colorAdjusterFunctions.includes(node.value.toLowerCase());
}
module.exports = {
diff --git a/src/language-graphql/printer-graphql.js b/src/language-graphql/printer-graphql.js
index 70f0df48a..8b7948804 100644
--- a/src/language-graphql/printer-graphql.js
+++ b/src/language-graphql/printer-graphql.js
@@ -653,7 +653,7 @@ function canAttachComment(node) {
function printComment(commentPath) {
const comment = commentPath.getValue();
if (comment.kind === "Comment") {
- return "#" + comment.value.trimRight();
+ return "#" + comment.value.trimEnd();
}
throw new Error("Not a comment: " + JSON.stringify(comment));
diff --git a/src/language-handlebars/printer-glimmer.js b/src/language-handlebars/printer-glimmer.js
index 55631ea7b..6fd2a9abf 100644
--- a/src/language-handlebars/printer-glimmer.js
+++ b/src/language-handlebars/printer-glimmer.js
@@ -68,7 +68,7 @@ function print(path, options, print) {
}
case "ElementNode": {
const tagFirstChar = n.tag[0];
- const isLocal = n.tag.indexOf(".") !== -1;
+ const isLocal = n.tag.includes(".");
const isGlimmerComponent =
tagFirstChar.toUpperCase() === tagFirstChar || isLocal;
const hasChildren = n.children.length > 0;
@@ -79,7 +79,7 @@ function print(path, options, print) {
const isVoid =
(isGlimmerComponent && (!hasChildren || !hasNonWhitespaceChildren)) ||
- voidTags.indexOf(n.tag) !== -1;
+ voidTags.includes(n.tag);
const closeTagForNoBreak = isVoid ? concat([" />", softline]) : ">";
const closeTagForBreak = isVoid ? "/>" : ">";
const getParams = (path, print) =>
@@ -275,7 +275,7 @@ function print(path, options, print) {
// preserve a space inside of an attribute node where whitespace present,
// when next to mustache statement.
- const inAttrNode = path.stack.indexOf("attributes") >= 0;
+ const inAttrNode = path.stack.includes("attributes");
if (inAttrNode) {
const parentNode = path.getParentNode(0);
const isConcat = parentNode.type === "ConcatStatement";
@@ -334,7 +334,7 @@ function print(path, options, print) {
);
}
case "MustacheCommentStatement": {
- const dashes = n.value.indexOf("}}") > -1 ? "--" : "";
+ const dashes = n.value.includes("}}") ? "--" : "";
return concat(["{{!", dashes, n.value, dashes, "}}"]);
}
case "PathExpression": {
diff --git a/src/language-html/printer-html.js b/src/language-html/printer-html.js
index ebf2ce56b..02e45f3a3 100644
--- a/src/language-html/printer-html.js
+++ b/src/language-html/printer-html.js
@@ -631,7 +631,7 @@ function printOpeningTag(path, options, print) {
typeof ignoreAttributeData === "boolean"
? () => ignoreAttributeData
: Array.isArray(ignoreAttributeData)
- ? attr => ignoreAttributeData.indexOf(attr.rawName) !== -1
+ ? attr => ignoreAttributeData.includes(attr.rawName)
: () => false;
return path.map(attrPath => {
const attr = attrPath.getValue();
diff --git a/src/language-html/utils.js b/src/language-html/utils.js
index 0b7827312..a923aeb8e 100644
--- a/src/language-html/utils.js
+++ b/src/language-html/utils.js
@@ -62,13 +62,13 @@ function shouldPreserveContent(node, options) {
options.parser === "vue" &&
node.type === "element" &&
node.parent.type === "root" &&
- [
+ ![
"template",
"style",
"script",
// vue parser can be used for vue dom template as well, so we should still format top-level
"html"
- ].indexOf(node.fullName) === -1
+ ].includes(node.fullName)
) {
return true;
}
@@ -272,7 +272,7 @@ function forceBreakContent(node) {
forceBreakChildren(node) ||
(node.type === "element" &&
node.children.length !== 0 &&
- (["body", "script", "style"].indexOf(node.name) !== -1 ||
+ (["body", "script", "style"].includes(node.name) ||
node.children.some(child => hasNonTextChild(child)))) ||
(node.firstChild &&
node.firstChild === node.lastChild &&
@@ -287,7 +287,7 @@ function forceBreakChildren(node) {
return (
node.type === "element" &&
node.children.length !== 0 &&
- (["html", "head", "ul", "ol", "select"].indexOf(node.name) !== -1 ||
+ (["html", "head", "ul", "ol", "select"].includes(node.name) ||
(node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell"))
);
}
@@ -339,7 +339,7 @@ function preferHardlineAsSurroundingSpaces(node) {
case "directive":
return true;
case "element":
- return ["script", "select"].indexOf(node.name) !== -1;
+ return ["script", "select"].includes(node.name);
}
return false;
}
diff --git a/src/language-js/embed.js b/src/language-js/embed.js
index 0e5454648..f556ebc4b 100644
--- a/src/language-js/embed.js
+++ b/src/language-js/embed.js
@@ -615,7 +615,7 @@ function printHtmlTemplateLiteral(
return "``";
}
- const placeholderRegex = RegExp(composePlaceholder("(\\d+)"), "g");
+ const placeholderRegex = new RegExp(composePlaceholder("(\\d+)"), "g");
const contentDoc = mapDoc(
stripTrailingHardline(textToDoc(text, { parser })),
diff --git a/src/language-js/options.js b/src/language-js/options.js
index daf365f98..f8f21ea6a 100644
--- a/src/language-js/options.js
+++ b/src/language-js/options.js
@@ -76,16 +76,17 @@ module.exports = {
type: "choice",
default: [
{ since: "0.0.0", value: false },
- { since: "0.19.0", value: "none" }
+ { since: "0.19.0", value: "none" },
+ { since: "2.0.0", value: "es5" }
],
description: "Print trailing commas wherever possible when multi-line.",
choices: [
- { value: "none", description: "No trailing commas." },
{
value: "es5",
description:
"Trailing commas where valid in ES5 (objects, arrays, etc.)"
},
+ { value: "none", description: "No trailing commas." },
{
value: "all",
description:
diff --git a/src/language-js/pragma.js b/src/language-js/pragma.js
index 6bd14660c..ca67d5cc9 100644
--- a/src/language-js/pragma.js
+++ b/src/language-js/pragma.js
@@ -4,7 +4,7 @@ const docblock = require("jest-docblock");
function hasPragma(text) {
const pragmas = Object.keys(docblock.parse(docblock.extract(text)));
- return pragmas.indexOf("prettier") !== -1 || pragmas.indexOf("format") !== -1;
+ return pragmas.includes("prettier") || pragmas.includes("format");
}
function insertPragma(text) {
diff --git a/src/language-js/preprocess.js b/src/language-js/preprocess.js
index 57489c7b7..fc39070b8 100644
--- a/src/language-js/preprocess.js
+++ b/src/language-js/preprocess.js
@@ -10,7 +10,8 @@ function preprocess(ast, options) {
return Object.assign({}, ast, {
type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
node: ast,
- comments: []
+ comments: [],
+ rootMarker: options.rootMarker
});
default:
return ast;
diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js
index 9c588dfb6..0725c2dae 100644
--- a/src/language-js/printer-estree.js
+++ b/src/language-js/printer-estree.js
@@ -120,6 +120,16 @@ const {
let uid = 0;
function shouldPrintComma(options, level) {
+ // angular does not allow trailing comma
+ if (
+ options.parser === "__ng_interpolation" ||
+ options.parser === "__ng_action" ||
+ options.parser === "__ng_binding" ||
+ options.parser === "__ng_directive"
+ ) {
+ return false;
+ }
+
level = level || "es5";
switch (options.trailingComma) {
@@ -231,7 +241,7 @@ function genericPrint(path, options, printPath, args) {
const node = path.getValue();
if (hasFlowShorthandAnnotationComment(node)) {
parts.push(" /*");
- parts.push(node.trailingComments[0].value.trimLeft());
+ parts.push(node.trailingComments[0].value.trimStart());
parts.push("*/");
node.trailingComments[0].printed = true;
}
@@ -3550,7 +3560,7 @@ function printPathNoParens(path, options, print, args) {
path.call(print, "node"),
!n.node.comments || n.node.comments.length === 0
? []
- : concat([" //", n.node.comments[0].value.trimRight()])
+ : concat([" //", n.node.comments[0].value.trimEnd()])
)
);
case "NGChainedExpression":
@@ -3899,11 +3909,11 @@ function printJestEachTemplateLiteral(node, expressions, options) {
const correspondingExpression = stringifiedExpressions[i - 1];
row.cells.push(correspondingExpression);
- if (correspondingExpression.indexOf("\n") !== -1) {
+ if (correspondingExpression.includes("\n")) {
row.hasLineBreak = true;
}
- if (node.quasis[i].value.raw.indexOf("\n") !== -1) {
+ if (node.quasis[i].value.raw.includes("\n")) {
tableBody.push({ hasLineBreak: false, cells: [] });
}
}
@@ -5388,8 +5398,12 @@ function printJSXElement(path, options, print) {
containsMultipleAttributes ||
containsMultipleExpressions;
+ const isMdxBlock = path.getParentNode().rootMarker === "mdx";
+
const rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
- const jsxWhitespace = ifBreak(concat([rawJsxWhitespace, softline]), " ");
+ const jsxWhitespace = isMdxBlock
+ ? concat([" "])
+ : ifBreak(concat([rawJsxWhitespace, softline]), " ");
const isFacebookTranslationTag =
n.openingElement &&
@@ -5404,8 +5418,7 @@ function printJSXElement(path, options, print) {
isFacebookTranslationTag
);
- const containsText =
- n.children.filter(child => isMeaningfulJSXText(child)).length > 0;
+ const containsText = n.children.some(child => isMeaningfulJSXText(child));
// We can end up we multiple whitespace elements with empty string
// content between them.
@@ -5509,6 +5522,10 @@ function printJSXElement(path, options, print) {
? fill(multilineChildren)
: group(concat(multilineChildren), { shouldBreak: true });
+ if (isMdxBlock) {
+ return content;
+ }
+
const multiLineElem = group(
concat([
openingLines,
@@ -5852,16 +5869,16 @@ function shouldHugType(node) {
n.type === "TSNullKeyword"
).length;
- const objectCount = node.types.filter(
+ const hasObject = node.types.some(
n =>
n.type === "ObjectTypeAnnotation" ||
n.type === "TSTypeLiteral" ||
// This is a bit aggressive but captures Array<{x}>
n.type === "GenericTypeAnnotation" ||
n.type === "TSTypeReference"
- ).length;
+ );
- if (node.types.length - 1 === voidCount && objectCount > 0) {
+ if (node.types.length - 1 === voidCount && hasObject) {
return true;
}
}
@@ -5987,9 +6004,9 @@ function printComment(commentPath, options) {
if (
options.originalText.slice(options.locStart(comment)).startsWith("#!")
) {
- return "#!" + comment.value.trimRight();
+ return "#!" + comment.value.trimEnd();
}
- return "//" + comment.value.trimRight();
+ return "//" + comment.value.trimEnd();
default:
throw new Error("Not a comment: " + JSON.stringify(comment));
}
@@ -6013,8 +6030,8 @@ function printIndentableBlockComment(comment) {
hardline,
lines.map((line, index) =>
index === 0
- ? line.trimRight()
- : " " + (index < lines.length - 1 ? line.trim() : line.trimLeft())
+ ? line.trimEnd()
+ : " " + (index < lines.length - 1 ? line.trim() : line.trimStart())
)
),
"*/"
diff --git a/src/language-js/utils.js b/src/language-js/utils.js
index 6fb301d56..fb51d4f2d 100644
--- a/src/language-js/utils.js
+++ b/src/language-js/utils.js
@@ -298,7 +298,7 @@ function isSimpleFlowType(node) {
return (
node &&
- flowTypeAnnotations.indexOf(node.type) !== -1 &&
+ flowTypeAnnotations.includes(node.type) &&
!(node.type === "GenericTypeAnnotation" && node.typeParameters)
);
}
diff --git a/src/language-markdown/embed.js b/src/language-markdown/embed.js
index bd5339131..29261f35e 100644
--- a/src/language-markdown/embed.js
+++ b/src/language-markdown/embed.js
@@ -57,7 +57,10 @@ function embed(path, print, textToDoc, options) {
case "importExport":
return textToDoc(node.value, { parser: "babel" });
case "jsx":
- return textToDoc(node.value, { parser: "__js_expression" });
+ return textToDoc(`<$>${node.value}$>`, {
+ parser: "__js_expression",
+ rootMarker: "mdx"
+ });
}
return null;
@@ -69,7 +72,7 @@ function embed(path, print, textToDoc, options) {
const language = supportInfo.languages.find(
language =>
language.name.toLowerCase() === lang ||
- (language.aliases && language.aliases.indexOf(lang) !== -1) ||
+ (language.aliases && language.aliases.includes(lang)) ||
(language.extensions &&
language.extensions.find(ext => ext.substring(1) === lang))
);
diff --git a/src/language-markdown/parser-markdown.js b/src/language-markdown/parser-markdown.js
index 30b0b41b0..2881da96d 100644
--- a/src/language-markdown/parser-markdown.js
+++ b/src/language-markdown/parser-markdown.js
@@ -7,7 +7,6 @@ const parseFrontMatter = require("../utils/front-matter");
const { mapAst, INLINE_NODE_WRAPPER_TYPES } = require("./utils");
const mdx = require("./mdx");
const remarkMath = require("remark-math");
-const htmlParser = require("../language-html/parser-html").parsers.html;
/**
* based on [MDAST](https://github.com/syntax-tree/mdast) with following modifications:
@@ -55,34 +54,12 @@ function htmlToJsx() {
if (
node.type !== "html" ||
node.value.match(mdx.COMMENT_REGEX) ||
- INLINE_NODE_WRAPPER_TYPES.indexOf(parent.type) !== -1
+ INLINE_NODE_WRAPPER_TYPES.includes(parent.type)
) {
return node;
}
- const nodes = htmlParser.parse(node.value).children;
-
- // find out if there are adjacent JSX elements which should be allowed in mdx alike in markdown
- if (nodes.length <= 1) {
- return Object.assign({}, node, { type: "jsx" });
- }
-
- return nodes.reduce((newNodes, { sourceSpan: position, type }) => {
- const value = node.value.slice(
- position.start.offset,
- position.end.offset
- );
-
- if (value) {
- newNodes.push({
- type: type === "element" ? "jsx" : type,
- value,
- position
- });
- }
-
- return newNodes;
- }, []);
+ return Object.assign({}, node, { type: "jsx" });
});
}
diff --git a/src/language-markdown/pragma.js b/src/language-markdown/pragma.js
index 070fb50db..4ca546c0f 100644
--- a/src/language-markdown/pragma.js
+++ b/src/language-markdown/pragma.js
@@ -19,7 +19,8 @@ function startWithPragma(text) {
module.exports = {
startWithPragma,
- hasPragma: text => startWithPragma(parseFrontMatter(text).content.trimLeft()),
+ hasPragma: text =>
+ startWithPragma(parseFrontMatter(text).content.trimStart()),
insertPragma: text => {
const extracted = parseFrontMatter(text);
const pragma = ``;
diff --git a/src/language-markdown/preprocess.js b/src/language-markdown/preprocess.js
index 08caf1e91..edeaa09fd 100644
--- a/src/language-markdown/preprocess.js
+++ b/src/language-markdown/preprocess.js
@@ -120,10 +120,10 @@ function splitTextIntoSentences(ast, options) {
if (parentNode.type === "paragraph") {
if (index === 0) {
- value = value.trimLeft();
+ value = value.trimStart();
}
if (index === parentNode.children.length - 1) {
- value = value.trimRight();
+ value = value.trimEnd();
}
}
diff --git a/src/language-markdown/printer-markdown.js b/src/language-markdown/printer-markdown.js
index 16571274c..6ab4fb4cb 100644
--- a/src/language-markdown/printer-markdown.js
+++ b/src/language-markdown/printer-markdown.js
@@ -25,7 +25,7 @@ const {
} = require("../doc");
const {
getFencedCodeBlockValue,
- getOrderedListItemInfo,
+ hasGitDiffFriendlyOrderedList,
splitText,
punctuationPattern,
INLINE_NODE_TYPES,
@@ -35,12 +35,7 @@ const { replaceEndOfLineWith } = require("../common/util");
const TRAILING_HARDLINE_NODES = ["importExport"];
const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
-const SIBLING_NODE_TYPES = [
- "listItem",
- "definition",
- "footnoteDefinition",
- "jsx"
-];
+const SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
function genericPrint(path, options, print) {
const node = path.getValue();
@@ -70,7 +65,7 @@ function genericPrint(path, options, print) {
}
return concat([
normalizeDoc(printRoot(path, options, print)),
- TRAILING_HARDLINE_NODES.indexOf(getLastDescendantNode(node).type) === -1
+ !TRAILING_HARDLINE_NODES.includes(getLastDescendantNode(node).type)
? hardline
: ""
]);
@@ -235,7 +230,7 @@ function genericPrint(path, options, print) {
const value =
parentNode.type === "root" &&
privateUtil.getLast(parentNode.children) === node
- ? node.value.trimRight()
+ ? node.value.trimEnd()
: node.value;
const isHtmlComment = /^$/.test(value);
return concat(
@@ -251,11 +246,10 @@ function genericPrint(path, options, print) {
path.getParentNode()
);
- const isGitDiffFriendlyOrderedList =
- node.ordered &&
- node.children.length > 1 &&
- +getOrderedListItemInfo(node.children[1], options.originalText)
- .numberText === 1;
+ const isGitDiffFriendlyOrderedList = hasGitDiffFriendlyOrderedList(
+ node,
+ options
+ );
return printChildren(path, options, print, {
processor: (childPath, index) => {
@@ -488,7 +482,7 @@ function getAncestorCounter(path, typeOrTypes) {
let ancestorNode;
while ((ancestorNode = path.getParentNode(++counter))) {
- if (types.indexOf(ancestorNode.type) !== -1) {
+ if (types.includes(ancestorNode.type)) {
return counter;
}
}
@@ -723,7 +717,7 @@ function printChildren(path, options, print, events) {
if (
lastChildNode &&
- TRAILING_HARDLINE_NODES.indexOf(lastChildNode.type) !== -1
+ TRAILING_HARDLINE_NODES.includes(lastChildNode.type)
) {
if (shouldPrePrintTripleHardline(childNode, data)) {
parts.push(hardline);
@@ -770,55 +764,34 @@ function isPrettierIgnore(node) {
return match === null ? false : match[1] ? match[1] : "next";
}
-function isInlineNode(node) {
- return node && INLINE_NODE_TYPES.indexOf(node.type) !== -1;
-}
-
-function isEndsWithHardLine(node) {
- return node && /\n+$/.test(node.value);
-}
-
-function last(nodes) {
- return nodes && nodes[nodes.length - 1];
-}
-
-function shouldNotPrePrintHardline(node, { parentNode, parts, prevNode }) {
- const isFirstNode = parts.length === 0;
+function shouldNotPrePrintHardline(node, data) {
+ const isFirstNode = data.parts.length === 0;
+ const isInlineNode = INLINE_NODE_TYPES.includes(node.type);
const isInlineHTML =
node.type === "html" &&
- INLINE_NODE_WRAPPER_TYPES.indexOf(parentNode.type) !== -1;
+ INLINE_NODE_WRAPPER_TYPES.includes(data.parentNode.type);
- const isAfterHardlineNode =
- prevNode &&
- (isEndsWithHardLine(prevNode) ||
- isEndsWithHardLine(last(prevNode.children)));
-
- return (
- isFirstNode || isInlineNode(node) || isInlineHTML || isAfterHardlineNode
- );
+ return isFirstNode || isInlineNode || isInlineHTML;
}
-function shouldPrePrintDoubleHardline(node, { parentNode, prevNode }) {
- const prevNodeType = prevNode && prevNode.type;
- const nodeType = node.type;
+function shouldPrePrintDoubleHardline(node, data) {
+ const isSequence = (data.prevNode && data.prevNode.type) === node.type;
+ const isSiblingNode = isSequence && SIBLING_NODE_TYPES.includes(node.type);
- const isSequence = prevNodeType === nodeType;
- const isSiblingNode =
- isSequence && SIBLING_NODE_TYPES.indexOf(nodeType) !== -1;
+ const isInTightListItem =
+ data.parentNode.type === "listItem" && !data.parentNode.loose;
- const isInTightListItem = parentNode.type === "listItem" && !parentNode.loose;
- const isPrevNodeLooseListItem = prevNodeType === "listItem" && prevNode.loose;
- const isPrevNodePrettierIgnore = isPrettierIgnore(prevNode) === "next";
+ const isPrevNodeLooseListItem =
+ data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
+
+ const isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next";
const isBlockHtmlWithoutBlankLineBetweenPrevHtml =
- nodeType === "html" &&
- prevNodeType === "html" &&
- prevNode.position.end.line + 1 === node.position.start.line;
-
- const isJsxInlineSibling =
- (prevNodeType === "jsx" && isInlineNode(node)) ||
- (nodeType === "jsx" && isInlineNode(prevNode));
+ node.type === "html" &&
+ data.prevNode &&
+ data.prevNode.type === "html" &&
+ data.prevNode.position.end.line + 1 === node.position.start.line;
return (
isPrevNodeLooseListItem ||
@@ -826,8 +799,7 @@ function shouldPrePrintDoubleHardline(node, { parentNode, prevNode }) {
isSiblingNode ||
isInTightListItem ||
isPrevNodePrettierIgnore ||
- isBlockHtmlWithoutBlankLineBetweenPrevHtml ||
- isJsxInlineSibling
+ isBlockHtmlWithoutBlankLineBetweenPrevHtml
)
);
}
diff --git a/src/language-markdown/utils.js b/src/language-markdown/utils.js
index 702c7ccb7..dd1f00528 100644
--- a/src/language-markdown/utils.js
+++ b/src/language-markdown/utils.js
@@ -162,6 +162,34 @@ function getOrderedListItemInfo(orderListItem, originalText) {
return { numberText, marker, leadingSpaces };
}
+function hasGitDiffFriendlyOrderedList(node, options) {
+ if (!node.ordered) {
+ return false;
+ }
+
+ if (node.children.length < 2) {
+ return false;
+ }
+
+ const firstNumber = Number(
+ getOrderedListItemInfo(node.children[0], options.originalText).numberText
+ );
+
+ const secondNumber = Number(
+ getOrderedListItemInfo(node.children[1], options.originalText).numberText
+ );
+
+ if (firstNumber === 0 && node.children.length > 2) {
+ const thirdNumber = Number(
+ getOrderedListItemInfo(node.children[2], options.originalText).numberText
+ );
+
+ return secondNumber === 1 && thirdNumber === 1;
+ }
+
+ return secondNumber === 1;
+}
+
// workaround for https://github.com/remarkjs/remark/issues/351
// leading and trailing newlines are stripped by remark
function getFencedCodeBlockValue(node, originalText) {
@@ -202,21 +230,11 @@ function mapAst(ast, handler) {
return (function preorder(node, index, parentStack) {
parentStack = parentStack || [];
- let newNode = handler(node, index, parentStack);
- if (Array.isArray(newNode)) {
- return newNode;
- }
-
- newNode = Object.assign({}, newNode);
+ const newNode = Object.assign({}, handler(node, index, parentStack));
if (newNode.children) {
- newNode.children = newNode.children.reduce((nodes, child, index) => {
- let newNodes = preorder(child, index, [newNode].concat(parentStack));
- if (!Array.isArray(newNodes)) {
- newNodes = [newNodes];
- }
- nodes.push.apply(nodes, newNodes);
- return nodes;
- }, []);
+ newNode.children = newNode.children.map((child, index) => {
+ return preorder(child, index, [newNode].concat(parentStack));
+ });
}
return newNode;
@@ -229,6 +247,7 @@ module.exports = {
punctuationPattern,
getFencedCodeBlockValue,
getOrderedListItemInfo,
+ hasGitDiffFriendlyOrderedList,
INLINE_NODE_TYPES,
INLINE_NODE_WRAPPER_TYPES
};
diff --git a/src/language-yaml/printer-yaml.js b/src/language-yaml/printer-yaml.js
index 96d757a2b..8ab01f211 100644
--- a/src/language-yaml/printer-yaml.js
+++ b/src/language-yaml/printer-yaml.js
@@ -670,7 +670,7 @@ function isAbsolutelyPrintedAsSingleLineNode(node, options) {
switch (options.proseWrap) {
case "never":
- return node.value.indexOf("\n") === -1;
+ return !node.value.includes("\n");
case "always":
return !/[\n ]/.test(node.value);
// istanbul ignore next
diff --git a/src/language-yaml/utils.js b/src/language-yaml/utils.js
index 4a1e8d74c..7a562f0bd 100644
--- a/src/language-yaml/utils.js
+++ b/src/language-yaml/utils.js
@@ -22,7 +22,7 @@ function isNode(value, types) {
return (
value &&
typeof value.type === "string" &&
- (!types || types.indexOf(value.type) !== -1)
+ (!types || types.includes(value.type))
);
}
@@ -198,8 +198,8 @@ function getFlowScalarLineContents(nodeType, content, options) {
: index !== 0 && index !== lineContents.length - 1
? lineContent.trim()
: index === 0
- ? lineContent.trimRight()
- : lineContent.trimLeft()
+ ? lineContent.trimEnd()
+ : lineContent.trimStart()
);
if (options.proseWrap === "preserve") {
diff --git a/src/main/core.js b/src/main/core.js
index 0f37afe6a..7c2cc6e63 100644
--- a/src/main/core.js
+++ b/src/main/core.js
@@ -60,7 +60,7 @@ function attachComments(text, ast, opts) {
comments.attach(astComments, ast, text, opts);
}
ast.tokens = [];
- opts.originalText = opts.parser === "yaml" ? text : text.trimRight();
+ opts.originalText = opts.parser === "yaml" ? text : text.trimEnd();
return astComments;
}
@@ -90,7 +90,7 @@ function coreFormat(text, opts, addAlignmentSize) {
opts.endOfLine === "lf"
? doc
: mapDoc(doc, currentDoc =>
- typeof currentDoc === "string" && currentDoc.indexOf("\n") !== -1
+ typeof currentDoc === "string" && currentDoc.includes("\n")
? currentDoc.replace(/\n/g, eol)
: currentDoc
),
@@ -167,7 +167,7 @@ function coreFormat(text, opts, addAlignmentSize) {
let cursorOffset = newCursorNodeStart;
for (const entry of cursorNodeDiff) {
if (entry.removed) {
- if (entry.value.indexOf(CURSOR) > -1) {
+ if (entry.value.includes(CURSOR)) {
break;
}
} else {
@@ -221,7 +221,7 @@ function formatRange(text, opts) {
// Since the range contracts to avoid trailing whitespace,
// we need to remove the newline that was inserted by the `format` call.
- const rangeTrimmed = rangeResult.formatted.trimRight();
+ const rangeTrimmed = rangeResult.formatted.trimEnd();
const rangeLeft = text.slice(0, rangeStart);
const rangeRight = text.slice(rangeEnd);
@@ -293,7 +293,7 @@ function format(text, opts) {
const hasRangeEnd = opts.rangeEnd < text.length;
// get rid of CR/CRLF parsing
- if (text.indexOf("\r") !== -1) {
+ if (text.includes("\r")) {
const offsetKeys = [
hasCursor && "cursorOffset",
hasRangeStart && "rangeStart",
@@ -372,7 +372,7 @@ module.exports = {
parse(text, opts, massage) {
opts = normalizeOptions(opts);
- if (text.indexOf("\r") !== -1) {
+ if (text.includes("\r")) {
text = text.replace(/\r\n?/g, "\n");
}
const parsed = parser.parse(text, opts);
diff --git a/src/main/massage-ast.js b/src/main/massage-ast.js
index 4d06c81aa..3bfeb2828 100644
--- a/src/main/massage-ast.js
+++ b/src/main/massage-ast.js
@@ -2,7 +2,7 @@
function massageAST(ast, options, parent) {
if (Array.isArray(ast)) {
- return ast.map(e => massageAST(e, options, parent)).filter(e => e);
+ return ast.map(e => massageAST(e, options, parent)).filter(Boolean);
}
if (!ast || typeof ast !== "object") {
diff --git a/src/main/options-normalizer.js b/src/main/options-normalizer.js
index a46a579df..73c8eb695 100644
--- a/src/main/options-normalizer.js
+++ b/src/main/options-normalizer.js
@@ -26,7 +26,7 @@ class FlagSchema extends vnopts.ChoiceSchema {
if (
typeof value === "string" &&
value.length !== 0 &&
- this._flags.indexOf(value) === -1
+ !this._flags.includes(value)
) {
const suggestion = this._flags.find(flag => leven(flag, value) < 3);
if (suggestion) {
@@ -57,7 +57,7 @@ function normalizeOptions(
? vnopts.levenUnknownHandler
: Array.isArray(passThrough)
? (key, value) =>
- passThrough.indexOf(key) === -1 ? undefined : { [key]: value }
+ !passThrough.includes(key) ? undefined : { [key]: value }
: (key, value) => ({ [key]: value });
const descriptor = isCLI ? cliDescriptor : vnopts.apiDescriptor;
diff --git a/src/main/options.js b/src/main/options.js
index 0e01509c0..ebddeaa14 100644
--- a/src/main/options.js
+++ b/src/main/options.js
@@ -176,9 +176,9 @@ function inferParser(filepath, plugins) {
language.extensions.some(extension => filename.endsWith(extension))) ||
(language.filenames &&
language.filenames.find(name => name.toLowerCase() === filename)) ||
- (filename.indexOf(".") === -1 &&
+ (!filename.includes(".") &&
language.interpreters &&
- language.interpreters.indexOf(getInterpreter(filepath)) !== -1))
+ language.interpreters.includes(getInterpreter(filepath))))
);
return language && language.parsers[0];
diff --git a/src/main/range-util.js b/src/main/range-util.js
index ac80f89bd..657a52f97 100644
--- a/src/main/range-util.js
+++ b/src/main/range-util.js
@@ -138,11 +138,11 @@ function isSourceElement(opts, node) {
case "flow":
case "babel":
case "typescript":
- return jsSourceElements.indexOf(node.type) > -1;
+ return jsSourceElements.includes(node.type);
case "json":
- return jsonSourceElements.indexOf(node.type) > -1;
+ return jsonSourceElements.includes(node.type);
case "graphql":
- return graphqlSourceElements.indexOf(node.kind) > -1;
+ return graphqlSourceElements.includes(node.kind);
case "vue":
return node.tag !== "root";
}
diff --git a/src/main/support.js b/src/main/support.js
index 15c428064..a8cfaf3f4 100644
--- a/src/main/support.js
+++ b/src/main/support.js
@@ -36,8 +36,7 @@ function getSupportInfo(version, opts) {
"name"
)
.sort((a, b) => (a.name === b.name ? 0 : a.name < b.name ? -1 : 1))
- .filter(filterSince)
- .filter(filterDeprecated)
+ .filter(option => filterSince(option) && filterDeprecated(option))
.map(mapDeprecated)
.map(mapInternal)
.map(option => {
@@ -56,8 +55,7 @@ function getSupportInfo(version, opts) {
if (Array.isArray(newOption.choices)) {
newOption.choices = newOption.choices
- .filter(filterSince)
- .filter(filterDeprecated)
+ .filter(option => filterSince(option) && filterDeprecated(option))
.map(mapDeprecated);
}
@@ -96,7 +94,7 @@ function getSupportInfo(version, opts) {
}
// "babylon" was renamed to "babel" in 1.16.0
- if (useBabylonParser && language.parsers.indexOf("babel") !== -1) {
+ if (useBabylonParser && language.parsers.includes("babel")) {
return Object.assign({}, language, {
parsers: language.parsers.map(parser =>
parser === "babel" ? "babylon" : parser
diff --git a/tests/angular_component_examples/__snapshots__/jsfmt.spec.js.snap b/tests/angular_component_examples/__snapshots__/jsfmt.spec.js.snap
index 6fcbdffec..21ae6bd3d 100644
--- a/tests/angular_component_examples/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/angular_component_examples/__snapshots__/jsfmt.spec.js.snap
@@ -4,6 +4,7 @@ exports[`test.component.ts 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
+trailingComma: "none"
| printWidth
=====================================input======================================
@Component({
@@ -52,7 +53,6 @@ exports[`test.component.ts 2`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
-trailingComma: "es5"
| printWidth
=====================================input======================================
@Component({
diff --git a/tests/angular_component_examples/jsfmt.spec.js b/tests/angular_component_examples/jsfmt.spec.js
index ecbf77cc1..69598203b 100644
--- a/tests/angular_component_examples/jsfmt.spec.js
+++ b/tests/angular_component_examples/jsfmt.spec.js
@@ -1,2 +1,2 @@
+run_spec(__dirname, ["typescript"], { trailingComma: "none" });
run_spec(__dirname, ["typescript"]);
-run_spec(__dirname, ["typescript"], { trailingComma: "es5" });
diff --git a/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap b/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap
index 6a5d630a4..5bc48f0b1 100644
--- a/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap
@@ -3,6 +3,27 @@
exports[`logical-expression.ng 1`] = `
====================================options=====================================
parsers: ["__ng_interpolation"]
+printWidth: 80
+trailingComma: "none"
+ | printWidth
+=====================================input======================================
+[
+ advancedSearchService.patientInformationFieldsRow2 && advancedSearchService.patientInformationFieldsRow2.indexOf(advancedSearchService.formElementData.customFieldList[i].customFieldType) !== -1
+]
+
+=====================================output=====================================
+[
+ advancedSearchService.patientInformationFieldsRow2 &&
+ advancedSearchService.patientInformationFieldsRow2.indexOf(
+ advancedSearchService.formElementData.customFieldList[i].customFieldType
+ ) !== -1
+]
+================================================================================
+`;
+
+exports[`logical-expression.ng 2`] = `
+====================================options=====================================
+parsers: ["__ng_interpolation"]
printWidth: 80
| printWidth
=====================================input======================================
@@ -20,9 +41,97 @@ printWidth: 80
================================================================================
`;
+exports[`logical-expression.ng 3`] = `
+====================================options=====================================
+parsers: ["__ng_interpolation"]
+printWidth: 80
+trailingComma: "all"
+ | printWidth
+=====================================input======================================
+[
+ advancedSearchService.patientInformationFieldsRow2 && advancedSearchService.patientInformationFieldsRow2.indexOf(advancedSearchService.formElementData.customFieldList[i].customFieldType) !== -1
+]
+
+=====================================output=====================================
+[
+ advancedSearchService.patientInformationFieldsRow2 &&
+ advancedSearchService.patientInformationFieldsRow2.indexOf(
+ advancedSearchService.formElementData.customFieldList[i].customFieldType
+ ) !== -1
+]
+================================================================================
+`;
+
exports[`pipe-expression.ng 1`] = `
====================================options=====================================
parsers: ["__ng_interpolation"]
+printWidth: 80
+trailingComma: "none"
+ | printWidth
+=====================================input======================================
+[
+ a ? (b | c : d) : (e | f : g),
+ a | b | c | d,
+ ((a | b) | c) | d,
+ a | b:(c | d),
+ { a: b | c },
+ (a + b) | c,
+ (a | b) + c,
+ fn(a | b),
+ a?.b(c | d),
+ a[b | c],
+ ($students | async).items,
+ ($students | async)(),
+ myData | myPipe:'arg1':'arg2':'arg3',
+ value
+ | pipeA: {
+ keyA: reallySuperLongValue,
+ keyB: shortValue | pipeB | pipeC: valueToPipeC
+ } : {
+ keyA: reallySuperLongValue,
+ keyB: shortValue | pipeB | pipeC: valueToPipeC
+ }
+ | aaa,
+ (hideLinqPanel ? "ReportSelection.HideShowLabel_Show.String" : "ReportSelection.HideShowLabel_Hide.String") | localize:(localizationSection)
+]
+
+=====================================output=====================================
+[
+ a ? (b | c: d) : (e | f: g),
+ a | b | c | d,
+ a | b | c | d,
+ a | b: (c | d),
+ { a: b | c },
+ a + b | c,
+ (a | b) + c,
+ fn(a | b),
+ a?.b(c | d),
+ a[b | c],
+ ($students | async).items,
+ ($students | async)(),
+ myData | myPipe: "arg1":"arg2":"arg3",
+ value
+ | pipeA
+ : {
+ keyA: reallySuperLongValue,
+ keyB: shortValue | pipeB | pipeC: valueToPipeC
+ }
+ : {
+ keyA: reallySuperLongValue,
+ keyB: shortValue | pipeB | pipeC: valueToPipeC
+ }
+ | aaa,
+ (hideLinqPanel
+ ? "ReportSelection.HideShowLabel_Show.String"
+ : "ReportSelection.HideShowLabel_Hide.String"
+ ) | localize: localizationSection
+]
+================================================================================
+`;
+
+exports[`pipe-expression.ng 2`] = `
+====================================options=====================================
+parsers: ["__ng_interpolation"]
printWidth: 80
| printWidth
=====================================input======================================
@@ -85,3 +194,70 @@ printWidth: 80
]
================================================================================
`;
+
+exports[`pipe-expression.ng 3`] = `
+====================================options=====================================
+parsers: ["__ng_interpolation"]
+printWidth: 80
+trailingComma: "all"
+ | printWidth
+=====================================input======================================
+[
+ a ? (b | c : d) : (e | f : g),
+ a | b | c | d,
+ ((a | b) | c) | d,
+ a | b:(c | d),
+ { a: b | c },
+ (a + b) | c,
+ (a | b) + c,
+ fn(a | b),
+ a?.b(c | d),
+ a[b | c],
+ ($students | async).items,
+ ($students | async)(),
+ myData | myPipe:'arg1':'arg2':'arg3',
+ value
+ | pipeA: {
+ keyA: reallySuperLongValue,
+ keyB: shortValue | pipeB | pipeC: valueToPipeC
+ } : {
+ keyA: reallySuperLongValue,
+ keyB: shortValue | pipeB | pipeC: valueToPipeC
+ }
+ | aaa,
+ (hideLinqPanel ? "ReportSelection.HideShowLabel_Show.String" : "ReportSelection.HideShowLabel_Hide.String") | localize:(localizationSection)
+]
+
+=====================================output=====================================
+[
+ a ? (b | c: d) : (e | f: g),
+ a | b | c | d,
+ a | b | c | d,
+ a | b: (c | d),
+ { a: b | c },
+ a + b | c,
+ (a | b) + c,
+ fn(a | b),
+ a?.b(c | d),
+ a[b | c],
+ ($students | async).items,
+ ($students | async)(),
+ myData | myPipe: "arg1":"arg2":"arg3",
+ value
+ | pipeA
+ : {
+ keyA: reallySuperLongValue,
+ keyB: shortValue | pipeB | pipeC: valueToPipeC
+ }
+ : {
+ keyA: reallySuperLongValue,
+ keyB: shortValue | pipeB | pipeC: valueToPipeC
+ }
+ | aaa,
+ (hideLinqPanel
+ ? "ReportSelection.HideShowLabel_Show.String"
+ : "ReportSelection.HideShowLabel_Hide.String"
+ ) | localize: localizationSection
+]
+================================================================================
+`;
diff --git a/tests/angular_interpolation/jsfmt.spec.js b/tests/angular_interpolation/jsfmt.spec.js
index 09a639b7b..62daf3216 100644
--- a/tests/angular_interpolation/jsfmt.spec.js
+++ b/tests/angular_interpolation/jsfmt.spec.js
@@ -1 +1,3 @@
+run_spec(__dirname, ["__ng_interpolation"], { trailingComma: "none" });
run_spec(__dirname, ["__ng_interpolation"]);
+run_spec(__dirname, ["__ng_interpolation"], { trailingComma: "all" });
diff --git a/tests/arrays/__snapshots__/jsfmt.spec.js.snap b/tests/arrays/__snapshots__/jsfmt.spec.js.snap
index 235a17c3d..dbef45d26 100644
--- a/tests/arrays/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/arrays/__snapshots__/jsfmt.spec.js.snap
@@ -110,17 +110,17 @@ printWidth: 80
[
[0, 1],
[0, 1],
- [0, 1]
+ [0, 1],
];
[[], [1, 2, 3]];
[[1], [1]];
[
[1, 2],
- [1, 2, 3]
+ [1, 2, 3],
];
[
[1, 0],
- [1, 0]
+ [1, 0],
];
[{}];
[{}, {}];
@@ -138,11 +138,11 @@ printWidth: 80
[{ a, b }, { a }, { a }];
[
{ a, b },
- { a, b }
+ { a, b },
];
[
{ a, b },
- { a, b, c }
+ { a, b, c },
];
================================================================================
diff --git a/tests/arrows/__snapshots__/jsfmt.spec.js.snap b/tests/arrows/__snapshots__/jsfmt.spec.js.snap
index 6ee696948..c8de85468 100644
--- a/tests/arrows/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/arrows/__snapshots__/jsfmt.spec.js.snap
@@ -609,7 +609,7 @@ Seq(typeDef.interface.groups).forEach(group =>
Seq(group.members).forEach((member, memberName) =>
markdownDoc(member.doc, {
typePath: typePath.concat(memberName.slice(1)),
- signatures: member.signatures
+ signatures: member.signatures,
})
)
);
@@ -640,7 +640,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
- )
+ ),
})
}
/>
@@ -656,7 +656,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
- )
+ ),
})
}
/>
@@ -672,7 +672,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
- )
+ ),
})
}
/>
@@ -698,7 +698,7 @@ foo(
({
a,
- b
+ b,
}) => {}
);
@@ -711,7 +711,7 @@ foo(
({
a,
- b
+ b,
}) => {}
);
@@ -719,7 +719,7 @@ foo(
({
a,
- b
+ b,
}) => a
);
@@ -732,8 +732,8 @@ foo(
a: {
a,
- b
- }
+ b,
+ },
}) => {}
);
@@ -743,9 +743,9 @@ foo(
b: {
c,
- d
- }
- }
+ d,
+ },
+ },
}) => {}
);
@@ -756,10 +756,10 @@ foo(
c: {
d,
- e
- }
- }
- }
+ e,
+ },
+ },
+ },
}) => {}
);
@@ -768,8 +768,8 @@ foo(
a: {
a,
- b
- }
+ b,
+ },
}) => a
);
@@ -779,9 +779,9 @@ foo(
b: {
c,
- d
- }
- }
+ d,
+ },
+ },
}) => a
);
@@ -792,10 +792,10 @@ foo(
c: {
d,
- e
- }
- }
- }
+ e,
+ },
+ },
+ },
}) => a
);
@@ -807,11 +807,11 @@ foo(
c: {
d,
- e
- }
- }
- }
- }
+ e,
+ },
+ },
+ },
+ },
]) => {}
);
@@ -823,10 +823,10 @@ foo(
c: {
d,
- e
- }
- }
- }
+ e,
+ },
+ },
+ },
}
]) => {}
);
@@ -839,10 +839,10 @@ foo(
c: {
d,
- e
- }
- }
- }
+ e,
+ },
+ },
+ },
}
) => {}
);
@@ -853,9 +853,9 @@ foo(
{
a,
- b
- }
- ]
+ b,
+ },
+ ],
}) => {}
);
@@ -865,8 +865,8 @@ foo(
{
a,
- b
- }
+ b,
+ },
]
) => a
);
@@ -877,9 +877,9 @@ foo(
{
a,
- b
- }
- ]
+ b,
+ },
+ ],
]) => {}
);
@@ -895,13 +895,13 @@ foo(
d: {
e,
- f
- }
- }
- }
- ]
- ]
- ]
+ f,
+ },
+ },
+ },
+ ],
+ ],
+ ],
]) => {}
);
@@ -910,7 +910,7 @@ foo(
...{
a,
- b
+ b,
}
) => {}
);
@@ -921,8 +921,8 @@ foo(
{
a,
- b
- }
+ b,
+ },
]
) => {}
);
@@ -933,8 +933,8 @@ foo(
{
a,
- b
- }
+ b,
+ },
]
]) => {}
);
@@ -945,8 +945,8 @@ foo(
{
a,
- b
- }
+ b,
+ },
]
) => {}
);
@@ -956,7 +956,7 @@ foo(
a = (({
a,
- b
+ b,
}) => {})()
) => {}
);
@@ -966,7 +966,7 @@ foo(
a = f({
a,
- b
+ b,
})
) => {}
);
@@ -976,7 +976,7 @@ foo(
a = ({
a,
- b
+ b,
}) => {}
) => {}
);
@@ -987,7 +987,7 @@ foo(
f({
a,
- b
+ b,
})
) => {}
);
@@ -1406,7 +1406,7 @@ Seq(typeDef.interface.groups).forEach((group) =>
Seq(group.members).forEach((member, memberName) =>
markdownDoc(member.doc, {
typePath: typePath.concat(memberName.slice(1)),
- signatures: member.signatures
+ signatures: member.signatures,
})
)
);
@@ -1437,7 +1437,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
- )
+ ),
})
}
/>
@@ -1453,7 +1453,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
- )
+ ),
})
}
/>
@@ -1469,7 +1469,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
- )
+ ),
})
}
/>
@@ -1495,7 +1495,7 @@ foo(
({
a,
- b
+ b,
}) => {}
);
@@ -1508,7 +1508,7 @@ foo(
({
a,
- b
+ b,
}) => {}
);
@@ -1516,7 +1516,7 @@ foo(
({
a,
- b
+ b,
}) => a
);
@@ -1529,8 +1529,8 @@ foo(
a: {
a,
- b
- }
+ b,
+ },
}) => {}
);
@@ -1540,9 +1540,9 @@ foo(
b: {
c,
- d
- }
- }
+ d,
+ },
+ },
}) => {}
);
@@ -1553,10 +1553,10 @@ foo(
c: {
d,
- e
- }
- }
- }
+ e,
+ },
+ },
+ },
}) => {}
);
@@ -1565,8 +1565,8 @@ foo(
a: {
a,
- b
- }
+ b,
+ },
}) => a
);
@@ -1576,9 +1576,9 @@ foo(
b: {
c,
- d
- }
- }
+ d,
+ },
+ },
}) => a
);
@@ -1589,10 +1589,10 @@ foo(
c: {
d,
- e
- }
- }
- }
+ e,
+ },
+ },
+ },
}) => a
);
@@ -1604,11 +1604,11 @@ foo(
c: {
d,
- e
- }
- }
- }
- }
+ e,
+ },
+ },
+ },
+ },
]) => {}
);
@@ -1620,10 +1620,10 @@ foo(
c: {
d,
- e
- }
- }
- }
+ e,
+ },
+ },
+ },
}
]) => {}
);
@@ -1636,10 +1636,10 @@ foo(
c: {
d,
- e
- }
- }
- }
+ e,
+ },
+ },
+ },
}
) => {}
);
@@ -1650,9 +1650,9 @@ foo(
{
a,
- b
- }
- ]
+ b,
+ },
+ ],
}) => {}
);
@@ -1662,8 +1662,8 @@ foo(
{
a,
- b
- }
+ b,
+ },
]
) => a
);
@@ -1674,9 +1674,9 @@ foo(
{
a,
- b
- }
- ]
+ b,
+ },
+ ],
]) => {}
);
@@ -1692,13 +1692,13 @@ foo(
d: {
e,
- f
- }
- }
- }
- ]
- ]
- ]
+ f,
+ },
+ },
+ },
+ ],
+ ],
+ ],
]) => {}
);
@@ -1707,7 +1707,7 @@ foo(
...{
a,
- b
+ b,
}
) => {}
);
@@ -1718,8 +1718,8 @@ foo(
{
a,
- b
- }
+ b,
+ },
]
) => {}
);
@@ -1730,8 +1730,8 @@ foo(
{
a,
- b
- }
+ b,
+ },
]
]) => {}
);
@@ -1742,8 +1742,8 @@ foo(
{
a,
- b
- }
+ b,
+ },
]
) => {}
);
@@ -1753,7 +1753,7 @@ foo(
a = (({
a,
- b
+ b,
}) => {})()
) => {}
);
@@ -1763,7 +1763,7 @@ foo(
a = f({
a,
- b
+ b,
})
) => {}
);
@@ -1773,7 +1773,7 @@ foo(
a = ({
a,
- b
+ b,
}) => {}
) => {}
);
@@ -1784,7 +1784,7 @@ foo(
f({
a,
- b
+ b,
})
) => {}
);
@@ -1852,7 +1852,7 @@ export const bem = block =>
".",
css(block),
element ? \`__\${css(element)}\` : "",
- modifier ? \`--\${css(modifier)}\` : ""
+ modifier ? \`--\${css(modifier)}\` : "",
].join("");
".",
css(block),
element ? \`__\${css(element)}\` : "",
- modifier ? \`--\${css(modifier)}\` : ""
+ modifier ? \`--\${css(modifier)}\` : "",
].join("");
{
message: "test",
messageType: "SMS",
status: "Unknown",
- created: "11/01/2017 13:36"
+ created: "11/01/2017 13:36",
});
};
@@ -2109,7 +2109,7 @@ const foo = () => {
message: "test",
messageType: "SMS",
status: "Unknown",
- created: "11/01/2017 13:36"
+ created: "11/01/2017 13:36",
});
};
diff --git a/tests/assignment/__snapshots__/jsfmt.spec.js.snap b/tests/assignment/__snapshots__/jsfmt.spec.js.snap
index 7ad60db40..7f17be2c1 100644
--- a/tests/assignment/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/assignment/__snapshots__/jsfmt.spec.js.snap
@@ -51,14 +51,14 @@ let {
bottom: offsetBottom,
left: offsetLeft,
right: offsetRight,
- top: offsetTop
+ top: offsetTop,
} = getPressRectOffset == null ? DEFAULT_PRESS_RECT : getPressRectOffset();
const {
accessibilityModule: FooAccessibilityModule,
accessibilityModule: FooAccessibilityModule2,
accessibilityModule: FooAccessibilityModule3,
- accessibilityModule: FooAccessibilityModule4
+ accessibilityModule: FooAccessibilityModule4,
} = foo || {};
({ prop: toAssign = "default" } = { prop: "propval" });
diff --git a/tests/binary-expressions/__snapshots__/jsfmt.spec.js.snap b/tests/binary-expressions/__snapshots__/jsfmt.spec.js.snap
index f6b34ef95..7f120df44 100644
--- a/tests/binary-expressions/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/binary-expressions/__snapshots__/jsfmt.spec.js.snap
@@ -38,7 +38,7 @@ function f() {
entity.isInstallAvailable() &&
!entity.isQueue() &&
entity.isDisabled() && {
- id: entity.id
+ id: entity.id,
}
);
}
@@ -459,7 +459,7 @@ prevState = prevState || {
loadState: LOADED,
opened: false,
searchQuery: "",
- selectedCatalog: null
+ selectedCatalog: null,
};
prevState = prevState ||
@@ -468,7 +468,7 @@ prevState = prevState ||
loadState: LOADED,
opened: false,
searchQuery: "",
- selectedCatalog: null
+ selectedCatalog: null,
};
prevState =
@@ -478,7 +478,7 @@ prevState =
loadState: LOADED,
opened: false,
searchQuery: "",
- selectedCatalog: null
+ selectedCatalog: null,
});
prevState = prevState ||
@@ -487,14 +487,14 @@ prevState = prevState ||
loadState: LOADED,
opened: false,
searchQuery: "",
- selectedCatalog: null
+ selectedCatalog: null,
};
this.steps = steps || [
{
name: "mock-module",
- path: "/nux/mock-module"
- }
+ path: "/nux/mock-module",
+ },
];
this.steps =
@@ -502,15 +502,15 @@ this.steps =
(checkStep && [
{
name: "mock-module",
- path: "/nux/mock-module"
- }
+ path: "/nux/mock-module",
+ },
]);
this.steps = (steps && checkStep) || [
{
name: "mock-module",
- path: "/nux/mock-module"
- }
+ path: "/nux/mock-module",
+ },
];
const create = () => {
@@ -520,7 +520,7 @@ const create = () => {
result.ok && {
status: "ok",
createdAt: result.createdAt,
- updatedAt: result.updatedAt
+ updatedAt: result.updatedAt,
}
);
};
@@ -531,7 +531,7 @@ const create = () => {
(shouldReturn && result.ok && result) || {
status: "ok",
createdAt: result.createdAt,
- updatedAt: result.updatedAt
+ updatedAt: result.updatedAt,
}
);
};
@@ -540,12 +540,12 @@ const obj = {
state: shouldHaveState &&
stateIsOK && {
loadState: LOADED,
- opened: false
+ opened: false,
},
loadNext: (stateIsOK && hasNext) || {
- skipNext: true
+ skipNext: true,
},
- loaded: true
+ loaded: true,
};
================================================================================
@@ -611,7 +611,7 @@ printWidth: 80
!isJellyfishEnabled &&
diffUpdateMessageInput && {
fontSize: 14,
- color: "#fff"
+ color: "#fff",
}
}
/>;
diff --git a/tests/break-calls/__snapshots__/jsfmt.spec.js.snap b/tests/break-calls/__snapshots__/jsfmt.spec.js.snap
index 033f231d7..c3c7d27b9 100644
--- a/tests/break-calls/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/break-calls/__snapshots__/jsfmt.spec.js.snap
@@ -189,7 +189,7 @@ function helloWorld() {
props.value,
props.value,
props.value,
- props.value
+ props.value,
]);
}
@@ -210,7 +210,7 @@ function helloWorldWithReact() {
props.value,
props.value,
props.value,
- props.value
+ props.value,
]);
}
diff --git a/tests/classes/__snapshots__/jsfmt.spec.js.snap b/tests/classes/__snapshots__/jsfmt.spec.js.snap
index 2ed9a8969..24bc14877 100644
--- a/tests/classes/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/classes/__snapshots__/jsfmt.spec.js.snap
@@ -88,7 +88,7 @@ class InMemoryAppender extends log4javascript.Appender
implements ICachedLogMessageProvider {}
class Foo extends Immutable.Record({
- ipaddress: ""
+ ipaddress: "",
}) {
ipaddress: string;
}
@@ -197,7 +197,7 @@ class C {
}
({
- name /*comment*/() {}
+ name /*comment*/() {},
});
================================================================================
@@ -258,7 +258,7 @@ class B {
this.props.foofoofoofoofoofoo && this.props.barbarbarbar;
someInstanceProperty2 = {
- foo: this.props.foofoofoofoofoofoo && this.props.barbarbarbar
+ foo: this.props.foofoofoofoofoofoo && this.props.barbarbarbar,
};
someInstanceProperty3 = "foo";
diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap
index 099b640e1..b9f83a6fd 100644
--- a/tests/comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap
@@ -37,7 +37,7 @@ const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
let {
- d = b //comment
+ d = b, //comment
} = c;
================================================================================
@@ -61,7 +61,7 @@ const foo = {
a: "a" /* comment for this line */,
/* Section B */
- b: "b"
+ b: "b",
};
================================================================================
@@ -527,20 +527,20 @@ export /* comment */{};
const foo = "";
export {
- foo // comment
+ foo, // comment
};
const bar = "";
export {
// comment
- bar
+ bar,
};
const fooo = "";
const barr = "";
export {
fooo, // comment
- barr // comment
+ barr, // comment
};
================================================================================
@@ -702,7 +702,7 @@ const obj = {
f1 /* f */() {},
f2(/* args */) {},
f3() /* returns */ {},
- f4 /* f */(/* args */) /* returns */ {}
+ f4 /* f */(/* args */) /* returns */ {},
};
(function f /* f */() {})();
@@ -1022,7 +1022,7 @@ function f(
// not one before and one after.
throw new ProcessSystemError({
code: acc.error.code, // Alias of errno
- originalError: acc.error // Just in case.
+ originalError: acc.error, // Just in case.
});
// Adding a comment stops the pretty printing process and everything is
@@ -1030,30 +1030,30 @@ throw new ProcessSystemError({
export type BuckWebSocketMessage =
| {
// Not actually from Buck - this is to let the receiver know that the socket is connected.
- type: "SocketConnected"
+ type: "SocketConnected",
}
| {
type: "BuildProgressUpdated",
- progressValue: number
+ progressValue: number,
}
| {
type: "BuildFinished",
- exitCode: number
+ exitCode: number,
}
| {
- type: "BuildStarted"
+ type: "BuildStarted",
}
| {
- type: "ParseStarted"
+ type: "ParseStarted",
}
| {
- type: "ParseFinished"
+ type: "ParseFinished",
}
| {
- type: "RunStarted"
+ type: "RunStarted",
}
| {
- type: "RunComplete"
+ type: "RunComplete",
};
// Missing one level of indentation because of the comment
@@ -1069,7 +1069,7 @@ const rootEpic = (actions, store) =>
export type AsyncExecuteOptions = child_process$execFileOpts & {
// The contents to write to stdin.
stdin?: ?string,
- dontLogInNuclide?: ?boolean
+ dontLogInNuclide?: ?boolean,
};
// optional trailing comma gets moved all the way to the beginning
@@ -1571,7 +1571,7 @@ var x = {
sectionMetaData: SectionMetaData
/* $FlowFixMe This error was exposed while converting keyMirror
* to keyMirrorRecursive */
- ): $Enum {}
+ ): $Enum {},
};
class X2 {
@@ -2231,7 +2231,7 @@ const CONNECTION_STATUS = (exports.CONNECTION_STATUS = {
CLOSED: Object.freeze({ kind: "CLOSED" }),
CONNECTED: Object.freeze({ kind: "CONNECTED" }),
CONNECTING: Object.freeze({ kind: "CONNECTING" }),
- NOT_CONNECTED: Object.freeze({ kind: "NOT_CONNECTED" })
+ NOT_CONNECTED: Object.freeze({ kind: "NOT_CONNECTED" }),
});
/* A comment */
@@ -2374,23 +2374,23 @@ const foo3 = 123
let obj1 =
// Comment
{
- key: "val"
+ key: "val",
};
let obj2 =
// Comment
{
- key: "val"
+ key: "val",
};
let obj3 = {
// Comment
- key: "val"
+ key: "val",
};
let obj4 = {
// Comment
- key: "val"
+ key: "val",
};
let obj5 =
@@ -2403,12 +2403,12 @@ let obj6 =
let obj7 = [
// Comment
- "val"
+ "val",
];
let obj8 = [
// Comment
- "val"
+ "val",
];
let obj9 =
diff --git a/tests/comments_closure_typecast/__snapshots__/jsfmt.spec.js.snap b/tests/comments_closure_typecast/__snapshots__/jsfmt.spec.js.snap
index 109e446fe..d4df30ce9 100644
--- a/tests/comments_closure_typecast/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments_closure_typecast/__snapshots__/jsfmt.spec.js.snap
@@ -86,7 +86,7 @@ let inlineComment = /* some comment */ someReallyLongFunctionCall(
);
let object = {
- key: /* some comment */ someReallyLongFunctionCall(withLots, ofArguments)
+ key: /* some comment */ someReallyLongFunctionCall(withLots, ofArguments),
};
// preserve parens only for type casts
@@ -138,7 +138,7 @@ const style = /** @type {{
}} */ ({
width,
height,
- ...margins
+ ...margins,
});
const style2 = /**
@@ -146,7 +146,7 @@ const style2 = /**
* width: number,
* }}
*/ ({
- width
+ width,
});
// Spaces aren't necessary
diff --git a/tests/css_atrule/__snapshots__/jsfmt.spec.js.snap b/tests/css_atrule/__snapshots__/jsfmt.spec.js.snap
index 62029906e..242282b7e 100644
--- a/tests/css_atrule/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/css_atrule/__snapshots__/jsfmt.spec.js.snap
@@ -2584,29 +2584,20 @@ a {
@include section-type-1(
$header: (
margin: 0 0 $margin-base,
- text-align: left
+ text-align: left,
),
$decoration: (
type: base,
margin: 0 auto -1px 0,
primary-color: $brand-primary,
- secondary-color: $gray-light
+ secondary-color: $gray-light,
),
$title: (
margin: 0 0 $margin-small,
color: false,
font-size: $font-size-h3,
font-weight: false,
- line-height: $line-height-h3
- )
- );
-}
-
-a {
- @include item-spotlight-properties-transition(
- "-title",
- (
- box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15)
+ line-height: $line-height-h3,
)
);
}
@@ -2616,7 +2607,16 @@ a {
"-title",
(
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15),
- border-color: $brand-primary
+ )
+ );
+}
+
+a {
+ @include item-spotlight-properties-transition(
+ "-title",
+ (
+ box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15),
+ border-color: $brand-primary,
)
);
}
@@ -2627,7 +2627,7 @@ a {
(
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15),
border-color:
- $very-very-very-very-very-very-very-very-very-very-very-very-very-long-value
+ $very-very-very-very-very-very-very-very-very-very-very-very-very-long-value,
)
);
}
diff --git a/tests/css_scss/__snapshots__/jsfmt.spec.js.snap b/tests/css_scss/__snapshots__/jsfmt.spec.js.snap
index fc75d517c..e4d1b17e3 100644
--- a/tests/css_scss/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/css_scss/__snapshots__/jsfmt.spec.js.snap
@@ -4,6 +4,7 @@ exports[`import_comma.scss 1`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
+trailingComma: "none"
| printWidth
=====================================input======================================
@import "rounded-corners", "text-shadow";
@@ -18,7 +19,6 @@ exports[`import_comma.scss 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
-trailingComma: "es5"
| printWidth
=====================================input======================================
@import "rounded-corners", "text-shadow";
@@ -33,6 +33,7 @@ exports[`scss.scss 1`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
+trailingComma: "none"
| printWidth
=====================================input======================================
@media #{$g-breakpoint-tiny} {}
@@ -2055,7 +2056,6 @@ exports[`scss.scss 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
-trailingComma: "es5"
| printWidth
=====================================input======================================
@media #{$g-breakpoint-tiny} {}
diff --git a/tests/css_scss/jsfmt.spec.js b/tests/css_scss/jsfmt.spec.js
index 548d429d8..f2558a4a9 100644
--- a/tests/css_scss/jsfmt.spec.js
+++ b/tests/css_scss/jsfmt.spec.js
@@ -1,2 +1,2 @@
+run_spec(__dirname, ["scss"], { trailingComma: "none" });
run_spec(__dirname, ["scss"]);
-run_spec(__dirname, ["scss"], { trailingComma: "es5" });
diff --git a/tests/css_trailing_comma/__snapshots__/jsfmt.spec.js.snap b/tests/css_trailing_comma/__snapshots__/jsfmt.spec.js.snap
index 95cde73f2..387b0efa0 100644
--- a/tests/css_trailing_comma/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/css_trailing_comma/__snapshots__/jsfmt.spec.js.snap
@@ -4,6 +4,7 @@ exports[`at-rules.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
+trailingComma: "none"
| printWidth
=====================================input======================================
a {
@@ -79,7 +80,6 @@ exports[`at-rules.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
-trailingComma: "es5"
| printWidth
=====================================input======================================
a {
@@ -155,6 +155,7 @@ exports[`declaration.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
+trailingComma: "none"
| printWidth
=====================================input======================================
a {
@@ -173,7 +174,6 @@ exports[`declaration.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
-trailingComma: "es5"
| printWidth
=====================================input======================================
a {
@@ -192,6 +192,7 @@ exports[`list.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
+trailingComma: "none"
| printWidth
=====================================input======================================
$colors: hotpink deepskyblue firebrick,;
@@ -297,7 +298,6 @@ exports[`list.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
-trailingComma: "es5"
| printWidth
=====================================input======================================
$colors: hotpink deepskyblue firebrick,;
@@ -403,6 +403,7 @@ exports[`map.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
+trailingComma: "none"
| printWidth
=====================================input======================================
$map: (
@@ -447,7 +448,6 @@ exports[`map.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
-trailingComma: "es5"
| printWidth
=====================================input======================================
$map: (
@@ -492,6 +492,7 @@ exports[`selector_list.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
+trailingComma: "none"
| printWidth
=====================================input======================================
asdasldaskdhjkashdahsdkjahskdjhakjsdkjahsdhkasdhkajsdhakjsdhkajsdhjkahskjdkjahsjkdjkakjsdm,
@@ -523,7 +524,6 @@ exports[`selector_list.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
-trailingComma: "es5"
| printWidth
=====================================input======================================
asdasldaskdhjkashdahsdkjahskdjhakjsdkjahsdhkasdhkajsdhakjsdhkajsdhjkahskjdkjahsjkdjkakjsdm,
@@ -555,6 +555,7 @@ exports[`variable.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
+trailingComma: "none"
| printWidth
=====================================input======================================
$test: 1,;
@@ -572,7 +573,6 @@ exports[`variable.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
-trailingComma: "es5"
| printWidth
=====================================input======================================
$test: 1,;
diff --git a/tests/css_trailing_comma/jsfmt.spec.js b/tests/css_trailing_comma/jsfmt.spec.js
index ddf82c2c8..c9fbdf77d 100644
--- a/tests/css_trailing_comma/jsfmt.spec.js
+++ b/tests/css_trailing_comma/jsfmt.spec.js
@@ -1,2 +1,2 @@
-run_spec(__dirname, ["css"]);
-run_spec(__dirname, ["scss"], { trailingComma: "es5" });
+run_spec(__dirname, ["css"], { trailingComma: "none" });
+run_spec(__dirname, ["scss"]);
diff --git a/tests/decorators-ts/__snapshots__/jsfmt.spec.js.snap b/tests/decorators-ts/__snapshots__/jsfmt.spec.js.snap
index 898ab7e2f..a71428437 100644
--- a/tests/decorators-ts/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/decorators-ts/__snapshots__/jsfmt.spec.js.snap
@@ -68,7 +68,7 @@ export class HeroButtonComponent {
selector: "toh-hero-button",
template: \`
{{ label }}
- \`
+ \`,
})
export class HeroButtonComponent {
@Output() change = new EventEmitter();
diff --git a/tests/decorators/__snapshots__/jsfmt.spec.js.snap b/tests/decorators/__snapshots__/jsfmt.spec.js.snap
index c62a7faa8..0043aa91f 100644
--- a/tests/decorators/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/decorators/__snapshots__/jsfmt.spec.js.snap
@@ -91,7 +91,7 @@ var x = 100;
@Hello({
a: "a", // Comment is in the wrong place
// test
- b: "2"
+ b: "2",
})
class X {}
@@ -103,8 +103,8 @@ class X {}
// App modules.
CoreModule,
- SharedModule
- ]
+ SharedModule,
+ ],
})
export class AppModule {}
@@ -324,14 +324,14 @@ const dog = {
@readonly
@nonenumerable
@doubledValue
- eyes: 2
+ eyes: 2,
};
const foo = {
@multipleDecorators
@inline
@theyWontAllFitInOneline
- aVeryLongPropName: "A very long string as value"
+ aVeryLongPropName: "A very long string as value",
};
================================================================================
diff --git a/tests/destructuring/__snapshots__/jsfmt.spec.js.snap b/tests/destructuring/__snapshots__/jsfmt.spec.js.snap
index ba16e29d9..36f112ae8 100644
--- a/tests/destructuring/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/destructuring/__snapshots__/jsfmt.spec.js.snap
@@ -58,14 +58,14 @@ a = ([s = 1]) => 1;
const { children, ...props } = this.props;
const {
- user: { firstName, lastName }
+ user: { firstName, lastName },
} = this.props;
const {
name: { first, last },
organisation: {
- address: { street: orgStreetAddress, postcode: orgPostcode }
- }
+ address: { street: orgStreetAddress, postcode: orgPostcode },
+ },
} = user;
function f({ data: { name } }) {}
@@ -73,8 +73,8 @@ function f({ data: { name } }) {}
const UserComponent = function({
name: { first, last },
organisation: {
- address: { street: orgStreetAddress, postcode: orgPostcode }
- }
+ address: { street: orgStreetAddress, postcode: orgPostcode },
+ },
}) {
return;
};
@@ -83,7 +83,7 @@ const {
a,
b,
c,
- d: { e }
+ d: { e },
} = someObject;
try {
@@ -96,8 +96,8 @@ try {
// code
} catch ({
data: {
- message: { errors }
- }
+ message: { errors },
+ },
}) {
// code
}
@@ -105,7 +105,7 @@ try {
const obj = {
func(id, { blog: { title } }) {
return id + title;
- }
+ },
};
class A {
diff --git a/tests/do/__snapshots__/jsfmt.spec.js.snap b/tests/do/__snapshots__/jsfmt.spec.js.snap
index 74b5471dd..1794a10c0 100644
--- a/tests/do/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/do/__snapshots__/jsfmt.spec.js.snap
@@ -66,7 +66,7 @@ const envSpecific = {
domain: do {
if (env === "production") "https://abc.mno.com/";
else if (env === "development") "http://localhost:4000";
- }
+ },
};
let x = do {
diff --git a/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap b/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap
index f18e3604a..9196d71be 100644
--- a/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap
@@ -69,7 +69,7 @@ const obj = {
f(/* ... */) {},
f: (/* ... */) => {},
f: function(/* ... */) {},
- f: function f(/* ... */) {}
+ f: function f(/* ... */) {},
};
class Foo {
diff --git a/tests/export/__snapshots__/jsfmt.spec.js.snap b/tests/export/__snapshots__/jsfmt.spec.js.snap
index fc1d82ed2..43bc02edb 100644
--- a/tests/export/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/export/__snapshots__/jsfmt.spec.js.snap
@@ -27,7 +27,7 @@ export {
itGo,
multiLine,
andMore,
- soWeCanGetItTo80Columns
+ soWeCanGetItTo80Columns,
};
export { fitsIn, oneLine };
@@ -62,7 +62,7 @@ export {
itGo,
multiLine,
andMore,
- soWeCanGetItTo80Columns
+ soWeCanGetItTo80Columns,
};
export {fitsIn, oneLine};
diff --git a/tests/export_extension/__snapshots__/jsfmt.spec.js.snap b/tests/export_extension/__snapshots__/jsfmt.spec.js.snap
index 3f4f650ce..1cf43ab4d 100644
--- a/tests/export_extension/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/export_extension/__snapshots__/jsfmt.spec.js.snap
@@ -23,11 +23,11 @@ export c, { foo } from "mod";
export * as d, { bar } from "mod";
export { fooooooooooooooooooooooooooooooooooooooooooooooooo } from "fooooooooooooooooooooooooooooo";
export Bar, {
- barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
+ barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr,
} from "barrrrrrrrrrrrrrrrrrrrrrrrrrrr";
export {
foooooooooooooooooooooooooooooooooooooooooooooo,
- fooooooooooooooooooooooooooooooooooooooooooooooo
+ fooooooooooooooooooooooooooooooooooooooooooooooo,
} from "fooooooooooooooooooooooooooooo";
================================================================================
diff --git a/tests/exports/__snapshots__/jsfmt.spec.js.snap b/tests/exports/__snapshots__/jsfmt.spec.js.snap
index 8f1bf6388..29c751c00 100644
--- a/tests/exports/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/exports/__snapshots__/jsfmt.spec.js.snap
@@ -22,7 +22,7 @@ export {
value2 as value2_renamed,
value3,
value4 as value4_renamed,
- value5
+ value5,
} from "exports";
export a, { b } from "./baz";
diff --git a/tests/flow/annot/__snapshots__/jsfmt.spec.js.snap b/tests/flow/annot/__snapshots__/jsfmt.spec.js.snap
index 2e12dbe04..f98241fbd 100644
--- a/tests/flow/annot/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/annot/__snapshots__/jsfmt.spec.js.snap
@@ -80,7 +80,7 @@ var qux = function(str: string, i: number): number {
var obj: { str: string, i: number, j: boolean } = {
str: "...",
i: "...",
- k: false
+ k: false,
};
var arr: Array = [1, 2, "..."];
@@ -90,7 +90,7 @@ var array: number[] = [1, 2, "..."];
var matrix: number[][] = [
[1, 2],
- [3, 4]
+ [3, 4],
];
var matrix_parens: number[][] = matrix;
@@ -101,7 +101,7 @@ var array_of_nullable: (?number)[] = [null, 3];
var array_of_tuple: [number, string][] = [
[0, "foo"],
- [1, "bar"]
+ [1, "bar"],
];
var array_of_tuple_parens: [number, string][] = array_of_tuple;
@@ -127,7 +127,7 @@ function param_anno2(
return {
method: request.method,
params: request.params,
- relative_url: request.path
+ relative_url: request.path,
};
});
// ...
diff --git a/tests/flow/arith/__snapshots__/jsfmt.spec.js.snap b/tests/flow/arith/__snapshots__/jsfmt.spec.js.snap
index 013e7b4ca..2210d6018 100644
--- a/tests/flow/arith/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/arith/__snapshots__/jsfmt.spec.js.snap
@@ -187,7 +187,7 @@ let tests = [
(x + z: empty); // error, string ~> empty
(z + x: empty); // error, string ~> empty
- }
+ },
];
================================================================================
@@ -365,7 +365,7 @@ let tests = [
function(x: any, y: number, z: string) {
x > y;
x > z;
- }
+ },
];
================================================================================
diff --git a/tests/flow/arraylib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/arraylib/__snapshots__/jsfmt.spec.js.snap
index 616a5cba2..130d92dfc 100644
--- a/tests/flow/arraylib/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/arraylib/__snapshots__/jsfmt.spec.js.snap
@@ -111,7 +111,7 @@ function reduce_test() {
var flattened = [
[0, 1],
[2, 3],
- [4, 5]
+ [4, 5],
].reduce(function(a, b) {
return a.concat(b);
});
diff --git a/tests/flow/arrays/__snapshots__/jsfmt.spec.js.snap b/tests/flow/arrays/__snapshots__/jsfmt.spec.js.snap
index d2f576877..bb93e6a16 100644
--- a/tests/flow/arrays/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/arrays/__snapshots__/jsfmt.spec.js.snap
@@ -81,7 +81,7 @@ var abig2: Array<{ x: number, y: number }> = [
{ x: 0, y: 0, a: true },
{ x: 0, y: 0, b: "hey" },
{ x: 0, y: 0, c: 1 },
- { x: 0, y: 0, c: "hey" }
+ { x: 0, y: 0, c: "hey" },
];
module.exports = "arrays";
diff --git a/tests/flow/async/__snapshots__/jsfmt.spec.js.snap b/tests/flow/async/__snapshots__/jsfmt.spec.js.snap
index e0781b82d..f5a4550f4 100644
--- a/tests/flow/async/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/async/__snapshots__/jsfmt.spec.js.snap
@@ -559,17 +559,17 @@ var n = new (async function() {
var o = {
async m() {
await 1;
- }
+ },
};
var ot = {
async m(a: T) {
await 1;
- }
+ },
};
var oz = {
async async(async) {
await async;
- }
+ },
};
var x = { await: 5 };
diff --git a/tests/flow/binary/__snapshots__/jsfmt.spec.js.snap b/tests/flow/binary/__snapshots__/jsfmt.spec.js.snap
index 3a372e3d3..9e32fdb03 100644
--- a/tests/flow/binary/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/binary/__snapshots__/jsfmt.spec.js.snap
@@ -117,7 +117,7 @@ let tests = [
function(x: Object, y: mixed) {
"foo" in x; // ok
"foo" in y; // error
- }
+ },
];
================================================================================
diff --git a/tests/flow/callable/__snapshots__/jsfmt.spec.js.snap b/tests/flow/callable/__snapshots__/jsfmt.spec.js.snap
index b3a6b3ca0..8b73f94a2 100644
--- a/tests/flow/callable/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/callable/__snapshots__/jsfmt.spec.js.snap
@@ -20,7 +20,7 @@ function f(x) {
=====================================output=====================================
type F = {
(x: string): number,
- p?: string
+ p?: string,
};
function f(x) {
@@ -76,7 +76,7 @@ icall(0); // error, number ~> string
icall.call(null, 0); // error, number ~> string
type Callable = {
- (x: string): void
+ (x: string): void,
};
declare var callable: Callable;
diff --git a/tests/flow/class_statics/__snapshots__/jsfmt.spec.js.snap b/tests/flow/class_statics/__snapshots__/jsfmt.spec.js.snap
index 75fe34463..39990a863 100644
--- a/tests/flow/class_statics/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/class_statics/__snapshots__/jsfmt.spec.js.snap
@@ -132,7 +132,7 @@ module.exports = {
B: B,
C: C,
D: D,
- E: E
+ E: E,
};
================================================================================
diff --git a/tests/flow/classes/__snapshots__/jsfmt.spec.js.snap b/tests/flow/classes/__snapshots__/jsfmt.spec.js.snap
index bd7ccea15..4bc3bc97e 100644
--- a/tests/flow/classes/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/classes/__snapshots__/jsfmt.spec.js.snap
@@ -149,7 +149,7 @@ type Foo = {
a: string, // exists in TestClass
b: string, // doesn't exist
c?: ?string, // exists in TestClass, optional
- d?: number // doesn't exist
+ d?: number, // doesn't exist
};
class TestClass {
diff --git a/tests/flow/closure/__snapshots__/jsfmt.spec.js.snap b/tests/flow/closure/__snapshots__/jsfmt.spec.js.snap
index 076901bc0..8ad754b9b 100644
--- a/tests/flow/closure/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/closure/__snapshots__/jsfmt.spec.js.snap
@@ -142,7 +142,7 @@ var global_o = {
f: function() {},
g: function() {
global_y = 42;
- }
+ },
};
global_o.f();
@@ -163,7 +163,7 @@ function local_meth() {
f: function() {},
g: function() {
local_y = 42;
- }
+ },
};
local_o.f();
diff --git a/tests/flow/computed_props/__snapshots__/jsfmt.spec.js.snap b/tests/flow/computed_props/__snapshots__/jsfmt.spec.js.snap
index bbbf897cd..40e89cfdb 100644
--- a/tests/flow/computed_props/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/computed_props/__snapshots__/jsfmt.spec.js.snap
@@ -34,19 +34,19 @@ module.exports = { ColorId, ColorNumber };
var ColorId = {
RED: "R",
GREEN: "G",
- BLUE: "B"
+ BLUE: "B",
};
var ColorNumber = {
RED: "ff0000",
GREEN: "00ff00",
- BLUE: "0000ff"
+ BLUE: "0000ff",
};
var ColorIdToNumber = {
[ColorId.RED]: ColorNumber.RED,
[ColorId.GREEN]: ColorNumber.GREEN,
- [ColorId.BLUE]: ColorNumber.BLUE
+ [ColorId.BLUE]: ColorNumber.BLUE,
};
(ColorIdToNumber[ColorId.RED]: "ffffff"); // oops
@@ -80,7 +80,7 @@ var { ColorId, ColorNumber } = require("./test");
var ColorIdToNumber = {
[ColorId.RED]: ColorNumber.RED,
[ColorId.GREEN]: ColorNumber.GREEN,
- [ColorId.BLUE]: ColorNumber.BLUE
+ [ColorId.BLUE]: ColorNumber.BLUE,
};
(ColorIdToNumber[ColorId.GREEN]: "ffffff"); // oops
@@ -144,7 +144,7 @@ var dummy = require("./test");
module.exports = {
...dummy,
[hello]: "world",
- ...dummy
+ ...dummy,
};
================================================================================
@@ -183,14 +183,14 @@ var obj = {
x: 0,
m() {
return this.x;
- }
+ },
};
var x: string = obj["m"](); // error, number ~> string
var arr = [
function() {
return this.length;
- }
+ },
];
var y: string = arr[0](); // error: number ~> string
diff --git a/tests/flow/config_module_name_rewrite_haste/__snapshots__/jsfmt.spec.js.snap b/tests/flow/config_module_name_rewrite_haste/__snapshots__/jsfmt.spec.js.snap
index 1c5bca2a0..904cb4c77 100644
--- a/tests/flow/config_module_name_rewrite_haste/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/config_module_name_rewrite_haste/__snapshots__/jsfmt.spec.js.snap
@@ -60,7 +60,7 @@ module.exports = {
*/
module.exports = {
- numVal: 42
+ numVal: 42,
};
================================================================================
diff --git a/tests/flow/config_module_name_rewrite_node/__snapshots__/jsfmt.spec.js.snap b/tests/flow/config_module_name_rewrite_node/__snapshots__/jsfmt.spec.js.snap
index d2ebbabe2..186f69711 100644
--- a/tests/flow/config_module_name_rewrite_node/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/config_module_name_rewrite_node/__snapshots__/jsfmt.spec.js.snap
@@ -78,7 +78,7 @@ module.exports = {
/* @flow */
module.exports = {
- numVal: 42
+ numVal: 42,
};
================================================================================
diff --git a/tests/flow/constructor_annots/__snapshots__/jsfmt.spec.js.snap b/tests/flow/constructor_annots/__snapshots__/jsfmt.spec.js.snap
index 3011a2702..2c80a42e2 100644
--- a/tests/flow/constructor_annots/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/constructor_annots/__snapshots__/jsfmt.spec.js.snap
@@ -37,7 +37,7 @@ Foo.y = 0; // has static property y
Foo.prototype = {
m() {
return 0;
- }
+ },
};
// exporting Foo directly doesn't work
diff --git a/tests/flow/core_tests/__snapshots__/jsfmt.spec.js.snap b/tests/flow/core_tests/__snapshots__/jsfmt.spec.js.snap
index fd4ea9ff1..2c1a9bb53 100644
--- a/tests/flow/core_tests/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/core_tests/__snapshots__/jsfmt.spec.js.snap
@@ -90,7 +90,7 @@ let tests = [
Boolean(NaN);
Boolean(undefined);
Boolean("");
- }
+ },
];
================================================================================
@@ -166,7 +166,7 @@ let tests = [
function(x: Map) {
(x.get("foo"): boolean); // error, string | void
x.get(123); // error, wrong key type
- }
+ },
];
================================================================================
@@ -236,7 +236,7 @@ let tests = [
function() {
RegExp("foo", "z"); // error
new RegExp("foo", "z"); // error
- }
+ },
];
================================================================================
diff --git a/tests/flow/declare_class/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/declare_class/lib/__snapshots__/jsfmt.spec.js.snap
index 7ca26589c..cfbe46114 100644
--- a/tests/flow/declare_class/lib/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/declare_class/lib/__snapshots__/jsfmt.spec.js.snap
@@ -21,7 +21,7 @@ declare class _C {
foo(): number;
}
declare var _module: {
- C: Class<_C>
+ C: Class<_C>,
};
declare class D extends _module.C {
foo(): string;
diff --git a/tests/flow/declare_export/__snapshots__/jsfmt.spec.js.snap b/tests/flow/declare_export/__snapshots__/jsfmt.spec.js.snap
index 30e9e385d..c2255276b 100644
--- a/tests/flow/declare_export/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/declare_export/__snapshots__/jsfmt.spec.js.snap
@@ -126,7 +126,7 @@ module.exports = {
numberValue2: 2,
numberValue3: 3,
numberValue4: 4,
- numberValue5: 5
+ numberValue5: 5,
};
================================================================================
@@ -484,7 +484,7 @@ declare export {
declare export {
numberValue1,
- numberValue2 as numberValue2_renamed
+ numberValue2 as numberValue2_renamed,
} from "ES6_ExportFrom_Source1";
================================================================================
@@ -514,7 +514,7 @@ declare export {
declare export {
numberValue1,
- numberValue2 as numberValue2_renamed2
+ numberValue2 as numberValue2_renamed2,
} from "ES6_ExportFrom_Source2";
================================================================================
@@ -734,7 +734,7 @@ module.exports = {
*/
module.exports = {
- numberValue: 42
+ numberValue: 42,
};
================================================================================
@@ -1365,7 +1365,7 @@ import { specifierNumber } from "ES6_Named1"; // Error: Did you mean \`specifier
///////////////////////////////////////////////////
import {
numberValue1 as numberValue8,
- numberValue2 as numberValue9
+ numberValue2 as numberValue9,
} from "./ES6_ExportAllFromMulti";
var at1: number = numberValue8;
diff --git a/tests/flow/declare_type/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/declare_type/lib/__snapshots__/jsfmt.spec.js.snap
index 61fc535d7..87bf8bb91 100644
--- a/tests/flow/declare_type/lib/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/declare_type/lib/__snapshots__/jsfmt.spec.js.snap
@@ -69,7 +69,7 @@ declare module "foo" {
declare type Id = T;
declare var exports: {
- (a: number, b: number): number
+ (a: number, b: number): number,
};
}
diff --git a/tests/flow/destructuring/__snapshots__/jsfmt.spec.js.snap b/tests/flow/destructuring/__snapshots__/jsfmt.spec.js.snap
index 3d31ace49..37f21cab2 100644
--- a/tests/flow/destructuring/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/destructuring/__snapshots__/jsfmt.spec.js.snap
@@ -201,22 +201,22 @@ obj_rest({ p: { q: 0, r: null } });
function obj_prop_annot(
{
- p = true // error: boolean ~> string
+ p = true, // error: boolean ~> string
}: {
- p: string
+ p: string,
} = {
- p: 0 // error: number ~> string
+ p: 0, // error: number ~> string
}
) {
(p: void); // error: string ~> void
}
var {
- p = true // error: boolean ~> string
+ p = true, // error: boolean ~> string
}: {
- p: string
+ p: string,
} = {
- p: 0 // error: number ~> string
+ p: 0, // error: number ~> string
};
(p: void); // error: string ~> void
@@ -620,7 +620,7 @@ function bar() {
// @flow
var { x } = {
- x: { foo: "foo" }
+ x: { foo: "foo" },
};
function bar() {
diff --git a/tests/flow/dictionary/__snapshots__/jsfmt.spec.js.snap b/tests/flow/dictionary/__snapshots__/jsfmt.spec.js.snap
index bb54b9a0c..98d328ee5 100644
--- a/tests/flow/dictionary/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/dictionary/__snapshots__/jsfmt.spec.js.snap
@@ -57,7 +57,7 @@ function foo0(
}
function foo2(x: {
- [key: string]: number
+ [key: string]: number,
}): { [key: string]: number, +toString: () => string } {
// x's prototype has a toString method
return x;
@@ -469,7 +469,7 @@ function mix_with_declared_props(o: { [k: number]: X, p: Y }, x: X, y: Y) {
// Indeed, dict types are still Objects and have Object.prototype stuff
function object_prototype(o: {
- [k: string]: number
+ [k: string]: number,
}): { [k: string]: number, +toString: () => string } {
(o.toString(): boolean); // error: string ~> boolean
return o; // ok
@@ -480,7 +480,7 @@ function object_prototype(o: {
// write into a declared prop unsoundly.
function unsound_string_conversion_alias_declared_prop(o: {
[k: number]: any,
- "0": X
+ "0": X,
}) {
o[0] = "not-x"; // a["0"] no longer X
}
@@ -509,19 +509,19 @@ function subtype_dict_values_fresh_exception() {
let a: { [k: string]: A } = {
a: new A(), // ok, A == A
b: new B(), // ok, B <: A
- c: new C() // ok, C <: A
+ c: new C(), // ok, C <: A
};
let b: { [k: string]: B } = {
a: new A(), // error, A not <: B
b: new B(), // ok, B == B
- c: new C() // ok, C <: A
+ c: new C(), // ok, C <: A
};
let c: { [k: string]: C } = {
a: new A(), // error, A not <: C
b: new B(), // error, A not <: C
- c: new C() // ok, C == C
+ c: new C(), // ok, C == C
};
}
@@ -777,7 +777,7 @@ function foo3(x: { [key: string]: number }): { foo: number } {
// error: foo can't exist in x
function foo4(x: {
- [key: string]: number
+ [key: string]: number,
}): { [key: string]: number, foo: string } {
return x;
}
@@ -890,7 +890,7 @@ type QueryFunction = (params: Params) => string;
var o: { foo: QueryFunction } = {
foo(params) {
return params.count; // error, number ~/~ string
- }
+ },
};
module.exports = o;
diff --git a/tests/flow/disjoint-union-perf/__snapshots__/jsfmt.spec.js.snap b/tests/flow/disjoint-union-perf/__snapshots__/jsfmt.spec.js.snap
index 734f26e47..17ad46002 100644
--- a/tests/flow/disjoint-union-perf/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/disjoint-union-perf/__snapshots__/jsfmt.spec.js.snap
@@ -105,7 +105,7 @@ export type Pos = {
firstLine: number,
firstColumn: number,
lastLine: number,
- lastColumn: number
+ lastColumn: number,
};
export type TypedBinaryOpNode = {
@@ -115,7 +115,7 @@ export type TypedBinaryOpNode = {
rhs: TypedNode,
pos: Pos,
exprType: InferredType,
- typed: true
+ typed: true,
};
export type TypedUnaryMinusNode = {
@@ -123,7 +123,7 @@ export type TypedUnaryMinusNode = {
op: TypedNode,
pos: Pos,
exprType: InferredType,
- typed: true
+ typed: true,
};
export type TypedNumberNode = {
@@ -131,7 +131,7 @@ export type TypedNumberNode = {
value: number,
pos: Pos,
exprType: "number",
- typed: true
+ typed: true,
};
export type TypedStringLiteralNode = {
@@ -139,7 +139,7 @@ export type TypedStringLiteralNode = {
value: string,
pos: Pos,
exprType: "string",
- typed: true
+ typed: true,
};
export type TypedVariableNode = {
@@ -147,7 +147,7 @@ export type TypedVariableNode = {
name: string,
pos: Pos,
exprType: InferredType,
- typed: true
+ typed: true,
};
export type TypedFunctionInvocationNode = {
@@ -156,7 +156,7 @@ export type TypedFunctionInvocationNode = {
parameters: TypedNode[],
pos: Pos,
exprType: "error" | "string",
- typed: true
+ typed: true,
};
export type TypedNode =
@@ -961,18 +961,18 @@ export type Comment = {
loc: ?SourceLocation,
value: string,
leading: boolean,
- trailing: boolean
+ trailing: boolean,
};
export type SourceLocation = {
start: SourcePosition,
end: SourcePosition,
- source: ?string
+ source: ?string,
};
export type SourcePosition = {
line: number,
- column: number
+ column: number,
};
export type File = {
@@ -981,7 +981,7 @@ export type File = {
end: SourcePosition,
comments: ?Array,
type: "File",
- program: Program
+ program: Program,
};
export type Program = {
@@ -990,7 +990,7 @@ export type Program = {
end: SourcePosition,
comments: ?Array,
type: "Program",
- body: Statement[]
+ body: Statement[],
};
export type BinaryOperator =
@@ -1098,7 +1098,7 @@ export type EmptyStatement = {
start: SourcePosition,
end: SourcePosition,
comments: ?Array,
- type: "EmptyStatement"
+ type: "EmptyStatement",
};
export type BlockStatement = {
@@ -1107,7 +1107,7 @@ export type BlockStatement = {
end: SourcePosition,
comments: ?Array,
type: "BlockStatement",
- body: Statement[]
+ body: Statement[],
};
export type ExpressionStatement = {
@@ -1116,7 +1116,7 @@ export type ExpressionStatement = {
end: SourcePosition,
comments: ?Array,
type: "ExpressionStatement",
- expression: Expression
+ expression: Expression,
};
export type IfStatement = {
@@ -1127,7 +1127,7 @@ export type IfStatement = {
type: "IfStatement",
test: Expression,
consequent: Statement,
- alternate: ?Statement
+ alternate: ?Statement,
};
export type BreakStatement = {
@@ -1136,7 +1136,7 @@ export type BreakStatement = {
end: SourcePosition,
comments: ?Array,
type: "BreakStatement",
- label: ?Identifier
+ label: ?Identifier,
};
export type ContinueStatement = {
@@ -1145,7 +1145,7 @@ export type ContinueStatement = {
end: SourcePosition,
comments: ?Array,
type: "ContinueStatement",
- label: ?Identifier
+ label: ?Identifier,
};
export type ReturnStatement = {
@@ -1154,7 +1154,7 @@ export type ReturnStatement = {
end: SourcePosition,
comments: ?Array,
type: "ReturnStatement",
- argument: ?Expression
+ argument: ?Expression,
};
export type ThrowStatement = {
@@ -1163,7 +1163,7 @@ export type ThrowStatement = {
end: SourcePosition,
comments: ?Array,
type: "ThrowStatement",
- argument: ?Expression
+ argument: ?Expression,
};
export type WhileStatement = {
@@ -1173,7 +1173,7 @@ export type WhileStatement = {
comments: ?Array,
type: "WhileStatement",
test: Expression,
- body: Statement
+ body: Statement,
};
export type ForStatement = {
@@ -1185,7 +1185,7 @@ export type ForStatement = {
init: ?(VariableDeclaration | Expression),
test: ?Expression,
update: ?Expression,
- body: Statement
+ body: Statement,
};
export type ForInStatement = {
@@ -1196,7 +1196,7 @@ export type ForInStatement = {
type: "ForInStatement",
left: VariableDeclaration | Expression,
right: Expression,
- body: Statement
+ body: Statement,
};
export type TryStatement = {
@@ -1208,7 +1208,7 @@ export type TryStatement = {
block: BlockStatement,
handler: ?CatchClause,
handlers: CatchClause[],
- finalizer: ?BlockStatement
+ finalizer: ?BlockStatement,
};
export type CatchClause = {
@@ -1219,7 +1219,7 @@ export type CatchClause = {
type: "CatchClause",
param: Pattern,
guard: ?Expression,
- body: BlockStatement
+ body: BlockStatement,
};
export type Expression =
@@ -1245,7 +1245,7 @@ export type Identifier = {
end: SourcePosition,
comments: ?Array,
type: "Identifier",
- name: string
+ name: string,
};
export type Literal = {
@@ -1255,7 +1255,7 @@ export type Literal = {
comments: ?Array,
type: "Literal",
value: ?(string | boolean | number | RegExp),
- regex: ?{ pattern: string, flags: string }
+ regex: ?{ pattern: string, flags: string },
};
export type ThisExpression = {
@@ -1263,7 +1263,7 @@ export type ThisExpression = {
start: SourcePosition,
end: SourcePosition,
comments: ?Array,
- type: "ThisExpression"
+ type: "ThisExpression",
};
export type ArrayExpression = {
@@ -1272,7 +1272,7 @@ export type ArrayExpression = {
end: SourcePosition,
comments: ?Array,
type: "ArrayExpression",
- elements: Expression[]
+ elements: Expression[],
};
export type ObjectExpreession = {
@@ -1281,7 +1281,7 @@ export type ObjectExpreession = {
end: SourcePosition,
comments: ?Array,
type: "ObjectExpression",
- properties: Property[]
+ properties: Property[],
};
export type Property = {
@@ -1292,7 +1292,7 @@ export type Property = {
type: "Property",
kind: "init" | "get" | "set",
key: Literal | Identifier,
- value: Expression
+ value: Expression,
};
export type FunctionExpression = {
@@ -1303,7 +1303,7 @@ export type FunctionExpression = {
type: "FunctionExpression",
id: ?Identifier,
params: Pattern[],
- body: BlockStatement
+ body: BlockStatement,
};
export type BinaryExpression = {
@@ -1314,7 +1314,7 @@ export type BinaryExpression = {
type: "BinaryExpression",
operator: BinaryOperator,
left: Expression,
- right: Expression
+ right: Expression,
};
export type UnaryExpression = {
@@ -1325,7 +1325,7 @@ export type UnaryExpression = {
type: "UnaryExpression",
operator: UnaryOperator,
argument: Expression,
- prefix: boolean
+ prefix: boolean,
};
export type AssignmentExpression = {
@@ -1336,7 +1336,7 @@ export type AssignmentExpression = {
type: "AssignmentExpression",
operator: AssignmentOperator,
left: Pattern,
- right: Expression
+ right: Expression,
};
export type UpdateExpression = {
@@ -1347,7 +1347,7 @@ export type UpdateExpression = {
type: "UpdateExpression",
operator: UpdateOperator,
argument: Expression,
- prefix: boolean
+ prefix: boolean,
};
export type LogicalExpression = {
@@ -1358,7 +1358,7 @@ export type LogicalExpression = {
type: "LogicalExpression",
operator: LogicalOperator,
left: Expression,
- right: Expression
+ right: Expression,
};
export type ConditionalExpression = {
@@ -1369,7 +1369,7 @@ export type ConditionalExpression = {
type: "ConditionalExpression",
test: Expression,
consequent: Expression,
- alternate: Expression
+ alternate: Expression,
};
export type NewExpression = {
@@ -1379,7 +1379,7 @@ export type NewExpression = {
comments: ?Array,
type: "NewExpression",
callee: Expression,
- arguments: Expression[]
+ arguments: Expression[],
};
export type CallExpression = {
@@ -1389,7 +1389,7 @@ export type CallExpression = {
comments: ?Array,
type: "CallExpression",
callee: Expression,
- arguments: Expression[]
+ arguments: Expression[],
};
export type MemberExpression = {
@@ -1400,7 +1400,7 @@ export type MemberExpression = {
type: "MemberExpression",
object: Expression,
property: Identifier | Expression,
- computed: boolean
+ computed: boolean,
};
// ast-types exports all expressions as patterns.
// That seems not like it was intended.
@@ -1415,7 +1415,7 @@ export type VariableDeclaration = {
comments: ?Array,
type: "VariableDeclaration",
kind: "var" | "let" | "const",
- declarations: VariableDeclarator[]
+ declarations: VariableDeclarator[],
};
export type FunctionDeclaration = {
@@ -1426,7 +1426,7 @@ export type FunctionDeclaration = {
type: "FunctionDeclaration",
id: Identifier,
body: BlockStatement,
- params: Pattern[]
+ params: Pattern[],
};
export type VariableDeclarator = {
@@ -1436,7 +1436,7 @@ export type VariableDeclarator = {
comments: ?Array,
type: "VariableDeclarator",
id: Pattern,
- init: ?Expression
+ init: ?Expression,
};
const a: any = null;
@@ -1541,7 +1541,7 @@ export const builders: {
body: BlockStatement,
params: Pattern[]
): FunctionDeclaration,
- variableDeclarator(id: Pattern, init?: Expression): VariableDeclarator
+ variableDeclarator(id: Pattern, init?: Expression): VariableDeclarator,
} = a;
================================================================================
diff --git a/tests/flow/dom/__snapshots__/jsfmt.spec.js.snap b/tests/flow/dom/__snapshots__/jsfmt.spec.js.snap
index 75a42a91f..58624762c 100644
--- a/tests/flow/dom/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/dom/__snapshots__/jsfmt.spec.js.snap
@@ -32,7 +32,7 @@ let tests = [
// moveTo
function(ctx: CanvasRenderingContext2D) {
ctx.moveTo("0", "1"); // error: should be numbers
- }
+ },
];
================================================================================
@@ -62,7 +62,7 @@ let tests = [
function(document: Document) {
const event = document.createEvent("CustomEvent");
event.initCustomEvent("butts", true, false, { nice: 42 });
- }
+ },
];
================================================================================
@@ -100,7 +100,7 @@ let tests = [
(document.createElement("select"): HTMLSelectElement);
(document.querySelector("select"): HTMLSelectElement | null);
(document.createElement("hr"): HTMLElement); // GH #3752
- }
+ },
];
================================================================================
@@ -148,7 +148,7 @@ let tests = [
element.scrollIntoView({ behavior: "invalid" });
element.scrollIntoView({ block: "invalid" });
element.scrollIntoView(1);
- }
+ },
];
================================================================================
@@ -176,7 +176,7 @@ let tests = [
// getContext
function(el: HTMLCanvasElement) {
(el.getContext("2d"): ?CanvasRenderingContext2D);
- }
+ },
];
================================================================================
@@ -224,7 +224,7 @@ let tests = [
element.scrollIntoView({ behavior: "invalid" });
element.scrollIntoView({ block: "invalid" });
element.scrollIntoView(1);
- }
+ },
];
================================================================================
@@ -260,7 +260,7 @@ let tests = [
el.setRangeText("foo", 123, 234);
el.setRangeText("foo", 123, 234, "select");
el.setRangeText("foo", 123, 234, "bogus"); // invalid value
- }
+ },
];
================================================================================
@@ -374,7 +374,7 @@ let tests = [
window.onmessage = (event: MessageEvent) => {
(event.target: window);
};
- }
+ },
];
================================================================================
@@ -408,7 +408,7 @@ let tests = [
(path.arcTo(0, 0, 0, 0, 10): void); // valid
(path.arcTo(0, 0, 0, 0, 10, 20, 5): void); // valid
(path.arcTo(0, 0, 0, 0, 10, "20", 5): void); // invalid
- }
+ },
];
================================================================================
@@ -496,9 +496,9 @@ let tests = [
oldAttributeValue,
newAttributeValue,
attributeNamespace
- ) {}
- }
- })
+ ) {},
+ },
+ }),
});
},
// or with Object.assign()
@@ -513,8 +513,8 @@ let tests = [
oldAttributeValue,
newAttributeValue,
attributeNamespace
- ) {}
- })
+ ) {},
+ }),
});
},
// should complain about invalid callback parameters
@@ -526,10 +526,10 @@ let tests = [
oldVal: string, // Error: This might be null
newVal: string, // Error: This might be null
namespace: string
- ) {}
- }
+ ) {},
+ },
});
- }
+ },
];
================================================================================
@@ -930,10 +930,10 @@ let tests = [
); // valid
document.createNodeIterator(document.body, -1, node => "accept"); // invalid
document.createNodeIterator(document.body, -1, {
- acceptNode: node => NodeFilter.FILTER_ACCEPT
+ acceptNode: node => NodeFilter.FILTER_ACCEPT,
}); // valid
document.createNodeIterator(document.body, -1, {
- acceptNode: node => "accept"
+ acceptNode: node => "accept",
}); // invalid
document.createNodeIterator(document.body, -1, {}); // invalid
},
@@ -945,13 +945,13 @@ let tests = [
); // valid
document.createTreeWalker(document.body, -1, node => "accept"); // invalid
document.createTreeWalker(document.body, -1, {
- acceptNode: node => NodeFilter.FILTER_ACCEPT
+ acceptNode: node => NodeFilter.FILTER_ACCEPT,
}); // valid
document.createTreeWalker(document.body, -1, {
- acceptNode: node => "accept"
+ acceptNode: node => "accept",
}); // invalid
document.createTreeWalker(document.body, -1, {}); // invalid
- }
+ },
];
================================================================================
diff --git a/tests/flow/enumerror/__snapshots__/jsfmt.spec.js.snap b/tests/flow/enumerror/__snapshots__/jsfmt.spec.js.snap
index 0d54df5e3..8b359a7cd 100644
--- a/tests/flow/enumerror/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/enumerror/__snapshots__/jsfmt.spec.js.snap
@@ -40,8 +40,8 @@ function isActive(ad: {
state: $Keys<{
PAUSED: string,
ACTIVE: string,
- DELETED: string
- }>
+ DELETED: string,
+ }>,
}): boolean {
return ad.state === "ACTIVE";
}
@@ -50,7 +50,7 @@ isActive({ state: "PAUSE" });
var MyStates = {
PAUSED: "PAUSED",
ACTIVE: "ACTIVE",
- DELETED: "DELETED"
+ DELETED: "DELETED",
};
function isActive2(ad: { state: $Keys }): boolean {
return ad.state === MyStates.ACTIVE;
diff --git a/tests/flow/es6modules/__snapshots__/jsfmt.spec.js.snap b/tests/flow/es6modules/__snapshots__/jsfmt.spec.js.snap
index 08fc212e6..be1a4a441 100644
--- a/tests/flow/es6modules/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/es6modules/__snapshots__/jsfmt.spec.js.snap
@@ -118,7 +118,7 @@ module.exports = Object.freeze({
*/
module.exports = Object.freeze({
- numberValue1: 1
+ numberValue1: 1,
});
================================================================================
@@ -154,7 +154,7 @@ module.exports = {
numberValue2: 2,
numberValue3: 3,
numberValue4: 4,
- numberValue5: 5
+ numberValue5: 5,
};
================================================================================
@@ -578,7 +578,7 @@ export {
export {
numberValue1,
- numberValue2 as numberValue2_renamed
+ numberValue2 as numberValue2_renamed,
} from "ES6_ExportFrom_Source1";
================================================================================
@@ -608,7 +608,7 @@ export {
export {
numberValue1,
- numberValue2 as numberValue2_renamed2
+ numberValue2 as numberValue2_renamed2,
} from "ES6_ExportFrom_Source2";
================================================================================
@@ -858,7 +858,7 @@ module.exports = {
*/
module.exports = {
- numberValue: 42
+ numberValue: 42,
};
================================================================================
@@ -1518,7 +1518,7 @@ import { specifierNumber } from "ES6_Named1"; // Error: Did you mean \`specifier
///////////////////////////////////////////////////
import {
numberValue1 as numberValue8,
- numberValue2 as numberValue9
+ numberValue2 as numberValue9,
} from "./ES6_ExportAllFromMulti";
var at1: number = numberValue8;
diff --git a/tests/flow/es_declare_module/flow-typed/__snapshots__/jsfmt.spec.js.snap b/tests/flow/es_declare_module/flow-typed/__snapshots__/jsfmt.spec.js.snap
index df15de788..75c37f9f0 100644
--- a/tests/flow/es_declare_module/flow-typed/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/es_declare_module/flow-typed/__snapshots__/jsfmt.spec.js.snap
@@ -38,7 +38,7 @@ declare module "CJS_Clobbered" {
declare var num2: number;
declare type numType = number;
declare var exports: {
- numExport: number
+ numExport: number,
};
}
diff --git a/tests/flow/export_type/__snapshots__/jsfmt.spec.js.snap b/tests/flow/export_type/__snapshots__/jsfmt.spec.js.snap
index fa89e7a1a..e7818d1e3 100644
--- a/tests/flow/export_type/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/export_type/__snapshots__/jsfmt.spec.js.snap
@@ -72,7 +72,7 @@ import type {
inlinedType1,
standaloneType1,
talias1,
- talias3
+ talias3,
} from "./types_only";
var a: inlinedType1 = 42;
diff --git a/tests/flow/facebookisms/__snapshots__/jsfmt.spec.js.snap b/tests/flow/facebookisms/__snapshots__/jsfmt.spec.js.snap
index a0f8da778..d0204a912 100644
--- a/tests/flow/facebookisms/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/facebookisms/__snapshots__/jsfmt.spec.js.snap
@@ -78,7 +78,7 @@ let tests = [
(copyProperties(result, { foo: "a" }, { bar: 123 }): {
foo: string,
bar: number,
- baz: boolean
+ baz: boolean,
});
},
@@ -100,7 +100,7 @@ let tests = [
function(copyProperties: Object$Assign) {
function x(cb: Function) {}
x(copyProperties);
- }
+ },
];
================================================================================
@@ -140,7 +140,7 @@ let tests = [
let x: ?string = null;
invariant(x);
(x: string);
- }
+ },
];
================================================================================
@@ -254,7 +254,7 @@ let tests = [
function(mergeInto: $Facebookism$MergeInto) {
function x(cb: Function) {}
x(mergeInto);
- }
+ },
];
================================================================================
diff --git a/tests/flow/fetch/__snapshots__/jsfmt.spec.js.snap b/tests/flow/fetch/__snapshots__/jsfmt.spec.js.snap
index 99749677d..3c41d6ab0 100644
--- a/tests/flow/fetch/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/fetch/__snapshots__/jsfmt.spec.js.snap
@@ -47,10 +47,10 @@ const b: Promise = fetch(myRequest); // incorrect
var myInit = {
method: "GET",
headers: {
- "Content-Type": "image/jpeg"
+ "Content-Type": "image/jpeg",
},
mode: "cors",
- cache: "default"
+ cache: "default",
};
const c: Promise = fetch("image.png").then(response => response.blob()); // correct
@@ -221,10 +221,10 @@ new Request(new URL("http://example.org")); // correct
const h: Request = new Request("http://example.org", {
method: "GET",
headers: {
- "Content-Type": "image/jpeg"
+ "Content-Type": "image/jpeg",
},
mode: "cors",
- cache: "default"
+ cache: "default",
}); // correct
var bodyUsed: boolean = h.bodyUsed;
@@ -237,34 +237,34 @@ h.arrayBuffer().then((ab: Buffer) => ab); // incorrect
const i: Request = new Request("http://example.org", {
method: "POST",
headers: {
- "Content-Type": "application/octet-stream"
+ "Content-Type": "application/octet-stream",
},
- body: new ArrayBuffer(10)
+ body: new ArrayBuffer(10),
}); // correct
const j: Request = new Request("http://example.org", {
method: "POST",
headers: {
- "Content-Type": "application/octet-stream"
+ "Content-Type": "application/octet-stream",
},
- body: new Uint8Array(10)
+ body: new Uint8Array(10),
}); // correct
const k: Request = new Request("http://example.org", {
method: "POST",
headers: {
- "Content-Type": "image/jpeg"
+ "Content-Type": "image/jpeg",
},
body: new URLSearchParams("key=value"),
mode: "cors",
- cache: "default"
+ cache: "default",
}); // correct
const l: Request = new Request("http://example.org", {
method: "GET",
headers: "Content-Type: image/jpeg",
mode: "cors",
- cache: "default"
+ cache: "default",
}); // incorrect - headers is string
new Request("/", { method: "post" }); // correct
@@ -338,28 +338,28 @@ new Response("", { status: null }); // incorrect
const f: Response = new Response("responsebody", {
status: 404,
- headers: "'Content-Type': 'image/jpeg'"
+ headers: "'Content-Type': 'image/jpeg'",
}); // incorrect
const g: Response = new Response("responsebody", {
status: 404,
headers: {
- "Content-Type": "image/jpeg"
- }
+ "Content-Type": "image/jpeg",
+ },
}); // correct
const h: Response = new Response("responsebody", {
status: 404,
headers: new Headers({
- "Content-Type": "image/jpeg"
- })
+ "Content-Type": "image/jpeg",
+ }),
}); // correct, if verbose
const i: Response = new Response({
status: 404,
headers: new Headers({
- "Content-Type": "image/jpeg"
- })
+ "Content-Type": "image/jpeg",
+ }),
}); // incorrect
const ok: boolean = h.ok;
diff --git a/tests/flow/function/__snapshots__/jsfmt.spec.js.snap b/tests/flow/function/__snapshots__/jsfmt.spec.js.snap
index cdac9b498..f0eaa5ca4 100644
--- a/tests/flow/function/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/function/__snapshots__/jsfmt.spec.js.snap
@@ -173,7 +173,7 @@ let tests = [
function(x: { (a: string, b: string): void, bind(a: string): void }) {
(x.bind("foo"): void); // ok
(x.bind(123): void); // error, number !~> string
- }
+ },
];
================================================================================
@@ -411,7 +411,7 @@ let tests = [
// Non-(Function.prototype) properties on a \`Function\` type should be \`any\`
(z.foo: number);
(z.foo: string);
- }
+ },
];
// \`Function\` types can be bound (resulting in a \`Function\` type)
diff --git a/tests/flow/get-def/__snapshots__/jsfmt.spec.js.snap b/tests/flow/get-def/__snapshots__/jsfmt.spec.js.snap
index 671677e1b..497a4d3a5 100644
--- a/tests/flow/get-def/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/get-def/__snapshots__/jsfmt.spec.js.snap
@@ -106,7 +106,7 @@ module.exports = {
bar: function(): number {
return 42;
- }
+ },
};
================================================================================
diff --git a/tests/flow/get-def2/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/get-def2/lib/__snapshots__/jsfmt.spec.js.snap
index 53dbbd415..6bab10bb3 100644
--- a/tests/flow/get-def2/lib/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/get-def2/lib/__snapshots__/jsfmt.spec.js.snap
@@ -20,7 +20,7 @@ type $JSXIntrinsic = Class<$React.Component>;
type $JSXIntrinsics = {
div: $JSXIntrinsic<{ id: string }>,
- span: $JSXIntrinsic<{ id: string, class: string }>
+ span: $JSXIntrinsic<{ id: string, class: string }>,
};
================================================================================
diff --git a/tests/flow/getters_and_setters_disabled/__snapshots__/jsfmt.spec.js.snap b/tests/flow/getters_and_setters_disabled/__snapshots__/jsfmt.spec.js.snap
index 4974d7ad2..1769f05db 100644
--- a/tests/flow/getters_and_setters_disabled/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/getters_and_setters_disabled/__snapshots__/jsfmt.spec.js.snap
@@ -54,13 +54,13 @@ var f = {
get ["d"]() {
return "foo";
},
- set ["d"](x: number) {}
+ set ["d"](x: number) {},
};
type T = {
get a(): number,
set b(x: number): void,
- c: 10
+ c: 10,
};
declare class Foo {
diff --git a/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap b/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap
index 9d117c1a5..b1723bb70 100644
--- a/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap
@@ -379,7 +379,7 @@ var obj = {
set [z](x: string) {},
get [z](): string {
return string;
- }
+ },
};
// Test getting properties with getters
@@ -499,7 +499,7 @@ type T = {
set exampleOfOrderOfGetterAndSetter(x: B): void,
set exampleOfOrderOfGetterAndSetterReordered(x: B): void,
- get exampleOfOrderOfGetterAndSetterReordered(): A
+ get exampleOfOrderOfGetterAndSetterReordered(): A,
};
function test(obj: T) {
@@ -569,8 +569,8 @@ const Example = React.createClass({
set b(x: number) {
this.c = x;
},
- c: React.PropTypes.string
- }
+ c: React.PropTypes.string,
+ },
});
; // error: property \`a\` not found
diff --git a/tests/flow/import_type/__snapshots__/jsfmt.spec.js.snap b/tests/flow/import_type/__snapshots__/jsfmt.spec.js.snap
index ae07c78b8..e09bf87a9 100644
--- a/tests/flow/import_type/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/import_type/__snapshots__/jsfmt.spec.js.snap
@@ -155,13 +155,13 @@ export function givesAFoo3Obj(): AliasFoo3 {
*/
export type AliasFoo3 = {
- givesANum(): number
+ givesANum(): number,
};
export function givesAFoo3Obj(): AliasFoo3 {
return {
givesANum(): number {
return 42;
- }
+ },
};
}
diff --git a/tests/flow/import_typeof/__snapshots__/jsfmt.spec.js.snap b/tests/flow/import_typeof/__snapshots__/jsfmt.spec.js.snap
index b715c63fc..b8c34820c 100644
--- a/tests/flow/import_typeof/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/import_typeof/__snapshots__/jsfmt.spec.js.snap
@@ -175,13 +175,13 @@ export function givesAFoo3Obj(): AliasFoo3 {
*/
export type AliasFoo3 = {
- givesANum(): number
+ givesANum(): number,
};
export function givesAFoo3Obj(): AliasFoo3 {
return {
givesANum(): number {
return 42;
- }
+ },
};
}
diff --git a/tests/flow/indexer/__snapshots__/jsfmt.spec.js.snap b/tests/flow/indexer/__snapshots__/jsfmt.spec.js.snap
index ba3e11edd..d1fafacad 100644
--- a/tests/flow/indexer/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/indexer/__snapshots__/jsfmt.spec.js.snap
@@ -114,9 +114,9 @@ let tests = [
function() {
({}: {
[k1: string]: string,
- [k2: number]: number // error: not supported (yet)
+ [k2: number]: number, // error: not supported (yet)
});
- }
+ },
];
================================================================================
diff --git a/tests/flow/intersection/__snapshots__/jsfmt.spec.js.snap b/tests/flow/intersection/__snapshots__/jsfmt.spec.js.snap
index 10b6db13c..01c0d886a 100644
--- a/tests/flow/intersection/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/intersection/__snapshots__/jsfmt.spec.js.snap
@@ -103,7 +103,7 @@ type DuplexStreamOptions = ReadableStreamOptions &
WritableStreamOptions & {
allowHalfOpen?: boolean,
readableObjectMode?: boolean,
- writableObjectMode?: boolean
+ writableObjectMode?: boolean,
};
function hasObjectMode_bad(options: DuplexStreamOptions): boolean {
diff --git a/tests/flow/intersection/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/intersection/lib/__snapshots__/jsfmt.spec.js.snap
index f459e752e..fe67ca38e 100644
--- a/tests/flow/intersection/lib/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/intersection/lib/__snapshots__/jsfmt.spec.js.snap
@@ -55,13 +55,13 @@ type ObjAssignT = { foo: string } & { bar: string };
type ReadableStreamOptions = {
highWaterMark?: number,
encoding?: ?string,
- objectMode?: boolean
+ objectMode?: boolean,
};
type WritableStreamOptions = {
highWaterMark?: number,
decodeString?: boolean,
- objectMode?: boolean
+ objectMode?: boolean,
};
// used in test_fun.js
diff --git a/tests/flow/iterable/__snapshots__/jsfmt.spec.js.snap b/tests/flow/iterable/__snapshots__/jsfmt.spec.js.snap
index fa37d4bac..286e45fef 100644
--- a/tests/flow/iterable/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/iterable/__snapshots__/jsfmt.spec.js.snap
@@ -171,7 +171,7 @@ function makeIterator(coin_flip: () => boolean): Iterator {
} else {
return { done };
}
- }
+ },
};
}
@@ -188,7 +188,7 @@ function makeIterator(coin_flip: () => boolean): Iterator {
} else {
return { done }; // Error void ~> string
}
- }
+ },
};
}
diff --git a/tests/flow/jsx_intrinsics.builtin/__snapshots__/jsfmt.spec.js.snap b/tests/flow/jsx_intrinsics.builtin/__snapshots__/jsfmt.spec.js.snap
index de9eaa75c..3e7696b36 100644
--- a/tests/flow/jsx_intrinsics.builtin/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/jsx_intrinsics.builtin/__snapshots__/jsfmt.spec.js.snap
@@ -35,7 +35,7 @@ var React = require("react");
class CustomComponent extends React.Component {
props: {
- prop: string
+ prop: string,
};
}
diff --git a/tests/flow/jsx_intrinsics.custom/__snapshots__/jsfmt.spec.js.snap b/tests/flow/jsx_intrinsics.custom/__snapshots__/jsfmt.spec.js.snap
index 3d34522b5..64474b137 100644
--- a/tests/flow/jsx_intrinsics.custom/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/jsx_intrinsics.custom/__snapshots__/jsfmt.spec.js.snap
@@ -31,7 +31,7 @@ var React = require("react");
class CustomComponent extends React.Component {
props: {
- prop: string
+ prop: string,
};
}
diff --git a/tests/flow/jsx_intrinsics.custom/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/jsx_intrinsics.custom/lib/__snapshots__/jsfmt.spec.js.snap
index 53dbbd415..6bab10bb3 100644
--- a/tests/flow/jsx_intrinsics.custom/lib/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/jsx_intrinsics.custom/lib/__snapshots__/jsfmt.spec.js.snap
@@ -20,7 +20,7 @@ type $JSXIntrinsic = Class<$React.Component>;
type $JSXIntrinsics = {
div: $JSXIntrinsic<{ id: string }>,
- span: $JSXIntrinsic<{ id: string, class: string }>
+ span: $JSXIntrinsic<{ id: string, class: string }>,
};
================================================================================
diff --git a/tests/flow/keyvalue/__snapshots__/jsfmt.spec.js.snap b/tests/flow/keyvalue/__snapshots__/jsfmt.spec.js.snap
index 7a1e8cef1..390076d5f 100644
--- a/tests/flow/keyvalue/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/keyvalue/__snapshots__/jsfmt.spec.js.snap
@@ -20,7 +20,7 @@ let tests = [
let tests = [
function(x: { [key: number]: string }) {
(x[""]: number);
- }
+ },
];
================================================================================
diff --git a/tests/flow/last_duplicate_property_wins/__snapshots__/jsfmt.spec.js.snap b/tests/flow/last_duplicate_property_wins/__snapshots__/jsfmt.spec.js.snap
index 3aeea8c65..0307f81c1 100644
--- a/tests/flow/last_duplicate_property_wins/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/last_duplicate_property_wins/__snapshots__/jsfmt.spec.js.snap
@@ -97,7 +97,7 @@ const o = {
qux: 42,
qux(): string {
return "hello";
- } // last wins
+ }, // last wins
};
// check
diff --git a/tests/flow/literal/__snapshots__/jsfmt.spec.js.snap b/tests/flow/literal/__snapshots__/jsfmt.spec.js.snap
index 0e6875d23..6d49e6ddf 100644
--- a/tests/flow/literal/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/literal/__snapshots__/jsfmt.spec.js.snap
@@ -16,7 +16,7 @@ module.exports = APIKeys;
=====================================output=====================================
var APIKeys = {
AGE: "age",
- NAME: "name"
+ NAME: "name",
};
module.exports = APIKeys;
diff --git a/tests/flow/logical/__snapshots__/jsfmt.spec.js.snap b/tests/flow/logical/__snapshots__/jsfmt.spec.js.snap
index cdc9bb14a..66939ae06 100644
--- a/tests/flow/logical/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/logical/__snapshots__/jsfmt.spec.js.snap
@@ -916,7 +916,7 @@ function logical13(x: number): Array<{ x: string }> {
{ x: 1 && "bar" },
{ x: "foo" && "bar" },
{ x: "foo" && "bar" },
- { x: "foo" && "bar" }
+ { x: "foo" && "bar" },
];
}
@@ -932,7 +932,7 @@ function logical14(x: number): Array<{ x: string }> {
{ x: 0 || "bar" },
{ x: "foo" || "bar" },
{ x: "foo" || "bar" },
- { x: "foo" || "bar" }
+ { x: "foo" || "bar" },
];
}
diff --git a/tests/flow/missing_annotation/__snapshots__/jsfmt.spec.js.snap b/tests/flow/missing_annotation/__snapshots__/jsfmt.spec.js.snap
index e5a140386..74ec57481 100644
--- a/tests/flow/missing_annotation/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/missing_annotation/__snapshots__/jsfmt.spec.js.snap
@@ -121,24 +121,24 @@ var Foo = {
b: function(arg) {
// missing arg annotation
return {
- bar: arg
+ bar: arg,
};
},
c: function(arg: string) {
// no return annotation required
return {
- bar: arg
+ bar: arg,
};
},
d: function(
arg: string
): {
- bar: string
+ bar: string,
} {
return {
- bar: arg
+ bar: arg,
};
},
@@ -158,7 +158,7 @@ var Foo = {
// no error
return x;
};
- }
+ },
};
var Bar = {
@@ -170,7 +170,7 @@ var Bar = {
c: Foo.c("bar"), // no annotation required
- d: Foo.d("bar") // no annotation required
+ d: Foo.d("bar"), // no annotation required
};
(module.exports = Foo), Bar;
diff --git a/tests/flow/more_react/__snapshots__/jsfmt.spec.js.snap b/tests/flow/more_react/__snapshots__/jsfmt.spec.js.snap
index 1f9b6d610..c32b96549 100644
--- a/tests/flow/more_react/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow/more_react/__snapshots__/jsfmt.spec.js.snap
@@ -116,7 +116,7 @@ var App = React.createClass({
{foo(z, x)} // error, since z: number
);
- }
+ },
});
module.exports = App;
@@ -156,7 +156,7 @@ var React = require("react");
* react classes as initialized, when the class was created with createClass().
* This would manifest as complaining that metric requires an annotation */
var App = React.createClass({
- metrics: [1, 2, 3]
+ metrics: [1, 2, 3],
});
module.exports = App;
@@ -296,14 +296,14 @@ var React = require("React");
var C = React.createClass({
propTypes: {
- title: React.PropTypes.string.isRequired
- }
+ title: React.PropTypes.string.isRequired,
+ },
});
var D = React.createClass({
propTypes: {
name: React.PropTypes.string.isRequired,
- ...C.propTypes
- }
+ ...C.propTypes,
+ },
});