repo stringlengths 5 106 | file_url stringlengths 78 301 | file_path stringlengths 4 211 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:56:49 2026-01-05 02:23:25 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/type-query.js | src/language-js/print/type-query.js | /*
- `TSTypeQuery` (TypeScript)
- `TypeofTypeAnnotation` (flow)
*/
function printTypeQuery({ node }, print) {
const argumentPropertyName =
node.type === "TSTypeQuery" ? "exprName" : "argument";
return ["typeof ", print(argumentPropertyName), print("typeArguments")];
}
export { printTypeQuery };
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/ternary-old.js | src/language-js/print/ternary-old.js | import {
align,
dedent,
group,
ifBreak,
indent,
line,
softline,
} from "../../document/index.js";
import {
isBinaryCastExpression,
isCallExpression,
isJsxElement,
isMemberExpression,
} from "../utilities/index.js";
/**
* @import {Doc} from "../../document/index.js"
* @import AstPath from "../..... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/type-parameters.js | src/language-js/print/type-parameters.js | import {
group,
hardline,
ifBreak,
indent,
indentIfBreak,
join,
line,
lineSuffixBoundary,
softline,
} from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import {
CommentCheckFlags,
getFunctionParameters,
hasComment,
isObjectType,
isTestCall,... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/html-binding.js | src/language-js/print/html-binding.js | import { group, indent, join, line, softline } from "../../document/index.js";
function printHtmlBinding(path, options, print) {
if (options.__isVueBindings || options.__isVueForBindingLeft) {
const parameterDocs = path.map(print, "program", "body", 0, "params");
if (parameterDocs.length === 1) {
retu... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/union-type.js | src/language-js/print/union-type.js | import {
align,
group,
ifBreak,
indent,
join,
line,
softline,
} from "../../document/index.js";
import {
printComments,
printCommentsSeparately,
} from "../../main/comments/print.js";
import needsParentheses from "../parentheses/needs-parentheses.js";
import {
CommentCheckFlags,
createTypeCheckFun... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/try-statement.js | src/language-js/print/try-statement.js | import { indent, softline } from "../../document/index.js";
import hasNewline from "../../utilities/has-newline.js";
import { locEnd, locStart } from "../loc.js";
import { hasComment } from "../utilities/index.js";
import isBlockComment from "../utilities/is-block-comment.js";
function printTryStatement(path, options,... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/decorators.js | src/language-js/print/decorators.js | import {
breakParent,
group,
hardline,
join,
line,
} from "../../document/index.js";
import hasNewline from "../../utilities/has-newline.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import { hasSameLocStart, locEnd } from "../loc.js";
import { isExportDeclaration } from "../utilit... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/type-alias.js | src/language-js/print/type-alias.js | import { printAssignment } from "./assignment.js";
import { printDeclareToken } from "./miscellaneous.js";
/*
- `DeclareTypeAlias`(flow)
- `TypeAlias`(flow)
- `TSTypeAliasDeclaration`(TypeScript)
*/
function printTypeAlias(path, options, print) {
const { node } = path;
const parts = [
printDeclareToken(path),
... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/type-predicate.js | src/language-js/print/type-predicate.js | import { printTypeAnnotationProperty } from "./type-annotation.js";
/*
- `TSTypePredicate` (TypeScript)
- `TypePredicate` (flow)
*/
function printTypePredicate(path, print) {
const { node } = path;
const prefix =
node.type === "TSTypePredicate" && node.asserts
? "asserts "
: node.type === "TypePred... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/array.js | src/language-js/print/array.js | import {
fill,
group,
hardline,
ifBreak,
indent,
line,
softline,
} from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import hasNewline from "../../utilities/has-newline.js";
import isNextLineEmptyAfterIndex from "../../utilities/is-next-line-empty.js";
i... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/sequence-expression.js | src/language-js/print/sequence-expression.js | import {
group,
ifBreak,
indent,
join,
line,
softline,
} from "../../document/index.js";
import needsParentheses from "../parentheses/needs-parentheses.js";
import { isReturnOrThrowStatement } from "../utilities/index.js";
function shouldIndentSequenceExpression(path, options) {
const { key, parent } = p... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/statement-sequence.js | src/language-js/print/statement-sequence.js | import { hardline } from "../../document/index.js";
import { isNextLineEmpty } from "../utilities/index.js";
/**
* @import {Doc} from "../../document/index.js"
* @import AstPath from "../../common/ast-path.js")
*/
/*
- `Program` ("directives" and "body")
- `BlockStatement`
- `StaticBlock`
- `SwitchCase` ("conseque... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/tuple.js | src/language-js/print/tuple.js | /*
- `TSNamedTupleMember`(TypeScript)
- `TupleTypeLabeledElement`(flow)
*/
function printNamedTupleMember(path, options, print) {
const { node } = path;
return [
// `TupleTypeLabeledElement` only
node.variance ? print("variance") : "",
print("label"),
node.optional ? "?" : "",
": ",
print("... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/rest-type.js | src/language-js/print/rest-type.js | /*
- `TSRestType`(TypeScript)
- `TupleTypeSpreadElement`(flow)
*/
function printRestType(path, options, print) {
const { node } = path;
return [
"...",
...(node.type === "TupleTypeSpreadElement" && node.label
? [print("label"), ": "]
: []),
print("typeAnnotation"),
];
}
export { printRes... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/class.js | src/language-js/print/class.js | import {
group,
hardline,
ifBreak,
indent,
join,
line,
softline,
} from "../../document/index.js";
import {
printComments,
printCommentsSeparately,
printDanglingComments,
} from "../../main/comments/print.js";
import createGroupIdMapper from "../../utilities/create-group-id-mapper.js";
import isNonE... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/intersection-type.js | src/language-js/print/intersection-type.js | import { group, indent, line } from "../../document/index.js";
import { hasLeadingOwnLineComment, isObjectType } from "../utilities/index.js";
// `TSIntersectionType` and `IntersectionTypeAnnotation`
function printIntersectionType(path, options, print) {
let wasIndented = false;
return group(
path.map(({ isFir... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/comment.js | src/language-js/print/comment.js | import { hardline, join, replaceEndOfLine } from "../../document/index.js";
import { locEnd, locStart } from "../loc.js";
import isBlockComment from "../utilities/is-block-comment.js";
import isIndentableBlockComment from "../utilities/is-indentable-block-comment.js";
import isLineComment from "../utilities/is-line-com... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/flow.js | src/language-js/print/flow.js | /** @import {Doc} from "../../document/index.js" */
import * as assert from "#universal/assert";
import { replaceEndOfLine } from "../../document/index.js";
import printNumber from "../../utilities/print-number.js";
import printString from "../../utilities/print-string.js";
import getRaw from "../utilities/get-raw.js"... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/module-declaration.js | src/language-js/print/module-declaration.js | import { group } from "../../document/index.js";
import { printDeclareToken } from "./miscellaneous.js";
function printModuleDeclaration(path, options, print) {
const { node } = path;
return [
printDeclareToken(path),
node.kind === "global" ? "" : `${node.kind} `,
print("id"),
node.body ? [" ", gr... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/while-statement.js | src/language-js/print/while-statement.js | import { group, hardline } from "../../document/index.js";
import {
adjustClause,
printDoWhileStatementCondition,
printWhileStatementCondition,
} from "./miscellaneous.js";
function printWhileStatement(path, options, print) {
return group([
"while (",
printWhileStatementCondition(path, options, print),... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/block.js | src/language-js/print/block.js | import { hardline, indent } from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import {
CommentCheckFlags,
hasComment,
isNextLineEmpty,
} from "../utilities/index.js";
import { printStatementSeq... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/index-signature.js | src/language-js/print/index-signature.js | import {
group,
ifBreak,
indent,
join,
softline,
} from "../../document/index.js";
import { shouldPrintComma } from "../utilities/index.js";
import { printClassMemberSemicolon } from "./class.js";
import { printTypeAnnotationProperty } from "./type-annotation.js";
function printIndexSignature(path, options, ... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/bind-expression.js | src/language-js/print/bind-expression.js | import { group, indent, softline } from "../../document/index.js";
function printBindExpression(path, options, print) {
return [
print("object"),
group(indent([softline, printBindExpressionCallee(path, options, print)])),
];
}
function printBindExpressionCallee(path, options, print) {
return ["::", prin... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/class-body.js | src/language-js/print/class-body.js | import {
group,
hardline,
ifBreak,
indent,
line,
softline,
} from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import hasNewline from "../../utilities/has-newline.js";
import hasNewlineInRange from "../../utilities/has-newline-in-range.js";
import { locEnd... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/call-arguments.js | src/language-js/print/call-arguments.js | import { ArgExpansionBailout } from "../../common/errors.js";
import {
breakParent,
conditionalGroup,
group,
hardline,
ifBreak,
indent,
line,
softline,
willBreak,
} from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import {
CommentCheckFlags,
get... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/template-literal.js | src/language-js/print/template-literal.js | import {
addAlignmentToDoc,
align,
group,
hardline,
indent,
join,
label,
lineSuffixBoundary,
mapDoc,
printDocToString,
softline,
} from "../../document/index.js";
import getIndentSize from "../../utilities/get-indent-size.js";
import getStringWidth from "../../utilities/get-string-width.js";
impor... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/module.js | src/language-js/print/module.js | import {
group,
hardline,
ifBreak,
indent,
join,
line,
removeLines,
softline,
} from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import UnexpectedNodeError from "../../utilities/unex... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/miscellaneous.js | src/language-js/print/miscellaneous.js | import { group, indent, line, softline } from "../../document/index.js";
import {
CommentCheckFlags,
createTypeCheckFunction,
hasComment,
isCallExpression,
isMemberExpression,
} from "../utilities/index.js";
/**
* @import AstPath from "../../common/ast-path.js"
* @import {Doc} from "../../document/index.js... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/print/ternary.js | src/language-js/print/ternary.js | import {
breakParent,
dedent,
group,
hardline,
ifBreak,
indent,
line,
softline,
} from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import hasNewlineInRange from "../../utilities/has-newline-in-range.js";
import { locEnd, locStart } from "../loc.js";
i... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/semicolon/semicolon.js | src/language-js/semicolon/semicolon.js | import needsParentheses from "../parentheses/needs-parentheses.js";
import { shouldPrintParamsWithoutParens } from "../print/function.js";
import {
getLeftSidePathName,
hasNakedLeftSide,
isJsxElement,
} from "../utilities/index.js";
function shouldPrintLeadingSemicolon(path, options) {
if (
options.semi ||... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/comments/can-attach-comment.js | src/language-js/comments/can-attach-comment.js | import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import {
createTypeCheckFunction,
getFunctionParameters,
isMeaningfulEmptyStatement,
isMethod,
isShorthandSpecifier,
isTsAsConstExpression,
} from "../utilities/index.js";
/**
@import {Node} from "../types/estree.js";
@import AstPath from... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/comments/will-print-own-comments.js | src/language-js/comments/will-print-own-comments.js | import {
createTypeCheckFunction,
hasNodeIgnoreComment,
isIifeCalleeOrTaggedTemplateExpressionTag,
isJsxElement,
isUnionType,
shouldUnionTypePrintOwnComments,
} from "../utilities/index.js";
/**
@import {Node} from "../types/estree.js";
@import AstPath from "../../common/ast-path.js";
*/
const isClassOrIn... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/comments/is-gap.js | src/language-js/comments/is-gap.js | function isGap(text, { parser }) {
if (parser === "flow" || parser === "hermes" || parser === "babel-flow") {
// Example: (a /* b */ /* : c */)
// gap ^^^^
text = text.replaceAll(/[\s(]/g, "");
return text === "" || text === "/*" || text === "/*::";
}
}
export default isGap;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/comments/handle-comments.js | src/language-js/comments/handle-comments.js | import {
addDanglingComment,
addLeadingComment,
addTrailingComment,
} from "../../main/comments/utilities.js";
import getNextNonSpaceNonCommentCharacter from "../../utilities/get-next-non-space-non-comment-character.js";
import getNextNonSpaceNonCommentCharacterIndex from "../../utilities/get-next-non-space-non-c... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/create-type-check-function.js | src/language-js/utilities/create-type-check-function.js | import * as assert from "#universal/assert";
/**
@import {Node, Comment, NodeMap, CommentMap} from "../types/estree.js";
*/
/**
@typedef {Node | Comment} NodeOrComment
@typedef {NodeOrComment["type"]} NodeOrCommentTypes
*/
/**
@template {NodeOrCommentTypes[]} InputNodeTypes
@param {InputNodeTypes} typesArray
*/
func... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/is-flow-keyword-type.js | src/language-js/utilities/is-flow-keyword-type.js | import createTypeCheckFunction from "./create-type-check-function.js";
const isFlowKeywordType = createTypeCheckFunction([
"AnyTypeAnnotation",
"ThisTypeAnnotation",
"NumberTypeAnnotation",
"VoidTypeAnnotation",
"BooleanTypeAnnotation",
"BigIntTypeAnnotation",
"SymbolTypeAnnotation",
"StringTypeAnnotat... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/is-indentable-block-comment.js | src/language-js/utilities/is-indentable-block-comment.js | import isBlockComment from "./is-block-comment.js";
function isIndentableBlockCommentInternal(comment) {
/*
In postprocess.js
this only called when two comments are next to each other,
it's not possible for line comments.
In printComment
The line comments are checked first, it can't be a line comment eith... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/is-ts-keyword-type.js | src/language-js/utilities/is-ts-keyword-type.js | /**
* @returns {boolean}
*/
function isTsKeywordType({ type }) {
return type.startsWith("TS") && type.endsWith("Keyword");
}
export default isTsKeywordType;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/return-statement-has-leading-comment.js | src/language-js/utilities/return-statement-has-leading-comment.js | import hasNewlineInRange from "../../utilities/has-newline-in-range.js";
import { locEnd, locStart } from "../loc.js";
import {
CommentCheckFlags,
getLeftSide,
hasComment,
hasLeadingOwnLineComment,
hasNakedLeftSide,
isJsxElement,
} from "./index.js";
// This recurses the return argument, looking for the fi... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/get-text-without-comments.js | src/language-js/utilities/get-text-without-comments.js | import replaceNonLineBreaksWithSpace from "../../utilities/replace-non-line-breaks-with-space.js";
import { locEnd, locStart } from "../loc.js";
function getTextWithoutComments(options, start, end) {
let text = options.originalText.slice(start, end);
for (const comment of options[Symbol.for("comments")]) {
co... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/is-node-matches.js | src/language-js/utilities/is-node-matches.js | // Copied from https://github.com/sindresorhus/eslint-plugin-unicorn/blob/d53d935951aa815c763fc9441aa452c763294715/rules/utilities/is-node-matches.js
/**
* @import {Node} from "../types/estree.js"
*/
/**
Check if node matches object name or key path.
@param {Node} node - The AST node to check.
@param {string} name... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/is-line-comment.js | src/language-js/utilities/is-line-comment.js | import createTypeCheckFunction from "./create-type-check-function.js";
/**
@import {Comment} from "../types/estree.js";
*/
const isLineComment = createTypeCheckFunction([
"Line",
"CommentLine",
// `meriyah` has `SingleLine`, `HashbangComment`, `HTMLOpen`, and `HTMLClose`
"SingleLine",
"HashbangComment",
"... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/is-type-cast-comment.js | src/language-js/utilities/is-type-cast-comment.js | import isBlockComment from "./is-block-comment.js";
/**
@import {Comment} from "../types/estree.js"
*/
const cache = new WeakMap();
/**
* @param {Comment} comment
* @returns {boolean}
*/
function isTypeCastComment(comment) {
if (!cache.has(comment)) {
cache.set(
comment,
isBlockComment(comment) ... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/is-ignored.js | src/language-js/utilities/is-ignored.js | import { hasJsxIgnoreComment } from "../print/jsx.js";
import { hasNodeIgnoreComment } from "./index.js";
function isIgnored(path) {
return hasNodeIgnoreComment(path.node) || hasJsxIgnoreComment(path);
}
export default isIgnored;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/node-types.js | src/language-js/utilities/node-types.js | import createTypeCheckFunction from "./create-type-check-function.js";
export const isBinaryCastExpression = createTypeCheckFunction([
// TS
"TSAsExpression",
"TSSatisfiesExpression",
// Flow
"AsExpression",
"AsConstExpression",
"SatisfiesExpression",
]);
export const isUnionType = createTypeCheckFuncti... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/index.js | src/language-js/utilities/index.js | import { hasDescendant } from "../../utilities/ast.js";
import getStringWidth from "../../utilities/get-string-width.js";
import hasNewline from "../../utilities/has-newline.js";
import isNextLineEmptyAfterIndex from "../../utilities/is-next-line-empty.js";
import isNonEmptyArray from "../../utilities/is-non-empty-arra... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/vue-event-binding.js | src/language-js/utilities/vue-event-binding.js | import createTypeCheckFunction from "./create-type-check-function.js";
// https://github.com/vuejs/core/blob/35785f3cd7bd86cbec3f8324022491da2d088b61/packages/compiler-core/src/babelUtils.ts#L498
const isVueEventBindingTsNode = createTypeCheckFunction([
"TSAsExpression", // `foo as number`
"TSTypeAssertion", // `(... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/get-shebang.js | src/language-js/utilities/get-shebang.js | function getShebang(text) {
if (!text.startsWith("#!")) {
return "";
}
const index = text.indexOf("\n");
if (index === -1) {
return text;
}
return text.slice(0, index);
}
export default getShebang;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/is-meaningful-empty-statement.js | src/language-js/utilities/is-meaningful-empty-statement.js | /* The argument is a duck type of AstPath, so we can use it in comment attach and ast massage */
function isMeaningfulEmptyStatement({ node, parent }) {
if (node?.type !== "EmptyStatement") {
return false;
}
if (parent.type === "IfStatement") {
return parent.consequent === node || parent.alternate === no... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/get-raw.js | src/language-js/utilities/get-raw.js | function getRaw(node) {
return node.extra?.raw ?? node.raw;
}
export default getRaw;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/utilities/is-block-comment.js | src/language-js/utilities/is-block-comment.js | import createTypeCheckFunction from "./create-type-check-function.js";
/**
@import {Comment} from "../types/estree.js";
*/
/**
* @param {Comment} comment
* @returns {boolean}
*/
const isBlockComment = createTypeCheckFunction([
"Block",
"CommentBlock",
// `meriyah`
"MultiLine",
]);
export default isBlockCo... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/embed/css.js | src/language-js/embed/css.js | import {
cleanDoc,
hardline,
indent,
mapDoc,
replaceEndOfLine,
softline,
} from "../../document/index.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import { printTemplateExpressions } from "../print/template-literal.js";
import isNodeMatches from "../utilities/is-node-matches.js"... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/embed/graphql.js | src/language-js/embed/graphql.js | import { hardline, indent, join } from "../../document/index.js";
import {
escapeTemplateCharacters,
printTemplateExpressions,
} from "../print/template-literal.js";
import { hasLanguageComment } from "./utilities.js";
async function printEmbedGraphQL(textToDoc, print, path, options) {
const { node } = path;
... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/embed/index.js | src/language-js/embed/index.js | import { label } from "../../document/index.js";
import { isEmbedCss, printEmbedCss } from "./css.js";
import { isEmbedGraphQL, printEmbedGraphQL } from "./graphql.js";
import {
isAngularComponentTemplate,
isEmbedHtml,
printEmbedAngular,
printEmbedHtml,
} from "./html.js";
import { isEmbedMarkdown, printEmbedMa... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/embed/markdown.js | src/language-js/embed/markdown.js | import {
dedentToRoot,
indent,
literalline,
softline,
} from "../../document/index.js";
import { escapeTemplateCharacters } from "../print/template-literal.js";
async function printEmbedMarkdown(textToDoc, print, path /* , options*/) {
const { node } = path;
let text = node.quasis[0].value.raw.replaceAll(
... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/embed/utilities.js | src/language-js/embed/utilities.js | import {
CommentCheckFlags,
hasComment,
isArrayExpression,
isObjectProperty,
} from "../utilities/index.js";
const angularComponentObjectExpressionPredicates = [
(node, name) => node.type === "ObjectExpression" && name === "properties",
(node, name) =>
node.type === "CallExpression" &&
node.callee.... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-js/embed/html.js | src/language-js/embed/html.js | import {
group,
hardline,
indent,
label,
line,
mapDoc,
} from "../../document/index.js";
import {
printTemplateExpressions,
uncookTemplateElementValue,
} from "../print/template-literal.js";
import { hasLanguageComment, isAngularComponentTemplate } from "./utilities.js";
// The counter is needed to dis... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/get-max-continuous-count.js | src/utilities/get-max-continuous-count.js | import escapeStringRegexp from "escape-string-regexp";
/**
* @param {string} text
* @param {string} searchString
* @returns {number}
*/
function getMaxContinuousCount(text, searchString) {
let results = text.matchAll(
new RegExp(`(?:${escapeStringRegexp(searchString)})+`, "g"),
);
// TODO: Use `Iterator... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/whitespace-utilities.js | src/utilities/whitespace-utilities.js | import escapeStringRegexp from "escape-string-regexp";
class WhitespaceUtilities {
#whitespaceCharacters;
constructor(whitespaceCharacters) {
this.#whitespaceCharacters = new Set(whitespaceCharacters);
if (
process.env.NODE_ENV !== "production" &&
(this.#whitespaceCharacters.size === 0 ||
... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/get-interpreter.js | src/utilities/get-interpreter.js | import readlines from "n-readlines";
import { toPath } from "url-or-path";
/**
* @param {string | URL} file
* @returns {string | undefined}
*/
function readFileFirstLine(file) {
const liner = new readlines(toPath(file));
const firstLineBuffer = liner.next();
if (typeof liner.fd === "number") {
liner.clos... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/get-next-non-space-non-comment-character-index.js | src/utilities/get-next-non-space-non-comment-character-index.js | import { skipSpaces } from "./skip.js";
import skipInlineComment from "./skip-inline-comment.js";
import skipNewline from "./skip-newline.js";
import skipTrailingComment from "./skip-trailing-comment.js";
/**
* @param {string} text
* @param {number} startIndex
* @returns {number | false}
*/
function getNextNonSpac... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/narrow-emojis.evaluate.js | src/utilities/narrow-emojis.evaluate.js | import * as assert from "#universal/assert";
/**
* How the narrow emoji list was generated:
* 1. Start with Unicode's official emoji list https://unicode.org/Public/emoji/latest/emoji-test.txt
* 2. Select emojis that:
* - consist of a single code point, and
* - also have a variant with U+FE0F.
* 3. Manua... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/public.js | src/utilities/public.js | import getNextNonSpaceNonCommentCharacterIndexWithStartIndex from "./get-next-non-space-non-comment-character-index.js";
import isNextLineEmptyAfterIndex from "./is-next-line-empty.js";
import isPreviousLineEmptyWithStartIndex from "./is-previous-line-empty.js";
/** @import {Quote} from "./get-preferred-quote.js" */
... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/unexpected-node-error.js | src/utilities/unexpected-node-error.js | class UnexpectedNodeError extends Error {
name = "UnexpectedNodeError";
constructor(node, language, typeProperty = "type") {
super(
`Unexpected ${language} node ${typeProperty}: ${JSON.stringify(
node[typeProperty],
)}.`,
);
this.node = node;
}
}
export default UnexpectedNodeErro... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/html-whitespace.js | src/utilities/html-whitespace.js | import WhitespaceUtilities from "./whitespace-utilities.js";
// https://infra.spec.whatwg.org/#ascii-whitespace
const HTML_WHITESPACE_CHARACTERS = ["\t", "\n", "\f", "\r", " "];
const htmlWhitespace = new WhitespaceUtilities(HTML_WHITESPACE_CHARACTERS);
export default htmlWhitespace;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/get-string-width.js | src/utilities/get-string-width.js | import emojiRegex from "emoji-regex";
import {
// @ts-expect-error -- Private
_isFullWidth as isFullWidth,
// @ts-expect-error -- Private
_isWide as isWide,
} from "get-east-asian-width";
import narrowEmojis from "./narrow-emojis.evaluate.js";
const notAsciiRegex = /[^\x20-\x7F]/;
const narrowEmojisSet = new S... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/noop.js | src/utilities/noop.js | const noop = () => {};
export default noop;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/has-newline.js | src/utilities/has-newline.js | import { skipSpaces } from "./skip.js";
import skipNewline from "./skip-newline.js";
/** @import {SkipOptions} from "./skip.js" */
/**
* @param {string} text
* @param {number} startIndex
* @param {SkipOptions=} options
* @returns {boolean}
*/
function hasNewline(text, startIndex, options = {}) {
const idx = sk... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/replace-non-line-breaks-with-space.js | src/utilities/replace-non-line-breaks-with-space.js | import * as assert from "#universal/assert";
/**
Replaces all characters in the input string except line breaks `\n` with a space.
@param {string} string - The input string to process.
@returns {string}
*/
function replaceNonLineBreaksWithSpace(string) {
const replaced = string.replaceAll(/[^\n]/g, " ");
if (pro... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/ignore.js | src/utilities/ignore.js | import path from "node:path";
import url from "node:url";
import createIgnore from "ignore";
import { isUrl, toPath } from "url-or-path";
import readFile from "./read-file.js";
/** @type {(filePath: string) => string} */
const slash =
path.sep === "\\"
? (filePath) => filePath.replaceAll("\\", "/")
: (filePa... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/print-number.js | src/utilities/print-number.js | function printNumber(rawNumber) {
if (rawNumber.length === 1) {
return rawNumber;
}
return (
rawNumber
.toLowerCase()
// Remove unnecessary plus and zeroes from scientific notation.
.replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(?=\d)/, "$1$2")
// Remove unnecessary scientific notation (1e... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/has-spaces.js | src/utilities/has-spaces.js | import { skipSpaces } from "./skip.js";
/** @import {SkipOptions} from "./skip.js" */
// Not using, but it's public utils
/* c8 ignore start */
/**
* @param {string} text
* @param {number} startIndex
* @param {SkipOptions=} options
* @returns {boolean}
*/
function hasSpaces(text, startIndex, options = {}) {
co... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/ast.js | src/utilities/ast.js | import isObject from "./is-object.js";
/**
@import {GetVisitorKeys, Node} from "./create-get-visitor-keys.js"
@typedef {(node: Node) => boolean} Predicate
*/
/**
@param {Node} node
@param {{getVisitorKeys: GetVisitorKeys, filter?: Predicate}} options
*/
function* getChildren(node, options) {
const { getVisitorKeys,... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/is-non-empty-array.js | src/utilities/is-non-empty-array.js | /**
* @param {unknown} object
* @returns {object is Array<any>}
*/
function isNonEmptyArray(object) {
return Array.isArray(object) && object.length > 0;
}
export default isNonEmptyArray;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/get-alignment-size.js | src/utilities/get-alignment-size.js | /**
* @param {string} text
* @param {number} tabWidth
* @param {number=} startIndex
* @returns {number}
*/
function getAlignmentSize(text, tabWidth, startIndex = 0) {
let size = 0;
for (let i = startIndex; i < text.length; ++i) {
if (text[i] === "\t") {
// Tabs behave in a way that they are aligned t... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/import-from-directory.js | src/utilities/import-from-directory.js | import path from "node:path";
import importFromFile from "./import-from-file.js";
function importFromDirectory(specifier, directory) {
return importFromFile(specifier, path.join(directory, "noop.js"));
}
export default importFromDirectory;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/create-group-id-mapper.js | src/utilities/create-group-id-mapper.js | /**
* @param {string} description
* @returns {(node: any) => symbol}
*/
function createGroupIdMapper(description) {
const groupIds = new WeakMap();
return function (node) {
if (!groupIds.has(node)) {
groupIds.set(node, Symbol(description));
}
return groupIds.get(node);
};
}
export default cr... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/get-indent-size.js | src/utilities/get-indent-size.js | import getAlignmentSize from "./get-alignment-size.js";
/**
* @param {string} value
* @param {number} tabWidth
* @returns {number}
*/
function getIndentSize(value, tabWidth) {
const lastNewlineIndex = value.lastIndexOf("\n");
/* c8 ignore next 3 */
if (lastNewlineIndex === -1) {
return 0;
}
return g... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/read-file.js | src/utilities/read-file.js | import fs from "node:fs/promises";
import { isUrlString } from "url-or-path";
/**
* @param {string | URL} file
* @returns {Promise<undefined | string>}
*/
async function readFile(file) {
if (isUrlString(file)) {
file = new URL(file);
}
try {
return await fs.readFile(file, "utf8");
} catch (/** @typ... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/skip-newline.js | src/utilities/skip-newline.js | /** @import {SkipOptions} from "./skip.js" */
/**
* Check if a character is a newline character
* @param {string} character
* @returns {boolean}
*/
const isNewlineCharacter = (character) =>
character === "\n" ||
character === "\r" ||
character === "\u2028" ||
character === "\u2029";
// This one doesn't us... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/line-column-to-index.js | src/utilities/line-column-to-index.js | // Super inefficient, needs to be cached.
function lineColumnToIndex(lineColumn, text) {
let index = 0;
for (let i = 0; i < lineColumn.line - 1; ++i) {
index = text.indexOf("\n", index) + 1;
}
return index + lineColumn.column;
}
export default lineColumnToIndex;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/is-object.js | src/utilities/is-object.js | /**
* @param {unknown} object
* @returns {object is NonNullable<object>}
*/
function isObject(object) {
return object !== null && typeof object === "object";
}
export default isObject;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/is-next-line-empty.js | src/utilities/is-next-line-empty.js | import hasNewline from "./has-newline.js";
import { skipSpaces, skipToLineEnd } from "./skip.js";
import skipInlineComment from "./skip-inline-comment.js";
import skipNewline from "./skip-newline.js";
import skipTrailingComment from "./skip-trailing-comment.js";
/**
* @param {string} text
* @param {number} startInde... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/object-omit.js | src/utilities/object-omit.js | function omit(object, keys) {
keys = new Set(keys);
return Object.fromEntries(
Object.entries(object).filter(([key]) => !keys.has(key)),
);
}
export default omit;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/skip-inline-comment.js | src/utilities/skip-inline-comment.js | /**
* @param {string} text
* @param {number | false} startIndex
* @returns {number | false}
*/
function skipInlineComment(text, startIndex) {
/* c8 ignore next 3 */
if (startIndex === false) {
return false;
}
if (text.charAt(startIndex) === "/" && text.charAt(startIndex + 1) === "*") {
for (let i =... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/has-newline-in-range.js | src/utilities/has-newline-in-range.js | /**
* @param {string} text
* @param {number} startIndex
* @param {number} endIndex
* @returns {boolean}
*/
function hasNewlineInRange(text, startIndex, endIndex) {
for (let i = startIndex; i < endIndex; ++i) {
if (text.charAt(i) === "\n") {
return true;
}
}
return false;
}
export default hasNe... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/get-next-non-space-non-comment-character.js | src/utilities/get-next-non-space-non-comment-character.js | import getNextNonSpaceNonCommentCharacterIndex from "./get-next-non-space-non-comment-character-index.js";
/**
* @param {string} text
* @param {number} startIndex
* @returns {string}
*/
function getNextNonSpaceNonCommentCharacter(text, startIndex) {
const index = getNextNonSpaceNonCommentCharacterIndex(text, sta... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/create-mockable.js | src/utilities/create-mockable.js | /**
@template {{ [key: string]: any }} T
@template {keyof T} K
@param {T} implementations
@returns {{
mocked: T,
implementations: T,
mockImplementation(functionality: K, implementation: T[K]): void,
mockImplementations(overrideImplementations: T): void,
mockRestore(): void,
}}
*/
function createMockable(imple... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/create-get-visitor-keys.js | src/utilities/create-get-visitor-keys.js | import toFastProperties from "to-fast-properties";
/**
@typedef {(node: Node) => VisitorKeys} GetVisitorKeys
@typedef {NonNullable<object>} Node
@typedef {readonly string[]} VisitorKeys
*/
/**
@param {Record<string, VisitorKeys>} visitorKeys
@param {string} [typeProperty="type"]
@returns {GetVisitorKeys}
*/
function ... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/infer-parser.js | src/utilities/infer-parser.js | import {
fileURLToPath,
getFileBasename,
getInterpreter,
isUrl,
} from "#universal";
import isNonEmptyArray from "./is-non-empty-array.js";
/** @import {Options, SupportLanguage} from "../index.js" */
/**
* @param {SupportLanguage[]} languages
* @param {string | URL | undefined} [file]
* @returns {SupportL... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/is-previous-line-empty.js | src/utilities/is-previous-line-empty.js | import { skipSpaces } from "./skip.js";
import skipNewline from "./skip-newline.js";
// Note: this function doesn't ignore leading comments unlike isNextLineEmpty
/**
* @param {string} text
* @param {number} startIndex
* @returns {boolean}
*/
function isPreviousLineEmpty(text, startIndex) {
/** @type {number | f... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/try-combinations.js | src/utilities/try-combinations.js | /**
* @template {function} T
* @param {T[]} combinations
* @returns {ReturnType<T>}
*/
function tryCombinationsSync(combinations) {
const errors = [];
for (const fn of combinations) {
try {
return fn();
} catch (error) {
errors.push(error);
}
}
// TODO: Use `AggregateError` when we ... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/skip-trailing-comment.js | src/utilities/skip-trailing-comment.js | import { skipEverythingButNewLine } from "./skip.js";
/**
* @param {string} text
* @param {number | false} startIndex
* @returns {number | false}
*/
function skipTrailingComment(text, startIndex) {
/* c8 ignore next 3 */
if (startIndex === false) {
return false;
}
if (text.charAt(startIndex) === "/" &... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/get-preferred-quote.js | src/utilities/get-preferred-quote.js | /**
* @typedef {SINGLE_QUOTE | DOUBLE_QUOTE} Quote
*/
const SINGLE_QUOTE = "'";
const DOUBLE_QUOTE = '"';
const SINGLE_QUOTE_DATA = Object.freeze({
character: SINGLE_QUOTE,
codePoint: 39,
});
const DOUBLE_QUOTE_DATA = Object.freeze({
character: DOUBLE_QUOTE,
codePoint: 34,
});
const SINGLE_QUOTE_SETTINGS =... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/visitor-keys.js | src/utilities/visitor-keys.js | /**
@typedef {readonly string[]} Keys
@typedef {Record<string, Keys>} VisitorKeys */
const unique = (values) => [...new Set(values)];
/**
@param {...VisitorKeys} all
@returns {VisitorKeys}
*/
function unionVisitorKeys(...all) {
/** @type {VisitorKeys} */
const result = {};
for (const [type, keys] of all.flatMa... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/print-string.js | src/utilities/print-string.js | import * as assert from "#universal/assert";
import {
DOUBLE_QUOTE,
getPreferredQuote,
SINGLE_QUOTE,
} from "./get-preferred-quote.js";
import makeString from "./make-string.js";
/** @import {Quote} from "./get-preferred-quote.js" */
function printString(raw, options) {
assert.ok(/^(?<quote>["']).*\k<quote>$/... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/import-from-file.js | src/utilities/import-from-file.js | import { pathToFileURL } from "node:url";
// TODO: Use `import.meta.resolve` when it's available
import { resolve } from "import-meta-resolve";
function importFromFile(specifier, parent) {
const url = resolve(specifier, pathToFileURL(parent).href);
return import(url);
}
export default importFromFile;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/require-from-file.js | src/utilities/require-from-file.js | import { createRequire } from "node:module";
function requireFromFile(id, parent) {
const require = createRequire(parent);
return require(id);
}
export default requireFromFile;
| javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/partition.js | src/utilities/partition.js | /**
* @template Element
* @param {Array<Element>} array
* @param {(value: Element) => boolean} predicate
* @returns {[Array<Element>, Array<Element>]}
*/
function partition(array, predicate) {
/** @type {[Array<Element>, Array<Element>]} */
const result = [[], []];
for (const value of array) {
result[pr... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
prettier/prettier | https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/utilities/get-min-not-present-continuous-count.js | src/utilities/get-min-not-present-continuous-count.js | import escapeStringRegexp from "escape-string-regexp";
/**
* Calculates the minimum `n` (>= 1) where `searchString.repeat(n)` is not present in `text`.
* @param {string} text
* @param {string} searchString
* @example getMinNotPresentContinuousCount("```", "`") // 1
* @example getMinNotPresentContinuousCount("``` ... | javascript | MIT | ae0e00df55d47274cc53db8d2cdcd064849e088d | 2026-01-04T14:57:20.107180Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.