Merge branch 'master' of github.com:prettier/prettier into next

* 'master' of github.com:prettier/prettier:
  Don't lowercase element names in CSS selectors (#6947)
  Support string-to-package config in JSON schema: (#6941)
  Rename SECURITY.md to .github/SECURITY.md
  Create SECURITY.md
  Add the XML plugin to the docs (#6944)
  TypeScript: Fix formatting of type operators as arrow function… (#6901)
  SCSS: don't add extra comma after last comment in map (#6918)
  Remove typescript-etw from build (#6919)
This commit is contained in:
Panayiotis Lipiridis committed 2019-11-13 22:34:54 +01:00
commit 773470e287
21 files changed
+2355 -62

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
# Security Policy
## Reporting a Vulnerability
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
+20
View File
@@ -0,0 +1,20 @@
#### Don't lowercase element names in CSS selectors ([#6947](https://github.com/prettier/prettier/pull/6947) by [@ark120202](https://github.com/ark120202))
Previously, Prettier already preserved casing of unknown element names, but it did lowercase names of HTML elements.
This caused issues when CSS was applied to a case-sensitive document and an there was an element with the same name as in HTML, which is the case in NativeScript.
Prettier now always preserves original casing.
<!-- prettier-ignore -->
```css
/* Input */
Label {
}
/* Prettier stable */
label {
}
/* Prettier master */
Label {
}
```
+28
View File
@@ -0,0 +1,28 @@
#### Don't add extra comma after last comment in map ([#6918](https://github.com/prettier/prettier/pull/6918) by [@fisker](https://github.com/fisker))
Previously, when `trailingComma` set to `es5`, extra comma added after last comment in map.
<!-- prettier-ignore -->
```scss
// Input
$my-map: (
'foo': 1, // Comment
'bar': 2, // Comment
);
// Prettier stable
$my-map: (
"foo": 1,
// Comment
"bar": 2,
// Comment,
);
// Prettier master
$my-map: (
"foo": 1,
// Comment
"bar": 2,
// Comment
);
```
@@ -0,0 +1,24 @@
#### Fix formatting of type operator as arrow function return type ([#6901](https://github.com/prettier/prettier/pull/6901) by [@sosukesuzuki](https://github.com/sosukesuzuki))
<!-- prettier-ignore -->
```ts
// Input
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly["attributes"] & undefined
> => {};
// Prettier stable
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Collections.Parts.PrintedCircuitBoardAssembly["attributes"] &
undefined> => {};
// Prettier master
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly["attributes"] & undefined
> => {};
```
+1
View File
@@ -45,6 +45,7 @@ Providing at least one path to `--plugin-search-dir`/`pluginSearchDirs` turns of
- [`@prettier/plugin-pug`](https://github.com/prettier/plugin-pug) by [**@Shinigami92**](https://github.com/Shinigami92)
- [`@prettier/plugin-ruby`](https://github.com/prettier/plugin-ruby)
- [`@prettier/plugin-swift`](https://github.com/prettier/plugin-swift)
- [`@prettier/plugin-xml`](https://github.com/prettier/plugin-xml)
## Community Plugins
+2 -5
View File
@@ -41,11 +41,8 @@ const parsers = [
input: "src/language-js/parser-typescript.js",
target: "universal",
babelPlugins: [babelReplaceArrayIncludesWithIndexof],
commonjs: {
ignore: [
// Optional package for TypeScript that logs ETW events (a Windows-only technology).
"@microsoft/typescript-etw"
]
replace: {
'require("@microsoft/typescript-etw")': "undefined"
}
},
{
+11 -4
View File
@@ -18,7 +18,6 @@ function generateSchema(options) {
return {
$schema: "http://json-schema.org/draft-04/schema#",
title: "Schema for .prettierrc",
type: "object",
definitions: {
optionsDefinition: {
type: "object",
@@ -65,9 +64,17 @@ function generateSchema(options) {
}
}
},
allOf: [
{ $ref: "#/definitions/optionsDefinition" },
{ $ref: "#/definitions/overridesDefinition" }
oneOf: [
{
type: "object",
allOf: [
{ $ref: "#/definitions/optionsDefinition" },
{ $ref: "#/definitions/overridesDefinition" }
]
},
{
type: "string"
}
]
};
}
-6
View File
@@ -1,7 +1,5 @@
"use strict";
const htmlTagNames = require("html-tag-names");
function clean(ast, newObj, parent) {
[
"raw", // front-matter
@@ -142,10 +140,6 @@ function clean(ast, newObj, parent) {
if (ast.type === "selector-tag") {
const lowercasedValue = ast.value.toLowerCase();
if (htmlTagNames.indexOf(lowercasedValue) !== -1) {
newObj.value = lowercasedValue;
}
if (["from", "to"].indexOf(lowercasedValue) !== -1) {
newObj.value = lowercasedValue;
}
+6 -4
View File
@@ -36,7 +36,6 @@ const {
insideAtRuleNode,
insideURLFunctionInImportAtRuleNode,
isKeyframeAtRuleKeywords,
isHTMLTag,
isWideKeywords,
isSCSS,
isLastNode,
@@ -341,8 +340,7 @@ function genericPrint(path, options, print) {
prevNode.type === "selector-nesting"
? node.value
: adjustNumbers(
isHTMLTag(node.value) ||
isKeyframeAtRuleKeywords(path, node.value)
isKeyframeAtRuleKeywords(path, node.value)
? node.value.toLowerCase()
: node.value
)
@@ -740,6 +738,9 @@ function genericPrint(path, options, print) {
const isSCSSMapItem = isSCSSMapItemNode(path);
const lastItem = node.groups[node.groups.length - 1];
const isLastItemComment = lastItem && lastItem.type === "value-comment";
return group(
concat([
node.open ? path.call(print, "open") : "",
@@ -773,7 +774,8 @@ function genericPrint(path, options, print) {
])
),
ifBreak(
isSCSS(options.parser, options.originalText) &&
!isLastItemComment &&
isSCSS(options.parser, options.originalText) &&
isSCSSMapItem &&
shouldPrintComma(options)
? ","
-7
View File
@@ -1,7 +1,5 @@
"use strict";
const htmlTagNames = require("html-tag-names");
const colorAdjusterFunctions = [
"red",
"green",
@@ -153,10 +151,6 @@ function isLastNode(path, node) {
return nodes && nodes.indexOf(node) === nodes.length - 1;
}
function isHTMLTag(value) {
return htmlTagNames.indexOf(value.toLowerCase()) !== -1;
}
function isDetachedRulesetDeclarationNode(node) {
// If a Less file ends up being parsed with the SCSS parser, Less
// variable declarations will be parsed as atrules with names ending
@@ -400,7 +394,6 @@ module.exports = {
insideAtRuleNode,
insideURLFunctionInImportAtRuleNode,
isKeyframeAtRuleKeywords,
isHTMLTag,
isWideKeywords,
isSCSS,
isLastNode,
+8 -2
View File
@@ -4573,6 +4573,7 @@ function printTypeParameters(path, options, print, paramsKey) {
}
const grandparent = path.getNode(2);
const greatGrandParent = path.getNode(3);
const greatGreatGrandParent = path.getNode(4);
const isParameterInTestCall = grandparent != null && isTestCall(grandparent);
@@ -4590,12 +4591,17 @@ function printTypeParameters(path, options, print, paramsKey) {
// See https://github.com/prettier/prettier/pull/6467 for the context.
(greatGreatGrandParent &&
greatGreatGrandParent.type === "VariableDeclarator" &&
grandparent &&
grandparent.type === "TSTypeAnnotation" &&
greatGrandParent.type !== "ArrowFunctionExpression" &&
n[paramsKey][0].type !== "TSUnionType" &&
n[paramsKey][0].type !== "UnionTypeAnnotation" &&
n[paramsKey][0].type !== "TSIntersectionType" &&
n[paramsKey][0].type !== "IntersectionTypeAnnotation" &&
n[paramsKey][0].type !== "TSConditionalType" &&
n[paramsKey][0].type !== "TSMappedType")));
n[paramsKey][0].type !== "TSMappedType" &&
n[paramsKey][0].type !== "TSTypeOperator" &&
n[paramsKey][0].type !== "TSIndexedAccessType" &&
n[paramsKey][0].type !== "TSArrayType")));
if (shouldInline) {
return concat(["<", join(", ", path.map(print, paramsKey)), ">"]);
@@ -94,7 +94,7 @@ a:after {
background-color: orange;
}
table {
TABLE {
}
/* apply a dashed border to all unresolved elements */
@@ -298,7 +298,7 @@ TABLE {}
@import Keep;
html#KeepId.KeepClass,
HTML#KeepId.KeepClass,
a[HREF="KeepAttrValue"]:hover::first-letter,
svg[viewBox] linearGradient,
:not(:nth-child(2n + 1)) {
@@ -358,7 +358,7 @@ $KeepScssVar: val;
prop: val;
};
&Keep & element {
&Keep & Element {
prop: val;
}
@@ -438,7 +438,7 @@ a:after {
background-color: orange;
}
table {
TABLE {
}
.foo {
@@ -616,7 +616,7 @@ TABLE {}
@import Keep;
html#KeepId.KeepClass,
HTML#KeepId.KeepClass,
a[HREF="KeepAttrValue"]:hover::first-letter,
svg[viewBox] linearGradient,
:not(:nth-child(2n + 1)) {
@@ -680,7 +680,7 @@ $KeepTopLevelVar: val;
prop: val;
}
&Keep & element {
&Keep & Element {
prop: val;
}
@@ -755,7 +755,7 @@ a:after {
background-color: orange;
}
table {
TABLE {
}
.foo {
File diff suppressed because it is too large. Load diff
+1
View File
@@ -1 +1,2 @@
run_spec(__dirname, ["scss"]);
run_spec(__dirname, ["scss"], { trailingComma: "es5" });
@@ -695,7 +695,7 @@ svg|a {
*|a {
}
|b {
|B {
}
ns|* {
@@ -129,6 +129,11 @@ const isAnySuccessfulAttempt$: Observable<boolean> = this._quizService.isAnySucc
}),
);
const isAnySuccessfulAttempt2$: Observable<boolean> = this._someMethodWithLongName();
const fooooooooooooooo: SomeThing<boolean | string> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<boolean & string> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<keyof string> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<string[]> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<string["anchor"]> = looooooooooooooooooooooooooooooongNameFunc();
=====================================output=====================================
const foo: SomeThing<boolean> = func();
@@ -154,6 +159,21 @@ const isAnySuccessfulAttempt$: Observable<boolean> = this._quizService
})
);
const isAnySuccessfulAttempt2$: Observable<boolean> = this._someMethodWithLongName();
const fooooooooooooooo: SomeThing<
boolean | string
> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<
boolean & string
> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<
keyof string
> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<
string[]
> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<
string["anchor"]
> = looooooooooooooooooooooooooooooongNameFunc();
================================================================================
`;
@@ -12,3 +12,8 @@ const isAnySuccessfulAttempt$: Observable<boolean> = this._quizService.isAnySucc
}),
);
const isAnySuccessfulAttempt2$: Observable<boolean> = this._someMethodWithLongName();
const fooooooooooooooo: SomeThing<boolean | string> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<boolean & string> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<keyof string> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<string[]> = looooooooooooooooooooooooooooooongNameFunc();
const fooooooooooooooo: SomeThing<string["anchor"]> = looooooooooooooooooooooooooooooongNameFunc();
@@ -7,19 +7,15 @@ printWidth: 80
| printWidth
=====================================input======================================
export const getVehicleDescriptor = async (
vehicleId: string,
): Promise<
Descriptor | undefined
> => {}
vehicleId: string
): Promise<Descriptor> => {};
export const getVehicleDescriptor = async (
vehicleId: string,
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly['attributes'] | undefined
> => {}
Collections.Parts.PrintedCircuitBoardAssemblyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
> => {};
=====================================output=====================================
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor | undefined> => {};
@@ -30,6 +26,107 @@ export const getVehicleDescriptor = async (
Collections.Parts.PrintedCircuitBoardAssembly["attributes"] | undefined
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor & undefined> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly["attributes"] & undefined
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor["attributes"]> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly["attributessssssssssssssssssssssss"]
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<keyof Descriptor> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
keyof Collections.Parts.PrintedCircuitBoardAssemblyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor[]> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssemblyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy[]
> => {};
=====================================output=====================================
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssemblyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor | undefined> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly["attributes"] | undefined
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor & undefined> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly["attributes"] & undefined
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor["attributes"]> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly["attributessssssssssssssssssssssss"]
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<keyof Descriptor> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
keyof Collections.Parts.PrintedCircuitBoardAssemblyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor[]> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssemblyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy[]
> => {};
================================================================================
`;
+55 -8
View File
@@ -1,12 +1,59 @@
export const getVehicleDescriptor = async (
vehicleId: string,
): Promise<
Descriptor | undefined
> => {}
vehicleId: string
): Promise<Descriptor> => {};
export const getVehicleDescriptor = async (
vehicleId: string,
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly['attributes'] | undefined
> => {}
Collections.Parts.PrintedCircuitBoardAssemblyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor | undefined> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly["attributes"] | undefined
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor & undefined> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly["attributes"] & undefined
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor["attributes"]> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssembly["attributessssssssssssssssssssssss"]
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<keyof Descriptor> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
keyof Collections.Parts.PrintedCircuitBoardAssemblyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<Descriptor[]> => {};
export const getVehicleDescriptor = async (
vehicleId: string
): Promise<
Collections.Parts.PrintedCircuitBoardAssemblyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy[]
> => {};
@@ -3,14 +3,6 @@
exports[`schema 1`] = `
Object {
"$schema": "http://json-schema.org/draft-04/schema#",
"allOf": Array [
Object {
"$ref": "#/definitions/optionsDefinition",
},
Object {
"$ref": "#/definitions/overridesDefinition",
},
],
"definitions": Object {
"optionsDefinition": Object {
"properties": Object {
@@ -427,7 +419,22 @@ in order for it to be formatted.",
"type": "object",
},
},
"oneOf": Array [
Object {
"allOf": Array [
Object {
"$ref": "#/definitions/optionsDefinition",
},
Object {
"$ref": "#/definitions/overridesDefinition",
},
],
"type": "object",
},
Object {
"type": "string",
},
],
"title": "Schema for .prettierrc",
"type": "object",
}
`;
+1
View File
@@ -49,3 +49,4 @@
- "[Ruby](https://github.com/prettier/plugin-ruby)"
- "[Swift](https://github.com/prettier/plugin-swift)"
- "[TOML](https://github.com/bd82/toml-tools/tree/master/packages/prettier-plugin-toml)"
- "[XML](https://github.com/prettier/plugin-xml)"