Major refactor (#18381)
This commit is contained in:
1 parent
45a738c7c0
commit
e240f15e75
350 files changed
+1374
-1283
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
The core of the algorithm is implemented in `src/document/{printer,builders,utils}.js`. The printer uses the basic formatting abstractions provided to construct a format when printing a node.
|
The core of the algorithm is implemented in `src/document/{printer,builders,utilities}/`. The printer uses the basic formatting abstractions provided to construct a format when printing a node.
|
||||||
|
|
||||||
## Prettier's intermediate representation: `Doc`
|
## Prettier's intermediate representation: `Doc`
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -435,7 +435,7 @@ const configs = [
|
|||||||
"prettier-internal-rules/no-node-comments": [
|
"prettier-internal-rules/no-node-comments": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
file: "src/language-js/utils/index.js",
|
file: "src/language-js/utilities/index.js",
|
||||||
functions: ["hasComment", "getComments"],
|
functions: ["hasComment", "getComments"],
|
||||||
},
|
},
|
||||||
"src/language-js/pragma.js",
|
"src/language-js/pragma.js",
|
||||||
@@ -445,7 +445,7 @@ const configs = [
|
|||||||
"src/language-js/parse/json.js",
|
"src/language-js/parse/json.js",
|
||||||
"src/language-js/parse/acorn.js",
|
"src/language-js/parse/acorn.js",
|
||||||
"src/language-js/parse/oxc.js",
|
"src/language-js/parse/oxc.js",
|
||||||
"src/language-js/parse/utils/wrap-babel-expression.js",
|
"src/language-js/parse/utilities/wrap-babel-expression.js",
|
||||||
],
|
],
|
||||||
"prettier-internal-rules/prefer-create-type-check-function": [
|
"prettier-internal-rules/prefer-create-type-check-function": [
|
||||||
"error",
|
"error",
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ if (nodejsMajorVersion <= 14) {
|
|||||||
testPathIgnorePatterns.push(
|
testPathIgnorePatterns.push(
|
||||||
"<rootDir>/tests/integration/__tests__/plugin-parsers.js",
|
"<rootDir>/tests/integration/__tests__/plugin-parsers.js",
|
||||||
"<rootDir>/tests/integration/__tests__/normalize-doc.js",
|
"<rootDir>/tests/integration/__tests__/normalize-doc.js",
|
||||||
"<rootDir>/tests/integration/__tests__/doc-utils-clean-doc.js",
|
"<rootDir>/tests/integration/__tests__/doc-utilities-clean-doc.js",
|
||||||
"<rootDir>/tests/integration/__tests__/config-invalid.js",
|
"<rootDir>/tests/integration/__tests__/config-invalid.js",
|
||||||
// `@prettier/cli` uses `node:stream/consumers`, not available on Node.js v14
|
// `@prettier/cli` uses `node:stream/consumers`, not available on Node.js v14
|
||||||
"<rootDir>/tests/integration/__tests__/experimental-cli.js",
|
"<rootDir>/tests/integration/__tests__/experimental-cli.js",
|
||||||
|
|||||||
+1
-1
@@ -229,7 +229,7 @@
|
|||||||
"src/index.cjs",
|
"src/index.cjs",
|
||||||
"src/document/debug.js",
|
"src/document/debug.js",
|
||||||
"src/universal/*.browser.js",
|
"src/universal/*.browser.js",
|
||||||
"src/utils/unexpected-node-error.js",
|
"src/utilities/unexpected-node-error.js",
|
||||||
"src/language-js/types/estree.d.ts",
|
"src/language-js/types/estree.d.ts",
|
||||||
"src/**/**/*.d.ts"
|
"src/**/**/*.d.ts"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ const groupSize = Number(groupSizeString);
|
|||||||
const { format } = await import(`./${version}/dist/index.mjs`);
|
const { format } = await import(`./${version}/dist/index.mjs`);
|
||||||
|
|
||||||
const sourceText = readFileSync(
|
const sourceText = readFileSync(
|
||||||
process.env.PRETTIER_PERF_FILENAME || "../../src/language-js/utils/index.js",
|
process.env.PRETTIER_PERF_FILENAME ||
|
||||||
|
"../../src/language-js/utilities/index.js",
|
||||||
"utf8",
|
"utf8",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
WEBSITE_DIR,
|
WEBSITE_DIR,
|
||||||
writeFile,
|
writeFile,
|
||||||
writeJson,
|
writeJson,
|
||||||
} from "./utils/index.js";
|
} from "./utilities/index.js";
|
||||||
|
|
||||||
const runYarn = (command, args, options) =>
|
const runYarn = (command, args, options) =>
|
||||||
spawn("yarn", [command, ...args], { stdio: "inherit", ...options });
|
spawn("yarn", [command, ...args], { stdio: "inherit", ...options });
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { outdent } from "outdent";
|
import { outdent } from "outdent";
|
||||||
import rollupPluginLicense from "rollup-plugin-license";
|
import rollupPluginLicense from "rollup-plugin-license";
|
||||||
import { PROJECT_ROOT } from "../utils/index.js";
|
import { PROJECT_ROOT } from "../utilities/index.js";
|
||||||
|
|
||||||
const separator = `\n${"-".repeat(40)}\n\n`;
|
const separator = `\n${"-".repeat(40)}\n\n`;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import createEsmUtils from "esm-utils";
|
|||||||
import {
|
import {
|
||||||
PRODUCTION_MINIMAL_NODE_JS_VERSION,
|
PRODUCTION_MINIMAL_NODE_JS_VERSION,
|
||||||
PROJECT_ROOT,
|
PROJECT_ROOT,
|
||||||
} from "../utils/index.js";
|
} from "../utilities/index.js";
|
||||||
import esbuildPluginAddDefaultExport from "./esbuild-plugins/add-default-export.js";
|
import esbuildPluginAddDefaultExport from "./esbuild-plugins/add-default-export.js";
|
||||||
import esbuildPluginEvaluate from "./esbuild-plugins/evaluate.js";
|
import esbuildPluginEvaluate from "./esbuild-plugins/evaluate.js";
|
||||||
import esbuildPluginPrimitiveDefine from "./esbuild-plugins/primitive-define.js";
|
import esbuildPluginPrimitiveDefine from "./esbuild-plugins/primitive-define.js";
|
||||||
@@ -17,7 +17,7 @@ import esbuildPluginThrowWarnings from "./esbuild-plugins/throw-warnings.js";
|
|||||||
import esbuildPluginUmd from "./esbuild-plugins/umd.js";
|
import esbuildPluginUmd from "./esbuild-plugins/umd.js";
|
||||||
import esbuildPluginVisualizer from "./esbuild-plugins/visualizer.js";
|
import esbuildPluginVisualizer from "./esbuild-plugins/visualizer.js";
|
||||||
import transform from "./transform/index.js";
|
import transform from "./transform/index.js";
|
||||||
import { getPackageFile } from "./utils.js";
|
import { getPackageFile } from "./utilities.js";
|
||||||
|
|
||||||
const {
|
const {
|
||||||
readJsonSync,
|
readJsonSync,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
PROJECT_ROOT,
|
PROJECT_ROOT,
|
||||||
readJson,
|
readJson,
|
||||||
writeJson,
|
writeJson,
|
||||||
} from "../utils/index.js";
|
} from "../utilities/index.js";
|
||||||
|
|
||||||
const keysToKeep = [
|
const keysToKeep = [
|
||||||
"name",
|
"name",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import path from "node:path";
|
|||||||
import url from "node:url";
|
import url from "node:url";
|
||||||
import { isValidIdentifier } from "@babel/types";
|
import { isValidIdentifier } from "@babel/types";
|
||||||
import { outdent } from "outdent";
|
import { outdent } from "outdent";
|
||||||
import { PROJECT_ROOT, writeFile } from "../utils/index.js";
|
import { PROJECT_ROOT, writeFile } from "../utilities/index.js";
|
||||||
|
|
||||||
async function typesFileBuilder({ packageConfig, file }) {
|
async function typesFileBuilder({ packageConfig, file }) {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import createEsmUtils from "esm-utils";
|
|||||||
import styleText from "node-style-text";
|
import styleText from "node-style-text";
|
||||||
import prettyBytes from "pretty-bytes";
|
import prettyBytes from "pretty-bytes";
|
||||||
import prettyMilliseconds from "pretty-ms";
|
import prettyMilliseconds from "pretty-ms";
|
||||||
import { DIST_DIR } from "../utils/index.js";
|
import { DIST_DIR } from "../utilities/index.js";
|
||||||
import packageConfigs from "./config.js";
|
import packageConfigs from "./config.js";
|
||||||
import parseArguments from "./parse-arguments.js";
|
import parseArguments from "./parse-arguments.js";
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import path from "node:path";
|
|||||||
import url from "node:url";
|
import url from "node:url";
|
||||||
import createEsmUtils from "esm-utils";
|
import createEsmUtils from "esm-utils";
|
||||||
import { outdent } from "outdent";
|
import { outdent } from "outdent";
|
||||||
import { copyFile, DIST_DIR, PROJECT_ROOT } from "../utils/index.js";
|
import { copyFile, DIST_DIR, PROJECT_ROOT } from "../utilities/index.js";
|
||||||
import buildDependenciesLicense from "./build-dependencies-license.js";
|
import buildDependenciesLicense from "./build-dependencies-license.js";
|
||||||
import buildJavascriptModule from "./build-javascript-module.js";
|
import buildJavascriptModule from "./build-javascript-module.js";
|
||||||
import buildOxcWasmParser from "./build-oxc-wasm-parser.js";
|
import buildOxcWasmParser from "./build-oxc-wasm-parser.js";
|
||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
import buildTypes from "./build-types.js";
|
import buildTypes from "./build-types.js";
|
||||||
import esmifyTypescriptEslint from "./esmify-typescript-eslint.js";
|
import esmifyTypescriptEslint from "./esmify-typescript-eslint.js";
|
||||||
import modifyTypescriptModule from "./modify-typescript-module.js";
|
import modifyTypescriptModule from "./modify-typescript-module.js";
|
||||||
import { getPackageFile } from "./utils.js";
|
import { getPackageFile } from "./utilities.js";
|
||||||
|
|
||||||
const {
|
const {
|
||||||
require,
|
require,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import * as path from "node:path";
|
import * as path from "node:path";
|
||||||
import { outdent } from "outdent";
|
import { outdent } from "outdent";
|
||||||
import { PROJECT_ROOT, writeFile } from "../utils/index.js";
|
import { PROJECT_ROOT, writeFile } from "../utilities/index.js";
|
||||||
|
|
||||||
function esmifyTypescriptEslint(text) {
|
function esmifyTypescriptEslint(text) {
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import path from "node:path";
|
|||||||
import escapeStringRegexp from "escape-string-regexp";
|
import escapeStringRegexp from "escape-string-regexp";
|
||||||
import MagicString from "magic-string";
|
import MagicString from "magic-string";
|
||||||
import { outdent } from "outdent";
|
import { outdent } from "outdent";
|
||||||
import { PROJECT_ROOT, writeFile } from "../utils/index.js";
|
import { PROJECT_ROOT, writeFile } from "../utilities/index.js";
|
||||||
import UNUSED_SPECIFIERS from "./typescript-unused-specifiers.js";
|
import UNUSED_SPECIFIERS from "./typescript-unused-specifiers.js";
|
||||||
|
|
||||||
function* getModules(text) {
|
function* getModules(text) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { parseArgs } from "node:util";
|
import { parseArgs } from "node:util";
|
||||||
import { DIST_DIR } from "../utils/index.js";
|
import { DIST_DIR } from "../utilities/index.js";
|
||||||
|
|
||||||
const isUnique = (array) => new Set(array).size === array.length;
|
const isUnique = (array) => new Set(array).size === array.length;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import generate from "@babel/generator";
|
|||||||
import { parse } from "@babel/parser";
|
import { parse } from "@babel/parser";
|
||||||
import { traverseFast as traverse } from "@babel/types";
|
import { traverseFast as traverse } from "@babel/types";
|
||||||
import { outdent } from "outdent";
|
import { outdent } from "outdent";
|
||||||
import { PROJECT_ROOT, SOURCE_DIR } from "../../utils/index.js";
|
import { PROJECT_ROOT, SOURCE_DIR } from "../../utilities/index.js";
|
||||||
import * as transforms from "./transforms/index.js";
|
import * as transforms from "./transforms/index.js";
|
||||||
|
|
||||||
const packageTransforms = new Map([
|
const packageTransforms = new Map([
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { pathToFileURL } from "node:url";
|
import { pathToFileURL } from "node:url";
|
||||||
import makeSynchronized from "make-synchronized";
|
import makeSynchronized from "make-synchronized";
|
||||||
import { SOURCE_DIR } from "../../../utils/index.js";
|
import { SOURCE_DIR } from "../../../utilities/index.js";
|
||||||
|
|
||||||
const PUBLIC_MODULE_URL = pathToFileURL(
|
const PUBLIC_MODULE_URL = pathToFileURL(
|
||||||
path.join(SOURCE_DIR, "document/public.js"),
|
path.join(SOURCE_DIR, "document/public.js"),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { SOURCE_DIR } from "../../../utils/index.js";
|
import { SOURCE_DIR } from "../../../utilities/index.js";
|
||||||
import getPublicDocFunctionality from "./get-public-doc-functionality.js";
|
import getPublicDocFunctionality from "./get-public-doc-functionality.js";
|
||||||
import {
|
import {
|
||||||
createIdentifier,
|
createIdentifier,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import path from "node:path";
|
|||||||
import url from "node:url";
|
import url from "node:url";
|
||||||
import { resolve } from "import-meta-resolve";
|
import { resolve } from "import-meta-resolve";
|
||||||
import { isUrl, toUrl } from "url-or-path";
|
import { isUrl, toUrl } from "url-or-path";
|
||||||
import { PROJECT_ROOT } from "../utils/index.js";
|
import { PROJECT_ROOT } from "../utilities/index.js";
|
||||||
|
|
||||||
const NODE_MODULES_PATH = path.join(PROJECT_ROOT, "node_modules");
|
const NODE_MODULES_PATH = path.join(PROJECT_ROOT, "node_modules");
|
||||||
|
|
||||||
@@ -3,7 +3,7 @@ import fs from "node:fs/promises";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import eslintPluginCompat from "eslint-plugin-compat";
|
import eslintPluginCompat from "eslint-plugin-compat";
|
||||||
import buildConfig from "./build/config.js";
|
import buildConfig from "./build/config.js";
|
||||||
import { DIST_DIR } from "./utils/index.js";
|
import { DIST_DIR } from "./utilities/index.js";
|
||||||
|
|
||||||
const { browserslist: targets } = JSON.parse(
|
const { browserslist: targets } = JSON.parse(
|
||||||
await fs.readFile(new URL("../package.json", import.meta.url)),
|
await fs.readFile(new URL("../package.json", import.meta.url)),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
getEntries,
|
getEntries,
|
||||||
printEntries,
|
printEntries,
|
||||||
replaceVersions,
|
replaceVersions,
|
||||||
} from "./utils/changelog.js";
|
} from "./utilities/changelog.js";
|
||||||
|
|
||||||
const { previousVersion, newVersion } = parseArguments();
|
const { previousVersion, newVersion } = parseArguments();
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
getEntries,
|
getEntries,
|
||||||
printEntries,
|
printEntries,
|
||||||
replaceVersions,
|
replaceVersions,
|
||||||
} from "./utils/changelog.js";
|
} from "./utilities/changelog.js";
|
||||||
|
|
||||||
const { __dirname, require } = createEsmUtils(import.meta);
|
const { __dirname, require } = createEsmUtils(import.meta);
|
||||||
const blogDir = path.join(__dirname, "../website/blog");
|
const blogDir = path.join(__dirname, "../website/blog");
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { PROJECT_ROOT } from "./utils/index.js";
|
import { PROJECT_ROOT } from "./utilities/index.js";
|
||||||
|
|
||||||
const FORMAT_TEST_DIRECTORY = path.join(PROJECT_ROOT, "tests/format/");
|
const FORMAT_TEST_DIRECTORY = path.join(PROJECT_ROOT, "tests/format/");
|
||||||
const TEST_SCRIPT_FILE_NAME = "format.test.js";
|
const TEST_SCRIPT_FILE_NAME = "format.test.js";
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import enquirer from "enquirer";
|
import enquirer from "enquirer";
|
||||||
import openEditor from "open-editor";
|
import openEditor from "open-editor";
|
||||||
import { CHANGELOG_CATEGORIES } from "./utils/changelog-categories.js";
|
import { CHANGELOG_CATEGORIES } from "./utilities/changelog-categories.js";
|
||||||
|
|
||||||
const prNumberPrompt = new enquirer.NumberPrompt({
|
const prNumberPrompt = new enquirer.NumberPrompt({
|
||||||
message: "Input your Pull Request number:",
|
message: "Input your Pull Request number:",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { generateSchema } from "./utils/generate-schema.js";
|
import { generateSchema } from "./utilities/generate-schema.js";
|
||||||
|
|
||||||
console.log(await generateSchema());
|
console.log(await generateSchema());
|
||||||
@@ -6,7 +6,7 @@ import indexToPosition from "index-to-position";
|
|||||||
import { outdent } from "outdent";
|
import { outdent } from "outdent";
|
||||||
import remarkParse from "remark-parse";
|
import remarkParse from "remark-parse";
|
||||||
import unified from "unified";
|
import unified from "unified";
|
||||||
import { CHANGELOG_CATEGORIES } from "./utils/changelog-categories.js";
|
import { CHANGELOG_CATEGORIES } from "./utilities/changelog-categories.js";
|
||||||
|
|
||||||
const CHANGELOG_DIR = "changelog_unreleased";
|
const CHANGELOG_DIR = "changelog_unreleased";
|
||||||
const TEMPLATE_FILE = "TEMPLATE.md";
|
const TEMPLATE_FILE = "TEMPLATE.md";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// TODO: Implement this in `utils.js` when jest.importActual is landed.
|
// TODO: Implement this in `utilities.js` when jest.importActual is landed.
|
||||||
export default function getFormattedDate() {
|
export default function getFormattedDate() {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const isoStr = date.toISOString();
|
const isoStr = date.toISOString();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
import parseArguments from "./parse-arguments.js";
|
import parseArguments from "./parse-arguments.js";
|
||||||
import * as steps from "./steps/index.js";
|
import * as steps from "./steps/index.js";
|
||||||
import { logPromise, readJson } from "./utils.js";
|
import { logPromise, readJson } from "./utilities.js";
|
||||||
|
|
||||||
const params = parseArguments();
|
const params = parseArguments();
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
import { logPromise, readJson, runGit, runYarn, writeJson } from "../utils.js";
|
import {
|
||||||
|
logPromise,
|
||||||
|
readJson,
|
||||||
|
runGit,
|
||||||
|
runYarn,
|
||||||
|
writeJson,
|
||||||
|
} from "../utilities.js";
|
||||||
|
|
||||||
async function format() {
|
async function format() {
|
||||||
await runYarn(["fix:prettier"]);
|
await runYarn(["fix:prettier"]);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { runGit } from "../utils.js";
|
import { runGit } from "../utilities.js";
|
||||||
|
|
||||||
export default async function checkGitStatus({ next }) {
|
export default async function checkGitStatus({ next }) {
|
||||||
const { stdout: status } = await runGit(["status", "--porcelain"]);
|
const { stdout: status } = await runGit(["status", "--porcelain"]);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
import fastGlob from "fast-glob";
|
import fastGlob from "fast-glob";
|
||||||
import { runGit } from "../utils.js";
|
import { runGit } from "../utilities.js";
|
||||||
|
|
||||||
export default async function cleanChangelog({ repo }) {
|
export default async function cleanChangelog({ repo }) {
|
||||||
const changelogUnreleasedDir = fileURLToPath(
|
const changelogUnreleasedDir = fileURLToPath(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import styleText from "node-style-text";
|
import styleText from "node-style-text";
|
||||||
import { logPromise, readJson, runYarn } from "../utils.js";
|
import { logPromise, readJson, runYarn } from "../utilities.js";
|
||||||
|
|
||||||
export default async function generateBundles({ dry, version, manual }) {
|
export default async function generateBundles({ dry, version, manual }) {
|
||||||
if (!manual) {
|
if (!manual) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import { runGit, runYarn } from "../utils.js";
|
import { runGit, runYarn } from "../utilities.js";
|
||||||
|
|
||||||
const PROJECT_ROOT = new URL("../../../", import.meta.url);
|
const PROJECT_ROOT = new URL("../../../", import.meta.url);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { runYarn } from "../utils.js";
|
import { runYarn } from "../utilities.js";
|
||||||
|
|
||||||
const lintFiles = () => runYarn("lint");
|
const lintFiles = () => runYarn("lint");
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import styleText from "node-style-text";
|
import styleText from "node-style-text";
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
import { runGit, waitForEnter } from "../utils.js";
|
import { runGit, waitForEnter } from "../utilities.js";
|
||||||
|
|
||||||
export default async function mergeBlogPost({
|
export default async function mergeBlogPost({
|
||||||
dry,
|
dry,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import styleText from "node-style-text";
|
import styleText from "node-style-text";
|
||||||
import outdent from "outdent";
|
import outdent from "outdent";
|
||||||
import { fetchText, logPromise, writeFile } from "../utils.js";
|
import { fetchText, logPromise, writeFile } from "../utilities.js";
|
||||||
|
|
||||||
const SCHEMA_REPO = "SchemaStore/schemastore";
|
const SCHEMA_REPO = "SchemaStore/schemastore";
|
||||||
const SCHEMA_PATH = "src/schemas/json/prettierrc.json";
|
const SCHEMA_PATH = "src/schemas/json/prettierrc.json";
|
||||||
@@ -10,7 +10,7 @@ const EDIT_URL = `https://github.com/${SCHEMA_REPO}/edit/master/${SCHEMA_PATH}`;
|
|||||||
// Any optional or manual step can be warned in this script.
|
// Any optional or manual step can be warned in this script.
|
||||||
|
|
||||||
async function checkSchema() {
|
async function checkSchema() {
|
||||||
const { generateSchema } = await import("../../utils/generate-schema.js");
|
const { generateSchema } = await import("../../utilities/generate-schema.js");
|
||||||
const schema = await generateSchema();
|
const schema = await generateSchema();
|
||||||
const remoteSchema = await logPromise(
|
const remoteSchema = await logPromise(
|
||||||
"Checking current schema in SchemaStore",
|
"Checking current schema in SchemaStore",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import enquirer from "enquirer";
|
import enquirer from "enquirer";
|
||||||
import spawn from "nano-spawn";
|
import spawn from "nano-spawn";
|
||||||
import { waitForEnter } from "../utils.js";
|
import { waitForEnter } from "../utilities.js";
|
||||||
|
|
||||||
export default async function publishToNpm({ dry }) {
|
export default async function publishToNpm({ dry }) {
|
||||||
console.log(`Ready to publish to NPM${dry ? "(--dry-run)" : ""}`);
|
console.log(`Ready to publish to NPM${dry ? "(--dry-run)" : ""}`);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { runGit } from "../utils.js";
|
import { runGit } from "../utilities.js";
|
||||||
|
|
||||||
export default async function pushToGit({ version, repo }) {
|
export default async function pushToGit({ version, repo }) {
|
||||||
await runGit(["commit", "-am", `Release ${version}`]);
|
await runGit(["commit", "-am", `Release ${version}`]);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
getBlogPostInfo,
|
getBlogPostInfo,
|
||||||
getChangelogContent,
|
getChangelogContent,
|
||||||
waitForEnter,
|
waitForEnter,
|
||||||
} from "../utils.js";
|
} from "../utilities.js";
|
||||||
|
|
||||||
const RELEASE_URL_BASE = "https://github.com/prettier/prettier/releases/new?";
|
const RELEASE_URL_BASE = "https://github.com/prettier/prettier/releases/new?";
|
||||||
export function getReleaseUrl(version, previousVersion) {
|
export function getReleaseUrl(version, previousVersion) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
logPromise,
|
logPromise,
|
||||||
runYarn,
|
runYarn,
|
||||||
waitForEnter,
|
waitForEnter,
|
||||||
} from "../utils.js";
|
} from "../utilities.js";
|
||||||
|
|
||||||
function writeChangelog(params) {
|
function writeChangelog(params) {
|
||||||
const changelog = fs.readFileSync("CHANGELOG.md", "utf8");
|
const changelog = fs.readFileSync("CHANGELOG.md", "utf8");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import styleText from "node-style-text";
|
import styleText from "node-style-text";
|
||||||
import { fetchText, logPromise, processFile, runGit } from "../utils.js";
|
import { fetchText, logPromise, processFile, runGit } from "../utilities.js";
|
||||||
|
|
||||||
async function getNpmDependentsCount() {
|
async function getNpmDependentsCount() {
|
||||||
const npmPage = await logPromise(
|
const npmPage = await logPromise(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { processFile, readJson, runYarn, writeJson } from "../utils.js";
|
import { processFile, readJson, runYarn, writeJson } from "../utilities.js";
|
||||||
|
|
||||||
export default async function updateVersion({ version, next }) {
|
export default async function updateVersion({ version, next }) {
|
||||||
const pkg = await readJson("package.json");
|
const pkg = await readJson("package.json");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import styleText from "node-style-text";
|
import styleText from "node-style-text";
|
||||||
import outdent from "outdent";
|
import outdent from "outdent";
|
||||||
import { logPromise, waitForEnter } from "../utils.js";
|
import { logPromise, waitForEnter } from "../utilities.js";
|
||||||
|
|
||||||
export async function isVersionReleased(version) {
|
export async function isVersionReleased(version) {
|
||||||
const response = await fetch("https://registry.npmjs.org/prettier/");
|
const response = await fetch("https://registry.npmjs.org/prettier/");
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -4,7 +4,7 @@ import {
|
|||||||
directoryIgnorerWithoutNodeModules,
|
directoryIgnorerWithoutNodeModules,
|
||||||
} from "./directory-ignorer.js";
|
} from "./directory-ignorer.js";
|
||||||
import { fastGlob } from "./prettier-internal.js";
|
import { fastGlob } from "./prettier-internal.js";
|
||||||
import { lstatSafe, normalizeToPosix } from "./utils.js";
|
import { lstatSafe, normalizeToPosix } from "./utilities.js";
|
||||||
|
|
||||||
/** @import {Context} from './context.js' */
|
/** @import {Context} from './context.js' */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import stringify from "fast-json-stable-stringify";
|
import stringify from "fast-json-stable-stringify";
|
||||||
import { format, getFileInfo } from "../index.js";
|
import { format, getFileInfo } from "../index.js";
|
||||||
import { printToScreen } from "./utils.js";
|
import { printToScreen } from "./utilities.js";
|
||||||
|
|
||||||
// Note: This does not work with `--config-precedence`
|
// Note: This does not work with `--config-precedence`
|
||||||
async function logFileInfoOrDie(context) {
|
async function logFileInfoOrDie(context) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
|
|||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import findCacheDirectory from "find-cache-directory";
|
import findCacheDirectory from "find-cache-directory";
|
||||||
import { isJson, statSafe } from "./utils.js";
|
import { isJson, statSafe } from "./utilities.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find default cache file (`./node_modules/.cache/prettier/.prettier-cache`) using https://github.com/sindresorhus/find-cache-directory
|
* Find default cache file (`./node_modules/.cache/prettier/.prettier-cache`) using https://github.com/sindresorhus/find-cache-directory
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { resolveConfigFile } from "../index.js";
|
import { resolveConfigFile } from "../index.js";
|
||||||
import { normalizeToPosix, printToScreen } from "./utils.js";
|
import { normalizeToPosix, printToScreen } from "./utilities.js";
|
||||||
|
|
||||||
async function logResolvedConfigPathOrDie(context) {
|
async function logResolvedConfigPathOrDie(context) {
|
||||||
const file = context.argv.findConfigPath;
|
const file = context.argv.findConfigPath;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import fs from "node:fs";
|
|||||||
import stringify from "fast-json-stable-stringify";
|
import stringify from "fast-json-stable-stringify";
|
||||||
import fileEntryCache from "file-entry-cache";
|
import fileEntryCache from "file-entry-cache";
|
||||||
import { version as prettierVersion } from "../index.js";
|
import { version as prettierVersion } from "../index.js";
|
||||||
import { createHash } from "./utils.js";
|
import { createHash } from "./utilities.js";
|
||||||
|
|
||||||
const optionsHashCache = new WeakMap();
|
const optionsHashCache = new WeakMap();
|
||||||
const nodeVersion = process.version;
|
const nodeVersion = process.version;
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ import {
|
|||||||
errors,
|
errors,
|
||||||
picocolors,
|
picocolors,
|
||||||
} from "./prettier-internal.js";
|
} from "./prettier-internal.js";
|
||||||
import { normalizeToPosix, statSafe } from "./utils.js";
|
import { normalizeToPosix, statSafe } from "./utilities.js";
|
||||||
|
|
||||||
function diff(a, b) {
|
function diff(a, b) {
|
||||||
return createTwoFilesPatch("", "", a, b, "", "", { context: 2 });
|
return createTwoFilesPatch("", "", a, b, "", "", { context: 2 });
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import mockable from "./mockable.js";
|
|||||||
import { parseArgvWithoutPlugins } from "./options/parse-cli-arguments.js";
|
import { parseArgvWithoutPlugins } from "./options/parse-cli-arguments.js";
|
||||||
import printSupportInfo from "./print-support-info.js";
|
import printSupportInfo from "./print-support-info.js";
|
||||||
import { createDetailedUsage, createUsage } from "./usage.js";
|
import { createDetailedUsage, createUsage } from "./usage.js";
|
||||||
import { printToScreen } from "./utils.js";
|
import { printToScreen } from "./utilities.js";
|
||||||
|
|
||||||
async function run(rawArguments = process.argv.slice(2)) {
|
async function run(rawArguments = process.argv.slice(2)) {
|
||||||
// Create a default level logger, so we can log errors during `logLevel` parsing
|
// Create a default level logger, so we can log errors during `logLevel` parsing
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import { isCI } from "ci-info";
|
|||||||
import { __internal as sharedWithCli } from "../index.js";
|
import { __internal as sharedWithCli } from "../index.js";
|
||||||
import clearStreamText from "./utilities/clear-stream-text.js";
|
import clearStreamText from "./utilities/clear-stream-text.js";
|
||||||
|
|
||||||
const mockable = sharedWithCli.utils.createMockable({
|
const mockable = sharedWithCli.utilities.createMockable({
|
||||||
clearStreamText,
|
clearStreamText,
|
||||||
getTimestamp: performance.now.bind(performance),
|
getTimestamp: performance.now.bind(performance),
|
||||||
isCI: () => isCI,
|
isCI: () => isCI,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import camelCase from "camelcase";
|
import camelCase from "camelcase";
|
||||||
import { pick } from "../utils.js";
|
import { pick } from "../utilities.js";
|
||||||
import createMinimistOptions from "./create-minimist-options.js";
|
import createMinimistOptions from "./create-minimist-options.js";
|
||||||
import { getContextOptionsWithoutPlugins } from "./get-context-options.js";
|
import { getContextOptionsWithoutPlugins } from "./get-context-options.js";
|
||||||
import minimist from "./minimist.js";
|
import minimist from "./minimist.js";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import stringify from "fast-json-stable-stringify";
|
import stringify from "fast-json-stable-stringify";
|
||||||
import { format, getSupportInfo } from "../index.js";
|
import { format, getSupportInfo } from "../index.js";
|
||||||
import { omit, printToScreen } from "./utils.js";
|
import { omit, printToScreen } from "./utilities.js";
|
||||||
|
|
||||||
const sortByName = (array) =>
|
const sortByName = (array) =>
|
||||||
array.sort((a, b) => a.name.localeCompare(b.name));
|
array.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import camelCase from "camelcase";
|
import camelCase from "camelcase";
|
||||||
import { categoryOrder, usageSummary } from "./constants.evaluate.js";
|
import { categoryOrder, usageSummary } from "./constants.evaluate.js";
|
||||||
import { formatOptionsHiddenDefaults } from "./prettier-internal.js";
|
import { formatOptionsHiddenDefaults } from "./prettier-internal.js";
|
||||||
import { groupBy } from "./utils.js";
|
import { groupBy } from "./utilities.js";
|
||||||
|
|
||||||
const OPTION_USAGE_THRESHOLD = 25;
|
const OPTION_USAGE_THRESHOLD = 25;
|
||||||
const CHOICE_USAGE_MARGIN = 3;
|
const CHOICE_USAGE_MARGIN = 3;
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ const normalizeToPosix =
|
|||||||
? (filepath) => filepath.replaceAll("\\", "/")
|
? (filepath) => filepath.replaceAll("\\", "/")
|
||||||
: (filepath) => filepath;
|
: (filepath) => filepath;
|
||||||
|
|
||||||
export const { omit } = sharedWithCli.utils;
|
export const { omit } = sharedWithCli.utilities;
|
||||||
export {
|
export {
|
||||||
createHash,
|
createHash,
|
||||||
groupBy,
|
groupBy,
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { resolveConfig } from "../config/resolve-config.js";
|
import { resolveConfig } from "../config/resolve-config.js";
|
||||||
import { loadBuiltinPlugins, loadPlugins } from "../main/plugins/index.js";
|
import { loadBuiltinPlugins, loadPlugins } from "../main/plugins/index.js";
|
||||||
import { isIgnored } from "../utils/ignore.js";
|
import { isIgnored } from "../utilities/ignore.js";
|
||||||
import inferParser from "../utils/infer-parser.js";
|
import inferParser from "../utilities/infer-parser.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{ ignorePath?: string | URL | (string | URL)[], withNodeModules?: boolean, plugins: object, resolveConfig?: boolean }} FileInfoOptions
|
* @typedef {{ ignorePath?: string | URL | (string | URL)[], withNodeModules?: boolean, plugins: object, resolveConfig?: boolean }} FileInfoOptions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import createMockable from "../utils/create-mockable.js";
|
import createMockable from "../utilities/create-mockable.js";
|
||||||
|
|
||||||
const mockable = createMockable({
|
const mockable = createMockable({
|
||||||
getPrettierConfigSearchStopDirectory: () => undefined,
|
getPrettierConfigSearchStopDirectory: () => undefined,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import importFromFile from "../../utils/import-from-file.js";
|
import importFromFile from "../../utilities/import-from-file.js";
|
||||||
import requireFromFile from "../../utils/require-from-file.js";
|
import requireFromFile from "../../utilities/require-from-file.js";
|
||||||
|
|
||||||
const requireErrorCodesShouldBeIgnored = new Set([
|
const requireErrorCodesShouldBeIgnored = new Set([
|
||||||
"MODULE_NOT_FOUND",
|
"MODULE_NOT_FOUND",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { pathToFileURL } from "node:url";
|
|||||||
import json5 from "json5";
|
import json5 from "json5";
|
||||||
import parseJson from "parse-json";
|
import parseJson from "parse-json";
|
||||||
import { parse as parseToml } from "smol-toml";
|
import { parse as parseToml } from "smol-toml";
|
||||||
import readFile from "../../utils/read-file.js";
|
import readFile from "../../utilities/read-file.js";
|
||||||
|
|
||||||
async function readJson(file) {
|
async function readJson(file) {
|
||||||
const content = await readFile(file);
|
const content = await readFile(file);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import micromatch from "micromatch";
|
import micromatch from "micromatch";
|
||||||
import { toPath } from "url-or-path";
|
import { toPath } from "url-or-path";
|
||||||
import partition from "../utils/partition.js";
|
import partition from "../utilities/partition.js";
|
||||||
import {
|
import {
|
||||||
clearEditorconfigCache,
|
clearEditorconfigCache,
|
||||||
loadEditorconfig as loadEditorconfigForFile,
|
loadEditorconfig as loadEditorconfigForFile,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { convertEndOfLineToChars } from "../../common/end-of-line.js";
|
import { convertEndOfLineToChars } from "../../common/end-of-line.js";
|
||||||
import getStringWidth from "../../utils/get-string-width.js";
|
import getStringWidth from "../../utilities/get-string-width.js";
|
||||||
import {
|
import {
|
||||||
DOC_TYPE_ALIGN,
|
DOC_TYPE_ALIGN,
|
||||||
DOC_TYPE_ARRAY,
|
DOC_TYPE_ARRAY,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import noop from "../../utils/noop.js";
|
import noop from "../../utilities/noop.js";
|
||||||
import {
|
import {
|
||||||
DOC_TYPE_IF_BREAK,
|
DOC_TYPE_IF_BREAK,
|
||||||
DOC_TYPE_LINE,
|
DOC_TYPE_LINE,
|
||||||
|
|||||||
+2
-2
@@ -39,7 +39,7 @@ for (const name of debugApiFunctionNames) {
|
|||||||
prettier.__debug = debugApis;
|
prettier.__debug = debugApis;
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "production") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
prettier.util = require("./utils/public.js");
|
prettier.util = require("./utilities/public.js");
|
||||||
prettier.doc = require("./document/public.js");
|
prettier.doc = require("./document/public.js");
|
||||||
prettier.version = require("./main/version.evaluate.js").default;
|
prettier.version = require("./main/version.evaluate.js").default;
|
||||||
} else {
|
} else {
|
||||||
@@ -47,7 +47,7 @@ if (process.env.NODE_ENV === "production") {
|
|||||||
util: {
|
util: {
|
||||||
get() {
|
get() {
|
||||||
try {
|
try {
|
||||||
return require("./utils/public.js");
|
return require("./utilities/public.js");
|
||||||
} catch {
|
} catch {
|
||||||
// No op
|
// No op
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -844,7 +844,7 @@ export function getSupportInfo(
|
|||||||
*/
|
*/
|
||||||
export const version: string;
|
export const version: string;
|
||||||
|
|
||||||
// https://github.com/prettier/prettier/blob/next/src/utils/public.js
|
// https://github.com/prettier/prettier/blob/main/src/utilities/public.js
|
||||||
export namespace util {
|
export namespace util {
|
||||||
interface SkipOptions {
|
interface SkipOptions {
|
||||||
backwards?: boolean | undefined;
|
backwards?: boolean | undefined;
|
||||||
|
|||||||
+6
-6
@@ -30,10 +30,10 @@ import {
|
|||||||
getSupportInfo as getSupportInfoWithoutPlugins,
|
getSupportInfo as getSupportInfoWithoutPlugins,
|
||||||
normalizeOptionSettings,
|
normalizeOptionSettings,
|
||||||
} from "./main/support.js";
|
} from "./main/support.js";
|
||||||
import createMockable from "./utils/create-mockable.js";
|
import createMockable from "./utilities/create-mockable.js";
|
||||||
import { createIsIgnoredFunction } from "./utils/ignore.js";
|
import { createIsIgnoredFunction } from "./utilities/ignore.js";
|
||||||
import inferParserWithoutPlugins from "./utils/infer-parser.js";
|
import inferParserWithoutPlugins from "./utilities/infer-parser.js";
|
||||||
import omit from "./utils/object-omit.js";
|
import omit from "./utilities/object-omit.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {*} fn
|
* @param {*} fn
|
||||||
@@ -109,7 +109,7 @@ const sharedWithCli = {
|
|||||||
createTwoFilesPatch,
|
createTwoFilesPatch,
|
||||||
picocolors,
|
picocolors,
|
||||||
closetLevenshteinMatch,
|
closetLevenshteinMatch,
|
||||||
utils: {
|
utilities: {
|
||||||
omit,
|
omit,
|
||||||
createMockable,
|
createMockable,
|
||||||
},
|
},
|
||||||
@@ -139,4 +139,4 @@ export {
|
|||||||
export { default as getFileInfo } from "./common/get-file-info.js";
|
export { default as getFileInfo } from "./common/get-file-info.js";
|
||||||
export * as doc from "./document/public.js";
|
export * as doc from "./document/public.js";
|
||||||
export { default as version } from "./main/version.evaluate.js";
|
export { default as version } from "./main/version.evaluate.js";
|
||||||
export * as util from "./utils/public.js";
|
export * as util from "./utilities/public.js";
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import createGetVisitorKeys from "../utils/create-get-visitor-keys.js";
|
import createGetVisitorKeys from "../utilities/create-get-visitor-keys.js";
|
||||||
import visitorKeys from "./visitor-keys.js";
|
import visitorKeys from "./visitor-keys.js";
|
||||||
|
|
||||||
const getVisitorKeys = createGetVisitorKeys(visitorKeys);
|
const getVisitorKeys = createGetVisitorKeys(visitorKeys);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as linguistLanguages from "linguist-languages";
|
import * as linguistLanguages from "linguist-languages";
|
||||||
import createLanguage from "../utils/create-language.js";
|
import createLanguage from "../utilities/create-language.js";
|
||||||
|
|
||||||
const languages = [
|
const languages = [
|
||||||
createLanguage(linguistLanguages.CSS, (data) => ({
|
createLanguage(linguistLanguages.CSS, (data) => ({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import isNonEmptyArray from "../utils/is-non-empty-array.js";
|
import isNonEmptyArray from "../utilities/is-non-empty-array.js";
|
||||||
import lineColumnToIndex from "../utils/line-column-to-index.js";
|
import lineColumnToIndex from "../utilities/line-column-to-index.js";
|
||||||
import { skipEverythingButNewLine } from "../utils/skip.js";
|
import { skipEverythingButNewLine } from "../utilities/skip.js";
|
||||||
|
|
||||||
function fixValueWordLoc(node, originalIndex) {
|
function fixValueWordLoc(node, originalIndex) {
|
||||||
const { value } = node;
|
const { value } = node;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import postcssMediaQueryParser from "postcss-media-query-parser";
|
import postcssMediaQueryParser from "postcss-media-query-parser";
|
||||||
import { addMissingType, addTypePrefix } from "./utils.js";
|
import { addMissingType, addTypePrefix } from "./utilities.js";
|
||||||
|
|
||||||
const parse = postcssMediaQueryParser.default;
|
const parse = postcssMediaQueryParser.default;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import PostcssSelectorParser from "postcss-selector-parser/dist/processor.js";
|
import PostcssSelectorParser from "postcss-selector-parser/dist/processor.js";
|
||||||
import { addTypePrefix } from "./utils.js";
|
import { addTypePrefix } from "./utilities.js";
|
||||||
|
|
||||||
function parseSelector(selector) {
|
function parseSelector(selector) {
|
||||||
// If there's a comment inside of a selector, the parser tries to parse
|
// If there's a comment inside of a selector, the parser tries to parse
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import PostcssValuesParser from "postcss-values-parser/lib/parser.js";
|
import PostcssValuesParser from "postcss-values-parser/lib/parser.js";
|
||||||
import getFunctionArgumentsText from "../utils/get-function-arguments-text.js";
|
import getFunctionArgumentsText from "../utilities/get-function-arguments-text.js";
|
||||||
import getValueRoot from "../utils/get-value-root.js";
|
import getValueRoot from "../utilities/get-value-root.js";
|
||||||
import hasSCSSInterpolation from "../utils/has-scss-interpolation.js";
|
import hasSCSSInterpolation from "../utilities/has-scss-interpolation.js";
|
||||||
import hasStringOrFunction from "../utils/has-string-or-function.js";
|
import hasStringOrFunction from "../utilities/has-string-or-function.js";
|
||||||
import isSCSSVariable from "../utils/is-scss-variable.js";
|
import isSCSSVariable from "../utilities/is-scss-variable.js";
|
||||||
import parseSelector from "./parse-selector.js";
|
import parseSelector from "./parse-selector.js";
|
||||||
import { addTypePrefix } from "./utils.js";
|
import { addTypePrefix } from "./utilities.js";
|
||||||
|
|
||||||
const isClosingParenthesis = (node) =>
|
const isClosingParenthesis = (node) =>
|
||||||
node.type === "paren" && node.value === ")";
|
node.type === "paren" && node.value === ")";
|
||||||
|
|||||||
File renamed without changes.
@@ -12,10 +12,10 @@ import {
|
|||||||
import parseMediaQuery from "./parse/parse-media-query.js";
|
import parseMediaQuery from "./parse/parse-media-query.js";
|
||||||
import parseSelector from "./parse/parse-selector.js";
|
import parseSelector from "./parse/parse-selector.js";
|
||||||
import parseValue from "./parse/parse-value.js";
|
import parseValue from "./parse/parse-value.js";
|
||||||
import { addTypePrefix } from "./parse/utils.js";
|
import { addTypePrefix } from "./parse/utilities.js";
|
||||||
import { hasIgnorePragma, hasPragma } from "./pragma.js";
|
import { hasIgnorePragma, hasPragma } from "./pragma.js";
|
||||||
import isModuleRuleName from "./utils/is-module-rule-name.js";
|
import isModuleRuleName from "./utilities/is-module-rule-name.js";
|
||||||
import isSCSSNestedPropertyNode from "./utils/is-scss-nested-property-node.js";
|
import isSCSSNestedPropertyNode from "./utilities/is-scss-nested-property-node.js";
|
||||||
|
|
||||||
const DEFAULT_SCSS_DIRECTIVE = /(\s*)(!default).*$/u;
|
const DEFAULT_SCSS_DIRECTIVE = /(\s*)(!default).*$/u;
|
||||||
const GLOBAL_SCSS_DIRECTIVE = /(\s*)(!global).*$/u;
|
const GLOBAL_SCSS_DIRECTIVE = /(\s*)(!global).*$/u;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import {
|
|||||||
isSCSSControlDirectiveNode,
|
isSCSSControlDirectiveNode,
|
||||||
isSubtractionNode,
|
isSubtractionNode,
|
||||||
isWordNode,
|
isWordNode,
|
||||||
} from "../utils/index.js";
|
} from "../utilities/index.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @import AstPath from "../../common/ast-path.js"
|
* @import AstPath from "../../common/ast-path.js"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import printNumber from "../../utils/print-number.js";
|
import printNumber from "../../utilities/print-number.js";
|
||||||
import printString from "../../utils/print-string.js";
|
import printString from "../../utilities/print-string.js";
|
||||||
import CSS_UNITS from "./css-units.evaluate.js";
|
import CSS_UNITS from "./css-units.evaluate.js";
|
||||||
|
|
||||||
function printUnit(unit) {
|
function printUnit(unit) {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import {
|
|||||||
line,
|
line,
|
||||||
softline,
|
softline,
|
||||||
} from "../../document/index.js";
|
} from "../../document/index.js";
|
||||||
import isNextLineEmpty from "../../utils/is-next-line-empty.js";
|
import isNextLineEmpty from "../../utilities/is-next-line-empty.js";
|
||||||
import isNonEmptyArray from "../../utils/is-non-empty-array.js";
|
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
|
||||||
import { locEnd, locStart } from "../loc.js";
|
import { locEnd, locStart } from "../loc.js";
|
||||||
import {
|
import {
|
||||||
isConfigurationNode,
|
isConfigurationNode,
|
||||||
@@ -24,7 +24,7 @@ import {
|
|||||||
isSCSSMapItemNode,
|
isSCSSMapItemNode,
|
||||||
isURLFunctionNode,
|
isURLFunctionNode,
|
||||||
isVarFunctionNode,
|
isVarFunctionNode,
|
||||||
} from "../utils/index.js";
|
} from "../utilities/index.js";
|
||||||
import { shouldPrintTrailingComma } from "./misc.js";
|
import { shouldPrintTrailingComma } from "./misc.js";
|
||||||
|
|
||||||
function hasComma({ node, parent }, options) {
|
function hasComma({ node, parent }, options) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { hardline, line } from "../../document/index.js";
|
import { hardline, line } from "../../document/index.js";
|
||||||
import { isFrontMatter } from "../../main/front-matter/index.js";
|
import { isFrontMatter } from "../../main/front-matter/index.js";
|
||||||
import hasNewline from "../../utils/has-newline.js";
|
import hasNewline from "../../utilities/has-newline.js";
|
||||||
import isNextLineEmpty from "../../utils/is-next-line-empty.js";
|
import isNextLineEmpty from "../../utilities/is-next-line-empty.js";
|
||||||
import { locEnd, locStart } from "../loc.js";
|
import { locEnd, locStart } from "../loc.js";
|
||||||
|
|
||||||
function printSequence(path, options, print) {
|
function printSequence(path, options, print) {
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import {
|
|||||||
removeLines,
|
removeLines,
|
||||||
softline,
|
softline,
|
||||||
} from "../document/index.js";
|
} from "../document/index.js";
|
||||||
import isNonEmptyArray from "../utils/is-non-empty-array.js";
|
import isNonEmptyArray from "../utilities/is-non-empty-array.js";
|
||||||
import printString from "../utils/print-string.js";
|
import printString from "../utilities/print-string.js";
|
||||||
import UnexpectedNodeError from "../utils/unexpected-node-error.js";
|
import UnexpectedNodeError from "../utilities/unexpected-node-error.js";
|
||||||
import clean from "./clean.js";
|
import clean from "./clean.js";
|
||||||
import embed from "./embed.js";
|
import embed from "./embed.js";
|
||||||
import getVisitorKeys from "./get-visitor-keys.js";
|
import getVisitorKeys from "./get-visitor-keys.js";
|
||||||
@@ -47,7 +47,7 @@ import {
|
|||||||
isWideKeywords,
|
isWideKeywords,
|
||||||
lastLineHasInlineComment,
|
lastLineHasInlineComment,
|
||||||
maybeToLowerCase,
|
maybeToLowerCase,
|
||||||
} from "./utils/index.js";
|
} from "./utilities/index.js";
|
||||||
|
|
||||||
function genericPrint(path, options, print) {
|
function genericPrint(path, options, print) {
|
||||||
const { node } = path;
|
const { node } = path;
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import isNonEmptyArray from "../../utils/is-non-empty-array.js";
|
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
|
||||||
|
|
||||||
function hasSCSSInterpolation(groupList) {
|
function hasSCSSInterpolation(groupList) {
|
||||||
if (isNonEmptyArray(groupList)) {
|
if (isNonEmptyArray(groupList)) {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
|
|||||||
import createGetVisitorKeys from "../utils/create-get-visitor-keys.js";
|
import createGetVisitorKeys from "../utilities/create-get-visitor-keys.js";
|
||||||
import visitorKeys from "./visitor-keys.js";
|
import visitorKeys from "./visitor-keys.js";
|
||||||
|
|
||||||
const getVisitorKeys = createGetVisitorKeys(visitorKeys, "kind");
|
const getVisitorKeys = createGetVisitorKeys(visitorKeys, "kind");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as linguistLanguages from "linguist-languages";
|
import * as linguistLanguages from "linguist-languages";
|
||||||
import createLanguage from "../utils/create-language.js";
|
import createLanguage from "../utilities/create-language.js";
|
||||||
|
|
||||||
const languages = [
|
const languages = [
|
||||||
createLanguage(linguistLanguages.GraphQL, () => ({
|
createLanguage(linguistLanguages.GraphQL, () => ({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
FORMAT_PRAGMA_TO_INSERT,
|
FORMAT_PRAGMA_TO_INSERT,
|
||||||
GRAPHQL_HAS_IGNORE_PRAGMA_REGEXP,
|
GRAPHQL_HAS_IGNORE_PRAGMA_REGEXP,
|
||||||
GRAPHQL_HAS_PRAGMA_REGEXP,
|
GRAPHQL_HAS_PRAGMA_REGEXP,
|
||||||
} from "../utils/pragma/pragma.evaluate.js";
|
} from "../utilities/pragma/pragma.evaluate.js";
|
||||||
|
|
||||||
const hasPragma = (text) => GRAPHQL_HAS_PRAGMA_REGEXP.test(text);
|
const hasPragma = (text) => GRAPHQL_HAS_PRAGMA_REGEXP.test(text);
|
||||||
const hasIgnorePragma = (text) => GRAPHQL_HAS_IGNORE_PRAGMA_REGEXP.test(text);
|
const hasIgnorePragma = (text) => GRAPHQL_HAS_IGNORE_PRAGMA_REGEXP.test(text);
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import {
|
|||||||
line,
|
line,
|
||||||
softline,
|
softline,
|
||||||
} from "../document/index.js";
|
} from "../document/index.js";
|
||||||
import isNextLineEmpty from "../utils/is-next-line-empty.js";
|
import isNextLineEmpty from "../utilities/is-next-line-empty.js";
|
||||||
import isNonEmptyArray from "../utils/is-non-empty-array.js";
|
import isNonEmptyArray from "../utilities/is-non-empty-array.js";
|
||||||
import UnexpectedNodeError from "../utils/unexpected-node-error.js";
|
import UnexpectedNodeError from "../utilities/unexpected-node-error.js";
|
||||||
import getVisitorKeys from "./get-visitor-keys.js";
|
import getVisitorKeys from "./get-visitor-keys.js";
|
||||||
import { locEnd, locStart } from "./loc.js";
|
import { locEnd, locStart } from "./loc.js";
|
||||||
import { insertPragma } from "./pragma.js";
|
import { insertPragma } from "./pragma.js";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import htmlWhitespaceUtils from "../utils/html-whitespace-utils.js";
|
import htmlWhitespace from "../utilities/html-whitespace.js";
|
||||||
|
|
||||||
function clean(original, cloned, parent) {
|
function clean(original, cloned, parent) {
|
||||||
// (Glimmer/HTML) ignore TextNode
|
// (Glimmer/HTML) ignore TextNode
|
||||||
@@ -16,7 +16,7 @@ function clean(original, cloned, parent) {
|
|||||||
) {
|
) {
|
||||||
cloned.chars = "";
|
cloned.chars = "";
|
||||||
} else {
|
} else {
|
||||||
cloned.chars = htmlWhitespaceUtils.split(trimmed).join(" ");
|
cloned.chars = htmlWhitespace.split(trimmed).join(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import createGetVisitorKeys from "../utils/create-get-visitor-keys.js";
|
import createGetVisitorKeys from "../utilities/create-get-visitor-keys.js";
|
||||||
import visitorKeys from "./visitor-keys.evaluate.js";
|
import visitorKeys from "./visitor-keys.evaluate.js";
|
||||||
|
|
||||||
const getVisitorKeys = createGetVisitorKeys(visitorKeys);
|
const getVisitorKeys = createGetVisitorKeys(visitorKeys);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as linguistLanguages from "linguist-languages";
|
import * as linguistLanguages from "linguist-languages";
|
||||||
import createLanguage from "../utils/create-language.js";
|
import createLanguage from "../utilities/create-language.js";
|
||||||
|
|
||||||
const languages = [
|
const languages = [
|
||||||
createLanguage(linguistLanguages.Handlebars, () => ({
|
createLanguage(linguistLanguages.Handlebars, () => ({
|
||||||
|
|||||||
@@ -10,15 +10,19 @@ import {
|
|||||||
replaceEndOfLine,
|
replaceEndOfLine,
|
||||||
softline,
|
softline,
|
||||||
} from "../document/index.js";
|
} from "../document/index.js";
|
||||||
import getPreferredQuote from "../utils/get-preferred-quote.js";
|
import getPreferredQuote from "../utilities/get-preferred-quote.js";
|
||||||
import htmlWhitespaceUtils from "../utils/html-whitespace-utils.js";
|
import htmlWhitespace from "../utilities/html-whitespace.js";
|
||||||
import isNonEmptyArray from "../utils/is-non-empty-array.js";
|
import isNonEmptyArray from "../utilities/is-non-empty-array.js";
|
||||||
import UnexpectedNodeError from "../utils/unexpected-node-error.js";
|
import UnexpectedNodeError from "../utilities/unexpected-node-error.js";
|
||||||
import clean from "./clean.js";
|
import clean from "./clean.js";
|
||||||
import embed from "./embed.js";
|
import embed from "./embed.js";
|
||||||
import getVisitorKeys from "./get-visitor-keys.js";
|
import getVisitorKeys from "./get-visitor-keys.js";
|
||||||
import { locEnd, locStart } from "./loc.js";
|
import { locEnd, locStart } from "./loc.js";
|
||||||
import { hasPrettierIgnore, isVoidElement, isWhitespaceNode } from "./utils.js";
|
import {
|
||||||
|
hasPrettierIgnore,
|
||||||
|
isVoidElement,
|
||||||
|
isWhitespaceNode,
|
||||||
|
} from "./utilities.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@import {Doc} from "../document/index.js"
|
@import {Doc} from "../document/index.js"
|
||||||
@@ -170,8 +174,8 @@ function print(path, options, print) {
|
|||||||
|
|
||||||
if (parent.tag === "style") {
|
if (parent.tag === "style") {
|
||||||
text = text.replaceAll(/^\n+/gu, "");
|
text = text.replaceAll(/^\n+/gu, "");
|
||||||
text = htmlWhitespaceUtils.trimEnd(text);
|
text = htmlWhitespace.trimEnd(text);
|
||||||
text = htmlWhitespaceUtils.dedentString(text);
|
text = htmlWhitespace.dedentString(text);
|
||||||
|
|
||||||
return replaceEndOfLine(text, hardline);
|
return replaceEndOfLine(text, hardline);
|
||||||
}
|
}
|
||||||
@@ -218,7 +222,7 @@ function print(path, options, print) {
|
|||||||
return replaceEndOfLine(text);
|
return replaceEndOfLine(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
const isWhitespaceOnly = htmlWhitespaceUtils.isWhitespaceOnly(text);
|
const isWhitespaceOnly = htmlWhitespace.isWhitespaceOnly(text);
|
||||||
const { isFirst, isLast } = path;
|
const { isFirst, isLast } = path;
|
||||||
|
|
||||||
if (options.htmlWhitespaceSensitivity !== "ignore") {
|
if (options.htmlWhitespaceSensitivity !== "ignore") {
|
||||||
@@ -249,8 +253,7 @@ function print(path, options, print) {
|
|||||||
return breaks;
|
return breaks;
|
||||||
}
|
}
|
||||||
|
|
||||||
const leadingWhitespace =
|
const leadingWhitespace = htmlWhitespace.getLeadingWhitespace(text);
|
||||||
htmlWhitespaceUtils.getLeadingWhitespace(text);
|
|
||||||
|
|
||||||
let leadBreaks = [];
|
let leadBreaks = [];
|
||||||
if (leadingWhitespace) {
|
if (leadingWhitespace) {
|
||||||
@@ -264,8 +267,7 @@ function print(path, options, print) {
|
|||||||
text = text.slice(leadingWhitespace.length);
|
text = text.slice(leadingWhitespace.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tailingWhitespace =
|
const tailingWhitespace = htmlWhitespace.getTrailingWhitespace(text);
|
||||||
htmlWhitespaceUtils.getTrailingWhitespace(text);
|
|
||||||
let trailBreaks = [];
|
let trailBreaks = [];
|
||||||
if (tailingWhitespace) {
|
if (tailingWhitespace) {
|
||||||
if (!shouldTrimTrailingNewlines) {
|
if (!shouldTrimTrailingNewlines) {
|
||||||
@@ -351,12 +353,12 @@ function print(path, options, print) {
|
|||||||
trailingSpace = "";
|
trailingSpace = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (htmlWhitespaceUtils.hasLeadingWhitespace(text)) {
|
if (htmlWhitespace.hasLeadingWhitespace(text)) {
|
||||||
text = leadingSpace + htmlWhitespaceUtils.trimStart(text);
|
text = leadingSpace + htmlWhitespace.trimStart(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (htmlWhitespaceUtils.hasTrailingWhitespace(text)) {
|
if (htmlWhitespace.hasTrailingWhitespace(text)) {
|
||||||
text = htmlWhitespaceUtils.trimEnd(text) + trailingSpace;
|
text = htmlWhitespace.trimEnd(text) + trailingSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -672,7 +674,7 @@ function printInverse(path, options, print) {
|
|||||||
/* TextNode print helpers */
|
/* TextNode print helpers */
|
||||||
|
|
||||||
function getTextValueParts(value) {
|
function getTextValueParts(value) {
|
||||||
return join(line, htmlWhitespaceUtils.split(value));
|
return join(line, htmlWhitespace.split(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentAttributeName(path) {
|
function getCurrentAttributeName(path) {
|
||||||
@@ -712,7 +714,7 @@ function generateHardlines(number = 0) {
|
|||||||
|
|
||||||
/* StringLiteral print helpers */
|
/* StringLiteral print helpers */
|
||||||
|
|
||||||
/** @import {Quote} from "../utils/get-preferred-quote.js" */
|
/** @import {Quote} from "../utilities/get-preferred-quote.js" */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a string literal with the correct surrounding quotes based on
|
* Prints a string literal with the correct surrounding quotes based on
|
||||||
|
|||||||
File renamed without changes.
Loaded 100 of 350 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user