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/scripts/tools/eslint-plugin-prettier-internal-rules/no-conflicting-comment-check-flags.js
scripts/tools/eslint-plugin-prettier-internal-rules/no-conflicting-comment-check-flags.js
const MESSAGE_ID_UNIQUE = "unique"; const MESSAGE_ID_CONFLICTING = "conflicting"; const conflictingFlags = [ ["Leading", "Trailing", "Dangling"], ["Block", "Line"], ]; const isCommentCheckFlags = (node) => node.type === "MemberExpression" && !node.computed && !node.optional && node.object.type === "Identi...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/directly-loc-start-end.js
scripts/tools/eslint-plugin-prettier-internal-rules/directly-loc-start-end.js
const selector = [ "MemberExpression", "[computed=false]", '[property.type="Identifier"]', ':matches([property.name="locStart"], [property.name="locEnd"])', ].join(""); const MESSAGE_ID = "directly-loc-start-end"; export default { meta: { type: "suggestion", messages: { [MESSAGE_ID]: "...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/jsx-identifier-case.js
scripts/tools/eslint-plugin-prettier-internal-rules/jsx-identifier-case.js
const MESSAGE_ID = "jsx-identifier-case"; // To ignore variables, config eslint like this // {'prettier-internal-rules/jsx-identifier-case': ['error', 'name1', ... 'nameN']} export default { meta: { type: "suggestion", messages: { [MESSAGE_ID]: "Please rename '{{name}}' to '{{fixed}}'.", }, fi...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/index.js
scripts/tools/eslint-plugin-prettier-internal-rules/index.js
import fs from "node:fs/promises"; import path from "node:path"; import packageJson from "./package.json" with { type: "json" }; const rules = {}; for (const dirent of await fs.readdir(import.meta.dirname, { withFileTypes: true, })) { const fileName = dirent.name; if ( dirent.isDirectory() || !fileName...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/no-doc-public-import.js
scripts/tools/eslint-plugin-prettier-internal-rules/no-doc-public-import.js
import path from "node:path"; const selector = [ ":matches(ImportDeclaration, ExportNamedDeclaration, ImportExpression)", " > ", "Literal.source", ].join(""); const messageId = "no-doc-public-import"; const docIndexFile = path.join( import.meta.dirname, "../../../src/document/public.js", ); const ignored = ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/prefer-indent-if-break.js
scripts/tools/eslint-plugin-prettier-internal-rules/prefer-indent-if-break.js
const selector = [ "CallExpression", "[optional=false]", '[callee.type="Identifier"]', '[callee.name="ifBreak"]', "[arguments.length=3]", '[arguments.0.type="CallExpression"]', "[arguments.0.optional=false]", '[arguments.0.callee.type="Identifier"]', '[arguments.0.callee.name="indent"]', "[arguments...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/no-empty-flat-contents-for-if-break.js
scripts/tools/eslint-plugin-prettier-internal-rules/no-empty-flat-contents-for-if-break.js
const selector = [ "CallExpression", "[optional=false]", '[callee.type="Identifier"]', '[callee.name="ifBreak"]', "[arguments.length=2]", '[arguments.1.type="Literal"]', '[arguments.1.value=""]', ':not([arguments.0.type="SpreadElement"])', ].join(""); const messageId = "no-empty-flat-contents-for-if-br...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/better-parent-property-check-in-parentheses-check.js
scripts/tools/eslint-plugin-prettier-internal-rules/better-parent-property-check-in-parentheses-check.js
import path from "node:path"; const parentPropertyCheckSelector = [ "FunctionDeclaration", '[id.name="needsParens"]', " ", "BinaryExpression", ":matches(", [ [ '[left.type="MemberExpression"]', '[left.object.type="Identifier"]', '[left.object.name="parent"]', '[right.type="Ident...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/test.js
scripts/tools/eslint-plugin-prettier-internal-rules/test.js
import path from "node:path"; import { RuleTester } from "eslint"; import { outdent } from "outdent"; import plugin from "./index.js"; const test = (ruleId, tests) => { new RuleTester().run(ruleId, plugin.rules[ruleId], tests); }; test("await-cli-tests", { valid: [ "async () => await runCli()", "runCli()....
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/prefer-ast-path-each.js
scripts/tools/eslint-plugin-prettier-internal-rules/prefer-ast-path-each.js
const selector = [ "ExpressionStatement", ">", "CallExpression.expression", "[optional=false]", ">", "MemberExpression.callee", "[computed=false]", "[optional=false]", ">", "Identifier.property", '[name="map"]', ].join(""); const messageId = "prefer-ast-path-each"; export default { meta: { ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/prefer-is-non-empty-array.js
scripts/tools/eslint-plugin-prettier-internal-rules/prefer-is-non-empty-array.js
const getLengthSelector = (path) => `[${path}.type="MemberExpression"][${path}.property.type="Identifier"][${path}.property.name="length"]`; const selector = [ "LogicalExpression", ':not(FunctionDeclaration[id.name="isNonEmptyArray"] *)', '[operator="&&"]', `:matches(${[ // `&& foo.length` getLengthSe...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/massage-ast-parameter-names.js
scripts/tools/eslint-plugin-prettier-internal-rules/massage-ast-parameter-names.js
const MESSAGE_ID = "massage-ast-parameter-names"; const massageAstFunctionSelector = [ "FunctionDeclaration", "[async!=true]", "[generator!=true]", '[id.type="Identifier"]', '[id.name="clean"]', ].join(""); const getVariableIdentifiers = ({ identifiers, references }) => [ ...new Set([ ...identifiers, ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/print-function-parameter-order.js
scripts/tools/eslint-plugin-prettier-internal-rules/print-function-parameter-order.js
const messageId = "print-function-parameter-order"; const expectedParameters = ["path", "options", "print"]; export default { meta: { type: "suggestion", messages: { [messageId]: "`{{functionName}}` function parameters should in order of `path`, `options` and `print`.", }, }, create(con...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/prefer-fs-promises-submodule.js
scripts/tools/eslint-plugin-prettier-internal-rules/prefer-fs-promises-submodule.js
const selector = [ "ImportDeclaration", "[specifiers.length=1]", '[source.value="node:fs"]', ">", "ImportSpecifier:first-child", '[imported.name="promises"]', ].join(""); const messageId = "prefer-fs-promises-submodule"; export default { meta: { type: "suggestion", messages: { [messageId]:...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/await-cli-tests.js
scripts/tools/eslint-plugin-prettier-internal-rules/await-cli-tests.js
const selector = [ "CallExpression", '[callee.type="Identifier"]', '[callee.name="runCli"]', ].join(""); const MESSAGE_ID_CALL = "await-cli-tests/call"; const MESSAGE_ID_GETTER = "await-cli-tests/getter"; export default { meta: { type: "suggestion", messages: { [MESSAGE_ID_CALL]: "'runCli()' sho...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/prefer-create-type-check-function.js
scripts/tools/eslint-plugin-prettier-internal-rules/prefer-create-type-check-function.js
const MESSAGE_ID = "prefer-create-type-check-function"; const isTypeAccess = (node, parameterName) => { if (node.type === "ChainExpression") { node = node.expression; } return ( node.type === "MemberExpression" && !node.computed && node.object.type === "Identifier" && node.object.name === pa...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/prefer-ast-path-getters.js
scripts/tools/eslint-plugin-prettier-internal-rules/prefer-ast-path-getters.js
const selector = [ "CallExpression", "[optional=false]", "[arguments.length<2]", '[callee.type="MemberExpression"]', "[callee.computed=false]", "[callee.optional=false]", '[callee.object.type="Identifier"]', "[callee.object.name=/[pP]ath$/]", '[callee.property.type="Identifier"]', ].join(""); const m...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/no-unnecessary-ast-path-call.js
scripts/tools/eslint-plugin-prettier-internal-rules/no-unnecessary-ast-path-call.js
const selector = [ "CallExpression", "[optional=false]", '[callee.type="MemberExpression"]', "[callee.computed=false]", "[callee.optional=false]", '[callee.property.type="Identifier"]', '[callee.property.name="call"]', "[arguments.length=1]", '[arguments.0.type!="SpreadElement"]', ].join(""); const m...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/no-identifier-n.js
scripts/tools/eslint-plugin-prettier-internal-rules/no-identifier-n.js
import { findVariable } from "@eslint-community/eslint-utils"; const ERROR = "error"; const SUGGESTION = "suggestion"; const selector = [ "Identifier", '[name="n"]', `:not(${[ "MemberExpression[computed=false] > .property", "Property[shorthand=false][computed=false] > .key", ].join(", ")})`, ].join("")...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/no-legacy-format-test.js
scripts/tools/eslint-plugin-prettier-internal-rules/no-legacy-format-test.js
import path from "node:path"; const legacyRunFormatTestCall = [ "CallExpression", '[callee.type="Identifier"]', '[callee.name="run_spec"]', ].join(""); const runFormatTestCall = [ "CallExpression", '[callee.type="Identifier"]', '[callee.name="runFormatTest"]', ].join(""); const dirnameArgumentSelector = ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/no-node-comments.js
scripts/tools/eslint-plugin-prettier-internal-rules/no-node-comments.js
import path from "node:path"; // `node.comments` const memberExpressionSelector = [ "MemberExpression[computed=false]", "", ">", "Identifier.property", '[name="comments"]', ].join(""); // `const {comments} = node` // `const {comments: nodeComments} = node` const objectPatternSelector = [ "ObjectPattern", ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/tools/eslint-plugin-prettier-internal-rules/no-useless-ast-path-callback-parameter.js
scripts/tools/eslint-plugin-prettier-internal-rules/no-useless-ast-path-callback-parameter.js
const MESSAGE_ID_PATH = "error/path"; const MESSAGE_ID_INDEX = "error/index"; const MESSAGE_ID_VALUE = "error/value"; const messages = { [MESSAGE_ID_PATH]: "Use `{{name}}` directly instead of the first parameter.", [MESSAGE_ID_INDEX]: "Use `{{name}}.{{property}}` instead of the second parameter.", [MESSAGE_ID...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/benchmark/bench.js
scripts/benchmark/bench.js
import { readFileSync } from "node:fs"; const [, , version, method, groupCountString = 100, groupSizeString = 10] = process.argv; const groupCount = Number(groupCountString); const groupSize = Number(groupSizeString); const { format } = await import(`./${version}/dist/index.mjs`); const sourceText = readFileSync( ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/utilities.js
scripts/build/utilities.js
import fs from "node:fs"; import path from "node:path"; import url from "node:url"; import { resolve } from "import-meta-resolve"; import { isUrl, toUrl } from "url-or-path"; import { PROJECT_ROOT } from "../utilities/index.js"; const NODE_MODULES_PATH = path.join(PROJECT_ROOT, "node_modules"); /** Get a package file...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/build.js
scripts/build/build.js
#!/usr/bin/env node import fs from "node:fs/promises"; import path from "node:path"; import readline from "node:readline"; import styleText from "node-style-text"; import prettyBytes from "pretty-bytes"; import prettyMilliseconds from "pretty-ms"; import { DIST_DIR, PROJECT_ROOT } from "../utilities/index.js"; import ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/parse-arguments.js
scripts/build/parse-arguments.js
import path from "node:path"; import { parseArgs } from "node:util"; import { DIST_DIR } from "../utilities/index.js"; const isUnique = (array) => new Set(array).size === array.length; function parseArguments() { const { values } = parseArgs({ options: { package: { type: "string", multiple: true }, ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/hacks/esmify-typescript-eslint.js
scripts/build/hacks/esmify-typescript-eslint.js
/* Transform `@typescript-eslint/*` module to ESM */ import * as path from "node:path"; import { outdent } from "outdent"; import { PROJECT_ROOT, writeFile } from "../../utilities/index.js"; function esmifyTypescriptEslint(text) { /* ```js const foo = __importStar(require("foo")); const foo = require("foo"); ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/hacks/typescript-unused-specifiers.js
scripts/build/hacks/typescript-unused-specifiers.js
export default new Set([ "ANONYMOUS", "BreakpointResolver", "BuilderFileEmit", "BuilderProgramKind", "BuilderState", "CallHierarchy", "CheckMode", "ClassificationType", "ClassificationTypeNames", "CompletionInfoFlags", "CompletionTriggerKind", "Completions", "ContainerFlags", "DocumentHighli...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/hacks/modify-typescript-module.js
scripts/build/hacks/modify-typescript-module.js
import path from "node:path"; import escapeStringRegexp from "escape-string-regexp"; import MagicString from "magic-string"; import { outdent } from "outdent"; import { PROJECT_ROOT, writeFile } from "../../utilities/index.js"; import UNUSED_SPECIFIERS from "./typescript-unused-specifiers.js"; function* getModules(tex...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/hacks/build-oxc-wasm-parser.js
scripts/build/hacks/build-oxc-wasm-parser.js
import assert from "node:assert/strict"; import { existsSync, promises as fs } from "node:fs"; import url from "node:url"; import spawn from "nano-spawn"; import { outdent } from "outdent"; import packageJson from "../../../package.json" with { type: "json" }; const TEMPORARY_DIRECTORY = new URL("../../../.tmp/", impo...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/shims/babel-highlight.js
scripts/build/shims/babel-highlight.js
export const shouldHighlight = () => false; export default String;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/shims/method-find-last.js
scripts/build/shims/method-find-last.js
import { createMethodShim } from "./shared.js"; const arrayFindLast = Array.prototype.findLast ?? function (callback) { for (let index = this.length - 1; index >= 0; index--) { const element = this[index]; if (callback(element, index, this)) { return element; } } }; const findL...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/shims/colors.js
scripts/build/shims/colors.js
const colors = new Proxy(String, { get: () => colors }); export default colors; export const createColors = () => colors;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/shims/method-find-last-index.js
scripts/build/shims/method-find-last-index.js
import { createMethodShim } from "./shared.js"; const arrayFindLastIndex = Array.prototype.findLastIndex ?? function (callback) { for (let index = this.length - 1; index >= 0; index--) { const element = this[index]; if (callback(element, index, this)) { return index; } } retu...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/shims/debug.js
scripts/build/shims/debug.js
const debug = () => () => {}; export default debug;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/shims/method-is-well-formed.js
scripts/build/shims/method-is-well-formed.js
import { createMethodShim } from "./shared.js"; const LeadSurrogateMin = 0xd800; const LeadSurrogateMax = 0xdbff; const TrailSurrogateMin = 0xdc00; const stringIsWellFormed = String.prototype.isWellFormed ?? /* This implementation is not verified, should only apply to meriyah package https://github.com/meriya...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/shims/shared.js
scripts/build/shims/shared.js
const OPTIONAL_OBJECT = 0b01; const createMethodShim = (methodName, getImplementation) => (flags, object, ...arguments_) => { if (flags | OPTIONAL_OBJECT && (object === undefined || object === null)) { return; } const implementation = getImplementation.call(object) ?? object[methodName]; re...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/shims/method-to-reversed.js
scripts/build/shims/method-to-reversed.js
import { createMethodShim } from "./shared.js"; const arrayToReversed = Array.prototype.toReversed ?? function () { return [...this].reverse(); }; const toReversed = createMethodShim("toReversed", function () { if (Array.isArray(this)) { return arrayToReversed; } }); export default toReversed;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/shims/method-at.js
scripts/build/shims/method-at.js
import { createMethodShim } from "./shared.js"; /* Note: 1. `acorn` contains `RegExpValidationState` class with `.at` method (2 arguments) 2. `postcss` contains `Container` class with `.at` method */ function stringOrArrayAt(index) { return this[index < 0 ? this.length + index : index]; } const at = createMethodS...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/shims/method-replace-all.js
scripts/build/shims/method-replace-all.js
import { createMethodShim } from "./shared.js"; const stringReplaceAll = String.prototype.replaceAll ?? function (pattern, replacement) { // Simple detection to check if pattern is a `RegExp` if (pattern.global) { return this.replace(pattern, replacement); } // Doesn't work for substitutes, ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/index.js
scripts/build/transform/index.js
import path from "node:path"; import generate from "@babel/generator"; import { parse } from "@babel/parser"; import { traverseFast as traverse } from "@babel/types"; import { outdent } from "outdent"; import { PROJECT_ROOT, SOURCE_DIR } from "../../utilities/index.js"; import * as transforms from "./transforms/index.j...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/transform-method-at.js
scripts/build/transform/transforms/transform-method-at.js
import createMethodCallTransform from "./create-method-call-transform.js"; const transformAt = createMethodCallTransform({ methodName: "at", argumentsLength: 1, }); export default transformAt;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/transform-method-replace-all.js
scripts/build/transform/transforms/transform-method-replace-all.js
import createMethodCallTransform from "./create-method-call-transform.js"; const transformReplaceAll = createMethodCallTransform({ methodName: "replaceAll", argumentsLength: 2, }); export default transformReplaceAll;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/create-method-call-transform.js
scripts/build/transform/transforms/create-method-call-transform.js
import { fileURLToPath } from "node:url"; import { outdent } from "outdent"; import { OPTIONAL_OBJECT } from "../../shims/shared.js"; import { createIdentifier, isIdentifier } from "./utilities.js"; /* Doesn't work for optional call, computed property, and spread arguments */ /** * @param {import("@babel/types").Nod...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/transform-object-has-own.js
scripts/build/transform/transforms/transform-object-has-own.js
import { createMemberExpression, isIdentifier } from "./utilities.js"; /* `Object.hasOwn(foo, "bar")` -> `Object.prototype.hasOwnProperty.call(foo, "bar")` */ const transformObjectHasOwnCall = { shouldSkip: (text) => !text.includes("Object.hasOwn("), /** * @param {import("@babel/types").Node} node * @return...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/index.js
scripts/build/transform/transforms/index.js
// Replace imports with public doc module if possible export { default as "doc-module-imports" } from "./transform-doc-module-imports.js"; // Node.js 16.6.0, and for performance in Node.js 18 export { default as "method-at" } from "./transform-method-at.js"; // Node.js 18.0.0 export { default as "method-find-last" } fr...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/transform-method-to-reversed.js
scripts/build/transform/transforms/transform-method-to-reversed.js
import createMethodCallTransform from "./create-method-call-transform.js"; const transformToReversed = createMethodCallTransform({ methodName: "toReversed", argumentsLength: 0, }); export default transformToReversed;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/utilities.js
scripts/build/transform/transforms/utilities.js
function isIdentifier(node, name) { return node.type === "Identifier" && node.name === name; } function createIdentifier(name) { return { type: "Identifier", name }; } function createStringLiteral(value) { return { type: "StringLiteral", value }; } function createMemberExpression(path) { let node; for (co...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/transform-method-is-well-formed.js
scripts/build/transform/transforms/transform-method-is-well-formed.js
import createMethodCallTransform from "./create-method-call-transform.js"; const transformIsWellFormed = createMethodCallTransform({ methodName: "isWellFormed", argumentsLength: 0, }); export default transformIsWellFormed;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/transform-method-find-last.js
scripts/build/transform/transforms/transform-method-find-last.js
import createMethodCallTransform from "./create-method-call-transform.js"; const transformFindLast = createMethodCallTransform({ methodName: "findLast", argumentsLength: 1, }); export default transformFindLast;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/transform-doc-module-imports.js
scripts/build/transform/transforms/transform-doc-module-imports.js
import path from "node:path"; import { SOURCE_DIR } from "../../../utilities/index.js"; import getPublicDocFunctionality from "./get-public-doc-functionality.js"; import { createIdentifier, createMemberExpression, createStringLiteral, } from "./utilities.js"; const DOC_MODULE_DIRECTORY = path.join(SOURCE_DIR, "d...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/transform-method-find-last-index.js
scripts/build/transform/transforms/transform-method-find-last-index.js
import createMethodCallTransform from "./create-method-call-transform.js"; const transformFindLastIndex = createMethodCallTransform({ methodName: "findLastIndex", argumentsLength: 1, }); export default transformFindLastIndex;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/get-public-doc-functionality.js
scripts/build/transform/transforms/get-public-doc-functionality.js
import path from "node:path"; import { pathToFileURL } from "node:url"; import makeSynchronized from "make-synchronized"; import { SOURCE_DIR } from "../../../utilities/index.js"; const PUBLIC_MODULE_URL = pathToFileURL( path.join(SOURCE_DIR, "document/public.js"), ); let publicDocFunctionalities; async function ge...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/transform/transforms/transform-string-raw.js
scripts/build/transform/transforms/transform-string-raw.js
import jsesc from "jsesc"; import { createStringLiteral, isIdentifier } from "./utilities.js"; /** * @param {import("@babel/types").Node} node * @returns {boolean} */ function isStringRaw(node) { return ( node.type === "TaggedTemplateExpression" && node.tag.type === "MemberExpression" && !node.tag.com...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/builders/types.js
scripts/build/builders/types.js
import fs from "node:fs"; import path from "node:path"; import url from "node:url"; import { isValidIdentifier } from "@babel/types"; import { outdent } from "outdent"; import { writeFile } from "../../utilities/index.js"; async function typesFileBuilder({ packageConfig, file }) { /** * @typedef {{ from: string, ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/builders/copy-file.js
scripts/build/builders/copy-file.js
import path from "node:path"; import { copyFile } from "../../utilities/index.js"; const copyFileBuilder = ({ packageConfig, file }) => copyFile( path.isAbsolute(file.input) ? file.input : path.join(packageConfig.sourceDirectory, file.input), path.join(packageConfig.distDirectory, file.output), ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/builders/dependencies-license.js
scripts/build/builders/dependencies-license.js
import fs from "node:fs/promises"; import path from "node:path"; import { outdent } from "outdent"; import rollupPluginLicense from "rollup-plugin-license"; import { PROJECT_ROOT } from "../../utilities/index.js"; const separator = `\n${"-".repeat(40)}\n\n`; function toBlockQuote(text) { return text .trim() ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/builders/javascript-module.js
scripts/build/builders/javascript-module.js
import path from "node:path"; import url from "node:url"; import browserslistToEsbuild from "browserslist-to-esbuild"; import esbuild from "esbuild"; import createEsmUtils from "esm-utils"; import projectPackageJson from "../../../package.json" with { type: "json" }; import { PRODUCTION_MINIMAL_NODE_JS_VERSION } from "...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/builders/package-json.js
scripts/build/builders/package-json.js
import assert from "node:assert/strict"; import path from "node:path"; import projectPackageJson from "../../../package.json" with { type: "json" }; import { PRODUCTION_MINIMAL_NODE_JS_VERSION, readJson, writeJson, } from "../../utilities/index.js"; const keysToKeep = [ "name", "version", "description", ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/esbuild-plugins/add-default-export.js
scripts/build/esbuild-plugins/add-default-export.js
import path from "node:path"; const PLUGIN_NAMESPACE = "add-default-export"; export default function esbuildPluginAddDefaultExport() { return { name: "addDefaultExport", setup(build) { const { initialOptions } = build; if (initialOptions.format !== "esm") { return; } build.on...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/esbuild-plugins/visualizer.js
scripts/build/esbuild-plugins/visualizer.js
import fs from "node:fs/promises"; import { visualizer as esbuildVisualizer } from "esbuild-visualizer/dist/plugin/index.js"; export default function esbuildPluginVisualizer({ formats }) { formats = Object.fromEntries(formats.map((format) => [format, true])); return { name: "visualizer", setup(build) { ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/esbuild-plugins/shim-commonjs-objects.js
scripts/build/esbuild-plugins/shim-commonjs-objects.js
import fs from "node:fs"; import { outdent } from "outdent"; export default function esbuildPluginShimCommonjsObjects() { return { name: "shim-commonjs-objects", setup(build) { const { onEnd, initialOptions: esbuildOptions } = build; onEnd(() => { const file = esbuildOptions.outfile; ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/esbuild-plugins/replace-module.js
scripts/build/esbuild-plugins/replace-module.js
import fs from "node:fs/promises"; const DEFAULT_ON_RESOLVE_CONCEPTS = { filter: /./, namespace: "file" }; const DEFAULT_ON_LOAD_CONCEPTS = { filter: /\.(?:js|json|mjs|cjs)$/, namespace: "file", }; function processReplacements(replacements) { const onResolveReplacements = new Map(); const onLoadReplacements =...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/esbuild-plugins/umd.js
scripts/build/esbuild-plugins/umd.js
import fs from "node:fs"; import camelCase from "camelcase"; import { outdent } from "outdent"; const PLACEHOLDER = "__PLACEHOLDER__"; function getUmdWrapper({ name }, build) { const path = name.split("."); const { minify } = build.initialOptions; const temporaryName = minify ? "m" : camelCase(name); let glob...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/esbuild-plugins/evaluate.js
scripts/build/esbuild-plugins/evaluate.js
import assert from "node:assert"; import path from "node:path"; import url from "node:url"; import { isValidIdentifier } from "@babel/types"; import { outdent } from "outdent"; import serialize from "serialize-javascript"; function serializeModule(module) { return Object.entries(module) .map(([specifier, value])...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/esbuild-plugins/primitive-define.js
scripts/build/esbuild-plugins/primitive-define.js
function stringify(value) { if ( value !== null && !["boolean", "number", "string", "undefined"].includes(typeof value) ) { throw Object.assign(new TypeError("value not allowed"), { value }); } return value === undefined ? "undefined" : JSON.stringify(value); } /* Non-primitive value will cause es...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/esbuild-plugins/throw-warnings.js
scripts/build/esbuild-plugins/throw-warnings.js
/* Open https://esbuild.github.io/api/#log-override, run ```js [...document.querySelectorAll('details > summary > code')].map(code => code.textContent) ``` in console to get all message ids. */ const ESBUILD_MESSAGE_IDS = [ "assert-to-with", "assert-type-json", "assign-to-constant", "assign-to-define", "ass...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/esbuild-plugins/strip-node-protocol.js
scripts/build/esbuild-plugins/strip-node-protocol.js
export default function esbuildPluginStripNodeProtocol() { return { name: "strip-node-protocol", setup(build) { build.onResolve( { filter: /^node:/, namespace: "file" }, ({ path, kind }) => build.resolve(path.slice(5), { kind }), ); }, }; }
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/packages/index.js
scripts/build/packages/index.js
import pluginHermesBuildConfig from "./plugin-hermes.js"; import pluginOxcBuildConfig from "./plugin-oxc.js"; import prettierBuildConfig from "./prettier.js"; export default [ prettierBuildConfig, pluginHermesBuildConfig, pluginOxcBuildConfig, ];
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/packages/plugin-oxc.js
scripts/build/packages/plugin-oxc.js
import path from "node:path"; import { DIST_DIR, PACKAGES_DIRECTORY } from "../../utilities/index.js"; import { createJavascriptModuleBuilder } from "../builders/javascript-module.js"; import buildOxcWasmParser from "../hacks/build-oxc-wasm-parser.js"; import { getPackageFile } from "../utilities.js"; import { create...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/packages/prettier.js
scripts/build/packages/prettier.js
import path from "node:path"; import url from "node:url"; import createEsmUtils from "esm-utils"; import { outdent } from "outdent"; import { DIST_DIR, PROJECT_ROOT } from "../../utilities/index.js"; import { createJavascriptModuleBuilder } from "../builders/javascript-module.js"; import esmifyTypescriptEslint from ".....
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/packages/prettier-package-json.js
scripts/build/packages/prettier-package-json.js
import path from "node:path"; function generatePackageJson(packageJson, { packageConfig }) { const files = packageConfig.modules.flatMap((module) => module.files); return { ...packageJson, main: "./index.cjs", exports: { ".": { types: "./index.d.ts", require: "./index.cjs", ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/packages/config-helpers.js
scripts/build/packages/config-helpers.js
import fs from "node:fs"; import path from "node:path"; import { PROJECT_ROOT } from "../../utilities/index.js"; import { copyFileBuilder } from "../builders/copy-file.js"; import { createDependenciesLicenseBuilder } from "../builders/dependencies-license.js"; import { createJavascriptModuleBuilder } from "../builders/...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/build/packages/plugin-hermes.js
scripts/build/packages/plugin-hermes.js
import path from "node:path"; import { DIST_DIR, PACKAGES_DIRECTORY } from "../../utilities/index.js"; import { createJavascriptModuleBuilder } from "../builders/javascript-module.js"; import { getPackageFile } from "../utilities.js"; import { createPackageMetaFilesConfig, createTypesConfig, } from "./config-helper...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/utilities/changelog-categories.js
scripts/utilities/changelog-categories.js
export const CHANGELOG_CATEGORIES = [ "angular", "api", "cli", "css", "flow", "graphql", "handlebars", "html", "javascript", "json", "less", "lwc", "mjml", "markdown", "mdx", "scss", "typescript", "vue", "yaml", "misc", ];
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/utilities/index.js
scripts/utilities/index.js
import fs from "node:fs/promises"; import path from "node:path"; import url from "node:url"; const toPath = (path) => (path instanceof URL ? url.fileURLToPath(path) : path); async function readJson(file) { const data = await fs.readFile(file); return JSON.parse(data); } function writeJson(file, content) { cont...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/utilities/changelog.js
scripts/utilities/changelog.js
import fs from "node:fs"; import path from "node:path"; import createEsmUtils from "esm-utils"; import semver from "semver"; const { __dirname } = createEsmUtils(import.meta); export const changelogUnreleasedDirPath = path.join( __dirname, "../../changelog_unreleased", ); export const categories = [ { dir: "ja...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/scripts/utilities/generate-schema.js
scripts/utilities/generate-schema.js
function generateSchemaData(options) { return { $schema: "http://json-schema.org/draft-07/schema#", $id: "https://www.schemastore.org/prettierrc.json", definitions: { optionsDefinition: { type: "object", properties: Object.fromEntries( options .sort(({ name: opt...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/benchmarks/trim-indentation.js
benchmarks/trim-indentation.js
import assert from "node:assert/strict"; import { trimIndentation } from "../src/document/printer/trim-indentation.js"; import { runBenchmark } from "./utilities.js"; for (const size of [1, 1e1, 1e2]) { const trimmed = "foo".repeat(size / 2); const text = trimmed + " \t".repeat(size / 2); await runBenchmark( ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/benchmarks/print-doc-to-string.js
benchmarks/print-doc-to-string.js
import assert from "node:assert/strict"; import fs from "node:fs/promises"; import prettyBytes from "pretty-bytes"; import * as prettierProduction from "../node_modules/prettier/index.mjs"; import * as prettierDevelopment from "../src/index.js"; import { runBenchmark } from "./utilities.js"; assert.notEqual(prettierPr...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/benchmarks/string-buffer-compress.js
benchmarks/string-buffer-compress.js
import assert from "node:assert/strict"; import { runBenchmark } from "./utilities.js"; for (const size of [1e1, 1e2, 1e3, 1e4, 1e5]) { const maxLength = 10; const seperator = "|"; const strings = Array.from({ length: size }, () => "_"); const expected = { length: strings.join(seperator).length, times:...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/benchmarks/utilities.js
benchmarks/utilities.js
import { Bench } from "tinybench"; /** @import {BenchOptions} from "tinybench"; @typedef { | { name: string, implementation: () => any }[] | Record<string, () => any> } Implementations */ /** @param { | string | { name: string, assert?: (result: any) => void, } & BenchOptions }...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/benchmarks/string-concatenation.js
benchmarks/string-concatenation.js
import assert from "node:assert/strict"; import { runBenchmark } from "./utilities.js"; for (const size of [1e1, 1e2, 1e3, 1e4, 1e5]) { const strings = Array.from({ length: size }, () => "_"); const expected = strings.join(""); await runBenchmark( { name: `String concatenation (${size} strings)`, ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/benchmarks/get-preferred-quote.js
benchmarks/get-preferred-quote.js
import assert from "node:assert/strict"; // import * as prettierDevBundled from "../dist/prettier/index.mjs"; import * as prettierProduction from "../node_modules/prettier/index.mjs"; import * as prettierDevelopment from "../src/index.js"; import { runBenchmark } from "./utilities.js"; assert.notEqual(prettierProducti...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/standalone.js
src/standalone.js
import * as core from "./main/core.js"; import { getSupportInfo as getSupportInfoWithoutPlugins } from "./main/support.js"; function withPlugins( fn, optionsArgumentIndex = 1, // Usually `options` is the 2nd argument ) { // Returns Promises to consistent with functions in `index.js` return async (...args) => {...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/index.js
src/index.js
/* The following are bundled here since they are used in API too - fast-glob - diff.createTwoFilesPatch - leven.closestMatch - picocolors */ import { createTwoFilesPatch } from "diff"; import fastGlob from "fast-glob"; import { closestMatch as closetLevenshteinMatch } from "leven"; import picocolors from "picocolors"; ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/universal/index.browser.js
src/universal/index.browser.js
/** @param {string | URL} file @returns {string} */ const getFileBasename = (file) => String(file).split(/[/\\]/).pop(); // Ideally, we should only allow `URL` with `file:` protocol and // string starts with `file:`, but `URL` is missing in some environments // eg: `node:vm` const isUrl = (file) => String(file).starts...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/universal/index.js
src/universal/index.js
import path from "node:path"; import { toPath } from "url-or-path"; /** @param {string | URL} file @returns {string} */ const getFileBasename = (file) => { try { return path.basename(toPath(file)); } catch { return ""; } }; export { getFileBasename }; export { default as getInterpreter } from "../utilit...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/universal/assert.js
src/universal/assert.js
// Can't use `export *` // https://github.com/microsoft/TypeScript/issues/51923 export { equal, ok, strictEqual } from "node:assert";
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/universal/assert.browser.js
src/universal/assert.browser.js
export { default as equal, default as ok, default as strictEqual, } from "../utilities/noop.js";
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-css/index.js
src/language-css/index.js
import printer from "./printer-postcss.js"; export const printers = { postcss: printer, }; export { default as languages } from "./languages.evaluate.js"; export { default as options } from "./options.js"; export * as parsers from "./parser-postcss.js";
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-css/visitor-keys.evaluate.js
src/language-css/visitor-keys.evaluate.js
import { generateReferenceSharedVisitorKeys } from "../utilities/visitor-keys.js"; const visitorKeys = generateReferenceSharedVisitorKeys({ "css-root": ["frontMatter", "nodes"], "css-comment": [], "css-rule": ["selector", "nodes"], "css-decl": ["value", "selector", "nodes"], "css-atrule": ["selector", "param...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-css/clean.js
src/language-css/clean.js
import { isFrontMatter } from "../main/front-matter/index.js"; const ignoredProperties = new Set([ "raw", // front-matter "raws", "sourceIndex", "source", "before", "after", "trailingComma", "spaces", ]); function clean(original, cloned, parent) { if ( original.type === "css-comment" && pare...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-css/options.js
src/language-css/options.js
import commonOptions from "../common/common-options.evaluate.js"; // format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.evaluate.js const options = { singleQuote: commonOptions.singleQuote, }; export default options;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-css/loc.js
src/language-css/loc.js
import isNonEmptyArray from "../utilities/is-non-empty-array.js"; import lineColumnToIndex from "../utilities/line-column-to-index.js"; import { skipEverythingButNewLine } from "../utilities/skip.js"; function fixValueWordLoc(node, originalIndex) { const { value } = node; if (value === "-" || value === "--" || val...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-css/get-visitor-keys.js
src/language-css/get-visitor-keys.js
import createGetVisitorKeys from "../utilities/create-get-visitor-keys.js"; import visitorKeys from "./visitor-keys.evaluate.js"; const getVisitorKeys = createGetVisitorKeys(visitorKeys); export default getVisitorKeys;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-css/pragma.js
src/language-css/pragma.js
import { hasIgnorePragma as jsHasIgnorePragma, hasPragma as jsHasPragma, insertPragma as jsInsertPragma, } from "../language-js/pragma.js"; import { parseFrontMatter } from "../main/front-matter/index.js"; const hasPragma = (text) => jsHasPragma(parseFrontMatter(text).content); const hasIgnorePragma = (text) => ...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-css/printer-postcss.js
src/language-css/printer-postcss.js
import { breakParent, dedent, group, hardline, ifBreak, indent, join, line, lineSuffix, lineSuffixBoundary, removeLines, softline, } from "../document/index.js"; import isNonEmptyArray from "../utilities/is-non-empty-array.js"; import printString from "../utilities/print-string.js"; import Unexp...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-css/embed.js
src/language-css/embed.js
// A empty function to provide visitor keys, and let core format front matter function embed() {} // `front-matter` only available on `css-root` embed.getVisitorKeys = (node) => node.type === "css-root" ? ["frontMatter"] : []; export default embed;
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false
prettier/prettier
https://github.com/prettier/prettier/blob/ae0e00df55d47274cc53db8d2cdcd064849e088d/src/language-css/languages.evaluate.js
src/language-css/languages.evaluate.js
import * as linguistLanguages from "linguist-languages"; import createLanguage from "../utilities/create-language.js"; const languages = [ createLanguage(linguistLanguages.CSS, (data) => ({ parsers: ["css"], vscodeLanguageIds: ["css"], extensions: [ ...data.extensions, // `WeiXin Style Sheets...
javascript
MIT
ae0e00df55d47274cc53db8d2cdcd064849e088d
2026-01-04T14:57:20.107180Z
false