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",
"neovim",
"nicolo",
"nocheck",
"nnoremap",
"nocheck",
"nonenumerable",
"Nonspacing",
"noopener",
@@ -271,9 +271,9 @@
"Pschera",
"quasis",
"Raghuvir",
"raquo",
"Rasmus",
"Rattray",
"raquo",
"rattrayalex",
"readline",
"readlines",
@@ -283,6 +283,7 @@
"refmt",
"regexes",
"Reimplement",
"require",
"rhengles",
"ribaudo",
"Roadmap",
@@ -292,8 +293,8 @@
"sandhose",
"Sapegin",
"sbdchd",
"sdbm",
"scandir",
"sdbm",
"Serializers",
"setlocal",
"setq",
+1 -1
View File
@@ -1,6 +1,6 @@
import path from "node:path";
import fastGlob from "fast-glob";
import {statSafe} from "./utils.js"
import { statSafe } from "./utils.js";
/** @typedef {import('./context').Context} Context */
+4 -6
View File
@@ -1,8 +1,6 @@
"use strict";
const os = require("os");
const path = require("path");
const findCacheDir = require("find-cache-dir");
import os from "node:os";
import path from "node:path";
import findCacheDir from "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;
}
module.exports = findCacheFile;
export default findCacheFile;
+5 -8
View File
@@ -1,13 +1,10 @@
"use strict";
// Inspired by LintResultsCache from ESLint
// https://github.com/eslint/eslint/blob/c2d0a830754b6099a3325e6d3348c3ba983a677a/lib/cli-engine/lint-result-cache.js
const fileEntryCache = require("file-entry-cache");
const stringify = require("fast-json-stable-stringify");
// eslint-disable-next-line no-restricted-modules
const { version: prettierVersion } = require("../index.js");
const { createHash } = require("./utils.js");
import fileEntryCache from "file-entry-cache";
import stringify from "fast-json-stable-stringify";
import { version as prettierVersion } from "../index.js";
import { createHash } from "./utils.js";
const optionsHashCache = new WeakMap();
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;
try {
<<<<<<< HEAD
result = await format(context, input, options);
=======
if (isCacheExists) {
result = { formatted: input };
} else {
result = format(context, input, options);
result = await format(context, input, options);
}
>>>>>>> main
output = result.formatted;
} catch (error) {
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";
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
const printToScreen = console.log.bind(console);
@@ -77,5 +74,6 @@ export {
printToScreen,
groupBy,
pick,
createHash, statSafe
createHash,
statSafe,
};
+1 -1
View File
@@ -60,7 +60,7 @@ const languages = [
codemirrorMimeType: "text/jsx",
color: undefined,
})),
createLanguage(linguistLanguages.TypeScript, (data) => ({
createLanguage(linguistLanguages.TypeScript, () => ({
since: "1.4.0",
parsers: ["typescript", "babel-ts"],
vscodeLanguageIds: ["typescript"],
@@ -1,5 +1,4 @@
"use strict";
const createError = require("../../../common/parser-create-error.js");
import createError from "../../../common/parser-create-error.js";
function throwSyntaxError(node, message) {
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",
"extensions": [
".html",
".hta",
".htm",
".html.hl",
".inc",
@@ -406,10 +407,13 @@ exports[`CLI --support-info (stdout) 1`] = `
".frag",
".gs",
".jake",
".javascript",
".jsb",
".jscad",
".jsfl",
".jslib",
".jsm",
".jspre",
".jss",
".mjs",
".njs",
@@ -453,10 +457,14 @@ exports[`CLI --support-info (stdout) 1`] = `
},
{
"aceMode": "json",
"aliases": ["geojson", "jsonl", "topojson"],
"codemirrorMimeType": "application/json",
"codemirrorMode": "javascript",
"color": "#292929",
"extensions": [
".json",
".4DForm",
".4DProject",
".avsc",
".geojson",
".gltf",
@@ -474,8 +482,11 @@ exports[`CLI --support-info (stdout) 1`] = `
],
"filenames": [
".arcconfig",
".auto-changelog",
".c8rc",
".htmlhintrc",
".imgbotconfig",
".nycrc",
".tern-config",
".tern-project",
".watchmanconfig",
@@ -496,8 +507,10 @@ exports[`CLI --support-info (stdout) 1`] = `
"aliases": ["jsonc"],
"codemirrorMimeType": "text/javascript",
"codemirrorMode": "javascript",
"color": "#292929",
"extensions": [
".jsonc",
".code-snippets",
".sublime-build",
".sublime-commands",
".sublime-completions",
@@ -514,6 +527,7 @@ exports[`CLI --support-info (stdout) 1`] = `
],
"filenames": [
".babelrc",
".devcontainer.json",
".eslintrc.json",
".jscsrc",
".jshintrc",
@@ -538,8 +552,10 @@ exports[`CLI --support-info (stdout) 1`] = `
},
{
"aceMode": "json",
"aliases": ["geojson", "jsonl", "topojson"],
"codemirrorMimeType": "application/json",
"codemirrorMode": "javascript",
"color": "#292929",
"extensions": [".importmap"],
"filenames": ["package.json", "package-lock.json", "composer.json"],
"linguistLanguageId": 174,
@@ -554,6 +570,7 @@ exports[`CLI --support-info (stdout) 1`] = `
"aceMode": "javascript",
"codemirrorMimeType": "application/json",
"codemirrorMode": "javascript",
"color": "#267CB9",
"extensions": [".json5"],
"linguistLanguageId": 175,
"name": "JSON5",
@@ -587,6 +604,7 @@ exports[`CLI --support-info (stdout) 1`] = `
},
{
"aceMode": "less",
"aliases": ["less-css"],
"codemirrorMimeType": "text/css",
"codemirrorMode": "css",
"color": "#1d365d",
@@ -623,6 +641,7 @@ exports[`CLI --support-info (stdout) 1`] = `
"color": "#083fa1",
"extensions": [
".md",
".livemd",
".markdown",
".mdown",
".mdwn",
@@ -662,6 +681,7 @@ exports[`CLI --support-info (stdout) 1`] = `
},
{
"aceMode": "text",
"color": "#dc3a0c",
"extensions": [".pcss", ".postcss"],
"group": "CSS",
"linguistLanguageId": 262764437,
@@ -690,6 +710,7 @@ exports[`CLI --support-info (stdout) 1`] = `
"aceMode": "javascript",
"codemirrorMimeType": "text/jsx",
"codemirrorMode": "jsx",
"color": "#3178c6",
"extensions": [".tsx"],
"group": "TypeScript",
"linguistLanguageId": 94901924,
@@ -705,8 +726,8 @@ exports[`CLI --support-info (stdout) 1`] = `
"aliases": ["ts"],
"codemirrorMimeType": "application/typescript",
"codemirrorMode": "javascript",
"color": "#2b7489",
"extensions": [".ts", ".mts", ".cts"],
"color": "#3178c6",
"extensions": [".ts", ".cts", ".mts"],
"interpreters": ["deno", "ts-node"],
"linguistLanguageId": 378,
"name": "TypeScript",
@@ -750,6 +771,7 @@ exports[`CLI --support-info (stdout) 1`] = `
".clang-format",
".clang-tidy",
".gemrc",
"CITATION.cff",
"glide.lock",
".prettierrc",
".stylelintrc"
+6 -9
View File
@@ -1,14 +1,11 @@
"use strict";
const path = require("path");
const { promises: fs } = require("fs");
const rimraf = require("rimraf");
const { default: stripAnsi } = require("../../../vendors/strip-ansi.js");
const runPrettier = require("../run-prettier.js");
import path from "node:path";
import { promises as fs } from "node:fs";
import { fileURLToPath } from "node:url";
import rimraf from "rimraf";
import stripAnsi from "strip-ansi";
function resolveDir(dir) {
return path.join(__dirname, "..", dir);
return fileURLToPath(new URL(`../${dir}/`, import.meta.url));
}
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 = {});