fisker / prettier-regression-testing

Automates the prettier/prettier regression checks with GitHub Actions.
1 stars 0 forks source link

Run with pr 9672 #2

Closed fisker closed 3 years ago

fisker commented 3 years ago

run with pr 9672

fisker commented 3 years ago

run with pr 9672

fisker commented 3 years ago

run with pr 9672

github-actions[bot] commented 3 years ago

Diff by prettier/prettier@002dc6c45fd3f57d29e3f051e4a6362d32a8842f

diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts index 295e8209..4a9378d7 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts @@ -1237,10 +1237,9 @@ function validateUnderscores(name: string): boolean { return !wasUnderscore; }

-const PredefinedFormatToCheckFunction: Readonly<Record<

-const formatTestNames: Readonly<Record<

fisker commented 3 years ago

run with pr 9672

fisker commented 3 years ago

run with pr 9672

fisker commented 3 years ago

run with pr 9672

github-actions[bot] commented 3 years ago

Diff by prettier/prettier@002dc6c45fd3f57d29e3f051e4a6362d32a8842f

diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts index 295e8209..4a9378d7 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts @@ -1237,10 +1237,9 @@ function validateUnderscores(name: string): boolean { return !wasUnderscore; }

-const PredefinedFormatToCheckFunction: Readonly<Record<

-const formatTestNames: Readonly<Record<

fisker commented 3 years ago

run with pr 9672

github-actions[bot] commented 3 years ago

Diff by Prettier PR 9672

diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts index 295e8209..4a9378d7 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts @@ -1237,10 +1237,9 @@ function validateUnderscores(name: string): boolean { return !wasUnderscore; }

-const PredefinedFormatToCheckFunction: Readonly<Record<

-const formatTestNames: Readonly<Record<

fisker commented 3 years ago

run with pr 8300

github-actions[bot] commented 3 years ago

Diff by Prettier PR 8300

-const rule = new eslint.Linter().getRules().get("new-cap"); +const rule = new eslint.Linter()

-const noInvalidThisRule = new eslint.Linter().getRules().get("no-invalid-this"); +const noInvalidThisRule = new eslint.Linter()

-const rule = new eslint.Linter().getRules().get("no-unused-expressions"); +const rule = new eslint.Linter()

-const rule = new eslint.Linter().getRules().get("object-curly-spacing"); +const rule = new eslint.Linter()

-const rule = new eslint.Linter().getRules().get("semi"); +const rule = new eslint.Linter()

