This commit is contained in:
fisker committed 2022-06-19 11:28:28 +08:00
1 parent 0e0f879c1a
commit 21f2ea0f1e
13 files changed
+53 -83

No files matched your search

+4 -3
View File
@@ -221,8 +221,8 @@
"neoformat", "neoformat",
"neovim", "neovim",
"nicolo", "nicolo",
"nocheck",
"nnoremap", "nnoremap",
"nocheck",
"nonenumerable", "nonenumerable",
"Nonspacing", "Nonspacing",
"noopener", "noopener",
@@ -271,9 +271,9 @@
"Pschera", "Pschera",
"quasis", "quasis",
"Raghuvir", "Raghuvir",
"raquo",
"Rasmus", "Rasmus",
"Rattray", "Rattray",
"raquo",
"rattrayalex", "rattrayalex",
"readline", "readline",
"readlines", "readlines",
@@ -283,6 +283,7 @@
"refmt", "refmt",
"regexes", "regexes",
"Reimplement", "Reimplement",
"require",
"rhengles", "rhengles",
"ribaudo", "ribaudo",
"Roadmap", "Roadmap",
@@ -292,8 +293,8 @@
"sandhose", "sandhose",
"Sapegin", "Sapegin",
"sbdchd", "sbdchd",
"sdbm",
"scandir", "scandir",
"sdbm",
"Serializers", "Serializers",
"setlocal", "setlocal",
"setq", "setq",
+1 -1
View File
@@ -1,6 +1,6 @@
import path from "node:path"; import path from "node:path";
import fastGlob from "fast-glob"; import fastGlob from "fast-glob";
import {statSafe} from "./utils.js" import { statSafe } from "./utils.js";
/** @typedef {import('./context').Context} Context */ /** @typedef {import('./context').Context} Context */
+4 -6
View File
@@ -1,8 +1,6 @@
"use strict"; import os from "node:os";
import path from "node:path";
const os = require("os"); import findCacheDir from "find-cache-dir";
const path = require("path");
const findCacheDir = require("find-cache-dir");
/** /**
* Find default cache file (`./node_modules/.cache/prettier/.prettier-cache`) using https://github.com/avajs/find-cache-dir * Find default cache file (`./node_modules/.cache/prettier/.prettier-cache`) using https://github.com/avajs/find-cache-dir
@@ -16,4 +14,4 @@ function findCacheFile() {
return cacheFilePath; return cacheFilePath;
} }
module.exports = findCacheFile; export default findCacheFile;
+5 -8
View File
@@ -1,13 +1,10 @@
"use strict";
// Inspired by LintResultsCache from ESLint // Inspired by LintResultsCache from ESLint
// https://github.com/eslint/eslint/blob/c2d0a830754b6099a3325e6d3348c3ba983a677a/lib/cli-engine/lint-result-cache.js // https://github.com/eslint/eslint/blob/c2d0a830754b6099a3325e6d3348c3ba983a677a/lib/cli-engine/lint-result-cache.js
const fileEntryCache = require("file-entry-cache"); import fileEntryCache from "file-entry-cache";
const stringify = require("fast-json-stable-stringify"); import stringify from "fast-json-stable-stringify";
// eslint-disable-next-line no-restricted-modules import { version as prettierVersion } from "../index.js";
const { version: prettierVersion } = require("../index.js"); import { createHash } from "./utils.js";
const { createHash } = require("./utils.js");
const optionsHashCache = new WeakMap(); const optionsHashCache = new WeakMap();
const nodeVersion = process && process.version; const nodeVersion = process && process.version;
@@ -93,4 +90,4 @@ class FormatResultsCache {
} }
} }
module.exports = FormatResultsCache; export default FormatResultsCache;
+1 -5
View File
@@ -400,15 +400,11 @@ async function formatFiles(context) {
let output; let output;
try { try {
<<<<<<< HEAD
result = await format(context, input, options);
=======
if (isCacheExists) { if (isCacheExists) {
result = { formatted: input }; result = { formatted: input };
} else { } else {
result = format(context, input, options); result = await format(context, input, options);
} }
>>>>>>> main
output = result.formatted; output = result.formatted;
} catch (error) { } catch (error) {
handleError(context, filename, error, printedFilename); handleError(context, filename, error, printedFilename);
+4 -6
View File
@@ -1,12 +1,9 @@
import { promises as fs } from "node:fs";
import sdbm from "sdbm";
import { __internal as sharedWithCli } from "../index.js"; import { __internal as sharedWithCli } from "../index.js";
const { arrayify, getLast, isNonEmptyArray, partition } = sharedWithCli.utils; const { arrayify, getLast, isNonEmptyArray, partition } = sharedWithCli.utils;
const { promises: fs } = require("fs");
// eslint-disable-next-line no-restricted-modules
const { default: sdbm } = require("../../vendors/sdbm.js");
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
const printToScreen = console.log.bind(console); const printToScreen = console.log.bind(console);
@@ -77,5 +74,6 @@ export {
printToScreen, printToScreen,
groupBy, groupBy,
pick, pick,
createHash, statSafe createHash,
statSafe,
}; };
+1 -1
View File
@@ -60,7 +60,7 @@ const languages = [
codemirrorMimeType: "text/jsx", codemirrorMimeType: "text/jsx",
color: undefined, color: undefined,
})), })),
createLanguage(linguistLanguages.TypeScript, (data) => ({ createLanguage(linguistLanguages.TypeScript, () => ({
since: "1.4.0", since: "1.4.0",
parsers: ["typescript", "babel-ts"], parsers: ["typescript", "babel-ts"],
vscodeLanguageIds: ["typescript"], vscodeLanguageIds: ["typescript"],
@@ -1,5 +1,4 @@
"use strict"; import createError from "../../../common/parser-create-error.js";
const createError = require("../../../common/parser-create-error.js");
function throwSyntaxError(node, message) { function throwSyntaxError(node, message) {
const { start, end } = node.loc; const { start, end } = node.loc;
@@ -9,4 +8,4 @@ function throwSyntaxError(node, message) {
}); });
} }
module.exports = throwSyntaxError; export default throwSyntaxError;
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, ["angular"]); run_spec(import.meta, ["angular"]);
@@ -375,6 +375,7 @@ exports[`CLI --support-info (stdout) 1`] = `
"color": "#e34c26", "color": "#e34c26",
"extensions": [ "extensions": [
".html", ".html",
".hta",
".htm", ".htm",
".html.hl", ".html.hl",
".inc", ".inc",
@@ -406,10 +407,13 @@ exports[`CLI --support-info (stdout) 1`] = `
".frag", ".frag",
".gs", ".gs",
".jake", ".jake",
".javascript",
".jsb", ".jsb",
".jscad", ".jscad",
".jsfl", ".jsfl",
".jslib",
".jsm", ".jsm",
".jspre",
".jss", ".jss",
".mjs", ".mjs",
".njs", ".njs",
@@ -453,10 +457,14 @@ exports[`CLI --support-info (stdout) 1`] = `
}, },
{ {
"aceMode": "json", "aceMode": "json",
"aliases": ["geojson", "jsonl", "topojson"],
"codemirrorMimeType": "application/json", "codemirrorMimeType": "application/json",
"codemirrorMode": "javascript", "codemirrorMode": "javascript",
"color": "#292929",
"extensions": [ "extensions": [
".json", ".json",
".4DForm",
".4DProject",
".avsc", ".avsc",
".geojson", ".geojson",
".gltf", ".gltf",
@@ -474,8 +482,11 @@ exports[`CLI --support-info (stdout) 1`] = `
], ],
"filenames": [ "filenames": [
".arcconfig", ".arcconfig",
".auto-changelog",
".c8rc",
".htmlhintrc", ".htmlhintrc",
".imgbotconfig", ".imgbotconfig",
".nycrc",
".tern-config", ".tern-config",
".tern-project", ".tern-project",
".watchmanconfig", ".watchmanconfig",
@@ -496,8 +507,10 @@ exports[`CLI --support-info (stdout) 1`] = `
"aliases": ["jsonc"], "aliases": ["jsonc"],
"codemirrorMimeType": "text/javascript", "codemirrorMimeType": "text/javascript",
"codemirrorMode": "javascript", "codemirrorMode": "javascript",
"color": "#292929",
"extensions": [ "extensions": [
".jsonc", ".jsonc",
".code-snippets",
".sublime-build", ".sublime-build",
".sublime-commands", ".sublime-commands",
".sublime-completions", ".sublime-completions",
@@ -514,6 +527,7 @@ exports[`CLI --support-info (stdout) 1`] = `
], ],
"filenames": [ "filenames": [
".babelrc", ".babelrc",
".devcontainer.json",
".eslintrc.json", ".eslintrc.json",
".jscsrc", ".jscsrc",
".jshintrc", ".jshintrc",
@@ -538,8 +552,10 @@ exports[`CLI --support-info (stdout) 1`] = `
}, },
{ {
"aceMode": "json", "aceMode": "json",
"aliases": ["geojson", "jsonl", "topojson"],
"codemirrorMimeType": "application/json", "codemirrorMimeType": "application/json",
"codemirrorMode": "javascript", "codemirrorMode": "javascript",
"color": "#292929",
"extensions": [".importmap"], "extensions": [".importmap"],
"filenames": ["package.json", "package-lock.json", "composer.json"], "filenames": ["package.json", "package-lock.json", "composer.json"],
"linguistLanguageId": 174, "linguistLanguageId": 174,
@@ -554,6 +570,7 @@ exports[`CLI --support-info (stdout) 1`] = `
"aceMode": "javascript", "aceMode": "javascript",
"codemirrorMimeType": "application/json", "codemirrorMimeType": "application/json",
"codemirrorMode": "javascript", "codemirrorMode": "javascript",
"color": "#267CB9",
"extensions": [".json5"], "extensions": [".json5"],
"linguistLanguageId": 175, "linguistLanguageId": 175,
"name": "JSON5", "name": "JSON5",
@@ -587,6 +604,7 @@ exports[`CLI --support-info (stdout) 1`] = `
}, },
{ {
"aceMode": "less", "aceMode": "less",
"aliases": ["less-css"],
"codemirrorMimeType": "text/css", "codemirrorMimeType": "text/css",
"codemirrorMode": "css", "codemirrorMode": "css",
"color": "#1d365d", "color": "#1d365d",
@@ -623,6 +641,7 @@ exports[`CLI --support-info (stdout) 1`] = `
"color": "#083fa1", "color": "#083fa1",
"extensions": [ "extensions": [
".md", ".md",
".livemd",
".markdown", ".markdown",
".mdown", ".mdown",
".mdwn", ".mdwn",
@@ -662,6 +681,7 @@ exports[`CLI --support-info (stdout) 1`] = `
}, },
{ {
"aceMode": "text", "aceMode": "text",
"color": "#dc3a0c",
"extensions": [".pcss", ".postcss"], "extensions": [".pcss", ".postcss"],
"group": "CSS", "group": "CSS",
"linguistLanguageId": 262764437, "linguistLanguageId": 262764437,
@@ -690,6 +710,7 @@ exports[`CLI --support-info (stdout) 1`] = `
"aceMode": "javascript", "aceMode": "javascript",
"codemirrorMimeType": "text/jsx", "codemirrorMimeType": "text/jsx",
"codemirrorMode": "jsx", "codemirrorMode": "jsx",
"color": "#3178c6",
"extensions": [".tsx"], "extensions": [".tsx"],
"group": "TypeScript", "group": "TypeScript",
"linguistLanguageId": 94901924, "linguistLanguageId": 94901924,
@@ -705,8 +726,8 @@ exports[`CLI --support-info (stdout) 1`] = `
"aliases": ["ts"], "aliases": ["ts"],
"codemirrorMimeType": "application/typescript", "codemirrorMimeType": "application/typescript",
"codemirrorMode": "javascript", "codemirrorMode": "javascript",
"color": "#2b7489", "color": "#3178c6",
"extensions": [".ts", ".mts", ".cts"], "extensions": [".ts", ".cts", ".mts"],
"interpreters": ["deno", "ts-node"], "interpreters": ["deno", "ts-node"],
"linguistLanguageId": 378, "linguistLanguageId": 378,
"name": "TypeScript", "name": "TypeScript",
@@ -750,6 +771,7 @@ exports[`CLI --support-info (stdout) 1`] = `
".clang-format", ".clang-format",
".clang-tidy", ".clang-tidy",
".gemrc", ".gemrc",
"CITATION.cff",
"glide.lock", "glide.lock",
".prettierrc", ".prettierrc",
".stylelintrc" ".stylelintrc"
+6 -9
View File
@@ -1,14 +1,11 @@
"use strict"; import path from "node:path";
import { promises as fs } from "node:fs";
const path = require("path"); import { fileURLToPath } from "node:url";
const { promises: fs } = require("fs"); import rimraf from "rimraf";
const rimraf = require("rimraf"); import stripAnsi from "strip-ansi";
const { default: stripAnsi } = require("../../../vendors/strip-ansi.js");
const runPrettier = require("../run-prettier.js");
function resolveDir(dir) { function resolveDir(dir) {
return path.join(__dirname, "..", dir); return fileURLToPath(new URL(`../${dir}/`, import.meta.url));
} }
describe("--cache option", () => { describe("--cache option", () => {
-3
View File
@@ -1,3 +0,0 @@
// This file is generated automatically.
export {default} from "sdbm";
export * from "sdbm";
-35
View File
@@ -1,35 +0,0 @@
// @ts-nocheck
// This file is generated automatically
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// node_modules/sdbm/index.js
var sdbm_exports = {};
__export(sdbm_exports, {
default: () => sdbm
});
module.exports = __toCommonJS(sdbm_exports);
function sdbm(string) {
let hash = 0;
for (let i = 0; i < string.length; i++) {
hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
}
return hash >>> 0;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {});