Merge branch 'master' into next
This commit is contained in:
commit
7e3c0c73b3
58 files changed
+1588
-1072
No files matched your search
@@ -0,0 +1,12 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
[cspell.json]
|
||||
indent_size = 4
|
||||
@@ -42,6 +42,10 @@ rules:
|
||||
object: false
|
||||
- enforceForRenamedProperties: false
|
||||
prefer-spread: error
|
||||
quotes:
|
||||
- error
|
||||
- double
|
||||
- avoidEscape: true
|
||||
react/display-name: off
|
||||
react/no-deprecated: off
|
||||
react/prop-types: off
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#### handlebars: Fix superfluous line breaks in ConcatStatement ([7051](https://github.com/prettier/prettier/pull/7051) by [@dcyriller](https://github.com/dcyriller))
|
||||
#### Fix superfluous line breaks in ConcatStatement ([7051](https://github.com/prettier/prettier/pull/7051) by [@dcyriller](https://github.com/dcyriller))
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```hbs
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,24 @@
|
||||
#### Do not throw on broken html ([#7293](https://github.com/prettier/prettier/pull/7293) by [@fisker](https://github.com/fisker))
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<div><span>
|
||||
<
|
||||
|
||||
<!-- Prettier stable -->
|
||||
TypeError: Cannot read property 'start' of null
|
||||
at hasTrailingLineBreak (https://prettier.io/lib/standalone.js:19694:169)
|
||||
at forceBreakContent (https://prettier.io/lib/standalone.js:19668:154)
|
||||
at Object.genericPrint$2 [as print] (https://prettier.io/lib/standalone.js:21068:126)
|
||||
at callPluginPrintFunction (https://prettier.io/lib/standalone.js:15302:20)
|
||||
at https://prettier.io/lib/standalone.js:15253:18
|
||||
at Object.printComments (https://prettier.io/lib/standalone.js:14974:19)
|
||||
at printGenerically (https://prettier.io/lib/standalone.js:15252:24)
|
||||
at printChild (https://prettier.io/lib/standalone.js:21227:14)
|
||||
at https://prettier.io/lib/standalone.js:21211:104
|
||||
at FastPath.map (https://prettier.io/lib/standalone.js:15155:23)
|
||||
|
||||
<!-- Prettier master -->
|
||||
<div><span> < </span></div>
|
||||
```
|
||||
@@ -1,4 +1,4 @@
|
||||
# Format `throw` like `return` ([#7070](https://github.com/prettier/prettier/pull/7070) by [@sosukesuzuki](https://github.com/sosukesuzuki))
|
||||
#### Format `throw` like `return` ([#7070](https://github.com/prettier/prettier/pull/7070) by [@sosukesuzuki](https://github.com/sosukesuzuki))
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
@@ -21,4 +21,4 @@ function foo() {
|
||||
this.lookahead().type === tt.parenLeft.right
|
||||
);
|
||||
}
|
||||
```
|
||||
```
|
||||
@@ -1,5 +1,6 @@
|
||||
#### Fix moving semi for `return` to end of line-comment([#7140](https://github.com/prettier/prettier/pull/7140) by [@sosukesuzuki](https://github.com/sosukesuzuki))
|
||||
#### Fix moving semicolon to trailing comment in `return` ([#7140](https://github.com/prettier/prettier/pull/7140) by [@sosukesuzuki](https://github.com/sosukesuzuki))
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
return // comment
|
||||
|
||||
@@ -19,4 +19,3 @@ a {
|
||||
background-image: url($test-path + "static/test.jpg");
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#### Don't print trailing commas after rest elements in tuples ([#7075](https://github.com/prettier/prettier/pull/7075) by [@thorn](https://github.com/thorn0))
|
||||
#### Don't print trailing commas after rest elements in tuples ([#7075](https://github.com/prettier/prettier/pull/7075) by [@thorn0](https://github.com/thorn0))
|
||||
|
||||
* A rest element is always the last element of a tuple type. Nothing can be added after it.
|
||||
* While TS is okay with this comma, [Babel doesn't parse it](https://github.com/babel/babel/issues/10769)
|
||||
* In function parameters and array destructuring, such a comma is a syntax error. Keeping it in tuples is inconsistent.
|
||||
- A rest element is always the last element of a tuple type. Nothing can be added after it.
|
||||
- While TS is okay with this comma, [Babel doesn't parse it](https://github.com/babel/babel/issues/10769)
|
||||
- In function parameters and array destructuring, such a comma is a syntax error. Keeping it in tuples is inconsistent.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#### format vue SFC containing JSX script([#7180](https://github.com/prettier/prettier/pull/7180) by [@sosukesuzuki](https://github.com/sosukesuzuki))
|
||||
#### format vue SFC containing JSX script ([#7180](https://github.com/prettier/prettier/pull/7180) by [@sosukesuzuki](https://github.com/sosukesuzuki))
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<script lang="jsx">
|
||||
|
||||
+1
-5
@@ -1,12 +1,8 @@
|
||||
---
|
||||
id: plugins
|
||||
title: Plugins (Beta)
|
||||
title: Plugins
|
||||
---
|
||||
|
||||
## IN BETA
|
||||
|
||||
> The plugin API is in a **beta** state as of Prettier 1.10 and the API may change in the next release!
|
||||
|
||||
Plugins are ways of adding new languages to Prettier. Prettier's own implementations of all languages are expressed using the plugin API. The core `prettier` package contains JavaScript and other web-focused languages built in. For additional languages you'll need to install a plugin.
|
||||
|
||||
## Using Plugins
|
||||
|
||||
+15
-17
@@ -2,9 +2,7 @@
|
||||
"name": "prettier",
|
||||
"version": "2.0.0-dev",
|
||||
"description": "Prettier is an opinionated code formatter",
|
||||
"bin": {
|
||||
"prettier": "./bin/prettier.js"
|
||||
},
|
||||
"bin": "./bin/prettier.js",
|
||||
"repository": "prettier/prettier",
|
||||
"homepage": "https://prettier.io",
|
||||
"author": "James Long",
|
||||
@@ -16,7 +14,7 @@
|
||||
"dependencies": {
|
||||
"@angular/compiler": "8.2.14",
|
||||
"@babel/code-frame": "7.8.0",
|
||||
"@babel/parser": "7.7.5",
|
||||
"@babel/parser": "7.8.3",
|
||||
"@glimmer/syntax": "0.41.0",
|
||||
"@iarna/toml": "2.2.3",
|
||||
"@typescript-eslint/typescript-estree": "2.11.0",
|
||||
@@ -35,7 +33,7 @@
|
||||
"esutils": "2.0.3",
|
||||
"find-parent-dir": "0.3.0",
|
||||
"find-project-root": "1.1.1",
|
||||
"flow-parser": "0.113.0",
|
||||
"flow-parser": "0.116.0",
|
||||
"get-stream": "4.1.0",
|
||||
"globby": "6.1.0",
|
||||
"graphql": "14.5.8",
|
||||
@@ -67,7 +65,7 @@
|
||||
"resolve": "1.13.1",
|
||||
"semver": "7.1.1",
|
||||
"string-width": "4.2.0",
|
||||
"typescript": "3.7.3",
|
||||
"typescript": "3.7.4",
|
||||
"unicode-regex": "3.0.0",
|
||||
"unified": "8.4.2",
|
||||
"vnopts": "1.0.2",
|
||||
@@ -76,19 +74,20 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.7.7",
|
||||
"@babel/preset-env": "7.7.4",
|
||||
"@rollup/plugin-alias": "2.2.0",
|
||||
"@rollup/plugin-json": "4.0.0",
|
||||
"@rollup/plugin-replace": "2.2.1",
|
||||
"@rollup/plugin-alias": "3.0.0",
|
||||
"@rollup/plugin-commonjs": "11.0.1",
|
||||
"@rollup/plugin-json": "4.0.1",
|
||||
"@rollup/plugin-replace": "2.3.0",
|
||||
"babel-loader": "8.0.6",
|
||||
"benchmark": "2.1.4",
|
||||
"builtin-modules": "3.1.0",
|
||||
"codecov": "3.6.1",
|
||||
"cross-env": "6.0.3",
|
||||
"cspell": "4.0.44",
|
||||
"eslint": "6.6.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-prettier": "6.7.0",
|
||||
"eslint-formatter-friendly": "7.0.0",
|
||||
"eslint-plugin-import": "2.19.1",
|
||||
"eslint-plugin-import": "2.20.0",
|
||||
"eslint-plugin-prettier": "3.1.2",
|
||||
"eslint-plugin-react": "7.17.0",
|
||||
"eslint-plugin-unicorn": "15.0.1",
|
||||
@@ -101,19 +100,18 @@
|
||||
"mkdirp": "0.5.1",
|
||||
"prettier": "1.19.1",
|
||||
"rimraf": "3.0.0",
|
||||
"rollup": "1.27.13",
|
||||
"rollup": "1.29.0",
|
||||
"rollup-plugin-babel": "4.3.3",
|
||||
"rollup-plugin-commonjs": "10.1.0",
|
||||
"rollup-plugin-node-globals": "1.4.0",
|
||||
"rollup-plugin-node-resolve": "5.2.0",
|
||||
"rollup-plugin-terser": "5.1.2",
|
||||
"rollup-plugin-terser": "5.2.0",
|
||||
"shelljs": "0.8.3",
|
||||
"snapshot-diff": "0.6.1",
|
||||
"strip-ansi": "6.0.0",
|
||||
"synchronous-promise": "2.0.10",
|
||||
"tempy": "0.2.1",
|
||||
"terser-webpack-plugin": "2.2.2",
|
||||
"webpack": "4.41.2"
|
||||
"terser-webpack-plugin": "2.3.2",
|
||||
"webpack": "4.41.5"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
||||
@@ -126,7 +124,7 @@
|
||||
"perf-benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
||||
"check-types": "tsc",
|
||||
"lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly",
|
||||
"lint-docs": "prettier {.,docs,website,website/blog}/*.md --check",
|
||||
"lint-docs": "prettier {.,docs,website,website/blog,changelog_unreleased,changelog_unreleased/*}/*.md --check",
|
||||
"lint-dist": "eslint --no-eslintrc --no-ignore --env=browser \"dist/!(bin-prettier|index|third-party).js\"",
|
||||
"build": "node --max-old-space-size=3072 ./scripts/build/build.js",
|
||||
"build-docs": "node ./scripts/build-docs.js",
|
||||
|
||||
@@ -6,7 +6,7 @@ const { rollup } = require("rollup");
|
||||
const webpack = require("webpack");
|
||||
const resolve = require("rollup-plugin-node-resolve");
|
||||
const alias = require("@rollup/plugin-alias");
|
||||
const commonjs = require("rollup-plugin-commonjs");
|
||||
const commonjs = require("@rollup/plugin-commonjs");
|
||||
const nodeGlobals = require("rollup-plugin-node-globals");
|
||||
const json = require("@rollup/plugin-json");
|
||||
const replace = require("@rollup/plugin-replace");
|
||||
|
||||
@@ -147,7 +147,7 @@ const coreBundles = [
|
||||
}
|
||||
},
|
||||
{
|
||||
input: "src/doc/index.js",
|
||||
input: "src/document/index.js",
|
||||
name: "doc",
|
||||
type: "core",
|
||||
output: "doc.js",
|
||||
|
||||
@@ -13,7 +13,7 @@ module.exports = function() {
|
||||
require(id.replace(/^\0commonjs-proxy:/, "")),
|
||||
(_, v) => {
|
||||
if (typeof v === "function") {
|
||||
throw new Error(`Cannot evaluate functions.`);
|
||||
throw new Error("Cannot evaluate functions.");
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ const semver = require("semver");
|
||||
|
||||
module.exports = async function({ version, previousVersion }) {
|
||||
if (!semver.valid(version)) {
|
||||
throw new Error(`Invalid version specified`);
|
||||
throw new Error("Invalid version specified");
|
||||
}
|
||||
|
||||
if (!semver.gt(version, previousVersion)) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const util = require("./util");
|
||||
const { mapDoc } = require("../doc").utils;
|
||||
const { mapDoc } = require("../document").utils;
|
||||
|
||||
function isNextLineEmpty(text, node, options) {
|
||||
return util.isNextLineEmpty(text, node, options.locEnd);
|
||||
|
||||
@@ -24,7 +24,7 @@ const getExplorerMemoized = mem(opts => {
|
||||
|
||||
if (typeof result.config !== "object") {
|
||||
throw new Error(
|
||||
`Config is only allowed to be an object, ` +
|
||||
"Config is only allowed to be an object, " +
|
||||
`but received ${typeof result.config} in "${result.filepath}"`
|
||||
);
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -10,7 +10,7 @@ const loadPlugins = require("./common/load-plugins");
|
||||
|
||||
const config = require("./config/resolve-config");
|
||||
|
||||
const doc = require("./doc");
|
||||
const doc = require("./document");
|
||||
|
||||
// Luckily `opts` is always the 2nd argument
|
||||
function _withPlugins(fn) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
const {
|
||||
builders: { hardline, literalline, concat, markAsRoot },
|
||||
utils: { mapDoc }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
|
||||
function embed(path, print, textToDoc /*, options */) {
|
||||
const node = path.getValue();
|
||||
|
||||
@@ -25,7 +25,7 @@ const {
|
||||
ifBreak
|
||||
},
|
||||
utils: { removeLines }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
|
||||
const {
|
||||
getAncestorNode,
|
||||
@@ -914,7 +914,7 @@ const STANDARD_UNIT_REGEX = /[a-zA-Z]+/g;
|
||||
const WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g;
|
||||
const ADJUST_NUMBERS_REGEX = new RegExp(
|
||||
STRING_REGEX.source +
|
||||
`|` +
|
||||
"|" +
|
||||
`(${WORD_PART_REGEX.source})?` +
|
||||
`(${NUMBER_REGEX.source})` +
|
||||
`(${STANDARD_UNIT_REGEX.source})?`,
|
||||
|
||||
@@ -9,7 +9,7 @@ const {
|
||||
group,
|
||||
indent,
|
||||
ifBreak
|
||||
} = require("../doc").builders;
|
||||
} = require("../document").builders;
|
||||
const { hasIgnoreComment } = require("../common/util");
|
||||
const { isNextLineEmpty } = require("../common/util-shared");
|
||||
const { insertPragma } = require("./pragma");
|
||||
|
||||
@@ -9,7 +9,7 @@ const {
|
||||
group,
|
||||
indent,
|
||||
ifBreak
|
||||
} = require("../doc").builders;
|
||||
} = require("../document").builders;
|
||||
|
||||
// http://w3c.github.io/html/single-page.html#void-elements
|
||||
const voidTags = [
|
||||
|
||||
@@ -4,7 +4,7 @@ const clean = require("./clean");
|
||||
const {
|
||||
builders,
|
||||
utils: { stripTrailingHardline, mapDoc }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
const {
|
||||
breakParent,
|
||||
dedentToRoot,
|
||||
@@ -838,7 +838,7 @@ function printOpeningTagStartMarker(node) {
|
||||
case "ieConditionalStartComment":
|
||||
return `<!--[if ${node.condition}`;
|
||||
case "ieConditionalEndComment":
|
||||
return `<!--<!`;
|
||||
return "<!--<!";
|
||||
case "interpolation":
|
||||
return "{{";
|
||||
case "docType":
|
||||
@@ -860,11 +860,11 @@ function printOpeningTagEndMarker(node) {
|
||||
return "]>";
|
||||
case "element":
|
||||
if (node.condition) {
|
||||
return `><!--<![endif]-->`;
|
||||
return "><!--<![endif]-->";
|
||||
}
|
||||
// fall through
|
||||
default:
|
||||
return `>`;
|
||||
return ">";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -893,9 +893,9 @@ function printClosingTagEndMarker(node, options) {
|
||||
switch (node.type) {
|
||||
case "ieConditionalComment":
|
||||
case "ieConditionalEndComment":
|
||||
return `[endif]-->`;
|
||||
return "[endif]-->";
|
||||
case "ieConditionalStartComment":
|
||||
return `]><!-->`;
|
||||
return "]><!-->";
|
||||
case "interpolation":
|
||||
return "}}";
|
||||
case "element":
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const {
|
||||
builders: { concat, ifBreak, join, line }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
const parseSrcset = require("parse-srcset");
|
||||
|
||||
function printImgSrcset(value) {
|
||||
@@ -19,7 +19,7 @@ function printImgSrcset(value) {
|
||||
const hasX = srcset.some(src => src.d);
|
||||
|
||||
if (hasW + hasH + hasX !== 1) {
|
||||
throw new Error(`Mixed descriptor in srcset is not supported`);
|
||||
throw new Error("Mixed descriptor in srcset is not supported");
|
||||
}
|
||||
|
||||
const key = hasW ? "w" : hasH ? "h" : "d";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const {
|
||||
builders: { concat, group }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
|
||||
/**
|
||||
* v-for="... in ..."
|
||||
|
||||
@@ -330,7 +330,8 @@ function hasTrailingLineBreak(node) {
|
||||
(node.next
|
||||
? node.next.sourceSpan.start.line > node.sourceSpan.end.line
|
||||
: node.parent.type === "root" ||
|
||||
node.parent.endSourceSpan.start.line > node.sourceSpan.end.line)
|
||||
(node.parent.endSourceSpan &&
|
||||
node.parent.endSourceSpan.start.line > node.sourceSpan.end.line))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ const {
|
||||
dedentToRoot
|
||||
},
|
||||
utils: { mapDoc, stripTrailingHardline }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
|
||||
function embed(path, print, textToDoc, options) {
|
||||
const node = path.getValue();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const {
|
||||
builders: { concat, join, line }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
|
||||
function printHtmlBinding(path, options, print) {
|
||||
const node = path.getValue();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const { concat, hardline, indent, join } = require("../doc").builders;
|
||||
const { concat, hardline, indent, join } = require("../document").builders;
|
||||
const preprocess = require("./preprocess");
|
||||
|
||||
function genericPrint(path, options, print) {
|
||||
|
||||
@@ -115,7 +115,7 @@ const {
|
||||
},
|
||||
utils: { willBreak, isLineNext, isEmpty, removeLines },
|
||||
printer: { printDocToString }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
|
||||
let uid = 0;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ const support = require("../main/support");
|
||||
const {
|
||||
builders: { hardline, literalline, concat, markAsRoot },
|
||||
utils: { mapDoc }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
const { getFencedCodeBlockValue } = require("./utils");
|
||||
|
||||
function embed(path, print, textToDoc, options) {
|
||||
|
||||
@@ -22,7 +22,7 @@ const {
|
||||
},
|
||||
utils: { mapDoc },
|
||||
printer: { printDocToString }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
const {
|
||||
getFencedCodeBlockValue,
|
||||
hasGitDiffFriendlyOrderedList,
|
||||
|
||||
@@ -20,7 +20,7 @@ const {
|
||||
defineShortcut,
|
||||
mapNode
|
||||
} = require("./utils");
|
||||
const docBuilders = require("../doc").builders;
|
||||
const docBuilders = require("../document").builders;
|
||||
const {
|
||||
conditionalGroup,
|
||||
breakParent,
|
||||
|
||||
@@ -5,7 +5,7 @@ const comments = require("./comments");
|
||||
const FastPath = require("../common/fast-path");
|
||||
const multiparser = require("./multiparser");
|
||||
|
||||
const doc = require("../doc");
|
||||
const doc = require("../document");
|
||||
const docBuilders = doc.builders;
|
||||
const { concat, hardline, addAlignmentToDoc } = docBuilders;
|
||||
const docUtils = doc.utils;
|
||||
|
||||
@@ -9,7 +9,7 @@ const {
|
||||
lineSuffix,
|
||||
join,
|
||||
cursor
|
||||
} = require("../doc").builders;
|
||||
} = require("../document").builders;
|
||||
const {
|
||||
hasNewline,
|
||||
skipNewline,
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ const {
|
||||
utils: { mapDoc },
|
||||
printer: { printDocToString },
|
||||
debug: { printDocToDebug }
|
||||
} = require("../doc");
|
||||
} = require("../document");
|
||||
|
||||
const UTF8BOM = 0xfeff;
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ const core = require("./main/core");
|
||||
const { getSupportInfo } = require("./main/support");
|
||||
const sharedUtil = require("./common/util-shared");
|
||||
|
||||
const doc = require("./doc");
|
||||
const doc = require("./document");
|
||||
|
||||
const internalPlugins = [
|
||||
require("./language-css"),
|
||||
|
||||
@@ -1,5 +1,39 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`broken-html.html 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["html"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
<!--
|
||||
#7241,
|
||||
reproduction:
|
||||
two different element,
|
||||
linebreak
|
||||
\`<\`
|
||||
extra space(s)
|
||||
-->
|
||||
<div><span>
|
||||
|
||||
|
||||
|
||||
<
|
||||
|
||||
=====================================output=====================================
|
||||
<!--
|
||||
#7241,
|
||||
reproduction:
|
||||
two different element,
|
||||
linebreak
|
||||
\`<\`
|
||||
extra space(s)
|
||||
-->
|
||||
<div><span> < </span></div>
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`comment.html 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["html"]
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<!--
|
||||
#7241,
|
||||
reproduction:
|
||||
two different element,
|
||||
linebreak
|
||||
`<`
|
||||
extra space(s)
|
||||
-->
|
||||
<div><span>
|
||||
|
||||
|
||||
|
||||
<
|
||||
@@ -12,7 +12,8 @@ describe("write cursorOffset to stderr with --cursor-offset <int>", () => {
|
||||
|
||||
describe("cursorOffset should not be affected by full-width character", () => {
|
||||
runPrettier("cli", ["--cursor-offset", "21", "--parser", "babel"], {
|
||||
input: `const x = ["中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文"];`
|
||||
input:
|
||||
'const x = ["中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文"];'
|
||||
// ^ offset = 21 ^ width = 80
|
||||
}).test({
|
||||
/**
|
||||
|
||||
@@ -16,24 +16,24 @@ describe("show usage with --help", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe(`show detailed usage with --help l (alias)`, () => {
|
||||
describe("show detailed usage with --help l (alias)", () => {
|
||||
runPrettier("cli", ["--help", "l"]).test({
|
||||
status: 0
|
||||
});
|
||||
});
|
||||
|
||||
describe(`show detailed usage with plugin options (automatic resolution)`, () => {
|
||||
describe("show detailed usage with plugin options (automatic resolution)", () => {
|
||||
runPrettier("plugins/automatic", [
|
||||
"--help",
|
||||
"tab-width",
|
||||
"--parser=bar",
|
||||
`--plugin-search-dir=.`
|
||||
"--plugin-search-dir=."
|
||||
]).test({
|
||||
status: 0
|
||||
});
|
||||
});
|
||||
|
||||
describe(`show detailed usage with plugin options (manual resolution)`, () => {
|
||||
describe("show detailed usage with plugin options (manual resolution)", () => {
|
||||
runPrettier("cli", [
|
||||
"--help",
|
||||
"tab-width",
|
||||
|
||||
@@ -333,17 +333,17 @@ describe("API getFileInfo.sync with ignorePath", () => {
|
||||
test("with relative filePath", () => {
|
||||
expect(
|
||||
prettier.getFileInfo.sync(filePath, options).ignored
|
||||
).toMatchInlineSnapshot(`true`);
|
||||
).toMatchInlineSnapshot("true");
|
||||
});
|
||||
test("with relative filePath starts with dot", () => {
|
||||
expect(
|
||||
prettier.getFileInfo.sync(`./${filePath}`, options).ignored
|
||||
).toMatchInlineSnapshot(`true`);
|
||||
).toMatchInlineSnapshot("true");
|
||||
});
|
||||
test("with absolute filePath", () => {
|
||||
expect(
|
||||
prettier.getFileInfo.sync(path.resolve(filePath), options).ignored
|
||||
).toMatchInlineSnapshot(`true`);
|
||||
).toMatchInlineSnapshot("true");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ test("should work with foo plugin instance", () => {
|
||||
prettier.format(input, { parser: "foo-parser", plugins: [fooPlugin] })
|
||||
)
|
||||
).toMatchInlineSnapshot(
|
||||
`"\\"{\\\\\\"tabWidth\\\\\\":8,\\\\\\"bracketSpacing\\\\\\":false}\\""`
|
||||
'"\\"{\\\\\\"tabWidth\\\\\\":8,\\\\\\"bracketSpacing\\\\\\":false}\\""'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -5,7 +5,12 @@ const runPrettier = require("../runPrettier");
|
||||
describe("plugin default options should work", () => {
|
||||
runPrettier(
|
||||
"plugins/defaultOptions",
|
||||
["--stdin-filepath", "example.foo", "--plugin=./plugin"],
|
||||
[
|
||||
"--stdin-filepath",
|
||||
"example.foo",
|
||||
"--plugin=./plugin",
|
||||
"--no-editorconfig"
|
||||
],
|
||||
{ input: "hello-world" }
|
||||
).test({
|
||||
stdout: JSON.stringify({
|
||||
|
||||
@@ -27,3 +27,23 @@ test("shared util has correct structure", () => {
|
||||
expect(typeof sharedUtil.mapDoc).toEqual("function");
|
||||
expect(typeof sharedUtil.makeString).toEqual("function");
|
||||
});
|
||||
|
||||
test("sharedUtil.getMaxContinuousCount", () => {
|
||||
const { getMaxContinuousCount } = sharedUtil;
|
||||
|
||||
expect(getMaxContinuousCount("|---|--|-|--|---|", "-")).toEqual(3);
|
||||
expect(getMaxContinuousCount("|...|", ".")).toEqual(3);
|
||||
|
||||
const fixture = [
|
||||
"([a-f])([a-f])",
|
||||
"[a-f][a-f][a-f]",
|
||||
"a-fa-fa-fa-f",
|
||||
"bbbbbbbbbbbbbbbbbb" // neither `a-f` `[a-f]` `([a-f])` should matches `b`
|
||||
].join("");
|
||||
expect(getMaxContinuousCount(fixture, "([a-f])")).toEqual(2);
|
||||
expect(getMaxContinuousCount(fixture, "[a-f]")).toEqual(3);
|
||||
expect(getMaxContinuousCount(fixture, "a-f")).toEqual(4);
|
||||
expect(getMaxContinuousCount(fixture, "([a\\-f])")).toEqual(0);
|
||||
expect(getMaxContinuousCount(fixture, "[a\\-f]")).toEqual(0);
|
||||
expect(getMaxContinuousCount(fixture, "a\\-f")).toEqual(0);
|
||||
});
|
||||
@@ -50,7 +50,8 @@ describe("CLI overrides are still applied when no config is found with --config-
|
||||
"6",
|
||||
"--config-precedence",
|
||||
"file-override",
|
||||
"**/*.js"
|
||||
"**/*.js",
|
||||
"--no-editorconfig"
|
||||
]).test({
|
||||
status: 0
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# This file should be overridden by prettier.config.js
|
||||
root = true
|
||||
|
||||
[*]
|
||||
tab_width = 1
|
||||
@@ -7,8 +7,11 @@ const { SynchronousPromise } = require("synchronous-promise");
|
||||
|
||||
const isProduction = process.env.NODE_ENV === "production";
|
||||
const prettierRootDir = isProduction ? process.env.PRETTIER_DIR : "../";
|
||||
const prettierPkg = require(path.join(prettierRootDir, "package.json"));
|
||||
const prettierCli = path.join(prettierRootDir, prettierPkg.bin.prettier);
|
||||
const { bin } = require(path.join(prettierRootDir, "package.json"));
|
||||
const prettierCli = path.join(
|
||||
prettierRootDir,
|
||||
typeof bin === "object" ? bin.prettier : bin
|
||||
);
|
||||
|
||||
const thirdParty = isProduction
|
||||
? path.join(prettierRootDir, "./third-party")
|
||||
@@ -59,7 +62,7 @@ function runPrettier(dir, args, options) {
|
||||
const origStatSync = fs.statSync;
|
||||
|
||||
jest.spyOn(fs, "statSync").mockImplementation(filename => {
|
||||
if (path.basename(filename) === `virtualDirectory`) {
|
||||
if (path.basename(filename) === "virtualDirectory") {
|
||||
return origStatSync(path.join(__dirname, __filename));
|
||||
}
|
||||
return origStatSync(filename);
|
||||
|
||||
@@ -44,6 +44,10 @@ class Footer extends React.Component {
|
||||
<h5>Docs</h5>
|
||||
<a href={this.url("/index.html")}>About</a>
|
||||
<a href={this.url("/install.html")}>Usage</a>
|
||||
<br />
|
||||
<a href="https://www.netlify.com">
|
||||
<img src="https://www.netlify.com/img/global/badges/netlify-color-accent.svg" />
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<h5>Community</h5>
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
"react-dom": "16.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "7.7.7",
|
||||
"@babel/preset-react": "7.7.4",
|
||||
"@babel/preset-env": "7.8.3",
|
||||
"@babel/preset-react": "7.8.3",
|
||||
"@sandhose/prettier-animated-logo": "1.0.3",
|
||||
"babel-loader": "8.0.6",
|
||||
"concurrently": "5.0.2",
|
||||
"docusaurus": "1.14.3",
|
||||
"docusaurus": "1.14.4",
|
||||
"js-yaml": "3.13.1",
|
||||
"svgo": "1.3.2",
|
||||
"webpack": "4.41.5",
|
||||
|
||||
+621
-474
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user