Update typescript-estree to 5.x (#11676)
* Remove useJSXTextNode * Replace TSAbstractClassProperty to TSAbstractPropertyDefinition * Throw syntax error for inalid abstract property * Support PropertyDefinition for quoted props * Refactor postprocess * Add tests for removing TSParenthesizedType * Install new ts-estree * Remove unused handling TSPrivateIdentifier * Fix lint problem * Address review
This commit is contained in:
1 parent
7c6d0e462b
commit
65e01b7c03
29 files changed
+309
-267
No files matched your search
+1
-1
@@ -235,7 +235,7 @@ module.exports = {
|
||||
functions: ["hasComment", "getComments"],
|
||||
},
|
||||
"src/language-js/pragma.js",
|
||||
"src/language-js/parse/postprocess.js",
|
||||
"src/language-js/parse/postprocess/*.js",
|
||||
"src/language-js/parse/babel.js",
|
||||
"src/language-js/parse/meriyah.js",
|
||||
"src/language-js/parse/json.js",
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
"@babel/parser": "7.15.8",
|
||||
"@glimmer/syntax": "0.82.0",
|
||||
"@iarna/toml": "2.2.5",
|
||||
"@typescript-eslint/typescript-estree": "4.32.0",
|
||||
"@typescript-eslint/typescript-estree": "5.1.0",
|
||||
"angular-estree-parser": "2.5.0",
|
||||
"angular-html-parser": "1.8.0",
|
||||
"camelcase": "6.2.0",
|
||||
|
||||
@@ -460,7 +460,7 @@ function handleMethodNameComments({
|
||||
(enclosingNode.type === "ClassMethod" ||
|
||||
enclosingNode.type === "ClassProperty" ||
|
||||
enclosingNode.type === "PropertyDefinition" ||
|
||||
enclosingNode.type === "TSAbstractClassProperty" ||
|
||||
enclosingNode.type === "TSAbstractPropertyDefinition" ||
|
||||
enclosingNode.type === "TSAbstractMethodDefinition" ||
|
||||
enclosingNode.type === "TSDeclareMethod" ||
|
||||
enclosingNode.type === "MethodDefinition")
|
||||
|
||||
@@ -7,7 +7,7 @@ const {
|
||||
} = require("../../common/util.js");
|
||||
const createParser = require("./utils/create-parser.js");
|
||||
const createBabelParseError = require("./utils/create-babel-parse-error.js");
|
||||
const postprocess = require("./postprocess.js");
|
||||
const postprocess = require("./postprocess/index.js");
|
||||
const jsonParsers = require("./json.js");
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ const createError = require("../../common/parser-create-error.js");
|
||||
const tryCombinations = require("../../utils/try-combinations.js");
|
||||
const createParser = require("./utils/create-parser.js");
|
||||
const replaceHashbang = require("./utils/replace-hashbang.js");
|
||||
const postprocess = require("./postprocess.js");
|
||||
const postprocess = require("./postprocess/index.js");
|
||||
|
||||
/** @type {import("espree").Options} */
|
||||
const parseOptions = {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
const createError = require("../../common/parser-create-error.js");
|
||||
const createParser = require("./utils/create-parser.js");
|
||||
const replaceHashbang = require("./utils/replace-hashbang.js");
|
||||
const postprocess = require("./postprocess.js");
|
||||
const postprocess = require("./postprocess/index.js");
|
||||
|
||||
// https://github.com/facebook/flow/tree/master/packages/flow-parser#options
|
||||
const parseOptions = {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
const createError = require("../../common/parser-create-error.js");
|
||||
const tryCombinations = require("../../utils/try-combinations.js");
|
||||
const createParser = require("./utils/create-parser.js");
|
||||
const postprocess = require("./postprocess.js");
|
||||
const postprocess = require("./postprocess/index.js");
|
||||
|
||||
// https://github.com/meriyah/meriyah/blob/4676f60b6c149d7082bde2c9147f9ae2359c8075/src/parser.ts#L185
|
||||
const parseOptions = {
|
||||
|
||||
@@ -1,54 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
getLast,
|
||||
getNextNonSpaceNonCommentCharacter,
|
||||
} = require("../../common/util.js");
|
||||
const createError = require("../../common/parser-create-error.js");
|
||||
const { locStart, locEnd } = require("../loc.js");
|
||||
const { isTypeCastComment } = require("../comments.js");
|
||||
const { getLast } = require("../../../common/util.js");
|
||||
const { locStart, locEnd } = require("../../loc.js");
|
||||
const { isTypeCastComment } = require("../../comments.js");
|
||||
const visitNode = require("./visitNode.js");
|
||||
const { throwErrorForInvalidNodes } = require("./typescript.js");
|
||||
|
||||
function postprocess(ast, options) {
|
||||
// Invalid decorators are removed since `@typescript-eslint/typescript-estree` v4
|
||||
// https://github.com/typescript-eslint/typescript-eslint/pull/2375
|
||||
if (options.parser === "typescript" && options.originalText.includes("@")) {
|
||||
const { esTreeNodeToTSNodeMap, tsNodeToESTreeNodeMap } =
|
||||
options.tsParseResult;
|
||||
ast = visitNode(ast, (node) => {
|
||||
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
||||
if (!tsNode) {
|
||||
return;
|
||||
}
|
||||
const tsDecorators = tsNode.decorators;
|
||||
if (!Array.isArray(tsDecorators)) {
|
||||
return;
|
||||
}
|
||||
// `esTreeNodeToTSNodeMap.get(ClassBody)` and `esTreeNodeToTSNodeMap.get(ClassDeclaration)` has the same tsNode
|
||||
const esTreeNode = tsNodeToESTreeNodeMap.get(tsNode);
|
||||
if (esTreeNode !== node) {
|
||||
return;
|
||||
}
|
||||
const esTreeDecorators = esTreeNode.decorators;
|
||||
if (
|
||||
!Array.isArray(esTreeDecorators) ||
|
||||
esTreeDecorators.length !== tsDecorators.length ||
|
||||
tsDecorators.some((tsDecorator) => {
|
||||
const esTreeDecorator = tsNodeToESTreeNodeMap.get(tsDecorator);
|
||||
return (
|
||||
!esTreeDecorator || !esTreeDecorators.includes(esTreeDecorator)
|
||||
);
|
||||
})
|
||||
) {
|
||||
const { start, end } = esTreeNode.loc;
|
||||
throw createError(
|
||||
"Leading decorators must be attached to a class declaration",
|
||||
{
|
||||
start: { line: start.line, column: start.column + 1 },
|
||||
end: { line: end.line, column: end.column + 1 },
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
if (
|
||||
options.parser === "typescript" &&
|
||||
// decorators or abstract properties
|
||||
/@|abstract/.test(options.originalText)
|
||||
) {
|
||||
throwErrorForInvalidNodes(ast, options);
|
||||
}
|
||||
|
||||
// Keep Babel's non-standard ParenthesizedExpression nodes only if they have Closure-style type cast comments.
|
||||
@@ -138,20 +102,6 @@ function postprocess(ast, options) {
|
||||
];
|
||||
break;
|
||||
}
|
||||
case "ClassProperty":
|
||||
// TODO: Temporary auto-generated node type. To remove when typescript-estree has proper support for private fields.
|
||||
if (
|
||||
node.key &&
|
||||
node.key.type === "TSPrivateIdentifier" &&
|
||||
getNextNonSpaceNonCommentCharacter(
|
||||
options.originalText,
|
||||
node.key,
|
||||
locEnd
|
||||
) === "?"
|
||||
) {
|
||||
node.optional = true;
|
||||
}
|
||||
break;
|
||||
// For hack-style pipeline
|
||||
case "TopicReference":
|
||||
options.__isUsingHackPipeline = true;
|
||||
@@ -195,32 +145,6 @@ function transformChainExpression(node) {
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitNode(node, fn) {
|
||||
let entries;
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
entries = node.entries();
|
||||
} else if (
|
||||
node &&
|
||||
typeof node === "object" &&
|
||||
typeof node.type === "string"
|
||||
) {
|
||||
entries = Object.entries(node);
|
||||
} else {
|
||||
return node;
|
||||
}
|
||||
|
||||
for (const [key, child] of entries) {
|
||||
node[key] = visitNode(child, fn);
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
return fn(node) || node;
|
||||
}
|
||||
|
||||
function isUnbalancedLogicalTree(node) {
|
||||
return (
|
||||
node.type === "LogicalExpression" &&
|
||||
@@ -0,0 +1,80 @@
|
||||
"use strict";
|
||||
|
||||
const createError = require("../../../common/parser-create-error.js");
|
||||
const visitNode = require("./visitNode.js");
|
||||
|
||||
function throwSyntaxError(node, message) {
|
||||
const { start, end } = node.loc;
|
||||
throw createError(message, {
|
||||
start: { line: start.line, column: start.column + 1 },
|
||||
end: { line: end.line, column: end.column + 1 },
|
||||
});
|
||||
}
|
||||
|
||||
// Invalid decorators are removed since `@typescript-eslint/typescript-estree` v4
|
||||
// https://github.com/typescript-eslint/typescript-eslint/pull/2375
|
||||
function throwErrorForInvalidDecorator(
|
||||
tsNode,
|
||||
esTreeNode,
|
||||
tsNodeToESTreeNodeMap
|
||||
) {
|
||||
const tsDecorators = tsNode.decorators;
|
||||
if (!Array.isArray(tsDecorators)) {
|
||||
return;
|
||||
}
|
||||
const esTreeDecorators = esTreeNode.decorators;
|
||||
if (
|
||||
!Array.isArray(esTreeDecorators) ||
|
||||
esTreeDecorators.length !== tsDecorators.length ||
|
||||
tsDecorators.some((tsDecorator) => {
|
||||
const esTreeDecorator = tsNodeToESTreeNodeMap.get(tsDecorator);
|
||||
return !esTreeDecorator || !esTreeDecorators.includes(esTreeDecorator);
|
||||
})
|
||||
) {
|
||||
throwSyntaxError(
|
||||
esTreeNode,
|
||||
"Leading decorators must be attached to a class declaration"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Values of abstract property is removed since `@typescript-eslint/typescript-estree` v5
|
||||
// https://github.com/typescript-eslint/typescript-eslint/releases/tag/v5.0.0
|
||||
function throwErrorForInvalidAbstractProperty(tsNode, esTreeNode) {
|
||||
const SYNTAX_KIND_PROPERTY_DEFINITION = 165;
|
||||
const SYNTAX_KIND_ABSTRACT_KEYWORD = 126;
|
||||
if (
|
||||
tsNode.kind !== SYNTAX_KIND_PROPERTY_DEFINITION ||
|
||||
(tsNode.modifiers &&
|
||||
!tsNode.modifiers.some(
|
||||
(modifier) => modifier.kind === SYNTAX_KIND_ABSTRACT_KEYWORD
|
||||
))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (tsNode.initializer && esTreeNode.value === null) {
|
||||
throwSyntaxError(
|
||||
esTreeNode,
|
||||
"Abstract property cannot have an initializer"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function throwErrorForInvalidNodes(ast, options) {
|
||||
const { esTreeNodeToTSNodeMap, tsNodeToESTreeNodeMap } =
|
||||
options.tsParseResult;
|
||||
ast = visitNode(ast, (node) => {
|
||||
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
||||
if (!tsNode) {
|
||||
return;
|
||||
}
|
||||
const esTreeNode = tsNodeToESTreeNodeMap.get(tsNode);
|
||||
if (esTreeNode !== node) {
|
||||
return;
|
||||
}
|
||||
throwErrorForInvalidDecorator(tsNode, esTreeNode, tsNodeToESTreeNodeMap);
|
||||
throwErrorForInvalidAbstractProperty(tsNode, esTreeNode);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { throwErrorForInvalidNodes };
|
||||
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
function visitNode(node, fn) {
|
||||
let entries;
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
entries = node.entries();
|
||||
} else if (
|
||||
node &&
|
||||
typeof node === "object" &&
|
||||
typeof node.type === "string"
|
||||
) {
|
||||
entries = Object.entries(node);
|
||||
} else {
|
||||
return node;
|
||||
}
|
||||
|
||||
for (const [key, child] of entries) {
|
||||
node[key] = visitNode(child, fn);
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
return fn(node) || node;
|
||||
}
|
||||
|
||||
module.exports = visitNode;
|
||||
@@ -4,7 +4,7 @@ const createError = require("../../common/parser-create-error.js");
|
||||
const tryCombinations = require("../../utils/try-combinations.js");
|
||||
const createParser = require("./utils/create-parser.js");
|
||||
const replaceHashbang = require("./utils/replace-hashbang.js");
|
||||
const postprocess = require("./postprocess.js");
|
||||
const postprocess = require("./postprocess/index.js");
|
||||
|
||||
/** @type {import("@typescript-eslint/typescript-estree").TSESTreeOptions} */
|
||||
const parseOptions = {
|
||||
@@ -13,7 +13,6 @@ const parseOptions = {
|
||||
loc: true,
|
||||
range: true,
|
||||
comment: true,
|
||||
useJSXTextNode: true,
|
||||
jsx: true,
|
||||
tokens: true,
|
||||
loggerFn: false,
|
||||
|
||||
@@ -112,7 +112,7 @@ function printBinaryishExpression(path, options, print) {
|
||||
parent.type === "VariableDeclarator" ||
|
||||
parent.type === "ClassProperty" ||
|
||||
parent.type === "PropertyDefinition" ||
|
||||
parent.type === "TSAbstractClassProperty" ||
|
||||
parent.type === "TSAbstractPropertyDefinition" ||
|
||||
parent.type === "ClassPrivateProperty" ||
|
||||
isObjectProperty(parent);
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ function printClassProperty(path, options, print) {
|
||||
if (node.static) {
|
||||
parts.push("static ");
|
||||
}
|
||||
if (node.type === "TSAbstractClassProperty" || node.abstract) {
|
||||
if (node.type === "TSAbstractPropertyDefinition" || node.abstract) {
|
||||
parts.push("abstract ");
|
||||
}
|
||||
if (node.override) {
|
||||
|
||||
@@ -215,7 +215,7 @@ function shouldPrintSemicolonAfterClassProperty(node, nextNode) {
|
||||
switch (nextNode.type) {
|
||||
case "ClassProperty":
|
||||
case "PropertyDefinition":
|
||||
case "TSAbstractClassProperty":
|
||||
case "TSAbstractPropertyDefinition":
|
||||
return nextNode.computed;
|
||||
case "MethodDefinition": // Flow
|
||||
case "TSAbstractMethodDefinition": // TypeScript
|
||||
|
||||
@@ -113,7 +113,7 @@ function printTypescript(path, options, print) {
|
||||
case "TSAbstractMethodDefinition":
|
||||
case "TSDeclareMethod":
|
||||
return printClassMethod(path, options, print);
|
||||
case "TSAbstractClassProperty":
|
||||
case "TSAbstractPropertyDefinition":
|
||||
return printClassProperty(path, options, print);
|
||||
case "TSInterfaceHeritage":
|
||||
case "TSExpressionWithTypeArguments": // Babel AST
|
||||
@@ -486,9 +486,6 @@ function printTypescript(path, options, print) {
|
||||
|
||||
return parts;
|
||||
}
|
||||
// TODO: Temporary auto-generated node type. To remove when typescript-estree has proper support for private fields.
|
||||
case "TSPrivateIdentifier":
|
||||
return node.escapedText;
|
||||
|
||||
case "TSConditionalType":
|
||||
return printTernary(path, options, print);
|
||||
|
||||
@@ -96,7 +96,7 @@ function genericPrint(path, options, print, args) {
|
||||
type === "ClassPrivateMethod" ||
|
||||
type === "ClassProperty" ||
|
||||
type === "PropertyDefinition" ||
|
||||
type === "TSAbstractClassProperty" ||
|
||||
type === "TSAbstractPropertyDefinition" ||
|
||||
type === "ClassPrivateProperty" ||
|
||||
type === "MethodDefinition" ||
|
||||
type === "TSAbstractMethodDefinition" ||
|
||||
|
||||
@@ -708,8 +708,8 @@ function isStringPropSafeToUnquote(node, options) {
|
||||
// With `--strictPropertyInitialization`, TS treats properties with quoted names differently than unquoted ones.
|
||||
// See https://github.com/microsoft/TypeScript/pull/20075
|
||||
!(
|
||||
(options.parser === "typescript" || options.parser === "babel-ts") &&
|
||||
node.type === "ClassProperty"
|
||||
(options.parser === "babel-ts" && node.type === "ClassProperty") ||
|
||||
(options.parser === "typescript" && node.type === "PropertyDefinition")
|
||||
)) ||
|
||||
(isSimpleNumber(node.key.value) &&
|
||||
String(Number(node.key.value)) === node.key.value &&
|
||||
|
||||
@@ -89,3 +89,12 @@ exports[`snippet: #5 [typescript] format 1`] = `
|
||||
> 1 | let x6 = <div>>{\\"foo\\"}</div>;
|
||||
| ^"
|
||||
`;
|
||||
|
||||
exports[`value-of-abstract-property.ts [typescript] format 1`] = `
|
||||
"Abstract property cannot have an initializer (2:3)
|
||||
1 | abstract class Foo {
|
||||
> 2 | abstract prop = 3;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
3 | }
|
||||
4 |"
|
||||
`;
|
||||
@@ -0,0 +1,3 @@
|
||||
abstract class Foo {
|
||||
abstract prop = 3;
|
||||
}
|
||||
@@ -60,6 +60,94 @@ class Bar {
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`prettier-ignore-nested-unions.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel-ts"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
export type a =
|
||||
// foo
|
||||
| foo1&foo2
|
||||
// bar
|
||||
| bar1&bar2
|
||||
// prettier-ignore
|
||||
| (
|
||||
| aaaaaaaaaaaaa&1
|
||||
// b
|
||||
| bbbbbbbbbbbbb&2
|
||||
)
|
||||
// baz
|
||||
| baz1&baz2;
|
||||
|
||||
export type b =
|
||||
// foo
|
||||
| foo1&foo2
|
||||
// bar
|
||||
| bar1&bar2
|
||||
| (
|
||||
// prettier-ignore
|
||||
| aaaaaaaaaaaaa&1
|
||||
// b
|
||||
| bbbbbbbbbbbbb&2
|
||||
)
|
||||
// baz
|
||||
| baz1&baz2;
|
||||
|
||||
=====================================output=====================================
|
||||
export type a =
|
||||
// foo
|
||||
| (foo1 & foo2)
|
||||
// bar
|
||||
| (bar1 & bar2)
|
||||
// prettier-ignore
|
||||
| (
|
||||
| aaaaaaaaaaaaa&1
|
||||
// b
|
||||
| bbbbbbbbbbbbb&2
|
||||
)
|
||||
// baz
|
||||
| (baz1 & baz2);
|
||||
|
||||
export type b =
|
||||
// foo
|
||||
| (foo1 & foo2)
|
||||
// bar
|
||||
| (bar1 & bar2)
|
||||
| (
|
||||
| // prettier-ignore
|
||||
aaaaaaaaaaaaa&1
|
||||
// b
|
||||
| (bbbbbbbbbbbbb & 2)
|
||||
)
|
||||
// baz
|
||||
| (baz1 & baz2);
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`prettier-ignore-parenthesized-type.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel-ts"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
type Foo =
|
||||
// prettier-ignore
|
||||
(
|
||||
aa
|
||||
);
|
||||
|
||||
=====================================output=====================================
|
||||
type Foo =
|
||||
// prettier-ignore
|
||||
(
|
||||
aa
|
||||
);
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`tuple-labeled-ts.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel-ts"]
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,5 @@
|
||||
type Foo =
|
||||
// prettier-ignore
|
||||
(
|
||||
aa
|
||||
);
|
||||
@@ -92,3 +92,23 @@ class Bar {
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`prettier-ignore-parenthesized-type.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
type Foo =
|
||||
// prettier-ignore
|
||||
(
|
||||
aa
|
||||
);
|
||||
|
||||
=====================================output=====================================
|
||||
type Foo =
|
||||
// prettier-ignore
|
||||
aa;
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1,5 @@
|
||||
type Foo =
|
||||
// prettier-ignore
|
||||
(
|
||||
aa
|
||||
);
|
||||
@@ -44,9 +44,9 @@ exports[`abstractProperties.ts [babel-ts] format 1`] = `
|
||||
3 | private abstract b: 2;
|
||||
> 4 | static abstract c: 3;
|
||||
| ^
|
||||
5 |
|
||||
6 | abstract private d = 4;
|
||||
7 | private abstract e = 5;"
|
||||
5 | abstract private ['g'];
|
||||
6 | private abstract ['h'];
|
||||
7 | static abstract ['i'];"
|
||||
`;
|
||||
|
||||
exports[`abstractProperties.ts format 1`] = `
|
||||
@@ -59,14 +59,9 @@ abstract class Foo {
|
||||
abstract private a: 1;
|
||||
private abstract b: 2;
|
||||
static abstract c: 3;
|
||||
|
||||
abstract private d = 4;
|
||||
private abstract e = 5;
|
||||
static abstract f = 6;
|
||||
|
||||
abstract private ['g'] = 4;
|
||||
private abstract ['h'] = 5;
|
||||
static abstract ['i'] = 6;
|
||||
abstract private ['g'];
|
||||
private abstract ['h'];
|
||||
static abstract ['i'];
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
@@ -74,50 +69,9 @@ abstract class Foo {
|
||||
private abstract a: 1;
|
||||
private abstract b: 2;
|
||||
static abstract c: 3;
|
||||
|
||||
private abstract d = 4;
|
||||
private abstract e = 5;
|
||||
static abstract f = 6;
|
||||
|
||||
private abstract ["g"] = 4;
|
||||
private abstract ["h"] = 5;
|
||||
static abstract ["i"] = 6;
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`abstractPropertiesWithBreaks.ts [babel-ts] format 1`] = `
|
||||
"Property 'foobar' cannot have an initializer because it is marked abstract. (2:29)
|
||||
1 | abstract class Foo {
|
||||
> 2 | abstract private foobar =
|
||||
| ^
|
||||
3 | // comment to break
|
||||
4 | 1 +
|
||||
5 | // another comment to break"
|
||||
`;
|
||||
|
||||
exports[`abstractPropertiesWithBreaks.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
abstract class Foo {
|
||||
abstract private foobar =
|
||||
// comment to break
|
||||
1 +
|
||||
// another comment to break
|
||||
2;
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
abstract class Foo {
|
||||
private abstract foobar =
|
||||
// comment to break
|
||||
1 +
|
||||
// another comment to break
|
||||
2;
|
||||
private abstract ["g"];
|
||||
private abstract ["h"];
|
||||
static abstract ["i"];
|
||||
}
|
||||
|
||||
================================================================================
|
||||
|
||||
@@ -2,12 +2,7 @@ abstract class Foo {
|
||||
abstract private a: 1;
|
||||
private abstract b: 2;
|
||||
static abstract c: 3;
|
||||
|
||||
abstract private d = 4;
|
||||
private abstract e = 5;
|
||||
static abstract f = 6;
|
||||
|
||||
abstract private ['g'] = 4;
|
||||
private abstract ['h'] = 5;
|
||||
static abstract ['i'] = 6;
|
||||
abstract private ['g'];
|
||||
private abstract ['h'];
|
||||
static abstract ['i'];
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
abstract class Foo {
|
||||
abstract private foobar =
|
||||
// comment to break
|
||||
1 +
|
||||
// another comment to break
|
||||
2;
|
||||
}
|
||||
@@ -188,72 +188,6 @@ export type a =
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`prettier-ignore-nested-unions.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
export type a =
|
||||
// foo
|
||||
| foo1&foo2
|
||||
// bar
|
||||
| bar1&bar2
|
||||
// prettier-ignore
|
||||
| (
|
||||
| aaaaaaaaaaaaa&1
|
||||
// b
|
||||
| bbbbbbbbbbbbb&2
|
||||
)
|
||||
// baz
|
||||
| baz1&baz2;
|
||||
|
||||
export type b =
|
||||
// foo
|
||||
| foo1&foo2
|
||||
// bar
|
||||
| bar1&bar2
|
||||
| (
|
||||
// prettier-ignore
|
||||
| aaaaaaaaaaaaa&1
|
||||
// b
|
||||
| bbbbbbbbbbbbb&2
|
||||
)
|
||||
// baz
|
||||
| baz1&baz2;
|
||||
|
||||
=====================================output=====================================
|
||||
export type a =
|
||||
// foo
|
||||
| (foo1 & foo2)
|
||||
// bar
|
||||
| (bar1 & bar2)
|
||||
// prettier-ignore
|
||||
| (
|
||||
| aaaaaaaaaaaaa&1
|
||||
// b
|
||||
| bbbbbbbbbbbbb&2
|
||||
)
|
||||
// baz
|
||||
| (baz1 & baz2);
|
||||
|
||||
export type b =
|
||||
// foo
|
||||
| (foo1 & foo2)
|
||||
// bar
|
||||
| (bar1 & bar2)
|
||||
| (
|
||||
| // prettier-ignore
|
||||
aaaaaaaaaaaaa&1
|
||||
// b
|
||||
| (bbbbbbbbbbbbb & 2)
|
||||
)
|
||||
// baz
|
||||
| (baz1 & baz2);
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`union-parens.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
|
||||
@@ -1753,28 +1753,15 @@
|
||||
"@typescript-eslint/types" "5.0.0"
|
||||
"@typescript-eslint/visitor-keys" "5.0.0"
|
||||
|
||||
"@typescript-eslint/types@4.32.0":
|
||||
version "4.32.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.32.0.tgz#52c633c18da47aee09449144bf59565ab36df00d"
|
||||
integrity sha512-LE7Z7BAv0E2UvqzogssGf1x7GPpUalgG07nGCBYb1oK4mFsOiFC/VrSMKbZQzFJdN2JL5XYmsx7C7FX9p9ns0w==
|
||||
|
||||
"@typescript-eslint/types@5.0.0":
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.0.0.tgz#25d93f6d269b2d25fdc51a0407eb81ccba60eb0f"
|
||||
integrity sha512-dU/pKBUpehdEqYuvkojmlv0FtHuZnLXFBn16zsDmlFF3LXkOpkAQ2vrKc3BidIIve9EMH2zfTlxqw9XM0fFN5w==
|
||||
|
||||
"@typescript-eslint/typescript-estree@4.32.0":
|
||||
version "4.32.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.32.0.tgz#db00ccc41ccedc8d7367ea3f50c6994b8efa9f3b"
|
||||
integrity sha512-tRYCgJ3g1UjMw1cGG8Yn1KzOzNlQ6u1h9AmEtPhb5V5a1TmiHWcRyF/Ic+91M4f43QeChyYlVTcf3DvDTZR9vw==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "4.32.0"
|
||||
"@typescript-eslint/visitor-keys" "4.32.0"
|
||||
debug "^4.3.1"
|
||||
globby "^11.0.3"
|
||||
is-glob "^4.0.1"
|
||||
semver "^7.3.5"
|
||||
tsutils "^3.21.0"
|
||||
"@typescript-eslint/types@5.1.0":
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.1.0.tgz#a8a75ddfc611660de6be17d3ad950302385607a9"
|
||||
integrity sha512-sEwNINVxcB4ZgC6Fe6rUyMlvsB2jvVdgxjZEjQUQVlaSPMNamDOwO6/TB98kFt4sYYfNhdhTPBEQqNQZjMMswA==
|
||||
|
||||
"@typescript-eslint/typescript-estree@5.0.0":
|
||||
version "5.0.0"
|
||||
@@ -1789,13 +1776,18 @@
|
||||
semver "^7.3.5"
|
||||
tsutils "^3.21.0"
|
||||
|
||||
"@typescript-eslint/visitor-keys@4.32.0":
|
||||
version "4.32.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.32.0.tgz#455ba8b51242f2722a497ffae29313f33b14cb7f"
|
||||
integrity sha512-e7NE0qz8W+atzv3Cy9qaQ7BTLwWsm084Z0c4nIO2l3Bp6u9WIgdqCgyPyV5oSPDMIW3b20H59OOCmVk3jw3Ptw==
|
||||
"@typescript-eslint/typescript-estree@5.1.0":
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.1.0.tgz#132aea34372df09decda961cb42457433aa6e83d"
|
||||
integrity sha512-SSz+l9YrIIsW4s0ZqaEfnjl156XQ4VRmJsbA0ZE1XkXrD3cRpzuZSVCyqeCMR3EBjF27IisWakbBDGhGNIOvfQ==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "4.32.0"
|
||||
eslint-visitor-keys "^2.0.0"
|
||||
"@typescript-eslint/types" "5.1.0"
|
||||
"@typescript-eslint/visitor-keys" "5.1.0"
|
||||
debug "^4.3.2"
|
||||
globby "^11.0.4"
|
||||
is-glob "^4.0.3"
|
||||
semver "^7.3.5"
|
||||
tsutils "^3.21.0"
|
||||
|
||||
"@typescript-eslint/visitor-keys@5.0.0":
|
||||
version "5.0.0"
|
||||
@@ -1805,6 +1797,14 @@
|
||||
"@typescript-eslint/types" "5.0.0"
|
||||
eslint-visitor-keys "^3.0.0"
|
||||
|
||||
"@typescript-eslint/visitor-keys@5.1.0":
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.1.0.tgz#e01a01b27eb173092705ae983aa1451bd1842630"
|
||||
integrity sha512-uqNXepKBg81JVwjuqAxYrXa1Ql/YDzM+8g/pS+TCPxba0wZttl8m5DkrasbfnmJGHs4lQ2jTbcZ5azGhI7kK+w==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "5.1.0"
|
||||
eslint-visitor-keys "^3.0.0"
|
||||
|
||||
"@webassemblyjs/ast@1.11.1":
|
||||
version "1.11.1"
|
||||
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7"
|
||||
@@ -2751,7 +2751,7 @@ data-urls@^2.0.0:
|
||||
whatwg-mimetype "^2.3.0"
|
||||
whatwg-url "^8.0.0"
|
||||
|
||||
debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1:
|
||||
debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2:
|
||||
version "4.3.2"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
|
||||
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
|
||||
@@ -3653,7 +3653,7 @@ globals@^13.6.0, globals@^13.9.0:
|
||||
dependencies:
|
||||
type-fest "^0.20.2"
|
||||
|
||||
globby@11.0.4, globby@^11.0.1, globby@^11.0.3:
|
||||
globby@11.0.4, globby@^11.0.1, globby@^11.0.3, globby@^11.0.4:
|
||||
version "11.0.4"
|
||||
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5"
|
||||
integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==
|
||||
@@ -3958,6 +3958,13 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3:
|
||||
dependencies:
|
||||
is-extglob "^2.1.1"
|
||||
|
||||
is-glob@^4.0.3:
|
||||
version "4.0.3"
|
||||
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084"
|
||||
integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==
|
||||
dependencies:
|
||||
is-extglob "^2.1.1"
|
||||
|
||||
is-hexadecimal@^1.0.0:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz#cc35c97588da4bd49a8eedd6bc4082d44dcb23a7"
|
||||
|
||||
Reference in new issue
Block a user