Skip to content

Commit

Permalink
Switch parse-srcset to npm published version (prettier#13536)
Browse files Browse the repository at this point in the history
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
  • Loading branch information
2 people authored and medikoo committed Feb 4, 2024
1 parent 60a7bed commit c021b01
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 56 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@babel/types": "7.20.0",
"@glimmer/syntax": "0.84.2",
"@iarna/toml": "2.2.5",
"@prettier/parse-srcset": "2.0.1",
"@typescript-eslint/typescript-estree": "5.55.0",
"@typescript-eslint/visitor-keys": "5.45.0",
"acorn": "8.8.1",
Expand Down Expand Up @@ -74,7 +75,6 @@
"minimist": "1.2.6",
"n-readlines": "1.0.1",
"outdent": "0.8.0",
"parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee",
"please-upgrade-node": "3.2.0",
"postcss": "8.4.16",
"postcss-less": "6.0.0",
Expand Down
4 changes: 3 additions & 1 deletion src/common/create-ignorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ async function createIgnorer(ignoreFilePath, withNodeModules) {
content = await readFile(path.resolve(ignoreFilePath));
}

const ignorer = ignore({ allowRelativePaths: true }).add(content ?? "");
const ignorer = ignore
.default({ allowRelativePaths: true })
.add(content ?? "");
if (!withNodeModules) {
ignorer.add("node_modules");
}
Expand Down
2 changes: 1 addition & 1 deletion src/language-handlebars/printer-glimmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ function generateHardlines(number = 0) {

/* StringLiteral print helpers */

/** @typedef {import("../common/util").Quote} Quote */
/** @typedef {import("../common/util.js").Quote} Quote */

/**
* Prints a string literal with the correct surrounding quotes based on
Expand Down
8 changes: 4 additions & 4 deletions src/language-html/parser-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { parseIeConditionalComment } from "./conditional-comment.js";
import { locStart, locEnd } from "./loc.js";

/**
* @typedef {import('angular-html-parser/lib/compiler/src/ml_parser/ast').Node} AstNode
* @typedef {import('angular-html-parser/lib/compiler/src/ml_parser/ast').Attribute} Attribute
* @typedef {import('angular-html-parser/lib/compiler/src/ml_parser/ast').Element} Element
* @typedef {import('angular-html-parser/lib/compiler/src/ml_parser/parser').ParseTreeResult} ParserTreeResult
* @typedef {import('angular-html-parser/lib/compiler/src/ml_parser/ast.js').Node} AstNode
* @typedef {import('angular-html-parser/lib/compiler/src/ml_parser/ast.js').Attribute} Attribute
* @typedef {import('angular-html-parser/lib/compiler/src/ml_parser/ast.js').Element} Element
* @typedef {import('angular-html-parser/lib/compiler/src/ml_parser/parser.js').ParseTreeResult} ParserTreeResult
* @typedef {Omit<import('angular-html-parser').ParseOptions, 'canSelfClose'> & {
* name?: 'html' | 'angular' | 'vue' | 'lwc';
* canSelfClose?: boolean;
Expand Down
10 changes: 2 additions & 8 deletions src/language-html/syntax-attribute.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import parseSrcset from "parse-srcset";
import parseSrcset from "@prettier/parse-srcset";
import { ifBreak, join, line } from "../document/builders.js";

function printImgSrcset(value) {
const srcset = parseSrcset(value, {
logger: {
error(message) {
throw new Error(message);
},
},
});
const srcset = parseSrcset(value);

const hasW = srcset.some(({ w }) => w);
const hasH = srcset.some(({ h }) => h);
Expand Down
4 changes: 2 additions & 2 deletions src/language-js/comments/handle-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import isBlockComment from "../utils/is-block-comment.js";
import isTypeCastComment from "../utils/is-type-cast-comment.js";

/**
* @typedef {import("../types/estree").Node} Node
* @typedef {import("../types/estree").Comment} Comment
* @typedef {import("../types/estree.js").Node} Node
* @typedef {import("../types/estree.js").Comment} Comment
*
* @typedef {Object} CommentContext
* @property {Comment} comment
Expand Down
2 changes: 1 addition & 1 deletion src/language-js/comments/printer-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import isBlockComment from "../utils/is-block-comment.js";

/**
* @typedef {import("../types/estree").Node} Node
* @typedef {import("../types/estree.js").Node} Node
* @typedef {import("../../common/ast-path.js").default} AstPath
*/

Expand Down
2 changes: 1 addition & 1 deletion src/language-js/loc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import isNonEmptyArray from "../utils/is-non-empty-array.js";

/**
* @typedef {import("./types/estree").Node} Node
* @typedef {import("./types/estree.js").Node} Node
*/

function locStart(node) {
Expand Down
2 changes: 1 addition & 1 deletion src/language-js/print/function-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { locEnd } from "../loc.js";
import { ArgExpansionBailout } from "../../common/errors.js";
import { printFunctionTypeParameters } from "./misc.js";

/** @typedef {import("../../common/ast-path").default} AstPath */
/** @typedef {import("../../common/ast-path.js").default} AstPath */

function printFunctionParameters(
path,
Expand Down
4 changes: 2 additions & 2 deletions src/language-js/print/jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const isEmptyStringOrAnyLine = (doc) =>

/**
* @typedef {import("../../common/ast-path.js").default} AstPath
* @typedef {import("../types/estree").Node} Node
* @typedef {import("../types/estree").JSXElement} JSXElement
* @typedef {import("../types/estree.js").Node} Node
* @typedef {import("../types/estree.js").JSXElement} JSXElement
*/

// JSX expands children from the inside-out, instead of the outside-in.
Expand Down
2 changes: 1 addition & 1 deletion src/language-js/types/estree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as ESTree from "estree";
import * as Babel from "@babel/types";
import { TSESTree } from "@typescript-eslint/typescript-estree";
import { ESTree as Meriyah } from "meriyah";
import * as NGTree from "angular-estree-parser/lib/types";
import * as NGTree from "angular-estree-parser/lib/types.js";

type AdditionalFields = {
extra?: {
Expand Down
24 changes: 12 additions & 12 deletions src/language-js/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import isNodeMatches from "./is-node-matches.js";
const isIdentifierName = esutils.keyword.isIdentifierNameES5;

/**
* @typedef {import("../types/estree").Node} Node
* @typedef {import("../types/estree").TemplateLiteral} TemplateLiteral
* @typedef {import("../types/estree").Comment} Comment
* @typedef {import("../types/estree").MemberExpression} MemberExpression
* @typedef {import("../types/estree").OptionalMemberExpression} OptionalMemberExpression
* @typedef {import("../types/estree").CallExpression} CallExpression
* @typedef {import("../types/estree").OptionalCallExpression} OptionalCallExpression
* @typedef {import("../types/estree").Expression} Expression
* @typedef {import("../types/estree").Property} Property
* @typedef {import("../types/estree").ObjectTypeProperty} ObjectTypeProperty
* @typedef {import("../types/estree").TaggedTemplateExpression} TaggedTemplateExpression
* @typedef {import("../types/estree").Literal} Literal
* @typedef {import("../types/estree.js").Node} Node
* @typedef {import("../types/estree.js").TemplateLiteral} TemplateLiteral
* @typedef {import("../types/estree.js").Comment} Comment
* @typedef {import("../types/estree.js").MemberExpression} MemberExpression
* @typedef {import("../types/estree.js").OptionalMemberExpression} OptionalMemberExpression
* @typedef {import("../types/estree.js").CallExpression} CallExpression
* @typedef {import("../types/estree.js").OptionalCallExpression} OptionalCallExpression
* @typedef {import("../types/estree.js").Expression} Expression
* @typedef {import("../types/estree.js").Property} Property
* @typedef {import("../types/estree.js").ObjectTypeProperty} ObjectTypeProperty
* @typedef {import("../types/estree.js").TaggedTemplateExpression} TaggedTemplateExpression
* @typedef {import("../types/estree.js").Literal} Literal
*
* @typedef {import("../../common/ast-path.js").default} AstPath
*/
Expand Down
2 changes: 1 addition & 1 deletion src/language-js/utils/is-block-comment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import("../types/estree").Comment} Comment
* @typedef {import("../types/estree.js").Comment} Comment
*/

const BLOCK_COMMENT_TYPES = new Set([
Expand Down
2 changes: 1 addition & 1 deletion src/language-js/utils/is-node-matches.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copied from https://github.com/sindresorhus/eslint-plugin-unicorn/blob/d53d935951aa815c763fc9441aa452c763294715/rules/utils/is-node-matches.js

/**
* @typedef {import("../types/estree").Node} Node
* @typedef {import("../types/estree.js").Node} Node
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion src/language-js/utils/is-type-cast-comment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import isBlockComment from "./is-block-comment.js";

/**
* @typedef {import("../types/estree").Comment} Comment
* @typedef {import("../types/estree.js").Comment} Comment
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/multiparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { parse } from "./parser.js";
import createGetVisitorKeysFunction from "./create-get-visitor-keys-function.js";

async function printEmbeddedLanguages(
/** @type {import("../common/ast-path").default} */ path,
/** @type {import("../common/ast-path.js").default} */ path,
genericPrint,
options,
printAstToDoc,
Expand Down
2 changes: 1 addition & 1 deletion src/main/options-normalizer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import vnopts from "vnopts";

/**
* @typedef {import("./support").NamedOptionInfo} NamedOptionInfo
* @typedef {import("./support.js").NamedOptionInfo} NamedOptionInfo
*/

const cliDescriptor = {
Expand Down
2 changes: 1 addition & 1 deletion src/main/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { options as coreOptions } from "./core-options.js";
import currentVersion from "./version.evaluate.cjs";

/**
* @typedef {import("./core-options").OptionInfo} OptionInfo
* @typedef {import("./core-options.js").OptionInfo} OptionInfo
* @typedef {{ name: string; pluginDefaults: Array<any> } & OptionInfo} NamedOptionInfo
*/

Expand Down
2 changes: 1 addition & 1 deletion src/utils/text/skip-newline.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @typedef {import("./skip").SkipOptions} SkipOptions */
/** @typedef {import("./skip.js").SkipOptions} SkipOptions */

// This one doesn't use the above helper function because it wants to
// test \r\n in order and `skip` doesn't support ordering and we only
Expand Down
6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
"checkJs": true,
"noEmit": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"module": "NodeNext",
"resolveJsonModule": true,
"esModuleInterop": true,
// TBD it is desired to enabled strict type checking at some point:
"strict": false,
"typeRoots": ["./types", "./node_modules/@types"]
Expand All @@ -19,7 +17,6 @@
// [TBD] JavaScript sources *not* affected by src/language-*:
"src/main/ast-to-doc.js",
"src/main/core.js",
"src/common/create-ignorer.js",
"src/config/resolve-config.js",
"src/main/options-normalizer.js",
"src/common/get-file-info.js",
Expand All @@ -44,6 +41,7 @@
"src/index.js",
"src/standalone.js",
"index.js",
"src/index.cjs",
"standalone.js",
"bin/",
"dist/",
Expand Down
4 changes: 2 additions & 2 deletions types/angular-html-parser/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "angular-html-parser/lib/compiler/src/ml_parser/ast";
import { HtmlTagDefinition } from "angular-html-parser/lib/compiler/src/ml_parser/html_tags";
import { HtmlTagDefinition } from "angular-html-parser/lib/compiler/src/ml_parser/html_tags.js";

declare module "angular-html-parser/lib/compiler/src/ml_parser/ast" {
declare module "angular-html-parser/lib/compiler/src/ml_parser/ast.js" {
interface Attribute {
startSourceSpan: never;
endSourceSpan: never;
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,13 @@ __metadata:
languageName: node
linkType: hard

"@prettier/parse-srcset@npm:2.0.1":
version: 2.0.1
resolution: "@prettier/parse-srcset@npm:2.0.1"
checksum: 8f424434f12b4358dbbfb8c975d89d08520d47cbdba51fe48d585ae41be16fc41fcec82d4031be1d5b6c5487e6fe4d013ab320e253807ae23f1edb412b108fc9
languageName: node
linkType: hard

"@simple-dom/interface@npm:^1.4.0":
version: 1.4.0
resolution: "@simple-dom/interface@npm:1.4.0"
Expand Down Expand Up @@ -7476,13 +7483,6 @@ __metadata:
languageName: node
linkType: hard

"parse-srcset@ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee":
version: 1.0.2
resolution: "parse-srcset@https://github.com/ikatyang/parse-srcset.git#commit=54eb9c1cb21db5c62b4d0e275d7249516df6f0ee"
checksum: 4f3325a79e8d881d1d29ae4d2857a40b1d9d8d98f093b865a04a4e18ba5b136e7e1d37a317a8fc2ed10a8f473951c396f7c1b0904fe10de430e44811698ce0f1
languageName: node
linkType: hard

"path-browserify@npm:1.0.1":
version: 1.0.1
resolution: "path-browserify@npm:1.0.1"
Expand Down Expand Up @@ -7720,6 +7720,7 @@ __metadata:
"@glimmer/reference": 0.84.2
"@glimmer/syntax": 0.84.2
"@iarna/toml": 2.2.5
"@prettier/parse-srcset": 2.0.1
"@types/estree": 1.0.0
"@types/file-entry-cache": 5.0.2
"@types/find-cache-dir": 3.2.1
Expand Down Expand Up @@ -7801,7 +7802,6 @@ __metadata:
node-fetch: 3.2.10
npm-run-all: 4.1.5
outdent: 0.8.0
parse-srcset: "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee"
path-browserify: 1.0.1
please-upgrade-node: 3.2.0
postcss: 8.4.16
Expand Down

0 comments on commit c021b01

Please sign in to comment.