Merge branch 'main' into next

# Conflicts:
#	.github/workflows/dev-test.yml
#	jest.config.mjs
#	package.json
#	scripts/vendors/vendor-meta.json
#	scripts/vendors/vendors.mjs
#	src/cli/format.js
#	src/cli/options/create-minimist-options.js
#	src/cli/options/parse-cli-arguments.js
#	src/cli/usage.js
#	src/cli/utils.js
#	src/common/create-ignorer.js
#	src/common/load-plugins.js
#	src/config/resolve-config.js
#	src/index.js
#	src/language-css/utils/css-units.evaluate.js
#	src/language-html/ast.js
#	src/language-html/print-preprocess.js
#	src/language-html/utils/index.js
#	src/main/multiparser.js
#	tests/format/markdown/auto-link/jsfmt.spec.js
#	tests/integration/__tests__/__snapshots__/config-resolution.js.snap
#	tests/integration/__tests__/__snapshots__/with-config-precedence.js.snap
#	tests/integration/__tests__/file-info.js
#	yarn.lock
This commit is contained in:
fisker Cheung committed 2022-04-25 14:28:27 +08:00
commit a85f38f096
142 files changed
+2792 -1992

No files matched your search

+2 -2
View File
@@ -30,7 +30,7 @@ jobs:
run: yarn build
- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
@@ -50,7 +50,7 @@ jobs:
uses: actions/setup-node@v2.5.1
- name: Download Artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: dist
path: dist
+9 -8
View File
@@ -19,20 +19,21 @@ jobs:
- "macos-latest"
- "windows-latest"
node:
- "18"
- "16"
- "14"
include:
# only enable coverage on the fastest job
- os: "ubuntu-latest"
node: "16"
node: "18"
ENABLE_CODE_COVERAGE: true
FULL_TEST: true
CHECK_TEST_PARSERS: true
# exclude:
# - os: "macos-latest"
# node: "14"
# - os: "windows-latest"
# node: "14"
exclude:
- os: "macos-latest"
node: "16"
- os: "windows-latest"
node: "16"
env:
ENABLE_CODE_COVERAGE: ${{ matrix.ENABLE_CODE_COVERAGE }}
FULL_TEST: ${{ matrix.FULL_TEST }}
@@ -75,7 +76,7 @@ jobs:
run: yarn c8 yarn test:format --maxWorkers=2
- name: Upload Coverage
uses: codecov/codecov-action@v2.1.0
uses: codecov/codecov-action@v3.1.0
if: ${{ matrix.ENABLE_CODE_COVERAGE }}
with:
fail_ci_if_error: true
@@ -87,7 +88,7 @@ jobs:
# PRETTIER_FALLBACK_RESOLVE: true
# - name: Upload Coverage (PRETTIER_FALLBACK_RESOLVE)
# uses: codecov/codecov-action@v2.1.0
# uses: codecov/codecov-action@v3.1.0
# if: ${{ matrix.ENABLE_CODE_COVERAGE }}
# with:
# fail_ci_if_error: true
+10 -5
View File
@@ -28,7 +28,7 @@ jobs:
run: yarn build
- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
@@ -50,7 +50,7 @@ jobs:
run: yarn install --frozen-lockfile
- name: Download Artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: dist
path: dist
@@ -68,16 +68,21 @@ jobs:
- "macos-latest"
- "windows-latest"
node:
- "18"
- "16"
- "14"
- "12"
include:
- os: "ubuntu-latest"
node: "16"
node: "18"
FULL_TEST: true
exclude:
- os: "macos-latest"
node: "16"
- os: "macos-latest"
node: "14"
- os: "windows-latest"
node: "16"
- os: "windows-latest"
node: "14"
env:
@@ -103,7 +108,7 @@ jobs:
run: yarn install --frozen-lockfile
- name: Download Artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: dist
path: dist
@@ -145,7 +150,7 @@ jobs:
node-version: "0.10.48"
- name: Download Artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: dist
path: dist
+21
View File
@@ -0,0 +1,21 @@
#### Print the number of files need change (#12561 by @Harry-Hopkinson)
```console
# Prettier stable
$ prettier src --check
Checking formatting...
[warn] src/fileA.js
[warn] Code style issues found in the above file(s). Forgot to run Prettier?
# Prettier main
$ prettier src --check
Checking formatting...
[warn] src/fileA.js
[warn] src/fileB.js
[warn] Code style issues found in 2 files. Forgot to run Prettier?
$ prettier src --check
Checking formatting...
[warn] src/fileA.js
[warn] Code style issues found in the above file. Forgot to run Prettier?
```
+3
View File
@@ -0,0 +1,3 @@
#### Infer parser for `.importmap` files (#12603 by @fisker)
Format [`.importmap`](https://github.com/WICG/import-maps#import-map-processing) files as a JSON files.
+3
View File
@@ -0,0 +1,3 @@
#### Skip print code or write file when performance flags found (#12682 by @fisker)
When `--debug-benchmark` or `--debug-repeat` is used, the CLI will skip print the formatted code to the screen or write files.
+59
View File
@@ -0,0 +1,59 @@
#### Fix single line and empty description formatting (#12608 by @chimurai, @fisker)
<!-- prettier-ignore -->
```graphql
# Input
""" Customer """
type Person {
name: String
}
""""""
type Person {
name: String
}
# Prettier 2.6.2
"""
Customer
"""
type Person {
name: String
}
"""
"""
type Person {
name: String
}
# Prettier 2.6.2 (second format)
"""
Customer
"""
type Person {
name: String
}
"""
"""
type Person {
name: String
}
# Prettier main
"""
Customer
"""
type Person {
name: String
}
"""
"""
type Person {
name: String
}
```
+31
View File
@@ -0,0 +1,31 @@
#### Allow formatting for Vue template expression written in TypeScript (#12584 by @sosukesuzuki)
<!-- prettier-ignore -->
```vue
<!-- input -->
<script setup lang="ts">
let x: string | number = 1
</script>
<template>
{{ (x as number).toFixed(2) }}
</template>
<!-- Prettier stable -->
<script setup lang="ts">
let x: string | number = 1
</script>
<template>
{{ (x as number).toFixed(2) }}
</template>
<!-- Prettier main -->
<script setup lang="ts">
let x: string | number = 1;
</script>
<template>
{{ (x as number).toFixed(2) }}
</template>
```
+1 -1
View File
@@ -69,7 +69,7 @@ Console output if some of the files require re-formatting:
Checking formatting...
[warn] src/fileA.js
[warn] src/fileB.js
[warn] Code style issues found in the above file(s). Forgot to run Prettier?
[warn] Code style issues found in 2 files. Forgot to run Prettier?
```
The command will return exit code `1` in the second case, which is helpful inside the CI pipelines.
+21
View File
@@ -24,6 +24,27 @@ coverage
It’s recommended to have a `.prettierignore` in your project! This way you can run `prettier --write .` to make sure that everything is formatted (without mangling files you don’t want, or choking on generated files). And – your editor will know which files _not_ to format!
By default prettier ignores files in version control systems directories (".git", ".svn" and ".hg") and `node_modules` (if [`--with-node-modules` CLI option](cli.md#--with-node-modules) not specified)
So by default it will be
```js
**/.git
**/.svn
**/.hg
**/node_modules
```
and
```js
**/.git
**/.svn
**/.hg
```
if [`--with-node-modules` CLI option](cli.md#--with-node-modules) provided
(See also the [`--ignore-path` CLI option](cli.md#--ignore-path).)
## JavaScript
+12
View File
@@ -7,6 +7,7 @@ const isProduction = process.env.NODE_ENV === "production";
const ENABLE_CODE_COVERAGE = Boolean(process.env.ENABLE_CODE_COVERAGE);
const TEST_STANDALONE = Boolean(process.env.TEST_STANDALONE);
const INSTALL_PACKAGE = Boolean(process.env.INSTALL_PACKAGE);
const SKIP_TESTS_WITH_NEW_SYNTAX = process.versions.node.startsWith("12.");
let PRETTIER_DIR = isProduction
? path.join(PROJECT_ROOT, "dist")
@@ -26,16 +27,27 @@ if (!isProduction) {
"<rootDir>/tests/integration/__tests__/bundle.js"
);
}
if (SKIP_TESTS_WITH_NEW_SYNTAX) {
testPathIgnorePatterns.push(
"<rootDir>/tests/integration/__tests__/help-options.js"
);
}
const config = {
projects: [
"<rootDir>/jest-format-test.config.mjs",
isProduction && "<rootDir>/jest-integration-test.config.mjs",
].filter(Boolean),
setupFiles: ["<rootDir>/tests/config/setup.js"],
snapshotSerializers: [
"jest-snapshot-serializer-raw",
"jest-snapshot-serializer-ansi",
],
snapshotFormat: {
escapeString: false,
},
testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
testPathIgnorePatterns,
collectCoverage: ENABLE_CODE_COVERAGE,
collectCoverageFrom: ["<rootDir>/src/**/*.js", "<rootDir>/bin/**/*.js"],
+11 -26
View File
@@ -24,10 +24,10 @@
"dependencies": {
"@angular/compiler": "12.2.16",
"@babel/code-frame": "7.16.7",
"@babel/parser": "7.17.8",
"@glimmer/syntax": "0.84.1",
"@babel/parser": "7.17.9",
"@glimmer/syntax": "0.84.2",
"@iarna/toml": "2.2.5",
"@typescript-eslint/typescript-estree": "5.17.0",
"@typescript-eslint/typescript-estree": "5.20.0",
"acorn": "8.7.0",
"acorn-jsx": "5.3.2",
"angular-estree-parser": "2.5.0",
@@ -38,7 +38,7 @@
"ci-info": "3.3.0",
"cjk-regex": "2.0.1",
"cosmiconfig": "7.0.1",
"css-units-list": "0.0.5",
"css-units-list": "1.1.0",
"dashify": "2.0.0",
"diff": "5.0.0",
"editorconfig": "0.15.3",
@@ -49,7 +49,7 @@
"fast-glob": "3.2.11",
"fast-json-stable-stringify": "2.1.0",
"find-parent-dir": "0.3.1",
"flow-parser": "0.175.0",
"flow-parser": "0.176.3",
"get-stdin": "8.0.0",
"graphql": "15.6.1",
"html-element-attributes": "3.1.0",
@@ -62,7 +62,6 @@
"leven": "4.0.0",
"lines-and-columns": "2.0.3",
"linguist-languages": "7.15.0",
"lodash-es": "4.17.21",
"mem": "9.0.2",
"meriyah": "4.2.1",
"micromatch": "4.0.5",
@@ -82,7 +81,7 @@
"remark-math": "3.0.1",
"remark-parse": "8.0.3",
"resolve": "1.22.0",
"semver": "7.3.5",
"semver": "7.3.7",
"string-width": "5.0.1",
"strip-ansi": "7.0.1",
"typescript": "4.6.3",
@@ -93,34 +92,20 @@
"yaml-unist-parser": "1.3.1"
},
"devDependencies": {
"@babel/core": "7.17.8",
"@babel/core": "7.17.9",
"@babel/preset-env": "7.16.11",
"@babel/types": "7.17.0",
"@esbuild-plugins/node-modules-polyfill": "0.1.4",
"@glimmer/reference": "0.84.1",
"@glimmer/reference": "0.84.2",
"@jest/globals": "27.4.2",
"@types/estree": "0.0.51",
"@types/jest": "27.4.1",
"@typescript-eslint/eslint-plugin": "5.17.0",
"@typescript-eslint/eslint-plugin": "5.20.0",
"babel-jest": "27.5.1",
"benchmark": "2.1.4",
"browserslist-to-esbuild": "1.1.1",
"cross-env": "7.0.3",
"cspell": "5.19.5",
"enquirer": "2.3.6",
"esbuild": "0.14.30",
"esbuild-visualizer": "0.3.1",
"eslint": "8.12.0",
"eslint-config-prettier": "8.5.0",
"eslint-formatter-friendly": "7.0.0",
"eslint-plugin-compat": "4.0.2",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-jest": "26.1.3",
"eslint-plugin-prettier-internal-rules": "2.0.1",
"eslint-plugin-react": "7.29.4",
"eslint-plugin-regexp": "1.6.0",
"core-js": "3.22.2",
"eslint-plugin-unicorn": "42.0.0",
"esm-utils": "3.0.0",
"execa": "6.1.0",
"jest": "27.5.1",
"jest-light-runner": "0.1.1",
@@ -134,7 +119,7 @@
"prettier": "2.6.2",
"pretty-bytes": "6.0.0",
"rimraf": "3.0.2",
"rollup-plugin-license": "2.6.1",
"rollup-plugin-license": "2.7.0",
"snapshot-diff": "0.9.0",
"tempy": "2.0.0"
},
+1 -1
View File
@@ -11,7 +11,7 @@
"minimist": "1.2.6",
"node-fetch": "3.2.3",
"outdent": "0.8.0",
"semver": "7.3.5",
"semver": "7.3.7",
"string-width": "5.1.2"
},
"devDependencies": {
+4 -4
View File
@@ -2261,10 +2261,10 @@ saxes@^5.0.1:
dependencies:
xmlchars "^2.2.0"
semver@7.3.5, semver@^7.3.2:
version "7.3.5"
resolved "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz"
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
semver@7.3.7, semver@^7.3.2:
version "7.3.7"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f"
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
dependencies:
lru-cache "^6.0.0"
+42 -4
View File
@@ -101,6 +101,16 @@ function listDifferent(context, input, options, filename) {
return true;
}
function getPerformanceTestFlag(context) {
if (context.argv.debugBenchmark) {
return "--debug-benchmark";
}
if (context.argv.debugRepeat > 0) {
return "--debug-repeat";
}
}
async function format(context, input, opt) {
if (!opt.parser && !opt.filepath) {
throw new errors.UndefinedParserError(
@@ -266,7 +276,17 @@ async function formatStdin(context) {
return;
}
writeOutput(context, await format(context, input, options), options);
const formatted = await format(context, input, options);
const performanceTestFlag = getPerformanceTestFlag(context);
if (performanceTestFlag) {
context.logger.log(
`'${performanceTestFlag}' option found, skipped print code to screen.`
);
return;
}
writeOutput(context, formatted, options);
} catch (error) {
handleError(context, relativeFilepath || "stdin", error);
}
@@ -279,7 +299,7 @@ async function formatFiles(context) {
let numberOfUnformattedFilesFound = 0;
if (context.argv.check) {
if (context.argv.check && !getPerformanceTestFlag(context)) {
context.logger.log("Checking formatting...");
}
@@ -368,6 +388,14 @@ async function formatFiles(context) {
printedFilename.clear();
}
const performanceTestFlag = getPerformanceTestFlag(context);
if (performanceTestFlag) {
context.logger.log(
`'${performanceTestFlag}' option found, skipped print code or write files.`
);
return;
}
if (context.argv.write) {
// Don't write the file if it won't change in order not to invalidate
// mtime based caches.
@@ -416,11 +444,21 @@ async function formatFiles(context) {
if (context.argv.check) {
if (numberOfUnformattedFilesFound === 0) {
context.logger.log("All matched files use Prettier code style!");
} else if (numberOfUnformattedFilesFound === 1) {
context.logger.warn(
context.argv.write
? "Code style issues fixed in the above file."
: "Code style issues found in the above file. Forgot to run Prettier?"
);
} else {
context.logger.warn(
context.argv.write
? "Code style issues fixed in the above file(s)."
: "Code style issues found in the above file(s). Forgot to run Prettier?"
? "Code style issues found in " +
numberOfUnformattedFilesFound +
" files."
: "Code style issues found in " +
numberOfUnformattedFilesFound +
" files. Forgot to run Prettier?"
);
}
}
+5 -1
View File
@@ -1,4 +1,8 @@
import { partition } from "lodash-es";
import prettierInteral from "../prettier-internal.js";
const {
utils: { partition },
} = prettierInteral
export default function createMinimistOptions(detailedOptions) {
const [boolean, string] = partition(
+1 -1
View File
@@ -1,5 +1,5 @@
import { pick } from "lodash-es";
import camelCase from "camelcase";
import { pick } from "../utils.js";
import getContextOptions from "./get-context-options.js";
import minimist from "./minimist.js";
import createMinimistOptions from "./create-minimist-options.js";
+1 -1
View File
@@ -1,6 +1,6 @@
import { groupBy } from "lodash-es";
import camelCase from "camelcase";
import * as constant from "./constant.js";
import { groupBy } from "./utils.js";
const OPTION_USAGE_THRESHOLD = 25;
const CHOICE_USAGE_MARGIN = 3;
+36 -1
View File
@@ -1,4 +1,39 @@
// eslint-disable-next-line no-console
const printToScreen = console.log.bind(console);
export { printToScreen };
/**
* @template Obj
* @template Key
* @param {Array<Obj>} array
* @param {(value: Obj) => Key} iteratee
* @returns {{[p in Key]: T}}
*/
function groupBy(array, iteratee) {
const result = Object.create(null);
for (const value of array) {
const key = iteratee(value);
if (Array.isArray(result[key])) {
result[key].push(value);
} else {
result[key] = [value];
}
}
return result;
}
/**
* @template Obj
* @template {keyof Obj} Keys
* @param {Obj} object
* @param {Array<Keys>} keys
* @returns {{[key in Keys]: Obj[key]}}
*/
function pick(object, keys) {
const entries = keys.map((key) => [key, object[key]]);
return Object.fromEntries(entries);
}
export { printToScreen, groupBy, pick };
+1 -1
View File
@@ -4,7 +4,7 @@ import * as config from "../config/resolve-config.js";
import createIgnorer from "./create-ignorer.js";
/**
* @typedef {{ ignorePath?: string, withNodeModules?: boolean, plugins: object }} FileInfoOptions
* @typedef {{ ignorePath?: string, withNodeModules?: boolean, plugins: object, resolveConfig?: boolean }} FileInfoOptions
* @typedef {{ ignored: boolean, inferredParser: string | null }} FileInfoResult
*/
+3 -2
View File
@@ -2,9 +2,10 @@ import { createRequire } from "node:module";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { uniqBy, partition } from "lodash-es";
import fastGlob from "fast-glob";
import mem, { memClear } from "mem";
import partition from "../utils/partition.js"
import uniqByKey from "../utils/uniq-by-key.js"
import thirdParty from "./third-party.cjs";
import resolve from "./resolve.js";
@@ -92,7 +93,7 @@ function load(plugins, pluginSearchDirs) {
);
const externalPlugins = [
...uniqBy(
...uniqByKey(
[...externalManualLoadPluginInfos, ...externalAutoLoadPluginInfos],
"requirePath"
).map((externalPluginInfo) => ({
+15 -15
View File
@@ -3,19 +3,22 @@ import path from "node:path";
import micromatch from "micromatch";
import mem, { memClear } from "mem";
import thirdParty from "../common/third-party.cjs";
import loadToml from "../utils/load-toml.js";
import loadJson5 from "../utils/load-json5.js";
import resolve from "../common/resolve.js";
import partition from "../utils/partition.js";
import * as resolveEditorConfig from "./resolve-config-editorconfig.js";
/**
* @typedef {import("cosmiconfig/dist/Explorer").Explorer} Explorer
* @typedef {{sync: boolean; cache: boolean }} Options
* @typedef {ReturnType<import("cosmiconfig").cosmiconfig>} Explorer
* @typedef {ReturnType<import("cosmiconfig").cosmiconfigSync>} SyncExplorer
* @typedef {{sync?: boolean; cache?: boolean }} Options
*/
/**
* @type {(opts: Options) => Explorer}
* @template {Options} Opts
* @param {Opts} opts
* @return {Opts["sync"] extends true ? SyncExplorer : Explorer}
*/
const getExplorerMemoized = mem(
(opts) => {
@@ -67,8 +70,9 @@ const getExplorerMemoized = mem(
);
/**
* @param {Options} opts
* @return {Explorer}
* @template {Options} Opts
* @param {Opts} opts
* @return {Opts["sync"] extends true ? SyncExplorer : Explorer}
*/
function getExplorer(opts) {
// Normalize opts before passing to a memoized function
@@ -85,6 +89,7 @@ function _resolveConfig(filePath, opts, sync) {
};
const { load, search } = getExplorer(loadOpts);
const loadEditorConfig = resolveEditorConfig.getLoadFunction(loadOpts);
/** @type {[any, any]} */
const arr = [
opts.config ? load(opts.config) : search(filePath),
loadEditorConfig(filePath),
@@ -169,15 +174,10 @@ function pathMatchesGlobs(filePath, patterns, excludedPatterns) {
const patternList = Array.isArray(patterns) ? patterns : [patterns];
// micromatch always matches against basename when the option is enabled
// use only patterns without slashes with it to match minimatch behavior
const withSlashes = [];
const withoutSlashes = [];
for (const pattern of patternList) {
if (pattern.includes("/")) {
withSlashes.push(pattern);
} else {
withoutSlashes.push(pattern);
}
}
const [withSlashes, withoutSlashes] = partition(patternList, (pattern) =>
pattern.includes("/")
);
return (
micromatch.isMatch(filePath, withoutSlashes, {
ignore: excludedPatterns,
+7
View File
@@ -22,6 +22,7 @@ import * as optionsModule from "./main/options.js";
import * as optionsNormalizer from "./main/options-normalizer.js";
import arrayify from "./utils/arrayify.js";
import getLast from "./utils/get-last.js";
import partition from "./utils/partition.js";
import { isNonEmptyArray } from "./common/util.js";
const require = createRequire(import.meta.url);
@@ -45,6 +46,11 @@ function _withPlugins(
};
}
/**
* @param {*} fn
* @param {*} optsArgIdx
* @returns {*}
*/
function withPlugins(fn, optsArgIdx) {
const resultingFn = _withPlugins(fn, optsArgIdx);
if (fn.sync) {
@@ -97,6 +103,7 @@ const prettier = {
arrayify,
getLast,
isNonEmptyArray,
partition,
},
},
+17 -11
View File
@@ -125,13 +125,15 @@ function genericPrint(path, options, print) {
}
case "StringValue": {
if (node.block) {
return [
'"""',
const lines = node.value.replace(/"""/g, "\\$&").split("\n");
if (lines.length === 1) {
lines[0] = lines[0].trim();
}
return join(
hardline,
join(hardline, node.value.replace(/"""/g, "\\$&").split("\n")),
hardline,
'"""',
];
['"""', ...(lines.length > 0 ? lines : []), '"""'].filter(Boolean)
);
}
return [
'"',
@@ -572,15 +574,19 @@ function printInterfaces(path, options, print) {
return parts;
}
function clean(/*node, newNode , parent*/) {}
function clean(node, newNode /* , parent */) {
// We print single line `""" string """` as multiple line string,
// and the parser ignores space in multiple line string
if (node.kind === "StringValue" && node.block && !node.value.includes("\n")) {
newNode.value = newNode.value.trim();
}
}
clean.ignoredProperties = new Set(["loc", "comments"]);
function hasPrettierIgnore(path) {
const node = path.getValue();
return (
node &&
Array.isArray(node.comments) &&
node.comments.some((comment) => comment.value.trim() === "prettier-ignore")
return node?.comments?.some(
(comment) => comment.value.trim() === "prettier-ignore"
);
}
+1 -1
View File
@@ -14,7 +14,7 @@ function addBackslash(/* options*/) {
name: "addBackslash",
visitor: {
All(node) {
const childrenOrBody = node.children || node.body;
const childrenOrBody = node.children ?? node.body;
if (childrenOrBody) {
for (let i = 0; i < childrenOrBody.length - 1; i++) {
if (
+3 -3
View File
@@ -735,14 +735,14 @@ function needsOppositeQuote(path) {
/* SubExpression print helpers */
function printSubExpressionPathAndParams(path, print) {
const p = printPath(path, print);
const printed = printPath(path, print);
const params = printParams(path, print);
if (!params) {
return p;
return printed;
}
return indent([p, line, group(params)]);
return indent([printed, line, group(params)]);
}
/* misc. print helpers */
+5 -5
View File
@@ -30,7 +30,7 @@ function isGlimmerComponent(node) {
return (
isNodeOfSomeType(node, ["ElementNode"]) &&
typeof node.tag === "string" &&
node.tag[0] !== ":" &&
!node.tag.startsWith(":") &&
(isUppercase(node.tag[0]) || node.tag.includes("."))
);
}
@@ -38,9 +38,9 @@ function isGlimmerComponent(node) {
const voidTags = new Set(htmlVoidElements);
function isVoid(node) {
return (
voidTags.has(node.tag) ||
(isGlimmerComponent(node) &&
node.children.every((node) => isWhitespaceNode(node))) ||
voidTags.has(node.tag)
node.children.every((node) => isWhitespaceNode(node)))
);
}
@@ -69,9 +69,9 @@ function isNextNodeOfSomeType(path, types) {
function getSiblingNode(path, offset) {
const node = path.getValue();
const parentNode = path.getParentNode(0) || {};
const parentNode = path.getParentNode(0) ?? {};
const children =
parentNode.children || parentNode.body || parentNode.parts || [];
parentNode.children ?? parentNode.body ?? parentNode.parts ?? [];
const index = children.indexOf(node);
return index !== -1 && children[index + offset];
}
+56 -62
View File
@@ -6,38 +6,45 @@ const NODES_KEYS = {
children: true,
};
const NON_ENUMERABLE_PROPERTIES = new Set(["parent"]);
// TODO: typechecking is problematic for this class because of this issue:
// https://github.com/microsoft/TypeScript/issues/26811
class Node {
constructor(props = {}) {
for (const [key, value] of Object.entries(props)) {
if (key in NODES_KEYS) {
this._setNodes(key, value);
} else {
this[key] = value;
}
constructor(nodeOrProperties = {}) {
for (const property of new Set([
...NON_ENUMERABLE_PROPERTIES,
...Object.keys(nodeOrProperties),
])) {
this.setProperty(property, nodeOrProperties[property]);
}
}
_setNodes(key, nodes) {
if (nodes !== this[key]) {
this[key] = cloneAndUpdateNodes(nodes, this);
if (key === "attrs") {
setNonEnumerableProperty(
this,
"attrMap",
Object.fromEntries(
this[key].map((attr) => [attr.fullName, attr.value])
)
);
}
setProperty(property, value) {
if (this[property] === value) {
return;
}
if (property in NODES_KEYS) {
value = value.map((node) => this.createChild(node));
}
if (!NON_ENUMERABLE_PROPERTIES.has(property)) {
this[property] = value;
return;
}
Object.defineProperty(this, property, {
value,
enumerable: false,
configurable: true,
});
}
map(fn) {
/** @type{any} */
let newNode = null;
let newNode;
for (const NODES_KEY in NODES_KEYS) {
const nodes = this[NODES_KEY];
@@ -48,7 +55,7 @@ class Node {
// @ts-expect-error
newNode = new Node({ parent: this.parent });
}
newNode._setNodes(NODES_KEY, mappedNodes);
newNode.setProperty(NODES_KEY, mappedNodes);
}
}
}
@@ -76,15 +83,27 @@ class Node {
fn(this);
}
createChild(nodeOrProperties) {
const node =
nodeOrProperties instanceof Node
? nodeOrProperties.clone()
: new Node(nodeOrProperties);
node.setProperty("parent", this);
return node;
}
/**
* @param {Node} [target]
* @param {Object} [node]
*/
insertChildBefore(target, node) {
const newNode = new Node({ ...node, parent: this });
// @ts-expect-error
this.children.splice(this.children.indexOf(target), 0, newNode);
this.children.splice(
// @ts-expect-error
this.children.indexOf(target),
0,
this.createChild(node)
);
}
/**
@@ -100,49 +119,32 @@ class Node {
* @param {Object} [node]
*/
replaceChild(target, node) {
const newNode = new Node({ ...node, parent: this });
// @ts-expect-error
this.children[this.children.indexOf(target)] = newNode;
this.children[this.children.indexOf(target)] = this.createChild(node);
}
clone() {
return new Node(this);
}
/**
* @param {Array} [children]
*/
setChildren(children) {
this._setNodes("children", children);
}
get firstChild() {
// @ts-expect-error
return isNonEmptyArray(this.children) ? this.children[0] : null;
return this.children?.[0];
}
get lastChild() {
// @ts-expect-error
return isNonEmptyArray(this.children) ? getLast(this.children) : null;
return this.children?.[this.children.length - 1];
}
get prev() {
// @ts-expect-error
if (!this.parent) {
return null;
}
// @ts-expect-error
return this.parent.children[this.parent.children.indexOf(this) - 1];
return this.parent?.children[this.parent.children.indexOf(this) - 1];
}
get next() {
// @ts-expect-error
if (!this.parent) {
return null;
}
// @ts-expect-error
return this.parent.children[this.parent.children.indexOf(this) + 1];
return this.parent?.children[this.parent.children.indexOf(this) + 1];
}
// for element and attribute
@@ -150,10 +152,18 @@ class Node {
// @ts-expect-error
return this.hasExplicitNamespace ? this.fullName : this.name;
}
get fullName() {
// @ts-expect-error
return this.namespace ? this.namespace + ":" + this.name : this.name;
}
get attrMap() {
return Object.fromEntries(
// @ts-expect-error
this.attrs.map((attr) => [attr.fullName, attr.value])
);
}
}
function mapNodesIfChanged(nodes, fn) {
@@ -163,20 +173,4 @@ function mapNodesIfChanged(nodes, fn) {
: nodes;
}
function cloneAndUpdateNodes(nodes, parent) {
const siblings = nodes.map((node) =>
node instanceof Node ? node.clone() : new Node({ ...node, parent })
);
for (const sibling of siblings) {
sibling.parent = parent;
}
return siblings;
}
function setNonEnumerableProperty(obj, key, value) {
Object.defineProperty(obj, key, { value, enumerable: false });
}
export { Node };
-1
View File
@@ -6,7 +6,6 @@ const ignoredProperties = new Set([
"endSourceSpan",
"nameSpan",
"valueSpan",
"parent",
]);
function clean(ast, newNode) {
+9 -4
View File
@@ -127,11 +127,14 @@ function printEmbeddedAttributeValue(node, htmlTextToDoc, options) {
if (isKeyMatched(vueEventBindingPatterns)) {
const value = getValue();
const parser = isVueEventBindingExpression(value)
? "__js_expression"
: options.__should_parse_vue_template_with_ts
? "__vue_ts_event_binding"
: "__vue_event_binding";
return printMaybeHug(
attributeTextToDoc(value, {
parser: isVueEventBindingExpression(value)
? "__js_expression"
: "__vue_event_binding",
parser,
})
);
}
@@ -318,7 +321,9 @@ function embed(path, print, textToDoc, options) {
textToDocOptions.parser = "__ng_interpolation";
textToDocOptions.trailingComma = "none";
} else if (options.parser === "vue") {
textToDocOptions.parser = "__vue_expression";
textToDocOptions.parser = options.__should_parse_vue_template_with_ts
? "__vue_ts_expression"
: "__vue_expression";
} else {
textToDocOptions.parser = "__js_expression";
}
+17
View File
@@ -10,6 +10,7 @@ import {
isLeadingSpaceSensitiveNode,
isTrailingSpaceSensitiveNode,
isWhitespaceSensitiveNode,
isVueScriptTag,
} from "./utils/index.js";
const PREPROCESS_PIPELINE = [
@@ -23,6 +24,7 @@ const PREPROCESS_PIPELINE = [
addHasHtmComponentClosingTag,
addIsSpaceSensitive,
mergeSimpleElementIntoText,
markTsScript,
];
function preprocess(ast, options) {
@@ -404,4 +406,19 @@ function addIsSpaceSensitive(ast, options) {
});
}
function markTsScript(ast, options) {
if (options.parser === "vue") {
const vueScriptTag = ast.children.find((child) =>
isVueScriptTag(child, options)
);
if (!vueScriptTag) {
return;
}
const { lang } = vueScriptTag.attrMap;
if (lang === "ts" || lang === "typescript") {
options.__should_parse_vue_template_with_ts = true;
}
}
}
export default preprocess;
+6
View File
@@ -635,6 +635,11 @@ function getTextValueParts(node, value = node.value) {
: getDocParts(join(line, splitByHtmlWhitespace(value)));
}
function isVueScriptTag(node, options) {
return isVueSfcBlock(node, options) && node.name === "script";
}
export {
htmlTrim,
htmlTrimPreserveIndentation,
@@ -654,6 +659,7 @@ export {
inferScriptParser,
isVueCustomBlock,
isVueNonHtmlBlock,
isVueScriptTag,
isVueSlotAttribute,
isVueSfcBindingsAttribute,
isDanglingSpaceSensitiveNode,
+7 -9
View File
@@ -175,15 +175,13 @@ function clean(ast, newObj, parent) {
// we will not trim the comment value and we will expect exactly one space on
// either side of the GraphQL string
// Also see ./embed.js
const hasLanguageComment =
ast.leadingComments &&
ast.leadingComments.some(
(comment) =>
isBlockComment(comment) &&
["GraphQL", "HTML"].some(
(languageName) => comment.value === ` ${languageName} `
)
);
const hasLanguageComment = ast.leadingComments?.some(
(comment) =>
isBlockComment(comment) &&
["GraphQL", "HTML"].some(
(languageName) => comment.value === ` ${languageName} `
)
);
if (
hasLanguageComment ||
(parent.type === "CallExpression" && parent.callee.name === "graphql") ||
+1 -1
View File
@@ -88,7 +88,7 @@ const languages = [
since: "1.13.0",
parsers: ["json-stringify"],
vscodeLanguageIds: ["json"],
extensions: [], // .json file defaults to json instead of json-stringify
extensions: [".importmap"], // .json file defaults to json instead of json-stringify
filenames: ["package.json", "package-lock.json", "composer.json"],
})),
createLanguage(require("linguist-languages/data/JSON.json"), (data) => ({
+12 -1
View File
@@ -171,6 +171,11 @@ const parseEstree = createParse(
);
const parseExpression = createParse("parseExpression", appendPlugins(["jsx"]));
const parseTSExpression = createParse(
"parseExpression",
appendPlugins(["typescript"])
);
// Error codes are defined in
// - https://github.com/babel/babel/blob/v7.14.0/packages/babel-parser/src/parser/error-message.js
// - https://github.com/babel/babel/blob/v7.14.0/packages/babel-parser/src/plugins/typescript/index.js#L69-L153
@@ -229,21 +234,27 @@ const allowedMessageCodes = new Set([
]);
const babel = createParser(parse);
const babelTs = createParser(parseTypeScript);
const babelExpression = createParser(parseExpression);
const babelTSExpression = createParser(parseTSExpression);
// Export as a plugin so we can reuse the same bundle for UMD loading
const parser = {
parsers: {
babel,
"babel-flow": createParser(parseFlow),
"babel-ts": createParser(parseTypeScript),
"babel-ts": babelTs,
...jsonParsers,
/** @internal */
__js_expression: babelExpression,
/** for vue filter */
__vue_expression: babelExpression,
/** for vue filter written in TS */
__vue_ts_expression: babelTSExpression,
/** for vue event binding to handle semicolon */
__vue_event_binding: babel,
/** for vue event binding written in TS to handle semicolon */
__vue_ts_event_binding: babelTs,
/** verify that we can print this AST */
__babel_estree: createParser(parseEstree),
},
+6
View File
@@ -31,9 +31,15 @@ const parsers = {
get __vue_expression() {
return babel.parsers.__vue_expression;
},
get __vue_ts_expression() {
return require("./babel.js").parsers.__vue_ts_expression;
},
get __vue_event_binding() {
return babel.parsers.__vue_event_binding;
},
get __vue_ts_event_binding() {
return require("./babel.js").parsers.__vue_ts_event_binding;
},
// JS - Flow
get flow() {
return flow.parsers.flow;
+1
View File
@@ -5,6 +5,7 @@ function preprocess(ast, options) {
case "json-stringify":
case "__js_expression":
case "__vue_expression":
case "__vue_ts_expression":
return {
...ast,
type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
+4 -1
View File
@@ -218,7 +218,10 @@ function printPathNoParens(path, options, print, args) {
return [printDirective(node.expression, options), semi];
}
if (options.parser === "__vue_event_binding") {
if (
options.parser === "__vue_event_binding" ||
options.parser === "__vue_ts_event_binding"
) {
const parent = path.getParentNode();
if (
parent.type === "Program" &&
+95 -130
View File
@@ -53,10 +53,8 @@ function hasFlowShorthandAnnotationComment(node) {
// Syntax example: const r = new (window.Request /*: Class<Request> */)("");
return (
node.extra &&
node.extra.parenthesized &&
isNonEmptyArray(node.trailingComments) &&
isBlockComment(node.trailingComments[0]) &&
node.extra?.parenthesized &&
isBlockComment(node.trailingComments?.[0]) &&
FLOW_SHORTHAND_ANNOTATION.test(node.trailingComments[0].value)
);
}
@@ -66,10 +64,9 @@ function hasFlowShorthandAnnotationComment(node) {
* @returns {boolean}
*/
function hasFlowAnnotationComment(comments) {
const firstComment = comments?.[0];
return (
isNonEmptyArray(comments) &&
isBlockComment(comments[0]) &&
FLOW_ANNOTATION.test(comments[0].value)
isBlockComment(firstComment) && FLOW_ANNOTATION.test(firstComment.value)
);
}
@@ -118,12 +115,12 @@ function getLeftSide(node) {
return node.expressions[0];
}
return (
node.left ||
node.test ||
node.callee ||
node.object ||
node.tag ||
node.argument ||
node.left ??
node.test ??
node.callee ??
node.object ??
node.tag ??
node.argument ??
node.expression
);
}
@@ -156,37 +153,36 @@ function getLeftSidePathName(path, node) {
throw new Error("Unexpected node has no left side.");
}
function createTypeCheckFunction(types) {
types = new Set(types);
return (node) => types.has(node?.type);
}
/**
* @param {Comment} comment
* @returns {boolean}
*/
function isLineComment(comment) {
return (
comment.type === "Line" ||
comment.type === "CommentLine" ||
// `meriyah` has `SingleLine`, `HashbangComment`, `HTMLOpen`, and `HTMLClose`
comment.type === "SingleLine" ||
comment.type === "HashbangComment" ||
comment.type === "HTMLOpen" ||
comment.type === "HTMLClose"
);
}
const exportDeclarationTypes = new Set([
"ExportDefaultDeclaration",
"ExportDefaultSpecifier",
"DeclareExportDeclaration",
"ExportNamedDeclaration",
"ExportAllDeclaration",
const isLineComment = createTypeCheckFunction([
"Line",
"CommentLine",
// `meriyah` has `SingleLine`, `HashbangComment`, `HTMLOpen`, and `HTMLClose`
"SingleLine",
"HashbangComment",
"HTMLOpen",
"HTMLClose",
]);
/**
* @param {Node} node
* @returns {boolean}
*/
function isExportDeclaration(node) {
return node && exportDeclarationTypes.has(node.type);
}
const isExportDeclaration = createTypeCheckFunction([
"ExportDefaultDeclaration",
"ExportDefaultSpecifier",
"DeclareExportDeclaration",
"ExportNamedDeclaration",
"ExportAllDeclaration",
]);
/**
* @param {AstPath} path
@@ -205,22 +201,20 @@ function getParentExportDeclaration(path) {
* @param {Node} node
* @returns {boolean}
*/
function isLiteral(node) {
return (
node.type === "BooleanLiteral" ||
node.type === "DirectiveLiteral" ||
node.type === "Literal" ||
node.type === "NullLiteral" ||
node.type === "NumericLiteral" ||
node.type === "BigIntLiteral" ||
node.type === "DecimalLiteral" ||
node.type === "RegExpLiteral" ||
node.type === "StringLiteral" ||
node.type === "TemplateLiteral" ||
node.type === "TSTypeLiteral" ||
node.type === "JSXText"
);
}
const isLiteral = createTypeCheckFunction([
"BooleanLiteral",
"DirectiveLiteral",
"Literal",
"NullLiteral",
"NumericLiteral",
"BigIntLiteral",
"DecimalLiteral",
"RegExpLiteral",
"StringLiteral",
"TemplateLiteral",
"TSTypeLiteral",
"JSXText",
]);
/**
* @param {Node} node
@@ -256,24 +250,20 @@ function isStringLiteral(node) {
* @param {Node} node
* @returns {boolean}
*/
function isObjectType(node) {
return (
node.type === "ObjectTypeAnnotation" ||
node.type === "TSTypeLiteral" ||
node.type === "TSMappedType"
);
}
const isObjectType = createTypeCheckFunction([
"ObjectTypeAnnotation",
"TSTypeLiteral",
"TSMappedType",
]);
/**
* @param {Node} node
* @returns {boolean}
*/
function isFunctionOrArrowExpression(node) {
return (
node.type === "FunctionExpression" ||
node.type === "ArrowFunctionExpression"
);
}
const isFunctionOrArrowExpression = createTypeCheckFunction([
"FunctionExpression",
"ArrowFunctionExpression",
]);
/**
* @param {Node} node
@@ -287,14 +277,6 @@ function isFunctionOrArrowExpressionWithBody(node) {
);
}
/**
* @param {Node} node
* @returns {boolean}
*/
function isTemplateLiteral(node) {
return node.type === "TemplateLiteral";
}
/**
* Note: `inject` is used in AngularJS 1.x, `async` and `fakeAsync` in
* Angular 2+, although `async` is deprecated and replaced by `waitForAsync`
@@ -317,9 +299,7 @@ function isAngularTestWrapper(node) {
* @param {Node} node
* @returns {boolean}
*/
function isJsxNode(node) {
return node.type === "JSXElement" || node.type === "JSXFragment";
}
const isJsxNode = createTypeCheckFunction(["JSXElement", "JSXFragment"]);
function isTheOnlyJsxElementInMarkdown(options, path) {
if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
@@ -376,19 +356,15 @@ function isTypeAnnotationAFunction(node) {
);
}
const binaryishNodeTypes = new Set([
"BinaryExpression",
"LogicalExpression",
"NGPipeExpression",
]);
/**
* @param {Node} node
* @returns {boolean}
*/
function isBinaryish(node) {
return binaryishNodeTypes.has(node.type);
}
const isBinaryish = createTypeCheckFunction([
"BinaryExpression",
"LogicalExpression",
"NGPipeExpression",
]);
/**
* @param {Node} node
@@ -517,7 +493,7 @@ function isTestCall(node, parent) {
((node.callee.type === "Identifier" &&
unitTestRe.test(node.callee.name)) ||
isSkipOrOnlyBlock(node)) &&
(isTemplateLiteral(node.arguments[0]) ||
(node.arguments[0].type === "TemplateLiteral" ||
isStringLiteral(node.arguments[0]))
) {
// it("name", () => { ... }, 2500)
@@ -540,24 +516,19 @@ function isTestCall(node, parent) {
* @param {Node} node
* @returns {boolean}
*/
function isCallExpression(node) {
return (
node &&
(node.type === "CallExpression" || node.type === "OptionalCallExpression")
);
}
const isCallExpression = createTypeCheckFunction([
"CallExpression",
"OptionalCallExpression",
]);
/**
* @param {Node} node
* @returns {boolean}
*/
function isMemberExpression(node) {
return (
node &&
(node.type === "MemberExpression" ||
node.type === "OptionalMemberExpression")
);
}
const isMemberExpression = createTypeCheckFunction([
"MemberExpression",
"OptionalMemberExpression",
]);
/**
*
@@ -621,12 +592,8 @@ function isSimpleTemplateLiteral(node) {
* @returns {string}
*/
function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
if (tokenNode === "+") {
return "+" + keyword;
}
if (tokenNode === "-") {
return "-" + keyword;
if (tokenNode === "+" || tokenNode === "-") {
return tokenNode + keyword;
}
return keyword;
@@ -919,7 +886,7 @@ function isSimpleCallArgument(node, depth) {
}
function rawText(node) {
return node.extra ? node.extra.raw : node.raw;
return node.extra?.raw ?? node.raw;
}
function identity(x) {
@@ -1072,29 +1039,27 @@ function shouldFlatten(parentOp, nodeOp) {
return true;
}
const PRECEDENCE = {};
for (const [i, tier] of [
["|>"],
["??"],
["||"],
["&&"],
["|"],
["^"],
["&"],
["==", "===", "!=", "!=="],
["<", ">", "<=", ">=", "in", "instanceof"],
[">>", "<<", ">>>"],
["+", "-"],
["*", "/", "%"],
["**"],
].entries()) {
for (const op of tier) {
PRECEDENCE[op] = i;
}
}
function getPrecedence(op) {
return PRECEDENCE[op];
const PRECEDENCE = new Map(
[
["|>"],
["??"],
["||"],
["&&"],
["|"],
["^"],
["&"],
["==", "===", "!=", "!=="],
["<", ">", "<=", ">=", "in", "instanceof"],
[">>", "<<", ">>>"],
["+", "-"],
["*", "/", "%"],
["**"],
].flatMap((operators, index) =>
operators.map((operator) => [operator, index])
)
);
function getPrecedence(operator) {
return PRECEDENCE.get(operator);
}
function getLeftMost(node) {
@@ -1118,7 +1083,7 @@ function hasRestParameter(node) {
return true;
}
const parameters = getFunctionParameters(node);
return parameters.length > 0 && getLast(parameters).type === "RestElement";
return getLast(parameters)?.type === "RestElement";
}
const functionParametersCache = new WeakMap();
@@ -1256,7 +1221,7 @@ const getCommentTestFunction = (flags, fn) => {
* @returns {boolean}
*/
function hasComment(node, flags, fn) {
if (!node || !isNonEmptyArray(node.comments)) {
if (!isNonEmptyArray(node?.comments)) {
return false;
}
const test = getCommentTestFunction(flags, fn);
@@ -1270,7 +1235,7 @@ function hasComment(node, flags, fn) {
* @returns {Comment[]}
*/
function getComments(node, flags, fn) {
if (!node || !Array.isArray(node.comments)) {
if (!Array.isArray(node?.comments)) {
return [];
}
const test = getCommentTestFunction(flags, fn);
+7 -8
View File
@@ -2,17 +2,16 @@
* @typedef {import("../types/estree").Comment} Comment
*/
const BLOCK_COMMENT_TYPES = new Set([
"Block",
"CommentBlock",
// `meriyah`
"MultiLine",
]);
/**
* @param {Comment} comment
* @returns {boolean}
*/
function isBlockComment(comment) {
return (
comment.type === "Block" ||
comment.type === "CommentBlock" ||
// `meriyah`
comment.type === "MultiLine"
);
}
const isBlockComment = (comment) => BLOCK_COMMENT_TYPES.has(comment?.type);
export default isBlockComment;
+1 -1
View File
@@ -13,7 +13,7 @@ function startWithPragma(text) {
"m"
);
const matched = text.match(regex);
return matched && matched.index === 0;
return matched?.index === 0;
}
const hasPragma = (text) =>
+4 -6
View File
@@ -782,7 +782,7 @@ function isPrettierIgnore(node) {
}
}
return match ? (match[1] ? match[1] : "next") : false;
return match ? match[1] || "next" : false;
}
function shouldPrePrintHardline(node, data) {
@@ -804,21 +804,19 @@ function shouldPrePrintDoubleHardline(node, data) {
data.parentNode.type === "listItem" && !data.parentNode.loose;
const isPrevNodeLooseListItem =
data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
data.prevNode?.type === "listItem" && data.prevNode.loose;
const isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next";
const isBlockHtmlWithoutBlankLineBetweenPrevHtml =
node.type === "html" &&
data.prevNode &&
data.prevNode.type === "html" &&
data.prevNode?.type === "html" &&
data.prevNode.position.end.line + 1 === node.position.start.line;
const isHtmlDirectAfterListItem =
node.type === "html" &&
data.parentNode.type === "listItem" &&
data.prevNode &&
data.prevNode.type === "paragraph" &&
data.prevNode?.type === "paragraph" &&
data.prevNode.position.end.line + 1 === node.position.start.line;
return (
+3 -7
View File
@@ -219,15 +219,11 @@ function mapAst(ast, handler) {
}
function isAutolink(node) {
if (!node || node.type !== "link" || node.children.length !== 1) {
if (node?.type !== "link" || node.children.length !== 1) {
return false;
}
const child = node.children[0];
return (
child &&
locStart(node) === locStart(child) &&
locEnd(node) === locEnd(child)
);
const [child] = node.children;
return locStart(node) === locStart(child) && locEnd(node) === locEnd(child);
}
export {
+1 -1
View File
@@ -21,7 +21,7 @@ function parse(text) {
return root;
} catch (error) {
if (error && error.position) {
if (error?.position) {
throw createError(error.message, error.position);
}
+1 -1
View File
@@ -329,7 +329,7 @@ function printNode(node, parentNode, path, options, print) {
case "sequence":
return join(hardline, path.map(print, "children"));
case "sequenceItem":
return ["- ", alignWithSpaces(2, !node.content ? "" : print("content"))];
return ["- ", alignWithSpaces(2, node.content ? print("content") : "")];
case "mappingKey":
case "mappingValue":
return !node.content ? "" : print("content");
+5 -5
View File
@@ -136,23 +136,23 @@ function hasComments(node) {
}
function hasLeadingComments(node) {
return node && isNonEmptyArray(node.leadingComments);
return isNonEmptyArray(node?.leadingComments);
}
function hasMiddleComments(node) {
return node && isNonEmptyArray(node.middleComments);
return isNonEmptyArray(node?.middleComments);
}
function hasIndicatorComment(node) {
return node && node.indicatorComment;
return node?.indicatorComment;
}
function hasTrailingComment(node) {
return node && node.trailingComment;
return node?.trailingComment;
}
function hasEndComments(node) {
return node && isNonEmptyArray(node.endComments);
return isNonEmptyArray(node?.endComments);
}
/**
+2 -1
View File
@@ -200,7 +200,8 @@ function attach(comments, ast, text, options) {
options.parser === "json" ||
options.parser === "json5" ||
options.parser === "__js_expression" ||
options.parser === "__vue_expression"
options.parser === "__vue_expression" ||
options.parser === "__vue_ts_expression"
) {
if (locStart(comment) - locStart(ast) <= 0) {
addLeadingComment(ast, comment);
+1 -1
View File
@@ -12,7 +12,7 @@ const CATEGORY_SPECIAL = "Special";
* @typedef {Object} OptionInfo
* @property {string} [since] - available since version
* @property {string} category
* @property {'int' | 'boolean' | 'choice' | 'path'} type
* @property {'int' | 'boolean' | 'choice' | 'path' | 'string' | 'flag'} type
* @property {boolean} [array] - indicate it's an array of the specified type
* @property {OptionValueInfo} [default]
* @property {OptionRangeInfo} [range] - for type int
+2
View File
@@ -50,7 +50,9 @@ function textToDoc(
const astComments = ast.comments;
delete ast.comments;
attach(astComments, ast, text, nextOptions);
// @ts-expect-error -- Casting to `unique symbol` isn't allowed in JSDoc comment
nextOptions[Symbol.for("comments")] = astComments || [];
// @ts-expect-error -- Casting to `unique symbol` isn't allowed in JSDoc comment
nextOptions[Symbol.for("tokens")] = ast.tokens || [];
const doc = printAstToDoc(ast, nextOptions);
+25 -3
View File
@@ -1,6 +1,10 @@
import vnopts from "vnopts";
import getLast from "../utils/get-last.js";
/**
* @typedef {import("./support").NamedOptionInfo} NamedOptionInfo
*/
const cliDescriptor = {
key: (key) => (key.length === 1 ? `-${key}` : `--${key}`),
value: (value) => vnopts.apiDescriptor.value(value),
@@ -53,15 +57,20 @@ const getFlagSchema = ({ colorsModule, levenshteinDistance }) =>
let hasDeprecationWarned;
/**
* @param {*} options
* @param {*} optionInfos
* @param {{ logger?: false; isCLI?: boolean; passThrough?: boolean; colorsModule?: any; levenshteinDistance?: any }} param2
*/
function normalizeOptions(
options,
optionInfos,
{
logger,
logger = false,
isCLI = false,
passThrough = false,
colorsModule,
levenshteinDistance,
colorsModule = null,
levenshteinDistance = null,
} = {}
) {
const unknown = !passThrough
@@ -93,12 +102,14 @@ function normalizeOptions(
const shouldSuppressDuplicateDeprecationWarnings = logger !== false;
if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
// @ts-expect-error
normalizer._hasDeprecationWarned = hasDeprecationWarned;
}
const normalized = normalizer.normalize(options);
if (shouldSuppressDuplicateDeprecationWarnings) {
// @ts-expect-error
hasDeprecationWarned = normalizer._hasDeprecationWarned;
}
@@ -132,6 +143,7 @@ function optionInfosToSchemas(
if (optionInfo.alias && isCLI) {
schemas.push(
vnopts.AliasSchema.create({
// @ts-expect-error
name: optionInfo.alias,
sourceName: optionInfo.name,
})
@@ -142,6 +154,11 @@ function optionInfosToSchemas(
return schemas;
}
/**
* @param {NamedOptionInfo} optionInfo
* @param {any} param1
* @returns
*/
function optionInfoToSchema(
optionInfo,
{ isCLI, optionInfos, colorsModule, levenshteinDistance }
@@ -150,6 +167,7 @@ function optionInfoToSchema(
if (name === "plugin-search-dir" || name === "pluginSearchDirs") {
return vnopts.AnySchema.create({
// @ts-expect-error
name,
preprocess(value) {
if (value === false) {
@@ -158,6 +176,9 @@ function optionInfoToSchema(
value = Array.isArray(value) ? value : [value];
return value;
},
/**
* @param {Array<unknown> | false} value
*/
validate(value) {
if (value === false) {
return true;
@@ -258,6 +279,7 @@ function optionInfoToSchema(
? vnopts.ArraySchema.create({
...(isCLI ? { preprocess: (v) => (Array.isArray(v) ? v : [v]) } : {}),
...handlers,
// @ts-expect-error
valueSchema: SchemaConstructor.create(parameters),
})
: SchemaConstructor.create({ ...parameters, ...handlers });
+6
View File
@@ -9,6 +9,11 @@ const require = createRequire(import.meta.url);
const currentVersion = require("../../package.json").version;
/**
* @typedef {import("./core-options").OptionInfo} OptionInfo
* @typedef {{ name: string; pluginDefaults: Array<any> } & OptionInfo} NamedOptionInfo
*/
/**
* Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version
* of this function created by `withPlugins`. Don't pass them here directly.
@@ -18,6 +23,7 @@ const currentVersion = require("../../package.json").version;
* @param {boolean=} param0.showUnreleased
* @param {boolean=} param0.showDeprecated
* @param {boolean=} param0.showInternal
* @return {{ languages: Array<any>, options: Array<NamedOptionInfo> }}
*/
function getSupportInfo({
plugins = [],
+20
View File
@@ -0,0 +1,20 @@
"use strict";
/**
* @template Element
* @param {Array<Element>} array
* @param {(value: Element) => boolean} predicate
* @returns {[Array<Element>, Array<Element>]}
*/
function partition(array, predicate) {
/** @type {[Array<Element>, Array<Element>]} */
const result = [[], []];
for (const value of array) {
result[predicate(value) ? 0 : 1].push(value);
}
return result;
}
module.exports = partition;
+24
View File
@@ -0,0 +1,24 @@
"use strict";
/**
* @template {object} Element
* @param {Array<Element>} array
* @param {string | number | symbol} key
* @returns
*/
function uniqByKey(array, key) {
const result = [];
const seen = new Set();
for (const element of array) {
const value = element[key];
if (!seen.has(value)) {
seen.add(value);
result.push(element);
}
}
return result;
}
module.exports = uniqByKey;
@@ -1,5 +1,82 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`description.graphql format 1`] = `
====================================options=====================================
parsers: ["graphql"]
printWidth: 80
| printWidth
=====================================input======================================
""" Customer """
type Person {name: String}
""" Customer """
type Person {name: String}
"""
Customer
"""
type Person {name: String}
""""""
type Person {name: String}
""" """
type Person {name: String}
"""
1
2
"""
type Person {name: String}
=====================================output=====================================
"""
Customer
"""
type Person {
name: String
}
"""
Customer
"""
type Person {
name: String
}
"""
Customer
"""
type Person {
name: String
}
"""
"""
type Person {
name: String
}
"""
"""
type Person {
name: String
}
"""
1
2
"""
type Person {
name: String
}
================================================================================
`;
exports[`string.graphql format 1`] = `
====================================options=====================================
parsers: ["graphql"]
@@ -59,6 +136,14 @@ one: string
foo(input: {multiline: "ab\\ncd"}) { id }
}
{
foo(input: {multiline: """ foo """}) { id }
}
{
foo(input: {multiline: """ """}) { id }
}
=====================================output=====================================
query X($a: Int) @relay(meta: "{\\"lowPri\\": true}") {
a
@@ -129,5 +214,28 @@ input Input {
}
}
{
foo(
input: {
multiline: """
foo
"""
}
) {
id
}
}
{
foo(
input: {
multiline: """
"""
}
) {
id
}
}
================================================================================
`;
@@ -0,0 +1,25 @@
""" Customer """
type Person {name: String}
""" Customer """
type Person {name: String}
"""
Customer
"""
type Person {name: String}
""""""
type Person {name: String}
""" """
type Person {name: String}
"""
1
2
"""
type Person {name: String}
@@ -50,3 +50,11 @@ one: string
{
foo(input: {multiline: "ab\ncd"}) { id }
}
{
foo(input: {multiline: """ foo """}) { id }
}
{
foo(input: {multiline: """ """}) { id }
}
@@ -1017,9 +1017,9 @@ exports[`function-sent.js [acorn] format 1`] = `
"Unexpected token (4:33)
2 |
3 | function* generator() {
> 4 | console.log(\\"Sent\\", function.sent);
> 4 | console.log("Sent", function.sent);
| ^
5 | console.log(\\"Yield\\", yield);
5 | console.log("Yield", yield);
6 | }
7 |"
`;
@@ -1028,9 +1028,9 @@ exports[`function-sent.js [espree] format 1`] = `
"Unexpected token . (4:33)
2 |
3 | function* generator() {
> 4 | console.log(\\"Sent\\", function.sent);
> 4 | console.log("Sent", function.sent);
| ^
5 | console.log(\\"Yield\\", yield);
5 | console.log("Yield", yield);
6 | }
7 |"
`;
@@ -1039,9 +1039,9 @@ exports[`function-sent.js [meriyah] format 1`] = `
"Expected '(' (4:33)
2 |
3 | function* generator() {
> 4 | console.log(\\"Sent\\", function.sent);
> 4 | console.log("Sent", function.sent);
| ^
5 | console.log(\\"Yield\\", yield);
5 | console.log("Yield", yield);
6 | }
7 |"
`;
@@ -1080,21 +1080,21 @@ iterator.next(2); // Logs "Yield 2"
exports[`import-assertions-dynamic.js [acorn] format 1`] = `
"Unexpected token (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
exports[`import-assertions-dynamic.js [espree] format 1`] = `
"Unexpected token , (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
exports[`import-assertions-dynamic.js [meriyah] format 1`] = `
"Expected ')' (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
@@ -1115,21 +1115,21 @@ import("./foo.json", { assert: { type: "json" } });
exports[`import-assertions-static.js [acorn] format 1`] = `
"Unexpected token (1:31)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\" };
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |"
`;
exports[`import-assertions-static.js [espree] format 1`] = `
"Unexpected token assert (1:31)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\" };
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |"
`;
exports[`import-assertions-static.js [meriyah] format 1`] = `
"Unexpected token: 'identifier' (1:36)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\" };
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |"
`;
@@ -1297,9 +1297,9 @@ let m = module {
exports[`module-string-names.js [meriyah] format 1`] = `
"Expected '}' (1:13)
> 1 | import { \\"😄\\" as smile } from \\"./emojis.js\\";
> 1 | import { "😄" as smile } from "./emojis.js";
| ^
2 | export { smile as \\"😄\\" } from \\"./emojis.js\\";
2 | export { smile as "😄" } from "./emojis.js";
3 |"
`;
@@ -1884,9 +1884,9 @@ return list |> take(prefix.length, %) |> equals(%, prefix);
exports[`pipeline-operator-minimal.js [acorn] format 1`] = `
"Identifier 'result' has already been declared (7:5)
5 | result //=> \\"Hello, hello!\\"
5 | result //=> "Hello, hello!"
6 |
> 7 | let result = \\"hello\\"
> 7 | let result = "hello"
| ^
8 | |> doubleSay
9 | |> capitalize
@@ -1895,9 +1895,9 @@ exports[`pipeline-operator-minimal.js [acorn] format 1`] = `
exports[`pipeline-operator-minimal.js [espree] format 1`] = `
"Identifier 'result' has already been declared (7:5)
5 | result //=> \\"Hello, hello!\\"
5 | result //=> "Hello, hello!"
6 |
> 7 | let result = \\"hello\\"
> 7 | let result = "hello"
| ^
8 | |> doubleSay
9 | |> capitalize
@@ -1907,7 +1907,7 @@ exports[`pipeline-operator-minimal.js [espree] format 1`] = `
exports[`pipeline-operator-minimal.js [meriyah] format 1`] = `
"Unexpected token: '>' (8:4)
6 |
7 | let result = \\"hello\\"
7 | let result = "hello"
> 8 | |> doubleSay
| ^
9 | |> capitalize
@@ -5,7 +5,7 @@ exports[`null-arguments-item.js [__babel_estree] format 1`] = `
> 1 | foor('a', , 'b');
| ^
2 | foo('looooooooooooooooooooooooooooooooooooooooooooooong', , 'looooooooooooooooooooooooooooooooooooooooooooooong');
3 | foo(\\"a\\",
3 | foo("a",
4 | //1"
`;
@@ -14,7 +14,7 @@ exports[`null-arguments-item.js [acorn] format 1`] = `
> 1 | foor('a', , 'b');
| ^
2 | foo('looooooooooooooooooooooooooooooooooooooooooooooong', , 'looooooooooooooooooooooooooooooooooooooooooooooong');
3 | foo(\\"a\\",
3 | foo("a",
4 | //1"
`;
@@ -23,7 +23,7 @@ exports[`null-arguments-item.js [babel] format 1`] = `
> 1 | foor('a', , 'b');
| ^
2 | foo('looooooooooooooooooooooooooooooooooooooooooooooong', , 'looooooooooooooooooooooooooooooooooooooooooooooong');
3 | foo(\\"a\\",
3 | foo("a",
4 | //1"
`;
@@ -32,7 +32,7 @@ exports[`null-arguments-item.js [espree] format 1`] = `
> 1 | foor('a', , 'b');
| ^
2 | foo('looooooooooooooooooooooooooooooooooooooooooooooong', , 'looooooooooooooooooooooooooooooooooooooooooooooong');
3 | foo(\\"a\\",
3 | foo("a",
4 | //1"
`;
@@ -41,6 +41,6 @@ exports[`null-arguments-item.js [meriyah] format 1`] = `
> 1 | foor('a', , 'b');
| ^
2 | foo('looooooooooooooooooooooooooooooooooooooooooooooong', , 'looooooooooooooooooooooooooooooooooooooooooooooong');
3 | foo(\\"a\\",
3 | foo("a",
4 | //1"
`;
@@ -15,7 +15,7 @@ exports[`example.js [espree] format 1`] = `
`;
exports[`example.js [meriyah] format 1`] = `
"Calls to super must be in the \\"constructor\\" method of a class expression or class declaration that has a superclass (1:6)
"Calls to super must be in the "constructor" method of a class expression or class declaration that has a superclass (1:6)
> 1 | super();
| ^
2 |"
@@ -76,7 +76,7 @@ class Foo {
exports[`computed.js [acorn] format 1`] = `
"Unexpected token (2:12)
1 | class Foo {
> 2 | accessor [\\"bar\\"];
> 2 | accessor ["bar"];
| ^
3 | }
4 |"
@@ -85,7 +85,7 @@ exports[`computed.js [acorn] format 1`] = `
exports[`computed.js [espree] format 1`] = `
"Unexpected token [ (2:12)
1 | class Foo {
> 2 | accessor [\\"bar\\"];
> 2 | accessor ["bar"];
| ^
3 | }
4 |"
@@ -94,7 +94,7 @@ exports[`computed.js [espree] format 1`] = `
exports[`computed.js - {"semi":false} [acorn] format 1`] = `
"Unexpected token (2:12)
1 | class Foo {
> 2 | accessor [\\"bar\\"];
> 2 | accessor ["bar"];
| ^
3 | }
4 |"
@@ -103,7 +103,7 @@ exports[`computed.js - {"semi":false} [acorn] format 1`] = `
exports[`computed.js - {"semi":false} [espree] format 1`] = `
"Unexpected token [ (2:12)
1 | class Foo {
> 2 | accessor [\\"bar\\"];
> 2 | accessor ["bar"];
| ^
3 | }
4 |"
@@ -410,7 +410,7 @@ class Foo {
exports[`static-computed.js [acorn] format 1`] = `
"Unexpected token (2:19)
1 | class Foo {
> 2 | static accessor [\\"bar\\"];
> 2 | static accessor ["bar"];
| ^
3 | }
4 |"
@@ -419,7 +419,7 @@ exports[`static-computed.js [acorn] format 1`] = `
exports[`static-computed.js [espree] format 1`] = `
"Unexpected token [ (2:19)
1 | class Foo {
> 2 | static accessor [\\"bar\\"];
> 2 | static accessor ["bar"];
| ^
3 | }
4 |"
@@ -428,7 +428,7 @@ exports[`static-computed.js [espree] format 1`] = `
exports[`static-computed.js - {"semi":false} [acorn] format 1`] = `
"Unexpected token (2:19)
1 | class Foo {
> 2 | static accessor [\\"bar\\"];
> 2 | static accessor ["bar"];
| ^
3 | }
4 |"
@@ -437,7 +437,7 @@ exports[`static-computed.js - {"semi":false} [acorn] format 1`] = `
exports[`static-computed.js - {"semi":false} [espree] format 1`] = `
"Unexpected token [ (2:19)
1 | class Foo {
> 2 | static accessor [\\"bar\\"];
> 2 | static accessor ["bar"];
| ^
3 | }
4 |"
@@ -638,7 +638,7 @@ class Foo {
exports[`with-semicolon-1.js [acorn] format 1`] = `
"Unexpected token (2:12)
1 | class C {
> 2 | accessor clicked = \\"value\\";
> 2 | accessor clicked = "value";
| ^
3 | [foo]() {}
4 | }
@@ -648,7 +648,7 @@ exports[`with-semicolon-1.js [acorn] format 1`] = `
exports[`with-semicolon-1.js [espree] format 1`] = `
"Unexpected token clicked (2:12)
1 | class C {
> 2 | accessor clicked = \\"value\\";
> 2 | accessor clicked = "value";
| ^
3 | [foo]() {}
4 | }
@@ -658,7 +658,7 @@ exports[`with-semicolon-1.js [espree] format 1`] = `
exports[`with-semicolon-1.js - {"semi":false} [acorn] format 1`] = `
"Unexpected token (2:12)
1 | class C {
> 2 | accessor clicked = \\"value\\";
> 2 | accessor clicked = "value";
| ^
3 | [foo]() {}
4 | }
@@ -668,7 +668,7 @@ exports[`with-semicolon-1.js - {"semi":false} [acorn] format 1`] = `
exports[`with-semicolon-1.js - {"semi":false} [espree] format 1`] = `
"Unexpected token clicked (2:12)
1 | class C {
> 2 | accessor clicked = \\"value\\";
> 2 | accessor clicked = "value";
| ^
3 | [foo]() {}
4 | }
@@ -719,7 +719,7 @@ class C {
exports[`with-semicolon-2.js [acorn] format 1`] = `
"Unexpected token (2:12)
1 | class C {
> 2 | accessor clicked = \\"value\\";
> 2 | accessor clicked = "value";
| ^
3 | *foo() {}
4 | }
@@ -729,7 +729,7 @@ exports[`with-semicolon-2.js [acorn] format 1`] = `
exports[`with-semicolon-2.js [espree] format 1`] = `
"Unexpected token clicked (2:12)
1 | class C {
> 2 | accessor clicked = \\"value\\";
> 2 | accessor clicked = "value";
| ^
3 | *foo() {}
4 | }
@@ -739,7 +739,7 @@ exports[`with-semicolon-2.js [espree] format 1`] = `
exports[`with-semicolon-2.js - {"semi":false} [acorn] format 1`] = `
"Unexpected token (2:12)
1 | class C {
> 2 | accessor clicked = \\"value\\";
> 2 | accessor clicked = "value";
| ^
3 | *foo() {}
4 | }
@@ -749,7 +749,7 @@ exports[`with-semicolon-2.js - {"semi":false} [acorn] format 1`] = `
exports[`with-semicolon-2.js - {"semi":false} [espree] format 1`] = `
"Unexpected token clicked (2:12)
1 | class C {
> 2 | accessor clicked = \\"value\\";
> 2 | accessor clicked = "value";
| ^
3 | *foo() {}
4 | }
@@ -166,22 +166,22 @@ exports[`methods.js [acorn] format 1`] = `
"Unexpected character '@' (3:3)
1 |
2 | class Yo {
> 3 | @foo(\\"hello\\")
> 3 | @foo("hello")
| ^
4 | async plop() {}
5 |
6 | @anotherDecoratorWithALongName(\\"and a very long string as a first argument\\")"
6 | @anotherDecoratorWithALongName("and a very long string as a first argument")"
`;
exports[`methods.js [espree] format 1`] = `
"Unexpected character '@' (3:3)
1 |
2 | class Yo {
> 3 | @foo(\\"hello\\")
> 3 | @foo("hello")
| ^
4 | async plop() {}
5 |
6 | @anotherDecoratorWithALongName(\\"and a very long string as a first argument\\")"
6 | @anotherDecoratorWithALongName("and a very long string as a first argument")"
`;
exports[`methods.js format 1`] = `
@@ -266,7 +266,7 @@ export default class MyComponent {
exports[`mobx.js [acorn] format 1`] = `
"Unexpected character '@' (3:1)
1 | import {observable} from \\"mobx\\";
1 | import {observable} from "mobx";
2 |
> 3 | @observer class OrderLine {
| ^
@@ -277,7 +277,7 @@ exports[`mobx.js [acorn] format 1`] = `
exports[`mobx.js [espree] format 1`] = `
"Unexpected character '@' (3:1)
1 | import {observable} from \\"mobx\\";
1 | import {observable} from "mobx";
2 |
> 3 | @observer class OrderLine {
| ^
@@ -6,9 +6,9 @@ exports[`call-arguments.js [acorn] format 1`] = `
2 | expect(
> 3 | do {
| ^
4 | var bar = \\"foo\\";
4 | var bar = "foo";
5 | if (!bar) throw new Error(
6 | \\"unreachable\\""
6 | "unreachable""
`;
exports[`call-arguments.js [espree] format 1`] = `
@@ -17,9 +17,9 @@ exports[`call-arguments.js [espree] format 1`] = `
2 | expect(
> 3 | do {
| ^
4 | var bar = \\"foo\\";
4 | var bar = "foo";
5 | if (!bar) throw new Error(
6 | \\"unreachable\\""
6 | "unreachable""
`;
exports[`call-arguments.js [meriyah] format 1`] = `
@@ -28,9 +28,9 @@ exports[`call-arguments.js [meriyah] format 1`] = `
2 | expect(
> 3 | do {
| ^
4 | var bar = \\"foo\\";
4 | var bar = "foo";
5 | if (!bar) throw new Error(
6 | \\"unreachable\\""
6 | "unreachable""
`;
exports[`call-arguments.js format 1`] = `
@@ -2,28 +2,28 @@
exports[`assertions.js [acorn] format 1`] = `
"Unexpected token (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
exports[`assertions.js [espree] format 1`] = `
"Unexpected token , (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
exports[`assertions.js [flow] format 1`] = `
"Unexpected token \`,\`, expected the token \`)\` (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
exports[`assertions.js [meriyah] format 1`] = `
"Expected ')' (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
@@ -2,22 +2,22 @@
exports[`default-escaped.js [acorn] format 1`] = `
"Unexpected token (2:8)
1 | // export asyn\\\\u{63} from \\"async\\";
> 2 | export n\\\\u{63} from \\"async\\";
1 | // export asyn\\u{63} from "async";
> 2 | export n\\u{63} from "async";
| ^"
`;
exports[`default-escaped.js [espree] format 1`] = `
"Unexpected token n\\\\u{63} (2:8)
1 | // export asyn\\\\u{63} from \\"async\\";
> 2 | export n\\\\u{63} from \\"async\\";
"Unexpected token n\\u{63} (2:8)
1 | // export asyn\\u{63} from "async";
> 2 | export n\\u{63} from "async";
| ^"
`;
exports[`default-escaped.js [meriyah] format 1`] = `
"Unexpected token: 'identifier' (2:12)
1 | // export asyn\\\\u{63} from \\"async\\";
> 2 | export n\\\\u{63} from \\"async\\";
1 | // export asyn\\u{63} from "async";
> 2 | export n\\u{63} from "async";
| ^"
`;
@@ -81,14 +81,14 @@ export * as "foo" from "foo";
exports[`export-star-as-string2.js [flow] format 1`] = `
"Unexpected string, expected an identifier (1:13)
> 1 | export * as \\"foo\\" from 'foo'
> 1 | export * as "foo" from 'foo'
| ^^^^^
2 |"
`;
exports[`export-star-as-string2.js [typescript] format 1`] = `
"Identifier expected. (1:13)
> 1 | export * as \\"foo\\" from 'foo'
> 1 | export * as "foo" from 'foo'
| ^
2 |"
`;
@@ -2,34 +2,34 @@
exports[`test.js [acorn] format 1`] = `
"Unexpected token (3:8)
1 | export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from \\"exports\\";
1 | export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports";
2 |
> 3 | export a,{b} from \\"./baz\\";
> 3 | export a,{b} from "./baz";
| ^
4 |
5 | export * as ns from \\"mod\\";
5 | export * as ns from "mod";
6 |"
`;
exports[`test.js [espree] format 1`] = `
"Unexpected token a (3:8)
1 | export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from \\"exports\\";
1 | export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports";
2 |
> 3 | export a,{b} from \\"./baz\\";
> 3 | export a,{b} from "./baz";
| ^
4 |
5 | export * as ns from \\"mod\\";
5 | export * as ns from "mod";
6 |"
`;
exports[`test.js [meriyah] format 1`] = `
"Unexpected token: 'identifier' (3:8)
1 | export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from \\"exports\\";
1 | export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports";
2 |
> 3 | export a,{b} from \\"./baz\\";
> 3 | export a,{b} from "./baz";
| ^
4 |
5 | export * as ns from \\"mod\\";
5 | export * as ns from "mod";
6 |"
`;
@@ -2,21 +2,21 @@
exports[`dynamic-import.js [acorn] format 1`] = `
"Unexpected token (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
exports[`dynamic-import.js [espree] format 1`] = `
"Unexpected token , (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
exports[`dynamic-import.js [meriyah] format 1`] = `
"Expected ')' (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
@@ -37,32 +37,32 @@ import("./foo.json", { assert: { type: "json" } });
exports[`empty.js [acorn] format 1`] = `
"Unexpected token (2:33)
1 | export * as foo from \\"foo.json\\"
> 2 | export * as bar from \\"bar.json\\" assert { }
1 | export * as foo from "foo.json"
> 2 | export * as bar from "bar.json" assert { }
| ^
3 | export * as baz from \\"baz.json\\" assert { /* comment */ }
3 | export * as baz from "baz.json" assert { /* comment */ }
4 |
5 | import * as foo from \\"foo.json\\""
5 | import * as foo from "foo.json""
`;
exports[`empty.js [espree] format 1`] = `
"Unexpected token assert (2:33)
1 | export * as foo from \\"foo.json\\"
> 2 | export * as bar from \\"bar.json\\" assert { }
1 | export * as foo from "foo.json"
> 2 | export * as bar from "bar.json" assert { }
| ^
3 | export * as baz from \\"baz.json\\" assert { /* comment */ }
3 | export * as baz from "baz.json" assert { /* comment */ }
4 |
5 | import * as foo from \\"foo.json\\""
5 | import * as foo from "foo.json""
`;
exports[`empty.js [meriyah] format 1`] = `
"Unexpected token: 'identifier' (2:38)
1 | export * as foo from \\"foo.json\\"
> 2 | export * as bar from \\"bar.json\\" assert { }
1 | export * as foo from "foo.json"
> 2 | export * as bar from "bar.json" assert { }
| ^
3 | export * as baz from \\"baz.json\\" assert { /* comment */ }
3 | export * as baz from "baz.json" assert { /* comment */ }
4 |
5 | import * as foo from \\"foo.json\\""
5 | import * as foo from "foo.json""
`;
exports[`empty.js format 1`] = `
@@ -92,21 +92,21 @@ import * as baz from "baz.json" /* comment */;
exports[`multi-types.js [acorn] format 1`] = `
"Unexpected token (1:31)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\", type: \\"bar\\" };
> 1 | import json from "./foo.json" assert { type: "json", type: "bar" };
| ^
2 |"
`;
exports[`multi-types.js [espree] format 1`] = `
"Unexpected token assert (1:31)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\", type: \\"bar\\" };
> 1 | import json from "./foo.json" assert { type: "json", type: "bar" };
| ^
2 |"
`;
exports[`multi-types.js [meriyah] format 1`] = `
"Unexpected token: 'identifier' (1:36)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\", type: \\"bar\\" };
> 1 | import json from "./foo.json" assert { type: "json", type: "bar" };
| ^
2 |"
`;
@@ -127,21 +127,21 @@ import json from "./foo.json" assert { type: "json", type: "bar" };
exports[`non-type.js [acorn] format 1`] = `
"Unexpected token (1:28)
> 1 | import foo from \\"foo.json\\" assert { lazy: \\"true\\" };
> 1 | import foo from "foo.json" assert { lazy: "true" };
| ^
2 |"
`;
exports[`non-type.js [espree] format 1`] = `
"Unexpected token assert (1:28)
> 1 | import foo from \\"foo.json\\" assert { lazy: \\"true\\" };
> 1 | import foo from "foo.json" assert { lazy: "true" };
| ^
2 |"
`;
exports[`non-type.js [meriyah] format 1`] = `
"Unexpected token: 'identifier' (1:33)
> 1 | import foo from \\"foo.json\\" assert { lazy: \\"true\\" };
> 1 | import foo from "foo.json" assert { lazy: "true" };
| ^
2 |"
`;
@@ -178,28 +178,28 @@ assert({ type: "json" });
exports[`re-export.js [acorn] format 1`] = `
"Unexpected token (1:33)
> 1 | export { foo2 } from \\"foo.json\\" assert { type: \\"json\\" };
> 1 | export { foo2 } from "foo.json" assert { type: "json" };
| ^
2 | export * from \\"foo.json\\" assert { type: \\"json\\" };
3 | export * as foo3 from \\"foo.json\\" assert { type: \\"json\\" };
2 | export * from "foo.json" assert { type: "json" };
3 | export * as foo3 from "foo.json" assert { type: "json" };
4 |"
`;
exports[`re-export.js [espree] format 1`] = `
"Unexpected token assert (1:33)
> 1 | export { foo2 } from \\"foo.json\\" assert { type: \\"json\\" };
> 1 | export { foo2 } from "foo.json" assert { type: "json" };
| ^
2 | export * from \\"foo.json\\" assert { type: \\"json\\" };
3 | export * as foo3 from \\"foo.json\\" assert { type: \\"json\\" };
2 | export * from "foo.json" assert { type: "json" };
3 | export * as foo3 from "foo.json" assert { type: "json" };
4 |"
`;
exports[`re-export.js [meriyah] format 1`] = `
"Unexpected token: 'identifier' (1:38)
> 1 | export { foo2 } from \\"foo.json\\" assert { type: \\"json\\" };
> 1 | export { foo2 } from "foo.json" assert { type: "json" };
| ^
2 | export * from \\"foo.json\\" assert { type: \\"json\\" };
3 | export * as foo3 from \\"foo.json\\" assert { type: \\"json\\" };
2 | export * from "foo.json" assert { type: "json" };
3 | export * as foo3 from "foo.json" assert { type: "json" };
4 |"
`;
@@ -223,21 +223,21 @@ export * as foo3 from "foo.json" assert { type: "json" };
exports[`static-import.js [acorn] format 1`] = `
"Unexpected token (1:31)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\" };
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |"
`;
exports[`static-import.js [espree] format 1`] = `
"Unexpected token assert (1:31)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\" };
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |"
`;
exports[`static-import.js [meriyah] format 1`] = `
"Unexpected token: 'identifier' (1:36)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\" };
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |"
`;
@@ -258,21 +258,21 @@ import json from "./foo.json" assert { type: "json" };
exports[`without-from.js [acorn] format 1`] = `
"Unexpected token (1:14)
> 1 | import \\"foo\\" assert { type: \\"json\\" }
> 1 | import "foo" assert { type: "json" }
| ^
2 |"
`;
exports[`without-from.js [espree] format 1`] = `
"Unexpected token assert (1:14)
> 1 | import \\"foo\\" assert { type: \\"json\\" }
> 1 | import "foo" assert { type: "json" }
| ^
2 |"
`;
exports[`without-from.js [meriyah] format 1`] = `
"Unexpected token: 'identifier' (1:19)
> 1 | import \\"foo\\" assert { type: \\"json\\" }
> 1 | import "foo" assert { type: "json" }
| ^
2 |"
`;
@@ -2,21 +2,21 @@
exports[`dynamic-import.js - {"bracketSpacing":false} [acorn] format 1`] = `
"Unexpected token (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
exports[`dynamic-import.js - {"bracketSpacing":false} [espree] format 1`] = `
"Unexpected token , (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
exports[`dynamic-import.js - {"bracketSpacing":false} [meriyah] format 1`] = `
"Expected ')' (1:20)
> 1 | import(\\"./foo.json\\", { assert: { type: \\"json\\" } });
> 1 | import("./foo.json", { assert: { type: "json" } });
| ^
2 |"
`;
@@ -38,19 +38,19 @@ import("./foo.json", {assert: {type: "json"}});
exports[`empty.js - {"bracketSpacing":false} [acorn] format 1`] = `
"Unexpected token (1:33)
> 1 | export * as bar from \\"bar.json\\" assert { }
> 1 | export * as bar from "bar.json" assert { }
| ^"
`;
exports[`empty.js - {"bracketSpacing":false} [espree] format 1`] = `
"Unexpected token assert (1:33)
> 1 | export * as bar from \\"bar.json\\" assert { }
> 1 | export * as bar from "bar.json" assert { }
| ^"
`;
exports[`empty.js - {"bracketSpacing":false} [meriyah] format 1`] = `
"Unexpected token: 'identifier' (1:38)
> 1 | export * as bar from \\"bar.json\\" assert { }
> 1 | export * as bar from "bar.json" assert { }
| ^"
`;
@@ -70,21 +70,21 @@ export * as bar from "bar.json";
exports[`re-export.js - {"bracketSpacing":false} [acorn] format 1`] = `
"Unexpected token (1:33)
> 1 | export { foo2 } from \\"foo.json\\" assert { type: \\"json\\" };
> 1 | export { foo2 } from "foo.json" assert { type: "json" };
| ^
2 |"
`;
exports[`re-export.js - {"bracketSpacing":false} [espree] format 1`] = `
"Unexpected token assert (1:33)
> 1 | export { foo2 } from \\"foo.json\\" assert { type: \\"json\\" };
> 1 | export { foo2 } from "foo.json" assert { type: "json" };
| ^
2 |"
`;
exports[`re-export.js - {"bracketSpacing":false} [meriyah] format 1`] = `
"Unexpected token: 'identifier' (1:38)
> 1 | export { foo2 } from \\"foo.json\\" assert { type: \\"json\\" };
> 1 | export { foo2 } from "foo.json" assert { type: "json" };
| ^
2 |"
`;
@@ -106,21 +106,21 @@ export {foo2} from "foo.json" assert {type: "json"};
exports[`static-import.js - {"bracketSpacing":false} [acorn] format 1`] = `
"Unexpected token (1:31)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\" };
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |"
`;
exports[`static-import.js - {"bracketSpacing":false} [espree] format 1`] = `
"Unexpected token assert (1:31)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\" };
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |"
`;
exports[`static-import.js - {"bracketSpacing":false} [meriyah] format 1`] = `
"Unexpected token: 'identifier' (1:36)
> 1 | import json from \\"./foo.json\\" assert { type: \\"json\\" };
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |"
`;
@@ -5,7 +5,7 @@ exports[`comments.js [acorn] format 1`] = `
> 1 | const m = /*A1*/ module /*A2*/ { /*A3*/
| ^
2 | /*A4*/
3 | export const foo = \\"foo\\";
3 | export const foo = "foo";
4 | export { foo }; /*A5*/"
`;
@@ -14,7 +14,7 @@ exports[`comments.js [espree] format 1`] = `
> 1 | const m = /*A1*/ module /*A2*/ { /*A3*/
| ^
2 | /*A4*/
3 | export const foo = \\"foo\\";
3 | export const foo = "foo";
4 | export { foo }; /*A5*/"
`;
@@ -23,7 +23,7 @@ exports[`comments.js [meriyah] format 1`] = `
> 1 | const m = /*A1*/ module /*A2*/ { /*A3*/
| ^
2 | /*A4*/
3 | export const foo = \\"foo\\";
3 | export const foo = "foo";
4 | export { foo }; /*A5*/"
`;
@@ -211,7 +211,7 @@ exports[`range.js [acorn] format 1`] = `
| ^
2 | };
3 |
4 | foo(module { export let foo = \\"foo\\"; })"
4 | foo(module { export let foo = "foo"; })"
`;
exports[`range.js [espree] format 1`] = `
@@ -220,7 +220,7 @@ exports[`range.js [espree] format 1`] = `
| ^
2 | };
3 |
4 | foo(module { export let foo = \\"foo\\"; })"
4 | foo(module { export let foo = "foo"; })"
`;
exports[`range.js [meriyah] format 1`] = `
@@ -229,7 +229,7 @@ exports[`range.js [meriyah] format 1`] = `
| ^
2 | };
3 |
4 | foo(module { export let foo = \\"foo\\"; })"
4 | foo(module { export let foo = "foo"; })"
`;
exports[`range.js format 1`] = `
@@ -2,11 +2,11 @@
exports[`module-string-names-export.js [meriyah] format 1`] = `
"Only a identifier can be used to indicate alias (1:26)
> 1 | export { smile as \\"smile1\\" } from \\"./emojis.js\\";
> 1 | export { smile as "smile1" } from "./emojis.js";
| ^
2 | export { \\"smile\\" as smile2 } from \\"./emojis.js\\";
3 | export { \\"smile\\" as \\"smile3\\" } from \\"./emojis.js\\";
4 | export { foo1, bar as \\"foo2\\" } from \\"./emojis.js\\";"
2 | export { "smile" as smile2 } from "./emojis.js";
3 | export { "smile" as "smile3" } from "./emojis.js";
4 | export { foo1, bar as "foo2" } from "./emojis.js";"
`;
exports[`module-string-names-export.js format 1`] = `
@@ -38,10 +38,10 @@ export { "smile4" } from "./emojis.js";
exports[`module-string-names-import.js [meriyah] format 1`] = `
"Expected '}' (1:18)
> 1 | import { \\"default\\" as quotation1 } from \\"Confucius\\";
> 1 | import { "default" as quotation1 } from "Confucius";
| ^
2 | import { \\"foo\\" as bar, \\"default\\" as qux } from \\"module-a\\";
3 | import { \\"學而時習之,不亦說乎?\\" as quotation2 } from \\"Confucius\\";
2 | import { "foo" as bar, "default" as qux } from "module-a";
3 | import { "學而時習之,不亦說乎?" as quotation2 } from "Confucius";
4 |"
`;
@@ -2,53 +2,53 @@
exports[`text.js [acorn] format 1`] = `
"Bad escape sequence in untagged template literal (6:18)
4 | foo = markdown\`\\\\u{prettier}\\\\u{0065}\`;
5 | foo = css\`\\\\u{prettier}\\\\u{0065}\`;
> 6 | foo = /* HTML */\`\\\\u{prettier}\\\\u{0065}\`;
4 | foo = markdown\`\\u{prettier}\\u{0065}\`;
5 | foo = css\`\\u{prettier}\\u{0065}\`;
> 6 | foo = /* HTML */\`\\u{prettier}\\u{0065}\`;
| ^
7 | foo = /* GraphQL */\`\\\\u{prettier}\\\\u{0065}\`;
7 | foo = /* GraphQL */\`\\u{prettier}\\u{0065}\`;
8 |
9 | foo = foo\`\\\\u{prettier}\${foo}pr\\\\u{0065}ttier\`;"
9 | foo = foo\`\\u{prettier}\${foo}pr\\u{0065}ttier\`;"
`;
exports[`text.js [espree] format 1`] = `
"Bad escape sequence in untagged template literal (6:18)
4 | foo = markdown\`\\\\u{prettier}\\\\u{0065}\`;
5 | foo = css\`\\\\u{prettier}\\\\u{0065}\`;
> 6 | foo = /* HTML */\`\\\\u{prettier}\\\\u{0065}\`;
4 | foo = markdown\`\\u{prettier}\\u{0065}\`;
5 | foo = css\`\\u{prettier}\\u{0065}\`;
> 6 | foo = /* HTML */\`\\u{prettier}\\u{0065}\`;
| ^
7 | foo = /* GraphQL */\`\\\\u{prettier}\\\\u{0065}\`;
7 | foo = /* GraphQL */\`\\u{prettier}\\u{0065}\`;
8 |
9 | foo = foo\`\\\\u{prettier}\${foo}pr\\\\u{0065}ttier\`;"
9 | foo = foo\`\\u{prettier}\${foo}pr\\u{0065}ttier\`;"
`;
exports[`text.js [flow] format 1`] = `
"Unexpected token ILLEGAL (1:12)
> 1 | foo = foo\`\\\\u{prettier}\\\\u{0065}\`;
> 1 | foo = foo\`\\u{prettier}\\u{0065}\`;
| ^
2 | foo = html\`\\\\u{prettier}\\\\u{0065}\`;
3 | foo = graphql\`\\\\u{prettier}\\\\u{0065}\`;
4 | foo = markdown\`\\\\u{prettier}\\\\u{0065}\`;"
2 | foo = html\`\\u{prettier}\\u{0065}\`;
3 | foo = graphql\`\\u{prettier}\\u{0065}\`;
4 | foo = markdown\`\\u{prettier}\\u{0065}\`;"
`;
exports[`text.js [meriyah] format 1`] = `
"Invalid hexadecimal escape sequence (6:20)
4 | foo = markdown\`\\\\u{prettier}\\\\u{0065}\`;
5 | foo = css\`\\\\u{prettier}\\\\u{0065}\`;
> 6 | foo = /* HTML */\`\\\\u{prettier}\\\\u{0065}\`;
4 | foo = markdown\`\\u{prettier}\\u{0065}\`;
5 | foo = css\`\\u{prettier}\\u{0065}\`;
> 6 | foo = /* HTML */\`\\u{prettier}\\u{0065}\`;
| ^
7 | foo = /* GraphQL */\`\\\\u{prettier}\\\\u{0065}\`;
7 | foo = /* GraphQL */\`\\u{prettier}\\u{0065}\`;
8 |
9 | foo = foo\`\\\\u{prettier}\${foo}pr\\\\u{0065}ttier\`;"
9 | foo = foo\`\\u{prettier}\${foo}pr\\u{0065}ttier\`;"
`;
exports[`text.js [typescript] format 1`] = `
"Hexadecimal digit expected. (1:14)
> 1 | foo = foo\`\\\\u{prettier}\\\\u{0065}\`;
> 1 | foo = foo\`\\u{prettier}\\u{0065}\`;
| ^
2 | foo = html\`\\\\u{prettier}\\\\u{0065}\`;
3 | foo = graphql\`\\\\u{prettier}\\\\u{0065}\`;
4 | foo = markdown\`\\\\u{prettier}\\\\u{0065}\`;"
2 | foo = html\`\\u{prettier}\\u{0065}\`;
3 | foo = graphql\`\\u{prettier}\\u{0065}\`;
4 | foo = markdown\`\\u{prettier}\\u{0065}\`;"
`;
exports[`text.js format 1`] = `
@@ -2,7 +2,7 @@
exports[`computed.js [acorn] format 1`] = `
"Unexpected character '{' (2:9)
1 | const key = \\"a\\";
1 | const key = "a";
> 2 | assert(#{ [key]: 1 } === #{ a: 1 })
| ^
3 | assert(#{ [key.toUpperCase()]: 1 } === #{ A: 1 })
@@ -12,7 +12,7 @@ exports[`computed.js [acorn] format 1`] = `
exports[`computed.js [espree] format 1`] = `
"Unexpected character '{' (2:9)
1 | const key = \\"a\\";
1 | const key = "a";
> 2 | assert(#{ [key]: 1 } === #{ a: 1 })
| ^
3 | assert(#{ [key.toUpperCase()]: 1 } === #{ A: 1 })
@@ -22,7 +22,7 @@ exports[`computed.js [espree] format 1`] = `
exports[`computed.js [meriyah] format 1`] = `
"'#' not followed by identifier (2:8)
1 | const key = \\"a\\";
1 | const key = "a";
> 2 | assert(#{ [key]: 1 } === #{ a: 1 })
| ^
3 | assert(#{ [key.toUpperCase()]: 1 } === #{ A: 1 })
@@ -190,7 +190,7 @@ assert(record1.d?.a === undefined);
exports[`shorthand.js [acorn] format 1`] = `
"Unexpected character '{' (2:17)
1 | const url = \\"https://github.com/tc39/proposal-record-tuple\\";
1 | const url = "https://github.com/tc39/proposal-record-tuple";
> 2 | const record = #{ url }
| ^
3 | console.log(record.url) // https://github.com/tc39/proposal-record-tuple
@@ -199,7 +199,7 @@ exports[`shorthand.js [acorn] format 1`] = `
exports[`shorthand.js [espree] format 1`] = `
"Unexpected character '{' (2:17)
1 | const url = \\"https://github.com/tc39/proposal-record-tuple\\";
1 | const url = "https://github.com/tc39/proposal-record-tuple";
> 2 | const record = #{ url }
| ^
3 | console.log(record.url) // https://github.com/tc39/proposal-record-tuple
@@ -208,7 +208,7 @@ exports[`shorthand.js [espree] format 1`] = `
exports[`shorthand.js [meriyah] format 1`] = `
"'#' not followed by identifier (2:16)
1 | const url = \\"https://github.com/tc39/proposal-record-tuple\\";
1 | const url = "https://github.com/tc39/proposal-record-tuple";
> 2 | const record = #{ url }
| ^
3 | console.log(record.url) // https://github.com/tc39/proposal-record-tuple
@@ -235,28 +235,28 @@ console.log(record.url); // https://github.com/tc39/proposal-record-tuple
exports[`spread.js [acorn] format 1`] = `
"Unexpected character '{' (1:19)
> 1 | const formData = #{ title: \\"Implement all the things\\" }
> 1 | const formData = #{ title: "Implement all the things" }
| ^
2 | const taskNow = #{ id: 42, status: \\"WIP\\", ...formData }
3 | const taskLater = #{ ...taskNow, status: \\"DONE\\" }
2 | const taskNow = #{ id: 42, status: "WIP", ...formData }
3 | const taskLater = #{ ...taskNow, status: "DONE" }
4 |"
`;
exports[`spread.js [espree] format 1`] = `
"Unexpected character '{' (1:19)
> 1 | const formData = #{ title: \\"Implement all the things\\" }
> 1 | const formData = #{ title: "Implement all the things" }
| ^
2 | const taskNow = #{ id: 42, status: \\"WIP\\", ...formData }
3 | const taskLater = #{ ...taskNow, status: \\"DONE\\" }
2 | const taskNow = #{ id: 42, status: "WIP", ...formData }
3 | const taskLater = #{ ...taskNow, status: "DONE" }
4 |"
`;
exports[`spread.js [meriyah] format 1`] = `
"'#' not followed by identifier (1:18)
> 1 | const formData = #{ title: \\"Implement all the things\\" }
> 1 | const formData = #{ title: "Implement all the things" }
| ^
2 | const taskNow = #{ id: 42, status: \\"WIP\\", ...formData }
3 | const taskLater = #{ ...taskNow, status: \\"DONE\\" }
2 | const taskNow = #{ id: 42, status: "WIP", ...formData }
3 | const taskLater = #{ ...taskNow, status: "DONE" }
4 |"
`;
@@ -4,44 +4,44 @@ exports[`non-octal-eight-and-nine.js [acorn] format 1`] = `
"Invalid escape sequence (3:3)
1 | // https://github.com/babel/babel/pull/11852
2 |
> 3 | \\"\\\\8\\",\\"\\\\9\\";
> 3 | "\\8","\\9";
| ^
4 | () => {
5 | \\"use strict\\";
6 | \\"\\\\8\\", \\"\\\\9\\";"
5 | "use strict";
6 | "\\8", "\\9";"
`;
exports[`non-octal-eight-and-nine.js [espree] format 1`] = `
"Invalid escape sequence (3:3)
1 | // https://github.com/babel/babel/pull/11852
2 |
> 3 | \\"\\\\8\\",\\"\\\\9\\";
> 3 | "\\8","\\9";
| ^
4 | () => {
5 | \\"use strict\\";
6 | \\"\\\\8\\", \\"\\\\9\\";"
5 | "use strict";
6 | "\\8", "\\9";"
`;
exports[`non-octal-eight-and-nine.js - {"trailingComma":"all"} [acorn] format 1`] = `
"Invalid escape sequence (3:3)
1 | // https://github.com/babel/babel/pull/11852
2 |
> 3 | \\"\\\\8\\",\\"\\\\9\\";
> 3 | "\\8","\\9";
| ^
4 | () => {
5 | \\"use strict\\";
6 | \\"\\\\8\\", \\"\\\\9\\";"
5 | "use strict";
6 | "\\8", "\\9";"
`;
exports[`non-octal-eight-and-nine.js - {"trailingComma":"all"} [espree] format 1`] = `
"Invalid escape sequence (3:3)
1 | // https://github.com/babel/babel/pull/11852
2 |
> 3 | \\"\\\\8\\",\\"\\\\9\\";
> 3 | "\\8","\\9";
| ^
4 | () => {
5 | \\"use strict\\";
6 | \\"\\\\8\\", \\"\\\\9\\";"
5 | "use strict";
6 | "\\8", "\\9";"
`;
exports[`non-octal-eight-and-nine.js - {"trailingComma":"all"} format 1`] = `
@@ -2,29 +2,29 @@
exports[`throw_expression.js [acorn] format 1`] = `
"Unexpected token (1:26)
> 1 | function save(filename = throw new TypeError(\\"Argument required\\")) {}
> 1 | function save(filename = throw new TypeError("Argument required")) {}
| ^
2 |
3 | lint(ast, {
4 | with: () => throw new Error(\\"avoid using 'with' statements.\\")"
4 | with: () => throw new Error("avoid using 'with' statements.")"
`;
exports[`throw_expression.js [espree] format 1`] = `
"Unexpected token throw (1:26)
> 1 | function save(filename = throw new TypeError(\\"Argument required\\")) {}
> 1 | function save(filename = throw new TypeError("Argument required")) {}
| ^
2 |
3 | lint(ast, {
4 | with: () => throw new Error(\\"avoid using 'with' statements.\\")"
4 | with: () => throw new Error("avoid using 'with' statements.")"
`;
exports[`throw_expression.js [meriyah] format 1`] = `
"Unexpected token: 'throw' (1:30)
> 1 | function save(filename = throw new TypeError(\\"Argument required\\")) {}
> 1 | function save(filename = throw new TypeError("Argument required")) {}
| ^
2 |
3 | lint(ast, {
4 | with: () => throw new Error(\\"avoid using 'with' statements.\\")"
4 | with: () => throw new Error("avoid using 'with' statements.")"
`;
exports[`throw_expression.js format 1`] = `
@@ -2,7 +2,7 @@
exports[`trailing.js [acorn] format 1`] = `
"Unexpected token (1:8)
> 1 | export type Result<T, V> = | { kind: \\"not-test-editor1\\" } | { kind: \\"not-test-editor2\\" };
> 1 | export type Result<T, V> = | { kind: "not-test-editor1" } | { kind: "not-test-editor2" };
| ^
2 |
3 | // Note: there are trailing whitespace in this file
@@ -11,7 +11,7 @@ exports[`trailing.js [acorn] format 1`] = `
exports[`trailing.js [espree] format 1`] = `
"Unexpected token type (1:8)
> 1 | export type Result<T, V> = | { kind: \\"not-test-editor1\\" } | { kind: \\"not-test-editor2\\" };
> 1 | export type Result<T, V> = | { kind: "not-test-editor1" } | { kind: "not-test-editor2" };
| ^
2 |
3 | // Note: there are trailing whitespace in this file
@@ -20,7 +20,7 @@ exports[`trailing.js [espree] format 1`] = `
exports[`trailing.js [meriyah] format 1`] = `
"Unexpected token: 'identifier' (1:11)
> 1 | export type Result<T, V> = | { kind: \\"not-test-editor1\\" } | { kind: \\"not-test-editor2\\" };
> 1 | export type Result<T, V> = | { kind: "not-test-editor1" } | { kind: "not-test-editor2" };
| ^
2 |
3 | // Note: there are trailing whitespace in this file
@@ -46,7 +46,7 @@ exports[`parenthesized-decorators-tagged-template.ts [babel-ts] format 1`] = `
1 | class Test {
> 2 | @foo\`bar\`
| ^
3 | text: string = \\"text\\"
3 | text: string = "text"
4 | }
5 |"
`;
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`snippet: #0 [missing-comments] format 1`] = `"Comment \\"comment\\" was not printed. Please report this error!"`;
exports[`snippet: #0 [missing-comments] format 1`] = `"Comment "comment" was not printed. Please report this error!"`;
@@ -10,7 +10,7 @@ exports[`async-arrow-invalid.js [flow] format 1`] = `
exports[`default-escaped.js [flow] format 1`] = `
"Unexpected identifier, expected the token \`{\` (1:8)
> 1 | export asyn\\\\u{63} from \\"async\\";
> 1 | export asyn\\u{63} from "async";
| ^^^^^^^^^^
2 |"
`;
@@ -31,14 +31,14 @@ exports[`function-async.js [flow] format 1`] = `
exports[`module-attributes-dynamic.js [flow] format 1`] = `
"Unexpected token \`,\`, expected the token \`)\` (1:18)
> 1 | import(\\"foo.json\\", { with: { type: \\"json\\" } })
> 1 | import("foo.json", { with: { type: "json" } })
| ^
2 |"
`;
exports[`module-attributes-static.js [flow] format 1`] = `
"Unexpected token \`with\`, expected the token \`;\` (1:28)
> 1 | import foo from \\"foo.json\\" with type: \\"json\\";
> 1 | import foo from "foo.json" with type: "json";
| ^^^^
2 |"
`;
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`type-interfaces.graphql [graphql] format 1`] = `
"Syntax Error: Unexpected \\"|\\". (5:21)
"Syntax Error: Unexpected "|". (5:21)
3 | # which will break seperator detection added in #7305
4 |
> 5 | type A implements A | B {
@@ -7,7 +7,7 @@ exports[`snippet: #0 [acorn] format 1`] = `
`;
exports[`snippet: #0 [babel] format 1`] = `
"Unexpected token, expected \\"(\\" (1:5)
"Unexpected token, expected "(" (1:5)
> 1 | for each (a in b) {}
| ^"
`;
@@ -19,7 +19,7 @@ exports[`snippet: #0 [babel] format 2`] = `
`;
exports[`snippet: #0 [babel-flow] format 1`] = `
"Unexpected token, expected \\"(\\" (1:5)
"Unexpected token, expected "(" (1:5)
> 1 | for each (a in b) {}
| ^"
`;
@@ -31,7 +31,7 @@ exports[`snippet: #0 [babel-flow] format 2`] = `
`;
exports[`snippet: #0 [babel-ts] format 1`] = `
"Unexpected token, expected \\"(\\" (1:5)
"Unexpected token, expected "(" (1:5)
> 1 | for each (a in b) {}
| ^"
`;
@@ -13,42 +13,42 @@ exports[`html-like-comments.js [babel] format 1`] = `
exports[`import-assertions-for-export-without-from.js [babel] format 1`] = `
"Missing semicolon. (1:15)
> 1 | export { foo } assert { type: \\"json\\" };
> 1 | export { foo } assert { type: "json" };
| ^
2 |"
`;
exports[`import-assertions-with-parens.js [babel] format 1`] = `
"Unexpected token (1:19)
> 1 | import \\"x\\" assert ({type: 'json'});
> 1 | import "x" assert ({type: 'json'});
| ^
2 |"
`;
exports[`invalid-escape-in-identifier.js [babel] format 1`] = `
"Invalid Unicode escape. (1:7)
> 1 | const \\\\u{20} = 1
> 1 | const \\u{20} = 1
| ^
2 | const \\\\u{3000} = 1
2 | const \\u{3000} = 1
3 |"
`;
exports[`invalid-escape-in-identifier-2.js [babel] format 1`] = `
"Expecting Unicode escape sequence \\\\uXXXX. (1:3)
> 1 | a\\\\ = a
"Expecting Unicode escape sequence \\uXXXX. (1:3)
> 1 | a\\ = a
| ^
2 |"
`;
exports[`module-attributes.js [babel] format 1`] = `
"Unexpected token, expected \\"(\\" (1:33)
> 1 | import foo from \\"foo.json\\" with type: \\"json\\";
"Unexpected token, expected "(" (1:33)
> 1 | import foo from "foo.json" with type: "json";
| ^
2 |"
`;
exports[`no-for-in-init-concise-binary-in.js [babel] format 1`] = `
"Unexpected token, expected \\")\\" (3:18)
"Unexpected token, expected ")" (3:18)
1 | // https://github.com/babel/babel/pull/11931
2 |
> 3 | for (() => x in y;;);
@@ -64,7 +64,7 @@ exports[`partial-template-strings.js [babel] format 1`] = `
| ^
7 | name_not_found: \`'\${?}' not found.\`
8 | };
9 | Diagnostics.name_not_found(\\"foo\\"); // \\"'foo' not found.\\""
9 | Diagnostics.name_not_found("foo"); // "'foo' not found.""
`;
exports[`snippet: #0 [babel] format 1`] = `
@@ -155,7 +155,7 @@ exports[`snippet: #4 [acorn] format 1`] = `
`;
exports[`snippet: #4 [babel] format 1`] = `
"Unexpected token, expected \\",\\" (1:22)
"Unexpected token, expected "," (1:22)
> 1 | async (a) => (await a!) ** 6;
| ^"
`;
@@ -55,7 +55,7 @@ exports[`snippet: #0 [flow] format 1`] = `
`;
exports[`snippet: #0 [meriyah] format 1`] = `
"Identifier \\"let\\" disallowed as left-hand side expression in strict mode (1:9)
"Identifier "let" disallowed as left-hand side expression in strict mode (1:9)
> 1 | for (let.foo of []);
| ^"
`;
@@ -91,7 +91,7 @@ exports[`snippet: #1 [flow] format 1`] = `
`;
exports[`snippet: #1 [meriyah] format 1`] = `
"Identifier \\"let\\" disallowed as left-hand side expression in strict mode (1:9)
"Identifier "let" disallowed as left-hand side expression in strict mode (1:9)
> 1 | for (let().bar of []);
| ^"
`;
@@ -127,7 +127,7 @@ exports[`snippet: #2 [flow] format 1`] = `
`;
exports[`snippet: #2 [meriyah] format 1`] = `
"Identifier \\"let\\" disallowed as left-hand side expression in strict mode (1:10)
"Identifier "let" disallowed as left-hand side expression in strict mode (1:10)
> 1 | for (let\`\`.bar of []);
| ^"
`;
@@ -14,12 +14,12 @@ exports[`snippet: #0 [meriyah] format 1`] = `
exports[`snippet: #1 [espree] format 1`] = `
"The keyword 'interface' is reserved (1:8)
> 1 | import interface from \\"foo\\";
> 1 | import interface from "foo";
| ^"
`;
exports[`snippet: #1 [meriyah] format 1`] = `
"Unexpected strict mode reserved word (1:16)
> 1 | import interface from \\"foo\\";
> 1 | import interface from "foo";
| ^"
`;
@@ -20,91 +20,91 @@ exports[`snippet: #0 [json5] format 1`] = `
exports[`snippet: #1 [json] format 1`] = `
"Computed key is not allowed in JSON. (1:3)
> 1 | {[\\"foo\\"]:\\"bar\\"}
> 1 | {["foo"]:"bar"}
| ^^^^^"
`;
exports[`snippet: #1 [json-stringify] format 1`] = `
"Computed key is not allowed in JSON. (1:3)
> 1 | {[\\"foo\\"]:\\"bar\\"}
> 1 | {["foo"]:"bar"}
| ^^^^^"
`;
exports[`snippet: #1 [json5] format 1`] = `
"Computed key is not allowed in JSON. (1:3)
> 1 | {[\\"foo\\"]:\\"bar\\"}
> 1 | {["foo"]:"bar"}
| ^^^^^"
`;
exports[`snippet: #2 [json] format 1`] = `
"Operator '~' is not allowed in JSON. (1:9)
> 1 | {\\"foo\\": ~1}
> 1 | {"foo": ~1}
| ^^"
`;
exports[`snippet: #2 [json-stringify] format 1`] = `
"Operator '~' is not allowed in JSON. (1:9)
> 1 | {\\"foo\\": ~1}
> 1 | {"foo": ~1}
| ^^"
`;
exports[`snippet: #2 [json5] format 1`] = `
"Operator '~' is not allowed in JSON. (1:9)
> 1 | {\\"foo\\": ~1}
> 1 | {"foo": ~1}
| ^^"
`;
exports[`snippet: #3 [json] format 1`] = `
"'LogicalExpression' is not allowed in JSON. (1:9)
> 1 | {\\"foo\\": false || \\"bar\\"}
> 1 | {"foo": false || "bar"}
| ^^^^^^^^^^^^^^"
`;
exports[`snippet: #3 [json-stringify] format 1`] = `
"'LogicalExpression' is not allowed in JSON. (1:9)
> 1 | {\\"foo\\": false || \\"bar\\"}
> 1 | {"foo": false || "bar"}
| ^^^^^^^^^^^^^^"
`;
exports[`snippet: #3 [json5] format 1`] = `
"'LogicalExpression' is not allowed in JSON. (1:9)
> 1 | {\\"foo\\": false || \\"bar\\"}
> 1 | {"foo": false || "bar"}
| ^^^^^^^^^^^^^^"
`;
exports[`snippet: #4 [json] format 1`] = `
"'ArrowFunctionExpression' is not allowed in JSON. (1:9)
> 1 | {\\"foo\\": () => {}}
> 1 | {"foo": () => {}}
| ^^^^^^^^"
`;
exports[`snippet: #4 [json-stringify] format 1`] = `
"'ArrowFunctionExpression' is not allowed in JSON. (1:9)
> 1 | {\\"foo\\": () => {}}
> 1 | {"foo": () => {}}
| ^^^^^^^^"
`;
exports[`snippet: #4 [json5] format 1`] = `
"'ArrowFunctionExpression' is not allowed in JSON. (1:9)
> 1 | {\\"foo\\": () => {}}
> 1 | {"foo": () => {}}
| ^^^^^^^^"
`;
exports[`snippet: #5 [json] format 1`] = `
"Expecting Unicode escape sequence \\\\uXXXX. (1:10)
> 1 | packages\\\\the-hub\\\\cypress\\\\fixtures\\\\gridConfiguration.json
"Expecting Unicode escape sequence \\uXXXX. (1:10)
> 1 | packages\\the-hub\\cypress\\fixtures\\gridConfiguration.json
| ^"
`;
exports[`snippet: #5 [json-stringify] format 1`] = `
"Expecting Unicode escape sequence \\\\uXXXX. (1:10)
> 1 | packages\\\\the-hub\\\\cypress\\\\fixtures\\\\gridConfiguration.json
"Expecting Unicode escape sequence \\uXXXX. (1:10)
> 1 | packages\\the-hub\\cypress\\fixtures\\gridConfiguration.json
| ^"
`;
exports[`snippet: #5 [json5] format 1`] = `
"Expecting Unicode escape sequence \\\\uXXXX. (1:10)
> 1 | packages\\\\the-hub\\\\cypress\\\\fixtures\\\\gridConfiguration.json
"Expecting Unicode escape sequence \\uXXXX. (1:10)
> 1 | packages\\the-hub\\cypress\\fixtures\\gridConfiguration.json
| ^"
`;
@@ -401,21 +401,21 @@ exports[`snippet: #21 [json5] format 1`] = `
exports[`snippet: #22 [json] format 1`] = `
"Unexpected token (2:1)
1 | \\"use strict\\"
1 | "use strict"
> 2 | {}
| ^"
`;
exports[`snippet: #22 [json-stringify] format 1`] = `
"Unexpected token (2:1)
1 | \\"use strict\\"
1 | "use strict"
> 2 | {}
| ^"
`;
exports[`snippet: #22 [json5] format 1`] = `
"Unexpected token (2:1)
1 | \\"use strict\\"
1 | "use strict"
> 2 | {}
| ^"
`;
@@ -2,7 +2,7 @@
exports[`snippet: #0 [json-stringify] format 1`] = `
"Comment is not allowed in JSON. (1:1)
> 1 | /* comment */{\\"foo\\": 1}
> 1 | /* comment */{"foo": 1}
| ^^^^^^^^^^^^^"
`;
@@ -10,11 +10,11 @@ exports[`snippet: #1 [json-stringify] format 1`] = `
"Comment is not allowed in JSON. (1:1)
> 1 | // comment
| ^^^^^^^^^^
2 | {\\"foo\\": 1}"
2 | {"foo": 1}"
`;
exports[`snippet: #2 [json-stringify] format 1`] = `
"Comment is not allowed in JSON. (1:9)
> 1 | {\\"foo\\": /* comment */ 1}
> 1 | {"foo": /* comment */ 1}
| ^^^^^^^^^^^^^"
`;
@@ -14,7 +14,7 @@ exports[`inline-comment.less [less] format 1`] = `
exports[`open-double-quote.less [less] format 1`] = `
"CssSyntaxError: Unclosed string (2:17)
1 | a {
> 2 | background: url(\\"
> 2 | background: url("
| ^
3 | }
4 |"
@@ -2,7 +2,7 @@
exports[`default-escaped.ts [typescript] format 1`] = `
"Declaration or statement expected. (1:1)
> 1 | export asyn\\\\u{63} from \\"async\\";
> 1 | export asyn\\u{63} from "async";
| ^
2 |"
`;
@@ -25,7 +25,7 @@ exports[`invalid-jsx-1.ts [typescript] format 1`] = `
exports[`module-attributes-static.ts [typescript] format 1`] = `
"';' expected. (1:28)
> 1 | import foo from \\"foo.json\\" with type: \\"json\\";
> 1 | import foo from "foo.json" with type: "json";
| ^
2 |"
`;
@@ -52,25 +52,25 @@ exports[`snippet: #1 [typescript] format 1`] = `
exports[`snippet: #2 [typescript] format 1`] = `
"':' expected. (1:21)
> 1 | let x3 = <div>{\\"foo\\"}}</div>;
> 1 | let x3 = <div>{"foo"}}</div>;
| ^"
`;
exports[`snippet: #3 [typescript] format 1`] = `
"':' expected. (1:21)
> 1 | let x4 = <div>{\\"foo\\"}></div>;
> 1 | let x4 = <div>{"foo"}></div>;
| ^"
`;
exports[`snippet: #4 [typescript] format 1`] = `
"Expression expected. (1:15)
> 1 | let x5 = <div>}{\\"foo\\"}</div>;
> 1 | let x5 = <div>}{"foo"}</div>;
| ^"
`;
exports[`snippet: #5 [typescript] format 1`] = `
"Expression expected. (1:15)
> 1 | let x6 = <div>>{\\"foo\\"}</div>;
> 1 | let x6 = <div>>{"foo"}</div>;
| ^"
`;
@@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`unclosed_tag.vue [vue] format 1`] = `
"Unexpected character \\"EOF\\" (2:1)
"Unexpected character "EOF" (2:1)
1 | <div
> 2 |
| ^"
`;
exports[`unclosed_tag_in_template.vue [vue] format 1`] = `
"Unexpected character \\"/\\" (4:2)
"Unexpected character "/" (4:2)
2 | <p>Templates are formatted as well...
3 | </
> 4 | </template>
@@ -17,12 +17,12 @@ exports[`unclosed_tag_in_template.vue [vue] format 1`] = `
`;
exports[`upper-case.html [vue] format 1`] = `
"Void elements do not have end tags \\"Input\\" (8:21)
6 | <div id=\\"app\\">
"Void elements do not have end tags "Input" (8:21)
6 | <div id="app">
7 | <!-- when vue parse use for html, Input should not treat as component -->
> 8 | <Input>{{value}}</Input>
| ^^^^^^^^
9 | </div>
10 | </body>
11 | <script src=\\"https://unpkg.com/vue/dist/vue.js\\"></script>"
11 | <script src="https://unpkg.com/vue/dist/vue.js"></script>"
`;
@@ -117,6 +117,29 @@ printWidth: 80
================================================================================
`;
exports[`test.importmap format 1`] = `
====================================options=====================================
parsers: []
printWidth: 80
| printWidth
=====================================input======================================
{"imports": {
"prettier": "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs",
"prettier/": "https://unpkg.com/prettier@2.6.2/"
}
}
=====================================output=====================================
{
"imports": {
"prettier": "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs",
"prettier/": "https://unpkg.com/prettier@2.6.2/"
}
}
================================================================================
`;
exports[`test.js format 1`] = `
====================================options=====================================
parsers: []
@@ -0,0 +1,5 @@
{"imports": {
"prettier": "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs",
"prettier/": "https://unpkg.com/prettier@2.6.2/"
}
}
@@ -35,7 +35,7 @@ abstract class Bar {
`;
exports[`constructor.ts [babel-ts] format 1`] = `
"Unexpected token, expected \\",\\" (2:22)
"Unexpected token, expected "," (2:22)
1 | class foo {
> 2 | constructor(static a: number) {}
| ^
@@ -351,7 +351,7 @@ interface AudioBufferList {
`;
exports[`methods.ts [babel-ts] format 1`] = `
"Unexpected token, expected \\";\\" (6:10)
"Unexpected token, expected ";" (6:10)
4 |
5 | interface Iterable<T> {
> 6 | export [Symbol.iterator](): Iterator<T>;
@@ -442,7 +442,7 @@ const;
`;
exports[`errorOnInitializerInInterfaceProperty.ts [babel-ts] format 1`] = `
"Unexpected token, expected \\";\\" (2:17)
"Unexpected token, expected ";" (2:17)
1 | interface Foo {
> 2 | bar: number = 5;
| ^
@@ -153,7 +153,7 @@ class f7<> {
`;
exports[`index-signature.ts [babel-ts] format 1`] = `
"Unexpected token, expected \\"]\\" (4:13)
"Unexpected token, expected "]" (4:13)
2 |
3 | type TwoParams = {
> 4 | [a: string, b: string]: string;
@@ -164,7 +164,7 @@ exports[`index-signature.ts [babel-ts] format 1`] = `
`;
exports[`index-signature.ts - {"trailingComma":"all"} [babel-ts] format 1`] = `
"Unexpected token, expected \\"]\\" (4:13)
"Unexpected token, expected "]" (4:13)
2 |
3 | type TwoParams = {
> 4 | [a: string, b: string]: string;
@@ -238,7 +238,7 @@ type TooLongSingleParam = {
`;
exports[`index-signature.ts - {"trailingComma":"es5"} [babel-ts] format 1`] = `
"Unexpected token, expected \\"]\\" (4:13)
"Unexpected token, expected "]" (4:13)
2 |
3 | type TwoParams = {
> 4 | [a: string, b: string]: string;
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`keywords.ts [babel-ts] format 1`] = `
"Unexpected token, expected \\"{\\" (9:12)
"Unexpected token, expected "{" (9:12)
7 |
8 | // Apparently this parses :P
> 9 | export private public protected static readonly abstract async enum X { }
@@ -196,7 +196,7 @@ class G {
`;
exports[`module.ts [babel-ts] format 1`] = `
"Unexpected token, expected \\"{\\" (7:10)
"Unexpected token, expected "{" (7:10)
5 |
6 | // Apparently this parses :P
> 7 | export private public protected static readonly abstract async enum X { }
@@ -0,0 +1,43 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`basic.vue format 1`] = `
====================================options=====================================
parsers: ["vue"]
printWidth: 80
| printWidth
=====================================input======================================
<script setup lang="ts">
let x = 1;
function log(...args) {
console.log(...args);
}
</script>
<template>
<div @click="if (x === 1 as number) { log('hello') } else { log('nonhello') };">{{ x }}</div>
</template>
=====================================output=====================================
<script setup lang="ts">
let x = 1;
function log(...args) {
console.log(...args);
}
</script>
<template>
<div
@click="
if (x === (1 as number)) {
log('hello');
} else {
log('nonhello');
}
"
>
{{ x }}
</div>
</template>
================================================================================
`;
@@ -0,0 +1,10 @@
<script setup lang="ts">
let x = 1;
function log(...args) {
console.log(...args);
}
</script>
<template>
<div @click="if (x === 1 as number) { log('hello') } else { log('nonhello') };">{{ x }}</div>
</template>
@@ -0,0 +1 @@
run_spec(__dirname, ["vue"]);
@@ -0,0 +1,45 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`basic.vue format 1`] = `
====================================options=====================================
parsers: ["vue"]
printWidth: 80
| printWidth
=====================================input======================================
<template>
<p v-if="isFolder(file)">{{ ( file as mymodule.Folder ).deadline }}</p>
</template>
<script lang="ts"></script>
=====================================output=====================================
<template>
<p v-if="isFolder(file)">{{ (file as mymodule.Folder).deadline }}</p>
</template>
<script lang="ts"></script>
================================================================================
`;
exports[`not-working-with-non-ts-script.vue format 1`] = `
====================================options=====================================
parsers: ["vue"]
printWidth: 80
| printWidth
=====================================input======================================
<template>
<p v-if="isFolder(file)">{{ ( file as mymodule.Folder ).deadline }}</p>
</template>
<script></script>
=====================================output=====================================
<template>
<p v-if="isFolder(file)">{{ ( file as mymodule.Folder ).deadline }}</p>
</template>
<script></script>
================================================================================
`;
+5
View File
@@ -0,0 +1,5 @@
<template>
<p v-if="isFolder(file)">{{ ( file as mymodule.Folder ).deadline }}</p>
</template>
<script lang="ts"></script>
Loaded 100 of 142 files, more files were not shown because too many files have changed in this diff. Show more