-const compatibilityTests = flatMap(compatSources, data =>

diff --git a/repos/babel/packages/babel-core/test/path.js b/repos/babel/packages/babel-core/test/path.js index 2edb48921..d151b88c8 100644 --- a/repos/babel/packages/babel-core/test/path.js +++ b/repos/babel/packages/babel-core/test/path.js @@ -30,18 +30,20 @@ describe("traversal path", function () { new Plugin({ visitor: { ArrowFunctionExpression: function (path) {

@@ -1888,8 +1889,9 @@ export default (superClass: Class): Class =>

   node.test = expr;
   node.consequent = consequent;

diff --git a/repos/babel/packages/babel-preset-env/data/shipped-proposals.js b/repos/babel/packages/babel-preset-env/data/shipped-proposals.js index 95ca9b119..baeca41a9 100644 --- a/repos/babel/packages/babel-preset-env/data/shipped-proposals.js +++ b/repos/babel/packages/babel-preset-env/data/shipped-proposals.js @@ -4,7 +4,7 @@

const proposalPlugins = new Set([ "proposal-class-properties",

diff --git a/repos/prettier/src/language-css/index.js b/repos/prettier/src/language-css/index.js index c69c43461..1f881d51d 100644 --- a/repos/prettier/src/language-css/index.js +++ b/repos/prettier/src/language-css/index.js @@ -5,32 +5,44 @@ const printer = require("./printer-postcss"); const options = require("./options");

const languages = [

  • createLanguage(require("linguist-languages/data/CSS.json"), (data) => ({

  • since: "1.4.0",

  • parsers: ["css"],

  • vscodeLanguageIds: ["css"],

  • extensions: [

  • ...data.extensions,

  • // WeiXin Style Sheets(Weixin Mini Programs)

  • // https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/

  • ".wxss",

  • ],

  • })),

  • createLanguage(require("linguist-languages/data/PostCSS.json"), () => ({

  • since: "1.4.0",

  • parsers: ["css"],

  • vscodeLanguageIds: ["postcss"],

  • })),

  • createLanguage(require("linguist-languages/data/Less.json"), () => ({

  • since: "1.4.0",

  • parsers: ["less"],

  • vscodeLanguageIds: ["less"],

  • })),

  • createLanguage(require("linguist-languages/data/SCSS.json"), () => ({

  • since: "1.4.0",

  • parsers: ["scss"],

  • vscodeLanguageIds: ["scss"],

  • })),

  • createLanguage(

  • require("linguist-languages/data/CSS.json"),

  • (data) => ({

  • since: "1.4.0",

  • parsers: ["css"],

  • vscodeLanguageIds: ["css"],

  • extensions: [

  • ...data.extensions,

  • // WeiXin Style Sheets(Weixin Mini Programs)

  • // https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/

  • ".wxss",

  • ],

  • })

  • ),

  • createLanguage(

  • require("linguist-languages/data/PostCSS.json"),

  • () => ({

  • since: "1.4.0",

  • parsers: ["css"],

  • vscodeLanguageIds: ["postcss"],

  • })

  • ),

  • createLanguage(

  • require("linguist-languages/data/Less.json"),

  • () => ({

  • since: "1.4.0",

  • parsers: ["less"],

  • vscodeLanguageIds: ["less"],

  • })

  • ),

  • createLanguage(

  • require("linguist-languages/data/SCSS.json"),

  • () => ({

  • since: "1.4.0",

  • parsers: ["scss"],

  • vscodeLanguageIds: ["scss"],

  • })

  • ), ];

    const printers = { diff --git a/repos/prettier/src/language-graphql/index.js b/repos/prettier/src/language-graphql/index.js index b991a850f..c3f9a6367 100644 --- a/repos/prettier/src/language-graphql/index.js +++ b/repos/prettier/src/language-graphql/index.js @@ -5,11 +5,14 @@ const printer = require("./printer-graphql"); const options = require("./options");

    const languages = [

  • createLanguage(require("linguist-languages/data/GraphQL.json"), () => ({

  • since: "1.5.0",

  • parsers: ["graphql"],

  • vscodeLanguageIds: ["graphql"],

  • })),

  • createLanguage(

  • require("linguist-languages/data/GraphQL.json"),

  • () => ({

  • since: "1.5.0",

  • parsers: ["graphql"],

  • vscodeLanguageIds: ["graphql"],

  • })

  • ), ];

    const printers = { diff --git a/repos/prettier/src/language-handlebars/index.js b/repos/prettier/src/language-handlebars/index.js index 01e35dd96..be3e56fbb 100644 --- a/repos/prettier/src/language-handlebars/index.js +++ b/repos/prettier/src/language-handlebars/index.js @@ -4,11 +4,14 @@ const createLanguage = require("../utils/create-language"); const printer = require("./printer-glimmer");

    const languages = [

  • createLanguage(require("linguist-languages/data/Handlebars.json"), () => ({

  • since: null, // unreleased

  • parsers: ["glimmer"],

  • vscodeLanguageIds: ["handlebars"],

  • })),

  • createLanguage(

  • require("linguist-languages/data/Handlebars.json"),

  • () => ({

  • since: null, // unreleased

  • parsers: ["glimmer"],

  • vscodeLanguageIds: ["handlebars"],

  • })

  • ), ];

    const printers = { diff --git a/repos/prettier/src/language-html/index.js b/repos/prettier/src/language-html/index.js index 61882c524..b4e28ee9c 100644 --- a/repos/prettier/src/language-html/index.js +++ b/repos/prettier/src/language-html/index.js @@ -5,35 +5,47 @@ const printer = require("./printer-html"); const options = require("./options");

    const languages = [

  • createLanguage(require("linguist-languages/data/HTML.json"), () => ({

  • name: "Angular",

  • since: "1.15.0",

  • parsers: ["angular"],

  • vscodeLanguageIds: ["html"],

  • extensions: [".component.html"],

  • filenames: [],

  • })),

  • createLanguage(require("linguist-languages/data/HTML.json"), (data) => ({

  • since: "1.15.0",

  • parsers: ["html"],

  • vscodeLanguageIds: ["html"],

  • extensions: data.extensions.concat([

  • ".mjml", // MJML is considered XML in Linguist but it should be formatted as HTML

  • ]),

  • })),

  • createLanguage(require("linguist-languages/data/HTML.json"), () => ({

  • name: "Lightning Web Components",

  • since: "1.17.0",

  • parsers: ["lwc"],

  • vscodeLanguageIds: ["html"],

  • extensions: [],

  • filenames: [],

  • })),

  • createLanguage(require("linguist-languages/data/Vue.json"), () => ({

  • since: "1.10.0",

  • parsers: ["vue"],

  • vscodeLanguageIds: ["vue"],

  • })),

  • createLanguage(

  • require("linguist-languages/data/HTML.json"),

  • () => ({

  • name: "Angular",

  • since: "1.15.0",

  • parsers: ["angular"],

  • vscodeLanguageIds: ["html"],

  • extensions: [".component.html"],

  • filenames: [],

  • })

  • ),

  • createLanguage(

  • require("linguist-languages/data/HTML.json"),

  • (data) => ({

  • since: "1.15.0",

  • parsers: ["html"],

  • vscodeLanguageIds: ["html"],

  • extensions: data.extensions.concat([

  • ".mjml", // MJML is considered XML in Linguist but it should be formatted as HTML

  • ]),

  • })

  • ),

  • createLanguage(

  • require("linguist-languages/data/HTML.json"),

  • () => ({

  • name: "Lightning Web Components",

  • since: "1.17.0",

  • parsers: ["lwc"],

  • vscodeLanguageIds: ["html"],

  • extensions: [],

  • filenames: [],

  • })

  • ),

  • createLanguage(

  • require("linguist-languages/data/Vue.json"),

  • () => ({

  • since: "1.10.0",

  • parsers: ["vue"],

  • vscodeLanguageIds: ["vue"],

  • })

  • ), ];

    const printers = { diff --git a/repos/prettier/src/language-html/printer-html.js b/repos/prettier/src/language-html/printer-html.js index 0beeea663..2fb9a692a 100644 --- a/repos/prettier/src/language-html/printer-html.js +++ b/repos/prettier/src/language-html/printer-html.js @@ -210,8 +210,10 @@ function embed(path, print, textToDoc, options) { node.rawName, '="', group(

  • mapDoc(embeddedAttributeValueDoc, (doc) =>

  • typeof doc === "string" ? doc.replace(/"/g, """) : doc

  • mapDoc(

  • embeddedAttributeValueDoc,

  • (doc) =>

  • typeof doc === "string" ? doc.replace(/"/g, """) : doc ) ), '"', diff --git a/repos/prettier/src/language-js/embed.js b/repos/prettier/src/language-js/embed.js index 1797bf414..c03e81354 100644 --- a/repos/prettier/src/language-js/embed.js +++ b/repos/prettier/src/language-js/embed.js @@ -227,21 +227,24 @@ function uncook(cookedValue) { }

    function escapeTemplateCharacters(doc, raw) {

  • return mapDoc(doc, (currentDoc) => {

  • if (!currentDoc.parts) {

  • return currentDoc;

  • }

  • const parts = currentDoc.parts.map((part) => {

  • if (typeof part === "string") {

  • return raw ? part.replace(/(\*)/g, "$1$1\\") : uncook(part);

  • return mapDoc(

  • doc,

  • (currentDoc) => {

  • if (!currentDoc.parts) {

  • return currentDoc; }

  • return part;

  • });

  • const parts = currentDoc.parts.map((part) => {

  • if (typeof part === "string") {

  • return raw ? part.replace(/(\*)/g, "$1$1\\") : uncook(part);

  • }

  • return part;

  • });

  • return { ...currentDoc, parts };

  • });

  • return { ...currentDoc, parts };

  • }

  • ); }

    function transformCssDoc(quasisDoc, parentNode, expressionDocs) { @@ -269,52 +272,60 @@ function replacePlaceholders(quasisDoc, expressionDocs) { }

    let replaceCounter = 0;

  • const newDoc = mapDoc(quasisDoc, (doc) => {

  • if (!doc || !doc.parts || !doc.parts.length) {

  • return doc;

  • }

  • let { parts } = doc;

  • const atIndex = parts.indexOf("@");

  • const placeholderIndex = atIndex + 1;

  • if (

  • atIndex > -1 &&

  • typeof parts[placeholderIndex] === "string" &&

  • parts[placeholderIndex].startsWith("prettier-placeholder")

  • ) {

  • // If placeholder is split, join it

  • const at = parts[atIndex];

  • const placeholder = parts[placeholderIndex];

  • const rest = parts.slice(placeholderIndex + 1);

  • parts = parts

  • .slice(0, atIndex)

  • .concat([at + placeholder])

  • .concat(rest);

  • }

  • const newDoc = mapDoc(

  • quasisDoc,

  • (doc) => {

  • if (!doc || !doc.parts || !doc.parts.length) {

  • return doc;

  • }

  • const replacedParts = [];

  • parts.forEach((part) => {

  • if (typeof part !== "string" || !part.includes("@prettier-placeholder")) {

  • replacedParts.push(part);

  • return;

  • let { parts } = doc;

  • const atIndex = parts.indexOf("@");

  • const placeholderIndex = atIndex + 1;

  • if (

  • atIndex > -1 &&

  • typeof parts[placeholderIndex] === "string" &&

  • parts[placeholderIndex].startsWith("prettier-placeholder")

  • ) {

  • // If placeholder is split, join it

  • const at = parts[atIndex];

  • const placeholder = parts[placeholderIndex];

  • const rest = parts.slice(placeholderIndex + 1);

  • parts = parts

  • .slice(0, atIndex)

  • .concat([at + placeholder])

  • .concat(rest); }

  • // When we have multiple placeholders in one line, like:

  • // ${Child}${Child2}:not(:first-child)

  • part.split(/@prettier-placeholder-(\d+)-id/).forEach((component, idx) => {

  • // The placeholder is always at odd indices

  • if (idx % 2 === 0) {

  • replacedParts.push(replaceNewlinesWithLiterallines(component));

  • const replacedParts = [];

  • parts.forEach((part) => {

  • if (

  • typeof part !== "string" ||

  • !part.includes("@prettier-placeholder")

  • ) {

  • replacedParts.push(part); return; }

  • // The component will always be a number at odd index

  • replacedParts.push(expressionDocs[component]);

  • replaceCounter++;

  • // When we have multiple placeholders in one line, like:

  • // ${Child}${Child2}:not(:first-child)

  • part

  • .split(/@prettier-placeholder-(\d+)-id/)

  • .forEach((component, idx) => {

  • // The placeholder is always at odd indices

  • if (idx % 2 === 0) {

  • replacedParts.push(replaceNewlinesWithLiterallines(component));

  • return;

  • }

  • // The component will always be a number at odd index

  • replacedParts.push(expressionDocs[component]);

  • replaceCounter++;

  • }); });

  • });

  • return { ...doc, parts: replacedParts };

  • });

  • return { ...doc, parts: replacedParts };

  • }

  • ); return expressionDocs.length === replaceCounter ? newDoc : null; }

diff --git a/repos/prettier/src/language-js/index.js b/repos/prettier/src/language-js/index.js index 00c22e142..465a6f280 100644 --- a/repos/prettier/src/language-js/index.js +++ b/repos/prettier/src/language-js/index.js @@ -27,52 +27,70 @@ const languages = [ ], }) ),

  • createLanguage(require("linguist-languages/data/JavaScript.json"), () => ({

  • name: "Flow",

  • since: "0.0.0",

  • parsers: ["flow", "babel-flow"],

  • vscodeLanguageIds: ["javascript"],

  • aliases: [],

  • filenames: [],

  • extensions: [".js.flow"],

  • })),

  • createLanguage(require("linguist-languages/data/JSX.json"), () => ({

  • since: "0.0.0",

  • parsers: [

  • "babel",

  • "babel-flow",

  • "babel-ts",

  • "flow",

  • "typescript",

  • "espree",

  • ],

  • vscodeLanguageIds: ["javascriptreact"],

  • })),

  • createLanguage(require("linguist-languages/data/TypeScript.json"), () => ({

  • since: "1.4.0",

  • parsers: ["typescript", "babel-ts"],

  • vscodeLanguageIds: ["typescript"],

  • })),

  • createLanguage(require("linguist-languages/data/TSX.json"), () => ({

  • since: "1.4.0",

  • parsers: ["typescript", "babel-ts"],

  • vscodeLanguageIds: ["typescriptreact"],

  • })),

  • createLanguage(require("linguist-languages/data/JSON.json"), () => ({

  • name: "JSON.stringify",

  • since: "1.13.0",

  • parsers: ["json-stringify"],

  • vscodeLanguageIds: ["json"],

  • extensions: [], // .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) => ({

  • since: "1.5.0",

  • parsers: ["json"],

  • vscodeLanguageIds: ["json"],

  • filenames: [...data.filenames, ".prettierrc"],

  • extensions: data.extensions.filter((extension) => extension !== ".jsonl"),

  • })),

  • createLanguage(

  • require("linguist-languages/data/JavaScript.json"),

  • () => ({

  • name: "Flow",

  • since: "0.0.0",

  • parsers: ["flow", "babel-flow"],

  • vscodeLanguageIds: ["javascript"],

  • aliases: [],

  • filenames: [],

  • extensions: [".js.flow"],

  • })

  • ),

  • createLanguage(

  • require("linguist-languages/data/JSX.json"),

  • () => ({

  • since: "0.0.0",

  • parsers: [

  • "babel",

  • "babel-flow",

  • "babel-ts",

  • "flow",

  • "typescript",

  • "espree",

  • ],

  • vscodeLanguageIds: ["javascriptreact"],

  • })

  • ),

  • createLanguage(

  • require("linguist-languages/data/TypeScript.json"),

  • () => ({

  • since: "1.4.0",

  • parsers: ["typescript", "babel-ts"],

  • vscodeLanguageIds: ["typescript"],

  • })

  • ),

  • createLanguage(

  • require("linguist-languages/data/TSX.json"),

  • () => ({

  • since: "1.4.0",

  • parsers: ["typescript", "babel-ts"],

  • vscodeLanguageIds: ["typescriptreact"],

  • })

  • ),

  • createLanguage(

  • require("linguist-languages/data/JSON.json"),

  • () => ({

  • name: "JSON.stringify",

  • since: "1.13.0",

  • parsers: ["json-stringify"],

  • vscodeLanguageIds: ["json"],

  • extensions: [], // .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) => ({

  • since: "1.5.0",

  • parsers: ["json"],

  • vscodeLanguageIds: ["json"],

  • filenames: [...data.filenames, ".prettierrc"],

  • extensions: data.extensions.filter((extension) => extension !== ".jsonl"),

  • })

  • ), createLanguage( require("linguist-languages/data/JSON with Comments.json"), (data) => ({ @@ -82,11 +100,14 @@ const languages = [ filenames: [...data.filenames, ".eslintrc"], }) ),

  • createLanguage(require("linguist-languages/data/JSON5.json"), () => ({

  • since: "1.13.0",

  • parsers: ["json5"],

  • vscodeLanguageIds: ["json5"],

  • })),

  • createLanguage(

  • require("linguist-languages/data/JSON5.json"),

  • () => ({

  • since: "1.13.0",

  • parsers: ["json5"],

  • vscodeLanguageIds: ["json5"],

  • })

  • ), ];

    const printers = { diff --git a/repos/prettier/src/language-js/postprocess.js b/repos/prettier/src/language-js/postprocess.js index 26f4049cf..6d23aee6e 100644 --- a/repos/prettier/src/language-js/postprocess.js +++ b/repos/prettier/src/language-js/postprocess.js @@ -29,107 +29,116 @@ function postprocess(ast, options) { // E.g.: /* @type {Foo} / (foo).bar(); // Let's use the fact that those ancestors and ParenthesizedExpression have the same start offset.

  • ast = visitNode(ast, (node) => {

  • if (

  • node.leadingComments &&

  • node.leadingComments.some(isTypeCastComment)

  • ) {

  • startOffsetsOfTypeCastedNodes.add(locStart(node));

  • }

  • });

  • ast = visitNode(ast, (node) => {

  • if (node.type === "ParenthesizedExpression") {

  • const { expression } = node;

  • // Align range with flow

  • if (expression.type === "TypeCastExpression") {

  • expression.range = node.range;

  • return expression;

  • ast = visitNode(

  • ast,

  • (node) => {

  • if (

  • node.leadingComments &&

  • node.leadingComments.some(isTypeCastComment)

  • ) {

  • startOffsetsOfTypeCastedNodes.add(locStart(node)); }

  • }

  • );

  • ast = visitNode(

  • ast,

  • (node) => {

  • if (node.type === "ParenthesizedExpression") {

  • const { expression } = node;

  • // Align range with flow

  • if (expression.type === "TypeCastExpression") {

  • expression.range = node.range;

  • return expression;

  • }

  • const start = locStart(node);

  • if (!startOffsetsOfTypeCastedNodes.has(start)) {

  • if (!expression.extra) {

  • expression.extra = {};

  • const start = locStart(node);

  • if (!startOffsetsOfTypeCastedNodes.has(start)) {

  • if (!expression.extra) {

  • expression.extra = {};

  • }

  • expression.extra.parenthesized = true;

  • expression.extra.parenStart = start;

  • return expression; }

  • expression.extra.parenthesized = true;

  • expression.extra.parenStart = start;

  • return expression; } }

  • });

  • ); }

  • ast = visitNode(ast, (node) => {

  • switch (node.type) {

  • // Espree

  • case "ChainExpression": {

  • return transformChainExpression(node.expression);

  • }

  • case "LogicalExpression": {

  • // We remove unneeded parens around same-operator LogicalExpressions

  • if (isUnbalancedLogicalTree(node)) {

  • return rebalanceLogicalTree(node);

  • ast = visitNode(

  • ast,

  • (node) => {

  • switch (node.type) {

  • // Espree

  • case "ChainExpression": {

  • return transformChainExpression(node.expression); }

  • break;

  • }

  • // fix unexpected locEnd caused by --no-semi style

  • case "VariableDeclaration": {

  • const lastDeclaration = getLast(node.declarations);

  • if (lastDeclaration && lastDeclaration.init) {

  • overrideLocEnd(node, lastDeclaration);

  • case "LogicalExpression": {

  • // We remove unneeded parens around same-operator LogicalExpressions

  • if (isUnbalancedLogicalTree(node)) {

  • return rebalanceLogicalTree(node);

  • }

  • break; }

  • break;

  • }

  • // remove redundant TypeScript nodes

  • case "TSParenthesizedType": {

  • node.typeAnnotation.range = composeLoc(node);

  • return node.typeAnnotation;

  • }

  • case "TSUnionType":

  • case "TSIntersectionType":

  • if (node.types.length === 1) {

  • const [firstType] = node.types;

  • // override loc, so that comments are attached properly

  • firstType.range = composeLoc(node);

  • return firstType;

  • // fix unexpected locEnd caused by --no-semi style

  • case "VariableDeclaration": {

  • const lastDeclaration = getLast(node.declarations);

  • if (lastDeclaration && lastDeclaration.init) {

  • overrideLocEnd(node, lastDeclaration);

  • }

  • break; }

  • break;

  • case "TSTypeParameter":

  • // babel-ts

  • if (typeof node.name === "string") {

  • node.name = {

  • type: "Identifier",

  • name: node.name,

  • range: composeLoc(node, node.name.length),

  • };

  • // remove redundant TypeScript nodes

  • case "TSParenthesizedType": {

  • node.typeAnnotation.range = composeLoc(node);

  • return node.typeAnnotation; }

  • break;

  • case "SequenceExpression": {

  • // Babel (unlike other parsers) includes spaces and comments in the range. Let's unify this.

  • const lastExpression = getLast(node.expressions);

  • if (locEnd(node) > locEnd(lastExpression)) {

  • node.range = composeLoc(node, lastExpression);

  • case "TSUnionType":

  • case "TSIntersectionType":

  • if (node.types.length === 1) {

  • const [firstType] = node.types;

  • // override loc, so that comments are attached properly

  • firstType.range = composeLoc(node);

  • return firstType;

  • }

  • break;

  • case "TSTypeParameter":

  • // babel-ts

  • if (typeof node.name === "string") {

  • node.name = {

  • type: "Identifier",

  • name: node.name,

  • range: composeLoc(node, node.name.length),

  • };

  • }

  • break;

  • case "SequenceExpression": {

  • // Babel (unlike other parsers) includes spaces and comments in the range. Let's unify this.

  • const lastExpression = getLast(node.expressions);

  • if (locEnd(node) > locEnd(lastExpression)) {

  • node.range = composeLoc(node, lastExpression);

  • }

  • break; }

  • 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; }

  • 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; }

  • });

  • );

    return ast;

diff --git a/repos/prettier/src/language-js/utils.js b/repos/prettier/src/language-js/utils.js index f3bf1f0a6..f7470cbd3 100644 --- a/repos/prettier/src/language-js/utils.js +++ b/repos/prettier/src/language-js/utils.js @@ -619,16 +619,19 @@ function hasDanglingComments(node) {

  • @returns {boolean} */ function hasNgSideEffect(path) {

    • return hasNode(path.getValue(), (node) => {
    • switch (node.type) {
    • case undefined:
    • return false;
    • case "CallExpression":
    • case "OptionalCallExpression":
    • case "AssignmentExpression":
    • return true;
    • return hasNode(
    • path.getValue(),
    • (node) => {
    • switch (node.type) {
    • case undefined:
    • return false;
    • case "CallExpression":
    • case "OptionalCallExpression":
    • case "AssignmentExpression":
    • return true;
    • } }
    • });
    • ); }

    function isNgForOf(node, index, parentNode) { diff --git a/repos/prettier/src/language-markdown/index.js b/repos/prettier/src/language-markdown/index.js index 318a691a4..f141b54f5 100644 --- a/repos/prettier/src/language-markdown/index.js +++ b/repos/prettier/src/language-markdown/index.js @@ -5,21 +5,27 @@ const printer = require("./printer-markdown"); const options = require("./options");

    const languages = [

    • createLanguage(require("linguist-languages/data/Markdown.json"), (data) => ({
    • since: "1.8.0",
    • parsers: ["markdown"],
    • vscodeLanguageIds: ["markdown"],
    • filenames: data.filenames.concat(["README"]),
    • extensions: data.extensions.filter((extension) => extension !== ".mdx"),
    • })),
    • createLanguage(require("linguist-languages/data/Markdown.json"), () => ({
    • name: "MDX",
    • since: "1.15.0",
    • parsers: ["mdx"],
    • vscodeLanguageIds: ["mdx"],
    • filenames: [],
    • extensions: [".mdx"],
    • })),
    • createLanguage(
    • require("linguist-languages/data/Markdown.json"),
    • (data) => ({
    • since: "1.8.0",
    • parsers: ["markdown"],
    • vscodeLanguageIds: ["markdown"],
    • filenames: data.filenames.concat(["README"]),
    • extensions: data.extensions.filter((extension) => extension !== ".mdx"),
    • })
    • ),
    • createLanguage(
    • require("linguist-languages/data/Markdown.json"),
    • () => ({
    • name: "MDX",
    • since: "1.15.0",
    • parsers: ["mdx"],
    • vscodeLanguageIds: ["mdx"],
    • filenames: [],
    • extensions: [".mdx"],
    • })
    • ), ];

    const printers = { diff --git a/repos/prettier/src/language-markdown/parser-markdown.js b/repos/prettier/src/language-markdown/parser-markdown.js index bb961f103..7871e904c 100644 --- a/repos/prettier/src/language-markdown/parser-markdown.js +++ b/repos/prettier/src/language-markdown/parser-markdown.js @@ -48,17 +48,20 @@ function identity(x) {

    function htmlToJsx() { return (ast) =>

    • mapAst(ast, (node, _index, [parent]) => {
    • if (
    • node.type !== "html" ||
    • node.value.match(mdx.COMMENT_REGEX) ||
    • INLINE_NODE_WRAPPER_TYPES.includes(parent.type)
    • ) {
    • return node;
    • mapAst(
    • ast,
    • (node, _index, [parent]) => {
    • if (
    • node.type !== "html" ||
    • node.value.match(mdx.COMMENT_REGEX) ||
    • INLINE_NODE_WRAPPER_TYPES.includes(parent.type)
    • ) {
    • return node;
    • }
    • return { ...node, type: "jsx" }; }
    • return { ...node, type: "jsx" };
    • });
    • ); }

    function frontMatter() { diff --git a/repos/prettier/src/language-markdown/preprocess.js b/repos/prettier/src/language-markdown/preprocess.js index 5b97c7e42..5f4724e00 100644 --- a/repos/prettier/src/language-markdown/preprocess.js +++ b/repos/prettier/src/language-markdown/preprocess.js @@ -19,45 +19,54 @@ function preprocess(ast, options) { }

    function transformImportExport(ast) {

    • return mapAst(ast, (node) => {
    • if (node.type !== "import" && node.type !== "export") {
    • return node;
    • }
    • return mapAst(
    • ast,
    • (node) => {
    • if (node.type !== "import" && node.type !== "export") {
    • return node;
    • }
  • return { ...node, type: "importExport" };

  • });

  • return { ...node, type: "importExport" };

  • }

  • ); }

    function transformInlineCode(ast) {

  • return mapAst(ast, (node) => {

  • if (node.type !== "inlineCode") {

  • return node;

  • }

  • return mapAst(

  • ast,

  • (node) => {

  • if (node.type !== "inlineCode") {

  • return node;

  • }

  • return { ...node, value: node.value.replace(/\s+/g, " ") };

  • });

  • return { ...node, value: node.value.replace(/\s+/g, " ") };

  • }

  • ); }

    function restoreUnescapedCharacter(ast, options) {

  • return mapAst(ast, (node) => {

  • return node.type !== "text"

  • ? node

  • : {

  • ...node,

  • value:

  • node.value !== "*" &&

  • node.value !== "_" &&

  • node.value !== "$" && // handle these cases in printer

  • isSingleCharRegex.test(node.value) &&

  • node.position.end.offset - node.position.start.offset !==

  • node.value.length

  • ? options.originalText.slice(

  • node.position.start.offset,

  • node.position.end.offset

  • )

  • : node.value,

  • };

  • });

  • return mapAst(

  • ast,

  • (node) => {

  • return node.type !== "text"

  • ? node

  • : {

  • ...node,

  • value:

  • node.value !== "*" &&

  • node.value !== "_" &&

  • node.value !== "$" && // handle these cases in printer

  • isSingleCharRegex.test(node.value) &&

  • node.position.end.offset - node.position.start.offset !==

  • node.value.length

  • ? options.originalText.slice(

  • node.position.start.offset,

  • node.position.end.offset

  • )

  • : node.value,

  • };

  • }

  • ); }

    function mergeContinuousImportExport(ast) { @@ -77,21 +86,24 @@ function mergeContinuousImportExport(ast) { }

    function mergeChildren(ast, shouldMerge, mergeNode) {

  • return mapAst(ast, (node) => {

  • if (!node.children) {

  • return node;

  • }

  • const children = node.children.reduce((current, child) => {

  • const lastChild = current[current.length - 1];

  • if (lastChild && shouldMerge(lastChild, child)) {

  • current.splice(-1, 1, mergeNode(lastChild, child));

  • } else {

  • current.push(child);

  • return mapAst(

  • ast,

  • (node) => {

  • if (!node.children) {

  • return node; }

  • return current;

  • }, []);

  • return { ...node, children };

  • });

  • const children = node.children.reduce((current, child) => {

  • const lastChild = current[current.length - 1];

  • if (lastChild && shouldMerge(lastChild, child)) {

  • current.splice(-1, 1, mergeNode(lastChild, child));

  • } else {

  • current.push(child);

  • }

  • return current;

  • }, []);

  • return { ...node, children };

  • }

  • ); }

    function mergeContinuousTexts(ast) { @@ -110,79 +122,88 @@ function mergeContinuousTexts(ast) { }

    function splitTextIntoSentences(ast, options) {

  • return mapAst(ast, (node, index, [parentNode]) => {

  • if (node.type !== "text") {

  • return node;

  • }

  • return mapAst(

  • ast,

  • (node, index, [parentNode]) => {

  • if (node.type !== "text") {

  • return node;

  • }

  • let { value } = node;

  • let { value } = node;

  • if (parentNode.type === "paragraph") {

  • if (index === 0) {

  • value = value.trimStart();

  • }

  • if (index === parentNode.children.length - 1) {

  • value = value.trimEnd();

  • if (parentNode.type === "paragraph") {

  • if (index === 0) {

  • value = value.trimStart();

  • }

  • if (index === parentNode.children.length - 1) {

  • value = value.trimEnd();

  • } }

  • }

  • return {

  • type: "sentence",

  • position: node.position,

  • children: splitText(value, options),

  • };

  • });

  • return {

  • type: "sentence",

  • position: node.position,

  • children: splitText(value, options),

  • };

  • }

  • ); }

    function transformIndentedCodeblockAndMarkItsParentList(ast, options) {

  • return mapAst(ast, (node, index, parentStack) => {

  • if (node.type === "code") {

  • // the first char may point to \n, e.g. \n\t\tbar, just ignore it

  • const isIndented = /^\n?( {4,}|\t)/.test(

  • options.originalText.slice(

  • node.position.start.offset,

  • node.position.end.offset

  • )

  • );

  • node.isIndented = isIndented;

  • if (isIndented) {

  • for (let i = 0; i < parentStack.length; i++) {

  • const parent = parentStack[i];

  • // no need to check checked items

  • if (parent.hasIndentedCodeblock) {

  • break;

  • }

  • if (parent.type === "list") {

  • parent.hasIndentedCodeblock = true;

  • return mapAst(

  • ast,

  • (node, index, parentStack) => {

  • if (node.type === "code") {

  • // the first char may point to \n, e.g. \n\t\tbar, just ignore it

  • const isIndented = /^\n?( {4,}|\t)/.test(

  • options.originalText.slice(

  • node.position.start.offset,

  • node.position.end.offset

  • )

  • );

  • node.isIndented = isIndented;

  • if (isIndented) {

  • for (let i = 0; i < parentStack.length; i++) {

  • const parent = parentStack[i];

  • // no need to check checked items

  • if (parent.hasIndentedCodeblock) {

  • break;

  • }

  • if (parent.type === "list") {

  • parent.hasIndentedCodeblock = true;

  • } } } }

  • return node; }

  • return node;

  • });

  • ); }

    function markAlignedList(ast, options) {

  • return mapAst(ast, (node, index, parentStack) => {

  • if (node.type === "list" && node.children.length !== 0) {

  • // if one of its parents is not aligned, it's not possible to be aligned in sub-lists

  • for (let i = 0; i < parentStack.length; i++) {

  • const parent = parentStack[i];

  • if (parent.type === "list" && !parent.isAligned) {

  • node.isAligned = false;

  • return node;

  • return mapAst(

  • ast,

  • (node, index, parentStack) => {

  • if (node.type === "list" && node.children.length !== 0) {

  • // if one of its parents is not aligned, it's not possible to be aligned in sub-lists

  • for (let i = 0; i < parentStack.length; i++) {

  • const parent = parentStack[i];

  • if (parent.type === "list" && !parent.isAligned) {

  • node.isAligned = false;

  • return node;

  • } }

  • node.isAligned = isAligned(node); }

  • node.isAligned = isAligned(node);

  • return node; }

  • return node;

  • });

  • );

    function getListItemStart(listItem) { return listItem.children.length === 0 diff --git a/repos/prettier/src/language-markdown/printer-markdown.js b/repos/prettier/src/language-markdown/printer-markdown.js index 5b743215f..6a6272451 100644 --- a/repos/prettier/src/language-markdown/printer-markdown.js +++ b/repos/prettier/src/language-markdown/printer-markdown.js @@ -124,8 +124,9 @@ function genericPrint(path, options, print) { )) ) { // backslash is parsed as part of autolinks, so we need to remove it

  • escapedValue = escapedValue.replace(/^(\?[*_])+/, (prefix) =>

  • prefix.replace(/\/g, "")

  • escapedValue = escapedValue.replace(

  • /^(\?[*_])+/,

  • (prefix) => prefix.replace(/\/g, "") ); }

diff --git a/repos/prettier/src/language-yaml/index.js b/repos/prettier/src/language-yaml/index.js index 158de2d73..4ba007d8f 100644 --- a/repos/prettier/src/language-yaml/index.js +++ b/repos/prettier/src/language-yaml/index.js @@ -5,13 +5,16 @@ const printer = require("./printer-yaml"); const options = require("./options");

const languages = [

  • createLanguage(require("linguist-languages/data/YAML.json"), (data) => ({

  • since: "1.14.0",

  • parsers: ["yaml"],

  • vscodeLanguageIds: ["yaml", "ansible", "home-assistant"],

  • // yarn.lock is not YAML: https://github.com/yarnpkg/yarn/issues/5629

  • filenames: data.filenames.filter((filename) => filename !== "yarn.lock"),

  • })),

  • createLanguage(

  • require("linguist-languages/data/YAML.json"),

  • (data) => ({

  • since: "1.14.0",

  • parsers: ["yaml"],

  • vscodeLanguageIds: ["yaml", "ansible", "home-assistant"],

  • // yarn.lock is not YAML: https://github.com/yarnpkg/yarn/issues/5629

  • filenames: data.filenames.filter((filename) => filename !== "yarn.lock"),

  • })

  • ), ];

    const parsers = { diff --git a/repos/prettier/src/language-yaml/printer-yaml.js b/repos/prettier/src/language-yaml/printer-yaml.js index f13df3580..640b22c5c 100644 --- a/repos/prettier/src/language-yaml/printer-yaml.js +++ b/repos/prettier/src/language-yaml/printer-yaml.js @@ -329,8 +329,9 @@ function _print(node, parentNode, path, options, print) { } case "blockFolded": case "blockLiteral": {

  • const parentIndent = getAncestorCount(path, (ancestorNode) =>

  • isNode(ancestorNode, ["sequence", "mapping"])

  • const parentIndent = getAncestorCount(

  • path,

  • (ancestorNode) => isNode(ancestorNode, ["sequence", "mapping"]) ); const isLastDescendant = isLastDescendantNode(path); return concat([ diff --git a/repos/prettier/tests_config/utils/stringify-options-for-title.js b/repos/prettier/tests_config/utils/stringify-options-for-title.js index 2ea06ce77..7e54944d2 100644 --- a/repos/prettier/tests_config/utils/stringify-options-for-title.js +++ b/repos/prettier/tests_config/utils/stringify-options-for-title.js @@ -1,12 +1,14 @@ "use strict";

    function stringifyOptions(options) {

  • const string = JSON.stringify(options || {}, (key, value) =>

  • key === "plugins" || key === "errors"

  • ? undefined

  • : value === Infinity

  • ? "Infinity"

  • : value

  • const string = JSON.stringify(

  • options || {},

  • (key, value) =>

  • key === "plugins" || key === "errors"

  • ? undefined

  • : value === Infinity

  • ? "Infinity"

  • : value );

    return string === "{}" ? "" : string; Submodule repos/typescript-eslint contains modified content diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts index f0904f07..b7987274 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts @@ -82,21 +82,29 @@ export default util.createRule<Options, MessageIds>({ return; }

  • checkFunctionExpressionReturnType(node, options, sourceCode, loc =>

  • context.report({

  • node,

  • loc,

  • messageId: 'missingReturnType',

  • }),

  • checkFunctionExpressionReturnType(

  • node,

  • options,

  • sourceCode,

  • loc =>

  • context.report({

  • node,

  • loc,

  • messageId: 'missingReturnType',

  • }), ); }, FunctionDeclaration(node): void {

  • checkFunctionReturnType(node, options, sourceCode, loc =>

  • context.report({

  • node,

  • loc,

  • messageId: 'missingReturnType',

  • }),

  • checkFunctionReturnType(

  • node,

  • options,

  • sourceCode,

  • loc =>

  • context.report({

  • node,

  • loc,

  • messageId: 'missingReturnType',

  • }), ); }, }; diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts index 2ff89c59..9a3d132c 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts @@ -117,12 +117,14 @@ function getTypeParametersFromType( return undefined; }

  • return findFirstResult(declarations, decl =>

  • tsutils.isClassLikeDeclaration(decl) ||

  • ts.isTypeAliasDeclaration(decl) ||

  • ts.isInterfaceDeclaration(decl)

  • ? decl.typeParameters

  • : undefined,

  • return findFirstResult(

  • declarations,

  • decl =>

  • tsutils.isClassLikeDeclaration(decl) ||

  • ts.isTypeAliasDeclaration(decl) ||

  • ts.isInterfaceDeclaration(decl)

  • ? decl.typeParameters

  • : undefined, ); }

diff --git a/repos/typescript-eslint/packages/typescript-estree/src/node-utils.ts b/repos/typescript-eslint/packages/typescript-estree/src/node-utils.ts index 74c58666..b976e9c9 100644 --- a/repos/typescript-eslint/packages/typescript-estree/src/node-utils.ts +++ b/repos/typescript-eslint/packages/typescript-estree/src/node-utils.ts @@ -367,16 +367,19 @@ export function findNextToken( // this is token that starts at the end of previous token - return it return n; }

  • return firstDefined(n.getChildren(ast), (child: ts.Node) => {
  • const shouldDiveInChildNode =
  • // previous token is enclosed somewhere in the child
  • (child.pos <= previousToken.pos && child.end > previousToken.end) ||
  • // previous token ends exactly at the beginning of child
  • child.pos === previousToken.end;
  • return shouldDiveInChildNode && nodeHasTokens(child, ast)
  • ? find(child)
  • : undefined;
  • });
  • return firstDefined(
  • n.getChildren(ast),
  • (child: ts.Node) => {
  • const shouldDiveInChildNode =
  • // previous token is enclosed somewhere in the child
  • (child.pos <= previousToken.pos && child.end > previousToken.end) ||
  • // previous token ends exactly at the beginning of child
  • child.pos === previousToken.end;
  • return shouldDiveInChildNode && nodeHasTokens(child, ast)
  • ? find(child)
  • : undefined;
  • },
  • ); } }