sosukesuzuki / prettier-regression-testing

Automates the prettier/prettier regression checks with GitHub Actions.
1 stars 0 forks source link

test #2

Open sosukesuzuki opened 3 years ago

sosukesuzuki commented 3 years ago

run #8300

github-actions[bot] commented 3 years ago

prettier/prettier#8300 VS prettier/prettier@main :: babel/babel@2ae19d01b132f5222e1d5bee2c83921e2f107d70

Diff (379 lines) ```diff diff --git ORI/babel/packages/babel-cli/src/babel/util.js ALT/babel/packages/babel-cli/src/babel/util.js index 70d2c6b48..99e2534aa 100644 --- ORI/babel/packages/babel-cli/src/babel/util.js +++ ALT/babel/packages/babel-cli/src/babel/util.js @@ -21,15 +21,19 @@ export function readdir( includeDotfiles: boolean, filter?: ReaddirFilter, ): Array { - return readdirRecursive(dirname, (filename, _index, currentDirectory) => { - const stat = fs.statSync(path.join(currentDirectory, filename)); - - if (stat.isDirectory()) return true; - - return ( - (includeDotfiles || filename[0] !== ".") && (!filter || filter(filename)) - ); - }); + return readdirRecursive( + dirname, + (filename, _index, currentDirectory) => { + const stat = fs.statSync(path.join(currentDirectory, filename)); + + if (stat.isDirectory()) return true; + + return ( + (includeDotfiles || filename[0] !== ".") && + (!filter || filter(filename)) + ); + }, + ); } export function readdirForCompilable( @@ -37,9 +41,13 @@ export function readdirForCompilable( includeDotfiles: boolean, altExts?: Array, ): Array { - return readdir(dirname, includeDotfiles, function (filename) { - return isCompilableExtension(filename, altExts); - }); + return readdir( + dirname, + includeDotfiles, + function (filename) { + return isCompilableExtension(filename, altExts); + }, + ); } /** diff --git ORI/babel/packages/babel-core/src/config/caching.js ALT/babel/packages/babel-core/src/config/caching.js index 050c59d85..d60bc3874 100644 --- ORI/babel/packages/babel-core/src/config/caching.js +++ ALT/babel/packages/babel-core/src/config/caching.js @@ -128,9 +128,12 @@ function makeCachedFunction( // Flow refines handlerResult to Generator const gen = (handlerResult: Generator<*, ResultT, *>); - value = yield* onFirstPause(gen, () => { - finishLock = setupAsyncLocks(cache, futureCache, arg); - }); + value = yield* onFirstPause( + gen, + () => { + finishLock = setupAsyncLocks(cache, futureCache, arg); + }, + ); } else { // $FlowIgnore doesn't refine handlerResult to ResultT value = (handlerResult: ResultT); diff --git ORI/babel/packages/babel-core/src/config/full.js ALT/babel/packages/babel-core/src/config/full.js index 1e1855184..61576b81e 100644 --- ORI/babel/packages/babel-core/src/config/full.js +++ ALT/babel/packages/babel-core/src/config/full.js @@ -161,29 +161,32 @@ export default gensync<[any], ResolvedConfig | null>(function* loadFullConfig( const opts: Object = optionDefaults; mergeOptions(opts, options); - yield* enhanceError(context, function* loadPluginDescriptors() { - pluginDescriptorsByPass[0].unshift(...initialPluginsDescriptors); - - for (const descs of pluginDescriptorsByPass) { - const pass = []; - passes.push(pass); - - for (let i = 0; i < descs.length; i++) { - const descriptor: UnloadedDescriptor = descs[i]; - if (descriptor.options !== false) { - try { - pass.push(yield* loadPluginDescriptor(descriptor, pluginContext)); - } catch (e) { - if (e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") { - // print special message for `plugins: ["@babel/foo", { foo: "option" }]` - checkNoUnwrappedItemOptionPairs(descs, i, "plugin", e); + yield* enhanceError( + context, + function* loadPluginDescriptors() { + pluginDescriptorsByPass[0].unshift(...initialPluginsDescriptors); + + for (const descs of pluginDescriptorsByPass) { + const pass = []; + passes.push(pass); + + for (let i = 0; i < descs.length; i++) { + const descriptor: UnloadedDescriptor = descs[i]; + if (descriptor.options !== false) { + try { + pass.push(yield* loadPluginDescriptor(descriptor, pluginContext)); + } catch (e) { + if (e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") { + // print special message for `plugins: ["@babel/foo", { foo: "option" }]` + checkNoUnwrappedItemOptionPairs(descs, i, "plugin", e); + } + throw e; } - throw e; } } } - } - })(); + }, + )(); opts.plugins = passes[0]; opts.presets = passes @@ -324,10 +327,13 @@ const instantiatePlugin = makeWeakCache(function* ( dirname, }; - const inherits = yield* forwardAsync(loadPluginDescriptor, run => { - // If the inherited plugin changes, reinstantiate this plugin. - return cache.invalidate(data => run(inheritsDescriptor, data)); - }); + const inherits = yield* forwardAsync( + loadPluginDescriptor, + run => { + // If the inherited plugin changes, reinstantiate this plugin. + return cache.invalidate(data => run(inheritsDescriptor, data)); + }, + ); plugin.pre = chain(inherits.pre, plugin.pre); plugin.post = chain(inherits.post, plugin.post); diff --git ORI/babel/packages/babel-core/src/transformation/block-hoist-plugin.js ALT/babel/packages/babel-core/src/transformation/block-hoist-plugin.js index 477d2d5c3..5901aaf22 100644 --- ORI/babel/packages/babel-core/src/transformation/block-hoist-plugin.js +++ ALT/babel/packages/babel-core/src/transformation/block-hoist-plugin.js @@ -51,14 +51,17 @@ const blockHoistPlugin = { } if (!hasChange) return; - node.body = sortBy(node.body, function (bodyNode) { - let priority = bodyNode?._blockHoist; - if (priority == null) priority = 1; - if (priority === true) priority = 2; + node.body = sortBy( + node.body, + function (bodyNode) { + let priority = bodyNode?._blockHoist; + if (priority == null) priority = 1; + if (priority === true) priority = 2; - // Higher priorities should move toward the top. - return -1 * priority; - }); + // Higher priorities should move toward the top. + return -1 * priority; + }, + ); }, }, }, diff --git ORI/babel/packages/babel-core/src/transformation/file/merge-map.js ALT/babel/packages/babel-core/src/transformation/file/merge-map.js index 911867d96..02825f678 100644 --- ORI/babel/packages/babel-core/src/transformation/file/merge-map.js +++ ALT/babel/packages/babel-core/src/transformation/file/merge-map.js @@ -123,15 +123,18 @@ function filterApplicableOriginalRanges( ): OriginalMappings { // The mapping array is sorted by original location, so we can // binary-search it for the overlapping ranges. - return filterSortedArray(mappings, ({ original: outOriginal }) => { - if (line > outOriginal.line) return -1; - if (line < outOriginal.line) return 1; + return filterSortedArray( + mappings, + ({ original: outOriginal }) => { + if (line > outOriginal.line) return -1; + if (line < outOriginal.line) return 1; - if (columnStart >= outOriginal.columnEnd) return -1; - if (columnEnd <= outOriginal.columnStart) return 1; + if (columnStart >= outOriginal.columnEnd) return -1; + if (columnEnd <= outOriginal.columnStart) return 1; - return 0; - }); + return 0; + }, + ); } function eachInputGeneratedRange( diff --git ORI/babel/packages/babel-core/test/api.js ALT/babel/packages/babel-core/test/api.js index a180d707c..aae3c02df 100644 --- ORI/babel/packages/babel-core/test/api.js +++ ALT/babel/packages/babel-core/test/api.js @@ -429,24 +429,36 @@ describe("api", function () { // Writes value properly. expect( - doTransform("", file => { - file.shebang = "env node"; - }), + doTransform( + "", + file => { + file.shebang = "env node"; + }, + ), ).toBe(`#!env node`); expect( - doTransform("#!env node", file => { - file.shebang = "env node2"; - }), + doTransform( + "#!env node", + file => { + file.shebang = "env node2"; + }, + ), ).toBe(`#!env node2`); expect( - doTransform("", file => { - file.shebang = ""; - }), + doTransform( + "", + file => { + file.shebang = ""; + }, + ), ).toBe(``); expect( - doTransform("#!env node", file => { - file.shebang = ""; - }), + doTransform( + "#!env node", + file => { + file.shebang = ""; + }, + ), ).toBe(``); // Reads value properly. @@ -459,14 +471,17 @@ describe("api", function () { // Reads and writes properly. expect( - doTransform("#!env node", file => { - expect(file.shebang).toBe("env node"); + doTransform( + "#!env node", + file => { + expect(file.shebang).toBe("env node"); - file.shebang = "env node2"; - expect(file.shebang).toBe("env node2"); + file.shebang = "env node2"; + expect(file.shebang).toBe("env node2"); - file.shebang = "env node3"; - }), + file.shebang = "env node3"; + }, + ), ).toBe(`#!env node3`); }); diff --git ORI/babel/packages/babel-helper-module-imports/test/index.js ALT/babel/packages/babel-helper-module-imports/test/index.js index c1ef591d8..087919b90 100644 --- ORI/babel/packages/babel-helper-module-imports/test/index.js +++ ALT/babel/packages/babel-helper-module-imports/test/index.js @@ -28,11 +28,13 @@ function test(sourceType, opts, initializer, inputCode, expectedCode) { function ({ types: t }) { return { pre(file) { - file.set("helperGenerator", name => - t.memberExpression( - t.identifier("babelHelpers"), - t.identifier(name), - ), + file.set( + "helperGenerator", + name => + t.memberExpression( + t.identifier("babelHelpers"), + t.identifier(name), + ), ); }, visitor: { @@ -1138,8 +1140,9 @@ describe("@babel/helper-module-imports", () => { it("is disallowed in CJS modules", () => { expect(() => - testScript({ importPosition: "after" }, m => - m.addNamed("read", "source"), + testScript( + { importPosition: "after" }, + m => m.addNamed("read", "source"), ), ).toThrow(`"importPosition": "after" is only supported in modules`); }); diff --git ORI/babel/packages/babel-parser/src/plugins/flow/index.js ALT/babel/packages/babel-parser/src/plugins/flow/index.js index 9dfa320ec..e6808df0a 100644 --- ORI/babel/packages/babel-parser/src/plugins/flow/index.js +++ ALT/babel/packages/babel-parser/src/plugins/flow/index.js @@ -1760,8 +1760,9 @@ export default (superClass: Class): Class => isMethod?: boolean = false, ): void { if (allowExpressionBody) { - return this.forwardNoArrowParamsConversionAt(node, () => - super.parseFunctionBody(node, true, isMethod), + return this.forwardNoArrowParamsConversionAt( + node, + () => super.parseFunctionBody(node, true, isMethod), ); } @@ -1952,8 +1953,9 @@ export default (superClass: Class): Class => node.test = expr; node.consequent = consequent; - node.alternate = this.forwardNoArrowParamsConversionAt(node, () => - this.parseMaybeAssign(undefined, undefined, undefined), + node.alternate = this.forwardNoArrowParamsConversionAt( + node, + () => this.parseMaybeAssign(undefined, undefined, undefined), ); return this.finishNode(node, "ConditionalExpression"); @@ -2008,8 +2010,9 @@ export default (superClass: Class): Class => return [arrows, []]; } - return partition(arrows, node => - node.params.every(param => this.isAssignable(param, true)), + return partition( + arrows, + node => node.params.every(param => this.isAssignable(param, true)), ); } diff --git ORI/babel/packages/babel-plugin-proposal-record-and-tuple/src/index.js ALT/babel/packages/babel-plugin-proposal-record-and-tuple/src/index.js index 0a63de2e3..96bea5e12 100644 --- ORI/babel/packages/babel-plugin-proposal-record-and-tuple/src/index.js +++ ALT/babel/packages/babel-plugin-proposal-record-and-tuple/src/index.js @@ -54,11 +54,15 @@ export default declare((api, options) => { const cacheKey = `${name}:${isModule(programPath)}`; const cache = getOr(importCaches, programPath.node, () => new Map()); - const localBindingName = getOr(cache, cacheKey, () => { - return addNamed(programPath, name, polyfillModuleName, { - importedInterop: "uncompiled", - }).name; - }); + const localBindingName = getOr( + cache, + cacheKey, + () => { + return addNamed(programPath, name, polyfillModuleName, { + importedInterop: "uncompiled", + }).name; + }, + ); return t.identifier(localBindingName); } ```
github-actions[bot] commented 3 years ago

prettier/prettier#8300 VS prettier/prettier@main :: vuejs/eslint-plugin-vue@62f577dcfcb859c24c6e0d4615ad880f5e1d4688

Diff (70 lines) ```diff diff --git ORI/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js ALT/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js index d215a27..1ab212c 100644 --- ORI/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js +++ ALT/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js @@ -57,9 +57,11 @@ module.exports = { let eslintScope try { - eslintScope = getESLintModule('eslint-scope', () => - // @ts-ignore - require('eslint-scope') + eslintScope = getESLintModule( + 'eslint-scope', + () => + // @ts-ignore + require('eslint-scope') ) } catch (_e) { context.report({ @@ -70,9 +72,11 @@ module.exports = { } let espree try { - espree = getESLintModule('espree', () => - // @ts-ignore - require('espree') + espree = getESLintModule( + 'espree', + () => + // @ts-ignore + require('espree') ) } catch (_e) { context.report({ diff --git ORI/eslint-plugin-vue/lib/rules/no-unused-properties.js ALT/eslint-plugin-vue/lib/rules/no-unused-properties.js index be18224..41af202 100644 --- ORI/eslint-plugin-vue/lib/rules/no-unused-properties.js +++ ALT/eslint-plugin-vue/lib/rules/no-unused-properties.js @@ -381,8 +381,9 @@ function extractPatternOrThisProperties(node, context, withInTemplate) { // `arg.foo` const name = utils.getStaticPropertyName(parent) if (name) { - result.addUsed(name, () => - extractPatternOrThisProperties(parent, context, withInTemplate) + result.addUsed( + name, + () => extractPatternOrThisProperties(parent, context, withInTemplate) ) } else { result.unknown = true diff --git ORI/eslint-plugin-vue/tests/lib/utils/html-comments.js ALT/eslint-plugin-vue/tests/lib/utils/html-comments.js index 066c73e..6a0297e 100644 --- ORI/eslint-plugin-vue/tests/lib/utils/html-comments.js +++ ALT/eslint-plugin-vue/tests/lib/utils/html-comments.js @@ -37,10 +37,12 @@ function tokenize(code, option) { const linter = new Linter() const result = [] - linter.defineRule('vue/html-comments-test', (content) => - htmlComments.defineVisitor(content, option, (commentTokens) => { - result.push(commentTokens) - }) + linter.defineRule( + 'vue/html-comments-test', + (content) => + htmlComments.defineVisitor(content, option, (commentTokens) => { + result.push(commentTokens) + }) ) linter.defineParser('vue-eslint-parser', require('vue-eslint-parser')) linter.verify( ```
github-actions[bot] commented 3 years ago

prettier/prettier#8300 VS prettier/prettier@main :: excalidraw/excalidraw@25fd27515866b5704066d9301dd641c481f6c38c

Diff (355 lines) ```diff diff --git ORI/excalidraw/src/actions/actionProperties.tsx ALT/excalidraw/src/actions/actionProperties.tsx index 07072bae..f5175603 100644 --- ORI/excalidraw/src/actions/actionProperties.tsx +++ ALT/excalidraw/src/actions/actionProperties.tsx @@ -99,10 +99,13 @@ export const actionChangeStrokeColor = register({ name: "changeStrokeColor", perform: (elements, appState, value) => { return { - elements: changeProperty(elements, appState, (el) => - newElementWith(el, { - strokeColor: value, - }), + elements: changeProperty( + elements, + appState, + (el) => + newElementWith(el, { + strokeColor: value, + }), ), appState: { ...appState, currentItemStrokeColor: value }, commitToHistory: true, @@ -130,10 +133,13 @@ export const actionChangeBackgroundColor = register({ name: "changeBackgroundColor", perform: (elements, appState, value) => { return { - elements: changeProperty(elements, appState, (el) => - newElementWith(el, { - backgroundColor: value, - }), + elements: changeProperty( + elements, + appState, + (el) => + newElementWith(el, { + backgroundColor: value, + }), ), appState: { ...appState, currentItemBackgroundColor: value }, commitToHistory: true, @@ -161,10 +167,13 @@ export const actionChangeFillStyle = register({ name: "changeFillStyle", perform: (elements, appState, value) => { return { - elements: changeProperty(elements, appState, (el) => - newElementWith(el, { - fillStyle: value, - }), + elements: changeProperty( + elements, + appState, + (el) => + newElementWith(el, { + fillStyle: value, + }), ), appState: { ...appState, currentItemFillStyle: value }, commitToHistory: true, @@ -210,10 +219,13 @@ export const actionChangeStrokeWidth = register({ name: "changeStrokeWidth", perform: (elements, appState, value) => { return { - elements: changeProperty(elements, appState, (el) => - newElementWith(el, { - strokeWidth: value, - }), + elements: changeProperty( + elements, + appState, + (el) => + newElementWith(el, { + strokeWidth: value, + }), ), appState: { ...appState, currentItemStrokeWidth: value }, commitToHistory: true, @@ -257,11 +269,14 @@ export const actionChangeSloppiness = register({ name: "changeSloppiness", perform: (elements, appState, value) => { return { - elements: changeProperty(elements, appState, (el) => - newElementWith(el, { - seed: randomInteger(), - roughness: value, - }), + elements: changeProperty( + elements, + appState, + (el) => + newElementWith(el, { + seed: randomInteger(), + roughness: value, + }), ), appState: { ...appState, currentItemRoughness: value }, commitToHistory: true, @@ -305,10 +320,13 @@ export const actionChangeStrokeStyle = register({ name: "changeStrokeStyle", perform: (elements, appState, value) => { return { - elements: changeProperty(elements, appState, (el) => - newElementWith(el, { - strokeStyle: value, - }), + elements: changeProperty( + elements, + appState, + (el) => + newElementWith(el, { + strokeStyle: value, + }), ), appState: { ...appState, currentItemStrokeStyle: value }, commitToHistory: true, @@ -352,10 +370,13 @@ export const actionChangeOpacity = register({ name: "changeOpacity", perform: (elements, appState, value) => { return { - elements: changeProperty(elements, appState, (el) => - newElementWith(el, { - opacity: value, - }), + elements: changeProperty( + elements, + appState, + (el) => + newElementWith(el, { + opacity: value, + }), ), appState: { ...appState, currentItemOpacity: value }, commitToHistory: true, @@ -401,17 +422,21 @@ export const actionChangeFontSize = register({ name: "changeFontSize", perform: (elements, appState, value) => { return { - elements: changeProperty(elements, appState, (el) => { - if (isTextElement(el)) { - const element: ExcalidrawTextElement = newElementWith(el, { - fontSize: value, - }); - redrawTextBoundingBox(element); - return element; - } + elements: changeProperty( + elements, + appState, + (el) => { + if (isTextElement(el)) { + const element: ExcalidrawTextElement = newElementWith(el, { + fontSize: value, + }); + redrawTextBoundingBox(element); + return element; + } - return el; - }), + return el; + }, + ), appState: { ...appState, currentItemFontSize: value, @@ -462,17 +487,21 @@ export const actionChangeFontFamily = register({ name: "changeFontFamily", perform: (elements, appState, value) => { return { - elements: changeProperty(elements, appState, (el) => { - if (isTextElement(el)) { - const element: ExcalidrawTextElement = newElementWith(el, { - fontFamily: value, - }); - redrawTextBoundingBox(element); - return element; - } + elements: changeProperty( + elements, + appState, + (el) => { + if (isTextElement(el)) { + const element: ExcalidrawTextElement = newElementWith(el, { + fontFamily: value, + }); + redrawTextBoundingBox(element); + return element; + } - return el; - }), + return el; + }, + ), appState: { ...appState, currentItemFontFamily: value, @@ -522,17 +551,21 @@ export const actionChangeTextAlign = register({ name: "changeTextAlign", perform: (elements, appState, value) => { return { - elements: changeProperty(elements, appState, (el) => { - if (isTextElement(el)) { - const element: ExcalidrawTextElement = newElementWith(el, { - textAlign: value, - }); - redrawTextBoundingBox(element); - return element; - } + elements: changeProperty( + elements, + appState, + (el) => { + if (isTextElement(el)) { + const element: ExcalidrawTextElement = newElementWith(el, { + textAlign: value, + }); + redrawTextBoundingBox(element); + return element; + } - return el; - }), + return el; + }, + ), appState: { ...appState, currentItemTextAlign: value, @@ -588,10 +621,13 @@ export const actionChangeSharpness = register({ ? targetElements.every(isLinearElement) : isLinearElementType(appState.elementType); return { - elements: changeProperty(elements, appState, (el) => - newElementWith(el, { - strokeSharpness: value, - }), + elements: changeProperty( + elements, + appState, + (el) => + newElementWith(el, { + strokeSharpness: value, + }), ), appState: { ...appState, @@ -646,25 +682,29 @@ export const actionChangeArrowhead = register({ value: { position: "start" | "end"; type: Arrowhead }, ) => { return { - elements: changeProperty(elements, appState, (el) => { - if (isLinearElement(el)) { - const { position, type } = value; + elements: changeProperty( + elements, + appState, + (el) => { + if (isLinearElement(el)) { + const { position, type } = value; - if (position === "start") { - const element: ExcalidrawLinearElement = newElementWith(el, { - startArrowhead: type, - }); - return element; - } else if (position === "end") { - const element: ExcalidrawLinearElement = newElementWith(el, { - endArrowhead: type, - }); - return element; + if (position === "start") { + const element: ExcalidrawLinearElement = newElementWith(el, { + startArrowhead: type, + }); + return element; + } else if (position === "end") { + const element: ExcalidrawLinearElement = newElementWith(el, { + endArrowhead: type, + }); + return element; + } } - } - return el; - }), + return el; + }, + ), appState: { ...appState, [value.position === "start" diff --git ORI/excalidraw/src/components/App.tsx ALT/excalidraw/src/components/App.tsx index 79214807..023fa883 100644 --- ORI/excalidraw/src/components/App.tsx +++ ALT/excalidraw/src/components/App.tsx @@ -1746,8 +1746,9 @@ class App extends React.Component { x: number, y: number, ): NonDeleted[] { - return getElementsAtPosition(this.scene.getElements(), (element) => - hitTest(element, this.state, x, y), + return getElementsAtPosition( + this.scene.getElements(), + (element) => hitTest(element, this.state, x, y), ); } diff --git ORI/excalidraw/src/components/LayerUI.tsx ALT/excalidraw/src/components/LayerUI.tsx index 41c8aa2c..89367765 100644 --- ORI/excalidraw/src/components/LayerUI.tsx +++ ALT/excalidraw/src/components/LayerUI.tsx @@ -358,24 +358,25 @@ const LayerUI = ({ ); const renderExportDialog = () => { - const createExporter = - (type: ExportType): ExportCB => - async (exportedElements, scale) => { - if (canvas) { - await exportCanvas(type, exportedElements, appState, canvas, { - exportBackground: appState.exportBackground, - name: appState.name, - viewBackgroundColor: appState.viewBackgroundColor, - scale, - shouldAddWatermark: appState.shouldAddWatermark, - }) - .catch(muteFSAbortError) - .catch((error) => { - console.error(error); - setAppState({ errorMessage: error.message }); - }); - } - }; + const createExporter = (type: ExportType): ExportCB => async ( + exportedElements, + scale, + ) => { + if (canvas) { + await exportCanvas(type, exportedElements, appState, canvas, { + exportBackground: appState.exportBackground, + name: appState.name, + viewBackgroundColor: appState.viewBackgroundColor, + scale, + shouldAddWatermark: appState.shouldAddWatermark, + }) + .catch(muteFSAbortError) + .catch((error) => { + console.error(error); + setAppState({ errorMessage: error.message }); + }); + } + }; return (
github-actions[bot] commented 3 years ago

prettier/prettier#8300 VS prettier/prettier@main :: prettier/prettier@5f8bad8275a589ec903bddeacd484123c7db54ab

Diff (1413 lines) ```diff diff --git ORI/prettier/scripts/release/steps/update-dependents-count.js ALT/prettier/scripts/release/steps/update-dependents-count.js index b8e717537..066fa9ffc 100644 --- ORI/prettier/scripts/release/steps/update-dependents-count.js +++ ALT/prettier/scripts/release/steps/update-dependents-count.js @@ -41,16 +41,18 @@ async function update() { ); } - processFile("website/pages/en/index.js", (content) => - content - .replace( - /()(.*?)(<\/strong>)/, - `$1${formatNumber(dependentsCountNpm)}$3` - ) - .replace( - /()(.*?)(<\/strong>)/, - `$1${formatNumber(dependentsCountGithub)}$3` - ) + processFile( + "website/pages/en/index.js", + (content) => + content + .replace( + /()(.*?)(<\/strong>)/, + `$1${formatNumber(dependentsCountNpm)}$3` + ) + .replace( + /()(.*?)(<\/strong>)/, + `$1${formatNumber(dependentsCountGithub)}$3` + ) ); const isUpdated = await logPromise( diff --git ORI/prettier/scripts/release/steps/update-version.js ALT/prettier/scripts/release/steps/update-version.js index 081820765..cdf24f1a4 100644 --- ORI/prettier/scripts/release/steps/update-version.js +++ ALT/prettier/scripts/release/steps/update-version.js @@ -9,19 +9,25 @@ async function bump({ version }) { await writeJson("package.json", pkg, { spaces: 2 }); // Update github issue templates - processFile(".github/ISSUE_TEMPLATE/formatting.md", (content) => - content.replace(/^(\*\*Prettier ).*?(\*\*)$/m, `$1${version}$2`) + processFile( + ".github/ISSUE_TEMPLATE/formatting.md", + (content) => + content.replace(/^(\*\*Prettier ).*?(\*\*)$/m, `$1${version}$2`) ); - processFile(".github/ISSUE_TEMPLATE/integration.md", (content) => - content.replace(/^(- Prettier Version: ).*?$/m, `$1${version}`) + processFile( + ".github/ISSUE_TEMPLATE/integration.md", + (content) => content.replace(/^(- Prettier Version: ).*?$/m, `$1${version}`) ); - processFile("docs/install.md", (content) => - content.replace(/^(npx prettier@)\S+/m, `$1${version}`) + processFile( + "docs/install.md", + (content) => content.replace(/^(npx prettier@)\S+/m, `$1${version}`) ); // Update unpkg link in docs - processFile("docs/browser.md", (content) => - content.replace(/(\/\/unpkg\.com\/prettier@).*?\//g, `$1${version}/`) + processFile( + "docs/browser.md", + (content) => + content.replace(/(\/\/unpkg\.com\/prettier@).*?\//g, `$1${version}/`) ); await execa("yarn", ["update-stable-docs"], { diff --git ORI/prettier/src/document/doc-utils.js ALT/prettier/src/document/doc-utils.js index 084844cf4..3c27fbf2c 100644 --- ORI/prettier/src/document/doc-utils.js +++ ALT/prettier/src/document/doc-utils.js @@ -346,25 +346,32 @@ function normalizeParts(parts) { } function normalizeDoc(doc) { - return mapDoc(doc, (currentDoc) => { - if (Array.isArray(currentDoc)) { - return normalizeParts(currentDoc); - } - if (!currentDoc.parts) { - return currentDoc; + return mapDoc( + doc, + (currentDoc) => { + if (Array.isArray(currentDoc)) { + return normalizeParts(currentDoc); + } + if (!currentDoc.parts) { + return currentDoc; + } + return { + ...currentDoc, + parts: normalizeParts(currentDoc.parts), + }; } - return { - ...currentDoc, - parts: normalizeParts(currentDoc.parts), - }; - }); + ); } function replaceNewlinesWithLiterallines(doc) { - return mapDoc(doc, (currentDoc) => - typeof currentDoc === "string" && currentDoc.includes("\n") - ? currentDoc.split(/(\n)/g).map((v, i) => (i % 2 === 0 ? v : literalline)) - : currentDoc + return mapDoc( + doc, + (currentDoc) => + typeof currentDoc === "string" && currentDoc.includes("\n") + ? currentDoc + .split(/(\n)/g) + .map((v, i) => (i % 2 === 0 ? v : literalline)) + : currentDoc ); } diff --git ORI/prettier/src/language-css/index.js ALT/prettier/src/language-css/index.js index c69c43461..1f881d51d 100644 --- ORI/prettier/src/language-css/index.js +++ ALT/prettier/src/language-css/index.js @@ -5,32 +5,44 @@ const printer = require("./printer-postcss"); const options = require("./options"); const languages = [ - createLanguage(require("linguist-languages/data/CSS.json"), (data) => ({ - since: "1.4.0", - parsers: ["css"], - vscodeLanguageIds: ["css"], - extensions: [ - ...data.extensions, - // `WeiXin Style Sheets`(Weixin Mini Programs) - // https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/ - ".wxss", - ], - })), - createLanguage(require("linguist-languages/data/PostCSS.json"), () => ({ - since: "1.4.0", - parsers: ["css"], - vscodeLanguageIds: ["postcss"], - })), - createLanguage(require("linguist-languages/data/Less.json"), () => ({ - since: "1.4.0", - parsers: ["less"], - vscodeLanguageIds: ["less"], - })), - createLanguage(require("linguist-languages/data/SCSS.json"), () => ({ - since: "1.4.0", - parsers: ["scss"], - vscodeLanguageIds: ["scss"], - })), + createLanguage( + require("linguist-languages/data/CSS.json"), + (data) => ({ + since: "1.4.0", + parsers: ["css"], + vscodeLanguageIds: ["css"], + extensions: [ + ...data.extensions, + // `WeiXin Style Sheets`(Weixin Mini Programs) + // https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/ + ".wxss", + ], + }) + ), + createLanguage( + require("linguist-languages/data/PostCSS.json"), + () => ({ + since: "1.4.0", + parsers: ["css"], + vscodeLanguageIds: ["postcss"], + }) + ), + createLanguage( + require("linguist-languages/data/Less.json"), + () => ({ + since: "1.4.0", + parsers: ["less"], + vscodeLanguageIds: ["less"], + }) + ), + createLanguage( + require("linguist-languages/data/SCSS.json"), + () => ({ + since: "1.4.0", + parsers: ["scss"], + vscodeLanguageIds: ["scss"], + }) + ), ]; const printers = { diff --git ORI/prettier/src/language-graphql/index.js ALT/prettier/src/language-graphql/index.js index b991a850f..c3f9a6367 100644 --- ORI/prettier/src/language-graphql/index.js +++ ALT/prettier/src/language-graphql/index.js @@ -5,11 +5,14 @@ const printer = require("./printer-graphql"); const options = require("./options"); const languages = [ - createLanguage(require("linguist-languages/data/GraphQL.json"), () => ({ - since: "1.5.0", - parsers: ["graphql"], - vscodeLanguageIds: ["graphql"], - })), + createLanguage( + require("linguist-languages/data/GraphQL.json"), + () => ({ + since: "1.5.0", + parsers: ["graphql"], + vscodeLanguageIds: ["graphql"], + }) + ), ]; const printers = { diff --git ORI/prettier/src/language-handlebars/index.js ALT/prettier/src/language-handlebars/index.js index 04ca83ed1..817c7d49e 100644 --- ORI/prettier/src/language-handlebars/index.js +++ ALT/prettier/src/language-handlebars/index.js @@ -4,11 +4,14 @@ const createLanguage = require("../utils/create-language"); const printer = require("./printer-glimmer"); const languages = [ - createLanguage(require("linguist-languages/data/Handlebars.json"), () => ({ - since: "2.3.0", - parsers: ["glimmer"], - vscodeLanguageIds: ["handlebars"], - })), + createLanguage( + require("linguist-languages/data/Handlebars.json"), + () => ({ + since: "2.3.0", + parsers: ["glimmer"], + vscodeLanguageIds: ["handlebars"], + }) + ), ]; const printers = { diff --git ORI/prettier/src/language-html/index.js ALT/prettier/src/language-html/index.js index 1caf94c65..20e9d77b6 100644 --- ORI/prettier/src/language-html/index.js +++ ALT/prettier/src/language-html/index.js @@ -5,36 +5,48 @@ const printer = require("./printer-html"); const options = require("./options"); const languages = [ - createLanguage(require("linguist-languages/data/HTML.json"), () => ({ - name: "Angular", - since: "1.15.0", - parsers: ["angular"], - vscodeLanguageIds: ["html"], - extensions: [".component.html"], - filenames: [], - })), - createLanguage(require("linguist-languages/data/HTML.json"), (data) => ({ - since: "1.15.0", - parsers: ["html"], - vscodeLanguageIds: ["html"], - extensions: [ - ...data.extensions, - ".mjml", // MJML is considered XML in Linguist but it should be formatted as HTML - ], - })), - createLanguage(require("linguist-languages/data/HTML.json"), () => ({ - name: "Lightning Web Components", - since: "1.17.0", - parsers: ["lwc"], - vscodeLanguageIds: ["html"], - extensions: [], - filenames: [], - })), - createLanguage(require("linguist-languages/data/Vue.json"), () => ({ - since: "1.10.0", - parsers: ["vue"], - vscodeLanguageIds: ["vue"], - })), + createLanguage( + require("linguist-languages/data/HTML.json"), + () => ({ + name: "Angular", + since: "1.15.0", + parsers: ["angular"], + vscodeLanguageIds: ["html"], + extensions: [".component.html"], + filenames: [], + }) + ), + createLanguage( + require("linguist-languages/data/HTML.json"), + (data) => ({ + since: "1.15.0", + parsers: ["html"], + vscodeLanguageIds: ["html"], + extensions: [ + ...data.extensions, + ".mjml", // MJML is considered XML in Linguist but it should be formatted as HTML + ], + }) + ), + createLanguage( + require("linguist-languages/data/HTML.json"), + () => ({ + name: "Lightning Web Components", + since: "1.17.0", + parsers: ["lwc"], + vscodeLanguageIds: ["html"], + extensions: [], + filenames: [], + }) + ), + createLanguage( + require("linguist-languages/data/Vue.json"), + () => ({ + since: "1.10.0", + parsers: ["vue"], + vscodeLanguageIds: ["vue"], + }) + ), ]; const printers = { diff --git ORI/prettier/src/language-html/printer-html.js ALT/prettier/src/language-html/printer-html.js index 553329d0f..fd64f25ea 100644 --- ORI/prettier/src/language-html/printer-html.js +++ ALT/prettier/src/language-html/printer-html.js @@ -203,8 +203,10 @@ function embed(path, print, textToDoc, options) { node.rawName, '="', group( - mapDoc(embeddedAttributeValueDoc, (doc) => - typeof doc === "string" ? doc.replace(/"/g, """) : doc + mapDoc( + embeddedAttributeValueDoc, + (doc) => + typeof doc === "string" ? doc.replace(/"/g, """) : doc ) ), '"', diff --git ORI/prettier/src/language-js/embed/css.js ALT/prettier/src/language-js/embed/css.js index 7ff50144c..15bf46eeb 100644 --- ORI/prettier/src/language-js/embed/css.js +++ ALT/prettier/src/language-js/embed/css.js @@ -57,23 +57,28 @@ function replacePlaceholders(quasisDoc, expressionDocs) { return quasisDoc; } let replaceCounter = 0; - const newDoc = mapDoc(cleanDoc(quasisDoc), (doc) => { - if (typeof doc !== "string" || !doc.includes("@prettier-placeholder")) { - return doc; - } - // When we have multiple placeholders in one line, like: - // ${Child}${Child2}:not(:first-child) - return doc.split(/@prettier-placeholder-(\d+)-id/).map((component, idx) => { - // The placeholder is always at odd indices - if (idx % 2 === 0) { - return replaceNewlinesWithLiterallines(component); + const newDoc = mapDoc( + cleanDoc(quasisDoc), + (doc) => { + if (typeof doc !== "string" || !doc.includes("@prettier-placeholder")) { + return doc; } + // When we have multiple placeholders in one line, like: + // ${Child}${Child2}:not(:first-child) + return doc + .split(/@prettier-placeholder-(\d+)-id/) + .map((component, idx) => { + // The placeholder is always at odd indices + if (idx % 2 === 0) { + return replaceNewlinesWithLiterallines(component); + } - // The component will always be a number at odd index - replaceCounter++; - return expressionDocs[component]; - }); - }); + // The component will always be a number at odd index + replaceCounter++; + return expressionDocs[component]; + }); + } + ); return expressionDocs.length === replaceCounter ? newDoc : null; } diff --git ORI/prettier/src/language-js/embed/html.js ALT/prettier/src/language-js/embed/html.js index 99f5d9bde..a123968b4 100644 --- ORI/prettier/src/language-js/embed/html.js +++ ALT/prettier/src/language-js/embed/html.js @@ -45,34 +45,37 @@ function format(path, print, textToDoc, options, { parser }) { { stripTrailingHardline: true } ); - const contentDoc = mapDoc(doc, (doc) => { - if (typeof doc !== "string") { - return doc; - } + const contentDoc = mapDoc( + doc, + (doc) => { + if (typeof doc !== "string") { + return doc; + } - const parts = []; + const parts = []; - const components = doc.split(placeholderRegex); - for (let i = 0; i < components.length; i++) { - let component = components[i]; + const components = doc.split(placeholderRegex); + for (let i = 0; i < components.length; i++) { + let component = components[i]; - if (i % 2 === 0) { - if (component) { - component = uncookTemplateElementValue(component); - if (options.__embeddedInHtml) { - component = component.replace(/<\/(script)\b/gi, "<\\/$1"); + if (i % 2 === 0) { + if (component) { + component = uncookTemplateElementValue(component); + if (options.__embeddedInHtml) { + component = component.replace(/<\/(script)\b/gi, "<\\/$1"); + } + parts.push(component); } - parts.push(component); + continue; } - continue; + + const placeholderIndex = Number(component); + parts.push(expressionDocs[placeholderIndex]); } - const placeholderIndex = Number(component); - parts.push(expressionDocs[placeholderIndex]); + return parts; } - - return parts; - }); + ); const leadingWhitespace = /^\s/.test(text) ? " " : ""; const trailingWhitespace = /\s$/.test(text) ? " " : ""; diff --git ORI/prettier/src/language-js/index.js ALT/prettier/src/language-js/index.js index 1c22c7014..b9eaf644f 100644 --- ORI/prettier/src/language-js/index.js +++ ALT/prettier/src/language-js/index.js @@ -28,63 +28,81 @@ const languages = [ ], }) ), - createLanguage(require("linguist-languages/data/JavaScript.json"), () => ({ - name: "Flow", - since: "0.0.0", - parsers: ["flow", "babel-flow"], - vscodeLanguageIds: ["javascript"], - aliases: [], - filenames: [], - extensions: [".js.flow"], - })), - createLanguage(require("linguist-languages/data/JavaScript.json"), () => ({ - name: "JSX", - since: "0.0.0", - parsers: [ - "babel", - "babel-flow", - "babel-ts", - "flow", - "typescript", - "espree", - "meriyah", - ], - vscodeLanguageIds: ["javascriptreact"], - aliases: undefined, - filenames: undefined, - extensions: [".jsx"], - group: "JavaScript", - interpreters: undefined, - tmScope: "source.js.jsx", - aceMode: "javascript", - codemirrorMode: "jsx", - codemirrorMimeType: "text/jsx", - color: undefined, - })), - createLanguage(require("linguist-languages/data/TypeScript.json"), () => ({ - since: "1.4.0", - parsers: ["typescript", "babel-ts"], - vscodeLanguageIds: ["typescript"], - })), - createLanguage(require("linguist-languages/data/TSX.json"), () => ({ - since: "1.4.0", - parsers: ["typescript", "babel-ts"], - vscodeLanguageIds: ["typescriptreact"], - })), - createLanguage(require("linguist-languages/data/JSON.json"), () => ({ - name: "JSON.stringify", - since: "1.13.0", - parsers: ["json-stringify"], - vscodeLanguageIds: ["json"], - extensions: [], // .json file defaults to json instead of json-stringify - filenames: ["package.json", "package-lock.json", "composer.json"], - })), - createLanguage(require("linguist-languages/data/JSON.json"), (data) => ({ - since: "1.5.0", - parsers: ["json"], - vscodeLanguageIds: ["json"], - extensions: data.extensions.filter((extension) => extension !== ".jsonl"), - })), + createLanguage( + require("linguist-languages/data/JavaScript.json"), + () => ({ + name: "Flow", + since: "0.0.0", + parsers: ["flow", "babel-flow"], + vscodeLanguageIds: ["javascript"], + aliases: [], + filenames: [], + extensions: [".js.flow"], + }) + ), + createLanguage( + require("linguist-languages/data/JavaScript.json"), + () => ({ + name: "JSX", + since: "0.0.0", + parsers: [ + "babel", + "babel-flow", + "babel-ts", + "flow", + "typescript", + "espree", + "meriyah", + ], + vscodeLanguageIds: ["javascriptreact"], + aliases: undefined, + filenames: undefined, + extensions: [".jsx"], + group: "JavaScript", + interpreters: undefined, + tmScope: "source.js.jsx", + aceMode: "javascript", + codemirrorMode: "jsx", + codemirrorMimeType: "text/jsx", + color: undefined, + }) + ), + createLanguage( + require("linguist-languages/data/TypeScript.json"), + () => ({ + since: "1.4.0", + parsers: ["typescript", "babel-ts"], + vscodeLanguageIds: ["typescript"], + }) + ), + createLanguage( + require("linguist-languages/data/TSX.json"), + () => ({ + since: "1.4.0", + parsers: ["typescript", "babel-ts"], + vscodeLanguageIds: ["typescriptreact"], + }) + ), + createLanguage( + require("linguist-languages/data/JSON.json"), + () => ({ + name: "JSON.stringify", + since: "1.13.0", + parsers: ["json-stringify"], + vscodeLanguageIds: ["json"], + extensions: [], // .json file defaults to json instead of json-stringify + filenames: ["package.json", "package-lock.json", "composer.json"], + }) + ), + createLanguage( + require("linguist-languages/data/JSON.json"), + (data) => ({ + since: "1.5.0", + parsers: ["json"], + vscodeLanguageIds: ["json"], + extensions: data.extensions.filter((extension) => extension !== ".jsonl"), + }) + ), createLanguage( require("linguist-languages/data/JSON with Comments.json"), (data) => ({ @@ -94,11 +112,14 @@ const languages = [ filenames: [...data.filenames, ".eslintrc"], }) ), - createLanguage(require("linguist-languages/data/JSON5.json"), () => ({ - since: "1.13.0", - parsers: ["json5"], - vscodeLanguageIds: ["json5"], - })), + createLanguage( + require("linguist-languages/data/JSON5.json"), + () => ({ + since: "1.13.0", + parsers: ["json5"], + vscodeLanguageIds: ["json5"], + }) + ), ]; const printers = { diff --git ORI/prettier/src/language-js/parse-postprocess.js ALT/prettier/src/language-js/parse-postprocess.js index fd97535a7..e99026cca 100644 --- ORI/prettier/src/language-js/parse-postprocess.js +++ ALT/prettier/src/language-js/parse-postprocess.js @@ -14,41 +14,44 @@ function postprocess(ast, options) { if (options.parser === "typescript" && options.originalText.includes("@")) { const { esTreeNodeToTSNodeMap, tsNodeToESTreeNodeMap } = options.tsParseResult; - ast = visitNode(ast, (node) => { - const tsNode = esTreeNodeToTSNodeMap.get(node); - if (!tsNode) { - return; - } - const tsDecorators = tsNode.decorators; - if (!Array.isArray(tsDecorators)) { - return; - } - // `esTreeNodeToTSNodeMap.get(ClassBody)` and `esTreeNodeToTSNodeMap.get(ClassDeclaration)` has the same tsNode - const esTreeNode = tsNodeToESTreeNodeMap.get(tsNode); - if (esTreeNode !== node) { - return; - } - const esTreeDecorators = esTreeNode.decorators; - if ( - !Array.isArray(esTreeDecorators) || - esTreeDecorators.length !== tsDecorators.length || - tsDecorators.some((tsDecorator) => { - const esTreeDecorator = tsNodeToESTreeNodeMap.get(tsDecorator); - return ( - !esTreeDecorator || !esTreeDecorators.includes(esTreeDecorator) + ast = visitNode( + ast, + (node) => { + const tsNode = esTreeNodeToTSNodeMap.get(node); + if (!tsNode) { + return; + } + const tsDecorators = tsNode.decorators; + if (!Array.isArray(tsDecorators)) { + return; + } + // `esTreeNodeToTSNodeMap.get(ClassBody)` and `esTreeNodeToTSNodeMap.get(ClassDeclaration)` has the same tsNode + const esTreeNode = tsNodeToESTreeNodeMap.get(tsNode); + if (esTreeNode !== node) { + return; + } + const esTreeDecorators = esTreeNode.decorators; + if ( + !Array.isArray(esTreeDecorators) || + esTreeDecorators.length !== tsDecorators.length || + tsDecorators.some((tsDecorator) => { + const esTreeDecorator = tsNodeToESTreeNodeMap.get(tsDecorator); + return ( + !esTreeDecorator || !esTreeDecorators.includes(esTreeDecorator) + ); + }) + ) { + const { start, end } = esTreeNode.loc; + throw createError( + "Leading decorators must be attached to a class declaration", + { + start: { line: start.line, column: start.column + 1 }, + end: { line: end.line, column: end.column + 1 }, + } ); - }) - ) { - const { start, end } = esTreeNode.loc; - throw createError( - "Leading decorators must be attached to a class declaration", - { - start: { line: start.line, column: start.column + 1 }, - end: { line: end.line, column: end.column + 1 }, - } - ); + } } - }); + ); } // Keep Babel's non-standard ParenthesizedExpression nodes only if they have Closure-style type cast comments. @@ -64,96 +67,105 @@ function postprocess(ast, options) { // E.g.: /** @type {Foo} */ (foo).bar(); // Let's use the fact that those ancestors and ParenthesizedExpression have the same start offset. - ast = visitNode(ast, (node) => { - if ( - node.leadingComments && - node.leadingComments.some(isTypeCastComment) - ) { - startOffsetsOfTypeCastedNodes.add(locStart(node)); + ast = visitNode( + ast, + (node) => { + if ( + node.leadingComments && + node.leadingComments.some(isTypeCastComment) + ) { + startOffsetsOfTypeCastedNodes.add(locStart(node)); + } } - }); + ); - ast = visitNode(ast, (node) => { - if (node.type === "ParenthesizedExpression") { - const { expression } = node; + ast = visitNode( + ast, + (node) => { + if (node.type === "ParenthesizedExpression") { + const { expression } = node; - // Align range with `flow` - if (expression.type === "TypeCastExpression") { - expression.range = node.range; - return expression; - } + // Align range with `flow` + if (expression.type === "TypeCastExpression") { + expression.range = node.range; + return expression; + } - const start = locStart(node); - if (!startOffsetsOfTypeCastedNodes.has(start)) { - expression.extra = { ...expression.extra, parenthesized: true }; - return expression; + const start = locStart(node); + if (!startOffsetsOfTypeCastedNodes.has(start)) { + expression.extra = { ...expression.extra, parenthesized: true }; + return expression; + } } } - }); + ); } - ast = visitNode(ast, (node) => { - switch (node.type) { - // Espree - case "ChainExpression": { - return transformChainExpression(node.expression); - } - case "LogicalExpression": { - // We remove unneeded parens around same-operator LogicalExpressions - if (isUnbalancedLogicalTree(node)) { - return rebalanceLogicalTree(node); + ast = visitNode( + ast, + (node) => { + switch (node.type) { + // Espree + case "ChainExpression": { + return transformChainExpression(node.expression); } - break; - } - // fix unexpected locEnd caused by --no-semi style - case "VariableDeclaration": { - const lastDeclaration = getLast(node.declarations); - if (lastDeclaration && lastDeclaration.init) { - overrideLocEnd(node, lastDeclaration); + case "LogicalExpression": { + // We remove unneeded parens around same-operator LogicalExpressions + if (isUnbalancedLogicalTree(node)) { + return rebalanceLogicalTree(node); + } + break; } - break; - } - // remove redundant TypeScript nodes - case "TSParenthesizedType": { - node.typeAnnotation.range = [locStart(node), locEnd(node)]; - return node.typeAnnotation; - } - case "TSTypeParameter": - // babel-ts - if (typeof node.name === "string") { - const start = locStart(node); - node.name = { - type: "Identifier", - name: node.name, - range: [start, start + node.name.length], - }; + // fix unexpected locEnd caused by --no-semi style + case "VariableDeclaration": { + const lastDeclaration = getLast(node.declarations); + if (lastDeclaration && lastDeclaration.init) { + overrideLocEnd(node, lastDeclaration); + } + break; } - break; - case "SequenceExpression": { - // Babel (unlike other parsers) includes spaces and comments in the range. Let's unify this. - const lastExpression = getLast(node.expressions); - node.range = [ - locStart(node), - Math.min(locEnd(lastExpression), locEnd(node)), - ]; - break; - } - case "ClassProperty": - // TODO: Temporary auto-generated node type. To remove when typescript-estree has proper support for private fields. - if ( - node.key && - node.key.type === "TSPrivateIdentifier" && - getNextNonSpaceNonCommentCharacter( - options.originalText, - node.key, - locEnd - ) === "?" - ) { - node.optional = true; + // remove redundant TypeScript nodes + case "TSParenthesizedType": { + node.typeAnnotation.range = [locStart(node), locEnd(node)]; + return node.typeAnnotation; + } + case "TSTypeParameter": + // babel-ts + if (typeof node.name === "string") { + const start = locStart(node); + node.name = { + type: "Identifier", + name: node.name, + range: [start, start + node.name.length], + }; + } + break; + case "SequenceExpression": { + // Babel (unlike other parsers) includes spaces and comments in the range. Let's unify this. + const lastExpression = getLast(node.expressions); + node.range = [ + locStart(node), + Math.min(locEnd(lastExpression), locEnd(node)), + ]; + break; } - break; + case "ClassProperty": + // TODO: Temporary auto-generated node type. To remove when typescript-estree has proper support for private fields. + if ( + node.key && + node.key.type === "TSPrivateIdentifier" && + getNextNonSpaceNonCommentCharacter( + options.originalText, + node.key, + locEnd + ) === "?" + ) { + node.optional = true; + } + break; + } } - }); + ); return ast; diff --git ORI/prettier/src/language-js/parser-babel.js ALT/prettier/src/language-js/parser-babel.js index 869100d74..30754cfa1 100644 --- ORI/prettier/src/language-js/parser-babel.js +++ ALT/prettier/src/language-js/parser-babel.js @@ -118,8 +118,8 @@ function createParse(parseMethod, ...optionsCombinations) { } const { result: ast, error } = tryCombinations( - ...combinations.map( - (options) => () => parseWithOptions(parseMethod, text, options) + ...combinations.map((options) => () => + parseWithOptions(parseMethod, text, options) ) ); diff --git ORI/prettier/src/language-js/print/angular.js ALT/prettier/src/language-js/print/angular.js index aac03f3ec..cdd4af109 100644 --- ORI/prettier/src/language-js/print/angular.js +++ ALT/prettier/src/language-js/print/angular.js @@ -102,16 +102,19 @@ function isNgForOf(node, index, parentNode) { * @returns {boolean} */ function hasNgSideEffect(path) { - return hasNode(path.getValue(), (node) => { - switch (node.type) { - case undefined: - return false; - case "CallExpression": - case "OptionalCallExpression": - case "AssignmentExpression": - return true; + return hasNode( + path.getValue(), + (node) => { + switch (node.type) { + case undefined: + return false; + case "CallExpression": + case "OptionalCallExpression": + case "AssignmentExpression": + return true; + } } - }); + ); } module.exports = { printAngular }; diff --git ORI/prettier/src/language-js/print/template-literal.js ALT/prettier/src/language-js/print/template-literal.js index cfa61da53..7fb6aca1e 100644 --- ORI/prettier/src/language-js/print/template-literal.js +++ ALT/prettier/src/language-js/print/template-literal.js @@ -217,15 +217,18 @@ function printTemplateExpressions(path, print) { } function escapeTemplateCharacters(doc, raw) { - return mapDoc(doc, (currentDoc) => { - if (typeof currentDoc === "string") { - return raw - ? currentDoc.replace(/(\\*)`/g, "$1$1\\`") - : uncookTemplateElementValue(currentDoc); - } + return mapDoc( + doc, + (currentDoc) => { + if (typeof currentDoc === "string") { + return raw + ? currentDoc.replace(/(\\*)`/g, "$1$1\\`") + : uncookTemplateElementValue(currentDoc); + } - return currentDoc; - }); + return currentDoc; + } + ); } function uncookTemplateElementValue(cookedValue) { diff --git ORI/prettier/src/language-js/utils.js ALT/prettier/src/language-js/utils.js index 7a9e983f3..136315f7a 100644 --- ORI/prettier/src/language-js/utils.js +++ ALT/prettier/src/language-js/utils.js @@ -663,8 +663,10 @@ function hasLeadingOwnLineComment(text, node) { return hasNodeIgnoreComment(node); } - return hasComment(node, CommentCheckFlags.Leading, (comment) => - hasNewline(text, locEnd(comment)) + return hasComment( + node, + CommentCheckFlags.Leading, + (comment) => hasNewline(text, locEnd(comment)) ); } diff --git ORI/prettier/src/language-markdown/index.js ALT/prettier/src/language-markdown/index.js index 994023c43..3ce09f693 100644 --- ORI/prettier/src/language-markdown/index.js +++ ALT/prettier/src/language-markdown/index.js @@ -5,21 +5,27 @@ const printer = require("./printer-markdown"); const options = require("./options"); const languages = [ - createLanguage(require("linguist-languages/data/Markdown.json"), (data) => ({ - since: "1.8.0", - parsers: ["markdown"], - vscodeLanguageIds: ["markdown"], - filenames: [...data.filenames, "README"], - extensions: data.extensions.filter((extension) => extension !== ".mdx"), - })), - createLanguage(require("linguist-languages/data/Markdown.json"), () => ({ - name: "MDX", - since: "1.15.0", - parsers: ["mdx"], - vscodeLanguageIds: ["mdx"], - filenames: [], - extensions: [".mdx"], - })), + createLanguage( + require("linguist-languages/data/Markdown.json"), + (data) => ({ + since: "1.8.0", + parsers: ["markdown"], + vscodeLanguageIds: ["markdown"], + filenames: [...data.filenames, "README"], + extensions: data.extensions.filter((extension) => extension !== ".mdx"), + }) + ), + createLanguage( + require("linguist-languages/data/Markdown.json"), + () => ({ + name: "MDX", + since: "1.15.0", + parsers: ["mdx"], + vscodeLanguageIds: ["mdx"], + filenames: [], + extensions: [".mdx"], + }) + ), ]; const printers = { diff --git ORI/prettier/src/language-markdown/parser-markdown.js ALT/prettier/src/language-markdown/parser-markdown.js index a456c3cae..f7cdff3c6 100644 --- ORI/prettier/src/language-markdown/parser-markdown.js +++ ALT/prettier/src/language-markdown/parser-markdown.js @@ -49,17 +49,20 @@ function identity(x) { function htmlToJsx() { return (ast) => - mapAst(ast, (node, _index, [parent]) => { - if ( - node.type !== "html" || - mdx.COMMENT_REGEX.test(node.value) || - INLINE_NODE_WRAPPER_TYPES.includes(parent.type) - ) { - return node; + mapAst( + ast, + (node, _index, [parent]) => { + if ( + node.type !== "html" || + mdx.COMMENT_REGEX.test(node.value) || + INLINE_NODE_WRAPPER_TYPES.includes(parent.type) + ) { + return node; + } + + return { ...node, type: "jsx" }; } - - return { ...node, type: "jsx" }; - }); + ); } function frontMatter() { diff --git ORI/prettier/src/language-markdown/print-preprocess.js ALT/prettier/src/language-markdown/print-preprocess.js index 711b88895..65aa23622 100644 --- ORI/prettier/src/language-markdown/print-preprocess.js +++ ALT/prettier/src/language-markdown/print-preprocess.js @@ -20,40 +20,49 @@ function preprocess(ast, options) { } function transformImportExport(ast) { - return mapAst(ast, (node) => { - if (node.type !== "import" && node.type !== "export") { - return node; - } + return mapAst( + ast, + (node) => { + if (node.type !== "import" && node.type !== "export") { + return node; + } - return { ...node, type: "importExport" }; - }); + return { ...node, type: "importExport" }; + } + ); } function transformInlineCode(ast) { - return mapAst(ast, (node) => { - if (node.type !== "inlineCode") { - return node; - } + return mapAst( + ast, + (node) => { + if (node.type !== "inlineCode") { + return node; + } - return { ...node, value: node.value.replace(/\s+/g, " ") }; - }); + return { ...node, value: node.value.replace(/\s+/g, " ") }; + } + ); } function restoreUnescapedCharacter(ast, options) { - return mapAst(ast, (node) => - node.type !== "text" || - node.value === "*" || - node.value === "_" || // handle these cases in printer - !isSingleCharRegex.test(node.value) || - node.position.end.offset - node.position.start.offset === node.value.length - ? node - : { - ...node, - value: options.originalText.slice( - node.position.start.offset, - node.position.end.offset - ), - } + return mapAst( + ast, + (node) => + node.type !== "text" || + node.value === "*" || + node.value === "_" || // handle these cases in printer + !isSingleCharRegex.test(node.value) || + node.position.end.offset - node.position.start.offset === + node.value.length + ? node + : { + ...node, + value: options.originalText.slice( + node.position.start.offset, + node.position.end.offset + ), + } ); } @@ -74,21 +83,24 @@ function mergeContinuousImportExport(ast) { } function mergeChildren(ast, shouldMerge, mergeNode) { - return mapAst(ast, (node) => { - if (!node.children) { - return node; - } - const children = node.children.reduce((current, child) => { - const lastChild = getLast(current); - if (lastChild && shouldMerge(lastChild, child)) { - current.splice(-1, 1, mergeNode(lastChild, child)); - } else { - current.push(child); + return mapAst( + ast, + (node) => { + if (!node.children) { + return node; } - return current; - }, []); - return { ...node, children }; - }); + const children = node.children.reduce((current, child) => { + const lastChild = getLast(current); + if (lastChild && shouldMerge(lastChild, child)) { + current.splice(-1, 1, mergeNode(lastChild, child)); + } else { + current.push(child); + } + return current; + }, []); + return { ...node, children }; + } + ); } function mergeContinuousTexts(ast) { @@ -107,79 +119,88 @@ function mergeContinuousTexts(ast) { } function splitTextIntoSentences(ast, options) { - return mapAst(ast, (node, index, [parentNode]) => { - if (node.type !== "text") { - return node; - } + return mapAst( + ast, + (node, index, [parentNode]) => { + if (node.type !== "text") { + return node; + } - let { value } = node; + let { value } = node; - if (parentNode.type === "paragraph") { - if (index === 0) { - value = value.trimStart(); - } - if (index === parentNode.children.length - 1) { - value = value.trimEnd(); + if (parentNode.type === "paragraph") { + if (index === 0) { + value = value.trimStart(); + } + if (index === parentNode.children.length - 1) { + value = value.trimEnd(); + } } - } - return { - type: "sentence", - position: node.position, - children: splitText(value, options), - }; - }); + return { + type: "sentence", + position: node.position, + children: splitText(value, options), + }; + } + ); } function transformIndentedCodeblockAndMarkItsParentList(ast, options) { - return mapAst(ast, (node, index, parentStack) => { - if (node.type === "code") { - // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it - const isIndented = /^\n?( {4,}|\t)/.test( - options.originalText.slice( - node.position.start.offset, - node.position.end.offset - ) - ); - - node.isIndented = isIndented; - - if (isIndented) { - for (let i = 0; i < parentStack.length; i++) { - const parent = parentStack[i]; + return mapAst( + ast, + (node, index, parentStack) => { + if (node.type === "code") { + // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it + const isIndented = /^\n?( {4,}|\t)/.test( + options.originalText.slice( + node.position.start.offset, + node.position.end.offset + ) + ); - // no need to check checked items - if (parent.hasIndentedCodeblock) { - break; - } + node.isIndented = isIndented; - if (parent.type === "list") { - parent.hasIndentedCodeblock = true; + if (isIndented) { + for (let i = 0; i < parentStack.length; i++) { + const parent = parentStack[i]; + + // no need to check checked items + if (parent.hasIndentedCodeblock) { + break; + } + + if (parent.type === "list") { + parent.hasIndentedCodeblock = true; + } } } } + return node; } - return node; - }); + ); } function markAlignedList(ast, options) { - return mapAst(ast, (node, index, parentStack) => { - if (node.type === "list" && node.children.length > 0) { - // if one of its parents is not aligned, it's not possible to be aligned in sub-lists - for (let i = 0; i < parentStack.length; i++) { - const parent = parentStack[i]; - if (parent.type === "list" && !parent.isAligned) { - node.isAligned = false; - return node; + return mapAst( + ast, + (node, index, parentStack) => { + if (node.type === "list" && node.children.length > 0) { + // if one of its parents is not aligned, it's not possible to be aligned in sub-lists + for (let i = 0; i < parentStack.length; i++) { + const parent = parentStack[i]; + if (parent.type === "list" && !parent.isAligned) { + node.isAligned = false; + return node; + } } + + node.isAligned = isAligned(node); } - node.isAligned = isAligned(node); + return node; } - - return node; - }); + ); function getListItemStart(listItem) { return listItem.children.length === 0 diff --git ORI/prettier/src/language-markdown/printer-markdown.js ALT/prettier/src/language-markdown/printer-markdown.js index 6fe7c254c..1f6e18484 100644 --- ORI/prettier/src/language-markdown/printer-markdown.js +++ ALT/prettier/src/language-markdown/printer-markdown.js @@ -129,8 +129,9 @@ function genericPrint(path, options, print) { )) ) { // backslash is parsed as part of autolinks, so we need to remove it - escapedValue = escapedValue.replace(/^(\\?[*_])+/, (prefix) => - prefix.replace(/\\/g, "") + escapedValue = escapedValue.replace( + /^(\\?[*_])+/, + (prefix) => prefix.replace(/\\/g, "") ); } diff --git ORI/prettier/src/language-yaml/index.js ALT/prettier/src/language-yaml/index.js index 7205e75d8..b74e7514f 100644 --- ORI/prettier/src/language-yaml/index.js +++ ALT/prettier/src/language-yaml/index.js @@ -5,16 +5,19 @@ const printer = require("./printer-yaml"); const options = require("./options"); const languages = [ - createLanguage(require("linguist-languages/data/YAML.json"), (data) => ({ - since: "1.14.0", - parsers: ["yaml"], - vscodeLanguageIds: ["yaml", "ansible", "home-assistant"], - // yarn.lock is not YAML: https://github.com/yarnpkg/yarn/issues/5629 - filenames: [ - ...data.filenames.filter((filename) => filename !== "yarn.lock"), - ".prettierrc", - ], - })), + createLanguage( + require("linguist-languages/data/YAML.json"), + (data) => ({ + since: "1.14.0", + parsers: ["yaml"], + vscodeLanguageIds: ["yaml", "ansible", "home-assistant"], + // yarn.lock is not YAML: https://github.com/yarnpkg/yarn/issues/5629 + filenames: [ + ...data.filenames.filter((filename) => filename !== "yarn.lock"), + ".prettierrc", + ], + }) + ), ]; const parsers = { diff --git ORI/prettier/src/language-yaml/print/block.js ALT/prettier/src/language-yaml/print/block.js index 9e8e8e615..25da6a29e 100644 --- ORI/prettier/src/language-yaml/print/block.js +++ ALT/prettier/src/language-yaml/print/block.js @@ -26,8 +26,9 @@ const { alignWithSpaces } = require("./misc"); function printBlock(path, print, options) { const node = path.getValue(); - const parentIndent = getAncestorCount(path, (ancestorNode) => - isNode(ancestorNode, ["sequence", "mapping"]) + const parentIndent = getAncestorCount( + path, + (ancestorNode) => isNode(ancestorNode, ["sequence", "mapping"]) ); const isLastDescendant = isLastDescendantNode(path); /** @type {Doc[]} */ diff --git ORI/prettier/tests_config/utils/stringify-options-for-title.js ALT/prettier/tests_config/utils/stringify-options-for-title.js index dbc95627f..b08780695 100644 --- ORI/prettier/tests_config/utils/stringify-options-for-title.js +++ ALT/prettier/tests_config/utils/stringify-options-for-title.js @@ -1,12 +1,14 @@ "use strict"; function stringifyOptions(options) { - const string = JSON.stringify(options || {}, (key, value) => - key === "plugins" || key === "errors" - ? undefined - : value === Number.POSITIVE_INFINITY - ? "Infinity" - : value + const string = JSON.stringify( + options || {}, + (key, value) => + key === "plugins" || key === "errors" + ? undefined + : value === Number.POSITIVE_INFINITY + ? "Infinity" + : value ); return string === "{}" ? "" : string; ```
github-actions[bot] commented 3 years ago

prettier/prettier#8300 VS prettier/prettier@main :: typescript-eslint/typescript-eslint@d0d71862efd7e079694fa9513ea983cc908ec6f6

Diff (179 lines) ```diff diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts index f0904f07..b7987274 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts @@ -82,21 +82,29 @@ export default util.createRule({ return; } - checkFunctionExpressionReturnType(node, options, sourceCode, loc => - context.report({ - node, - loc, - messageId: 'missingReturnType', - }), + checkFunctionExpressionReturnType( + node, + options, + sourceCode, + loc => + context.report({ + node, + loc, + messageId: 'missingReturnType', + }), ); }, FunctionDeclaration(node): void { - checkFunctionReturnType(node, options, sourceCode, loc => - context.report({ - node, - loc, - messageId: 'missingReturnType', - }), + checkFunctionReturnType( + node, + options, + sourceCode, + loc => + context.report({ + node, + loc, + messageId: 'missingReturnType', + }), ); }, }; diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts index 2df93308..80ca3b5c 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts @@ -117,12 +117,14 @@ function getTypeParametersFromType( return undefined; } - return findFirstResult(declarations, decl => - ts.isClassLike(decl) || - ts.isTypeAliasDeclaration(decl) || - ts.isInterfaceDeclaration(decl) - ? decl.typeParameters - : undefined, + return findFirstResult( + declarations, + decl => + ts.isClassLike(decl) || + ts.isTypeAliasDeclaration(decl) || + ts.isInterfaceDeclaration(decl) + ? decl.typeParameters + : undefined, ); } diff --git ORI/typescript-eslint/packages/typescript-estree/src/node-utils.ts ALT/typescript-eslint/packages/typescript-estree/src/node-utils.ts index eb88660f..16b13268 100644 --- ORI/typescript-eslint/packages/typescript-estree/src/node-utils.ts +++ ALT/typescript-eslint/packages/typescript-estree/src/node-utils.ts @@ -369,16 +369,19 @@ export function findNextToken( // this is token that starts at the end of previous token - return it return n; } - return firstDefined(n.getChildren(ast), (child: ts.Node) => { - const shouldDiveInChildNode = - // previous token is enclosed somewhere in the child - (child.pos <= previousToken.pos && child.end > previousToken.end) || - // previous token ends exactly at the beginning of child - child.pos === previousToken.end; - return shouldDiveInChildNode && nodeHasTokens(child, ast) - ? find(child) - : undefined; - }); + return firstDefined( + n.getChildren(ast), + (child: ts.Node) => { + const shouldDiveInChildNode = + // previous token is enclosed somewhere in the child + (child.pos <= previousToken.pos && child.end > previousToken.end) || + // previous token ends exactly at the beginning of child + child.pos === previousToken.end; + return shouldDiveInChildNode && nodeHasTokens(child, ast) + ? find(child) + : undefined; + }, + ); } } diff --git ORI/typescript-eslint/packages/typescript-estree/tests/lib/parse.test.ts ALT/typescript-eslint/packages/typescript-estree/tests/lib/parse.test.ts index d4acba10..33b39367 100644 --- ORI/typescript-eslint/packages/typescript-estree/tests/lib/parse.test.ts +++ ALT/typescript-eslint/packages/typescript-estree/tests/lib/parse.test.ts @@ -492,23 +492,24 @@ describe('parseAndGenerateServices', () => { tsconfigRootDir: PROJECT_DIR, project: './tsconfig.json', }; - const testParse = - (filePath: string, extraFileExtensions: string[] = ['.vue']) => - (): void => { - try { - parser.parseAndGenerateServices(code, { - ...config, - extraFileExtensions, - filePath: join(PROJECT_DIR, filePath), - }); - } catch (error) { - /** - * Aligns paths between environments, node for windows uses `\`, for linux and mac uses `/` - */ - error.message = error.message.replace(/\\(?!["])/gm, '/'); - throw error; - } - }; + const testParse = ( + filePath: string, + extraFileExtensions: string[] = ['.vue'], + ) => (): void => { + try { + parser.parseAndGenerateServices(code, { + ...config, + extraFileExtensions, + filePath: join(PROJECT_DIR, filePath), + }); + } catch (error) { + /** + * Aligns paths between environments, node for windows uses `\`, for linux and mac uses `/` + */ + error.message = error.message.replace(/\\(?!["])/gm, '/'); + throw error; + } + }; describe('project includes', () => { it("doesn't error for matched files", () => { @@ -646,18 +647,16 @@ describe('parseAndGenerateServices', () => { project: './**/tsconfig.json', }; - const testParse = - ( - filePath: 'ignoreme' | 'includeme', - projectFolderIgnoreList?: TSESTreeOptions['projectFolderIgnoreList'], - ) => - (): void => { - parser.parseAndGenerateServices(code, { - ...config, - projectFolderIgnoreList, - filePath: join(PROJECT_DIR, filePath, './file.ts'), - }); - }; + const testParse = ( + filePath: 'ignoreme' | 'includeme', + projectFolderIgnoreList?: TSESTreeOptions['projectFolderIgnoreList'], + ) => (): void => { + parser.parseAndGenerateServices(code, { + ...config, + projectFolderIgnoreList, + filePath: join(PROJECT_DIR, filePath, './file.ts'), + }); + }; it('ignores nothing when given nothing', () => { expect(testParse('ignoreme')).not.toThrow(); ```
github-actions[bot] commented 3 years ago

prettier/prettier#8300 VS prettier/prettier@main :: vega/vega-lite@2dff36f971d76292ef3747fc3568e53bf747ef51

Diff (656 lines) ```diff diff --git ORI/vega-lite/src/compile/legend/encode.ts ALT/vega-lite/src/compile/legend/encode.ts index 180d8758e..c88a64f1f 100644 --- ORI/vega-lite/src/compile/legend/encode.ts +++ ALT/vega-lite/src/compile/legend/encode.ts @@ -181,9 +181,12 @@ function getMaxValue(channelDef: Encoding['opacity']) { export function getFirstConditionValue( channelDef: Encoding['fill' | 'stroke' | 'shape'] ): V { - return getConditionValue(channelDef, (v: V, conditionalDef: Conditional>) => { - return getFirstDefined(v, conditionalDef.value); - }); + return getConditionValue( + channelDef, + (v: V, conditionalDef: Conditional>) => { + return getFirstDefined(v, conditionalDef.value); + } + ); } function getConditionValue( diff --git ORI/vega-lite/src/compile/mark/encode/nonposition.ts ALT/vega-lite/src/compile/mark/encode/nonposition.ts index e6c5d58a3..390856f51 100644 --- ORI/vega-lite/src/compile/mark/encode/nonposition.ts +++ ALT/vega-lite/src/compile/mark/encode/nonposition.ts @@ -34,16 +34,21 @@ export function nonPosition( const channelDef = encoding[channel]; - return wrapCondition(model, channelDef, vgChannel ?? channel, cDef => { - return ref.midPoint({ - channel, - channelDef: cDef, - markDef, - config, - scaleName: model.scaleName(channel), - scale: model.getScaleComponent(channel), - stack: null, // No need to provide stack for non-position as it does not affect mid point - defaultRef - }); - }); + return wrapCondition( + model, + channelDef, + vgChannel ?? channel, + cDef => { + return ref.midPoint({ + channel, + channelDef: cDef, + markDef, + config, + scaleName: model.scaleName(channel), + scale: model.getScaleComponent(channel), + stack: null, // No need to provide stack for non-position as it does not affect mid point + defaultRef + }); + } + ); } diff --git ORI/vega-lite/src/compile/mark/encode/tooltip.ts ALT/vega-lite/src/compile/mark/encode/tooltip.ts index 1bf44ff88..9c24ac9cf 100644 --- ORI/vega-lite/src/compile/mark/encode/tooltip.ts +++ ALT/vega-lite/src/compile/mark/encode/tooltip.ts @@ -30,39 +30,44 @@ export function tooltip(model: UnitModel, opt: {reactiveGeom?: boolean} = {}) { return {tooltip: tooltipRefForEncoding({tooltip: channelDef}, stack, config, opt)}; } else { const datum = opt.reactiveGeom ? 'datum.datum' : 'datum'; - return wrapCondition(model, channelDef, 'tooltip', cDef => { - // use valueRef based on channelDef first - const tooltipRefFromChannelDef = textRef(cDef, config, datum); - if (tooltipRefFromChannelDef) { - return tooltipRefFromChannelDef; - } + return wrapCondition( + model, + channelDef, + 'tooltip', + cDef => { + // use valueRef based on channelDef first + const tooltipRefFromChannelDef = textRef(cDef, config, datum); + if (tooltipRefFromChannelDef) { + return tooltipRefFromChannelDef; + } - if (cDef === null) { - // Allow using encoding.tooltip = null to disable tooltip - return undefined; - } + if (cDef === null) { + // Allow using encoding.tooltip = null to disable tooltip + return undefined; + } - let markTooltip = getMarkPropOrConfig('tooltip', markDef, config); + let markTooltip = getMarkPropOrConfig('tooltip', markDef, config); - if (markTooltip === true) { - markTooltip = {content: 'encoding'}; - } + if (markTooltip === true) { + markTooltip = {content: 'encoding'}; + } - if (isString(markTooltip)) { - return {value: markTooltip}; - } else if (isObject(markTooltip)) { - // `tooltip` is `{fields: 'encodings' | 'fields'}` - if (isSignalRef(markTooltip)) { - return markTooltip; - } else if (markTooltip.content === 'encoding') { - return tooltipRefForEncoding(encoding, stack, config, opt); - } else { - return {signal: datum}; + if (isString(markTooltip)) { + return {value: markTooltip}; + } else if (isObject(markTooltip)) { + // `tooltip` is `{fields: 'encodings' | 'fields'}` + if (isSignalRef(markTooltip)) { + return markTooltip; + } else if (markTooltip.content === 'encoding') { + return tooltipRefForEncoding(encoding, stack, config, opt); + } else { + return {signal: datum}; + } } - } - return undefined; - }); + return undefined; + } + ); } } diff --git ORI/vega-lite/src/compile/predicate.ts ALT/vega-lite/src/compile/predicate.ts index 75335af3b..ea332b01b 100644 --- ORI/vega-lite/src/compile/predicate.ts +++ ALT/vega-lite/src/compile/predicate.ts @@ -11,14 +11,17 @@ import {parseSelectionPredicate} from './selection/parse'; */ // model is only used for selection filters. export function expression(model: Model, filterOp: LogicalComposition, node?: DataFlowNode): string { - return logicalExpr(filterOp, (predicate: Predicate) => { - if (isString(predicate)) { - return predicate; - } else if (isSelectionPredicate(predicate)) { - return parseSelectionPredicate(model, predicate, node); - } else { - // Filter Object - return fieldFilterExpression(predicate); + return logicalExpr( + filterOp, + (predicate: Predicate) => { + if (isString(predicate)) { + return predicate; + } else if (isSelectionPredicate(predicate)) { + return parseSelectionPredicate(model, predicate, node); + } else { + // Filter Object + return fieldFilterExpression(predicate); + } } - }); + ); } diff --git ORI/vega-lite/src/compile/projection/parse.ts ALT/vega-lite/src/compile/projection/parse.ts index 21c41693e..44f4e77ac 100644 --- ORI/vega-lite/src/compile/projection/parse.ts +++ ALT/vega-lite/src/compile/projection/parse.ts @@ -73,22 +73,25 @@ function gatherFitData(model: UnitModel) { } function mergeIfNoConflict(first: ProjectionComponent, second: ProjectionComponent): ProjectionComponent { - const allPropertiesShared = every(PROJECTION_PROPERTIES, prop => { - // neither has the property - if (!hasOwnProperty(first.explicit, prop) && !hasOwnProperty(second.explicit, prop)) { - return true; - } - // both have property and an equal value for property - if ( - hasOwnProperty(first.explicit, prop) && - hasOwnProperty(second.explicit, prop) && - // some properties might be signals or objects and require hashing for comparison - deepEqual(first.get(prop), second.get(prop)) - ) { - return true; + const allPropertiesShared = every( + PROJECTION_PROPERTIES, + prop => { + // neither has the property + if (!hasOwnProperty(first.explicit, prop) && !hasOwnProperty(second.explicit, prop)) { + return true; + } + // both have property and an equal value for property + if ( + hasOwnProperty(first.explicit, prop) && + hasOwnProperty(second.explicit, prop) && + // some properties might be signals or objects and require hashing for comparison + deepEqual(first.get(prop), second.get(prop)) + ) { + return true; + } + return false; } - return false; - }); + ); const size = deepEqual(first.size, second.size); if (size) { @@ -118,23 +121,26 @@ function parseNonUnitProjections(model: Model): ProjectionComponent { } // analyze parsed projections, attempt to merge - const mergable = every(model.children, child => { - const projection = child.component.projection; - if (!projection) { - // child layer does not use a projection - return true; - } else if (!nonUnitProjection) { - // cached 'projection' is null, cache this one - nonUnitProjection = projection; - return true; - } else { - const merge = mergeIfNoConflict(nonUnitProjection, projection); - if (merge) { - nonUnitProjection = merge; + const mergable = every( + model.children, + child => { + const projection = child.component.projection; + if (!projection) { + // child layer does not use a projection + return true; + } else if (!nonUnitProjection) { + // cached 'projection' is null, cache this one + nonUnitProjection = projection; + return true; + } else { + const merge = mergeIfNoConflict(nonUnitProjection, projection); + if (merge) { + nonUnitProjection = merge; + } + return !!merge; } - return !!merge; } - }); + ); // if cached one and all other children share the same projection, if (nonUnitProjection && mergable) { diff --git ORI/vega-lite/src/compile/selection/interval.ts ALT/vega-lite/src/compile/selection/interval.ts index 7dd7b69b1..2ebde45f0 100644 --- ORI/vega-lite/src/compile/selection/interval.ts +++ ALT/vega-lite/src/compile/selection/interval.ts @@ -200,13 +200,16 @@ function channelSignals( const size = model.getSizeSignalRef(channel === X ? 'width' : 'height').signal; const coord = `${channel}(unit)`; - const on = events(selCmpt, (def: OnEvent[], evt: Stream) => { - return [ - ...def, - {events: evt.between[0], update: `[${coord}, ${coord}]`}, // Brush Start - {events: evt, update: `[${vname}[0], clamp(${coord}, 0, ${size})]`} // Brush End - ]; - }); + const on = events( + selCmpt, + (def: OnEvent[], evt: Stream) => { + return [ + ...def, + {events: evt.between[0], update: `[${coord}, ${coord}]`}, // Brush Start + {events: evt, update: `[${vname}[0], clamp(${coord}, 0, ${size})]`} // Brush End + ]; + } + ); // React to pan/zooms of continuous scales. Non-continuous scales // (band, point) cannot be pan/zoomed and any other changes diff --git ORI/vega-lite/src/encoding.ts ALT/vega-lite/src/encoding.ts index 0e6b222da..9bdc3677e 100644 --- ORI/vega-lite/src/encoding.ts +++ ALT/vega-lite/src/encoding.ts @@ -324,18 +324,21 @@ export function channelHasField( } export function isAggregate(encoding: EncodingWithFacet) { - return some(CHANNELS, channel => { - if (channelHasField(encoding, channel)) { - const channelDef = encoding[channel]; - if (isArray(channelDef)) { - return some(channelDef, fieldDef => !!fieldDef.aggregate); - } else { - const fieldDef = getFieldDef(channelDef); - return fieldDef && !!fieldDef.aggregate; + return some( + CHANNELS, + channel => { + if (channelHasField(encoding, channel)) { + const channelDef = encoding[channel]; + if (isArray(channelDef)) { + return some(channelDef, fieldDef => !!fieldDef.aggregate); + } else { + const fieldDef = getFieldDef(channelDef); + return fieldDef && !!fieldDef.aggregate; + } } + return false; } - return false; - }); + ); } export function extractTransformsFromEncoding(oldEncoding: Encoding, config: Config) { diff --git ORI/vega-lite/src/normalize/selectioncompat.ts ALT/vega-lite/src/normalize/selectioncompat.ts index f5e64df73..b78d40119 100644 --- ORI/vega-lite/src/normalize/selectioncompat.ts +++ ALT/vega-lite/src/normalize/selectioncompat.ts @@ -142,18 +142,22 @@ function normalizeBinExtent(bin: BinParams): BinParams { function normalizePredicate(op: any, normParams: NormalizerParams) { // Normalize old compositions of selection names (e.g., selection: {and: ["one", "two"]}) const normalizeSelectionComposition = (o: LogicalComposition) => { - return normalizeLogicalComposition(o, param => { - const empty = normParams.emptySelections[param] ?? true; - const pred = {param, empty}; - normParams.selectionPredicates[param] ??= []; - normParams.selectionPredicates[param].push(pred); - return pred as any; - }); + return normalizeLogicalComposition( + o, + param => { + const empty = normParams.emptySelections[param] ?? true; + const pred = {param, empty}; + normParams.selectionPredicates[param] ??= []; + normParams.selectionPredicates[param].push(pred); + return pred as any; + } + ); }; return op.selection ? normalizeSelectionComposition(op.selection) - : normalizeLogicalComposition(op.test || op.filter, o => - o.selection ? normalizeSelectionComposition(o.selection) : o + : normalizeLogicalComposition( + op.test || op.filter, + o => (o.selection ? normalizeSelectionComposition(o.selection) : o) ); } diff --git ORI/vega-lite/test/compositemark/common.test.ts ALT/vega-lite/test/compositemark/common.test.ts index 845a89a47..8cc9eeba5 100644 --- ORI/vega-lite/test/compositemark/common.test.ts +++ ALT/vega-lite/test/compositemark/common.test.ts @@ -167,12 +167,15 @@ describe('common', () => { expect(isAggregate(aggregateTransform)).toBeTruthy(); expect( - some(aggregateTransform.aggregate, aggregateFieldDef => { - return ( - aggregateFieldDef.field === aggField && - (aggregateFieldDef.op === 'mean' || aggregateFieldDef.op === 'median') - ); - }) + some( + aggregateTransform.aggregate, + aggregateFieldDef => { + return ( + aggregateFieldDef.field === aggField && + (aggregateFieldDef.op === 'mean' || aggregateFieldDef.op === 'median') + ); + } + ) ).toBe(true); }); } diff --git ORI/vega-lite/test/compositemark/errorband.test.ts ALT/vega-lite/test/compositemark/errorband.test.ts index 4466d3a7f..249078a73 100644 --- ORI/vega-lite/test/compositemark/errorband.test.ts +++ ALT/vega-lite/test/compositemark/errorband.test.ts @@ -91,14 +91,20 @@ describe('normalizeErrorBand', () => { const layer = isLayerSpec(outputSpec) && outputSpec.layer; if (layer) { expect( - some(layer, unitSpec => { - return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && unitSpec.mark.type === 'rect'; - }) + some( + layer, + unitSpec => { + return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && unitSpec.mark.type === 'rect'; + } + ) ).toBe(true); expect( - some(layer, unitSpec => { - return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && unitSpec.mark.type === 'rule'; - }) + some( + layer, + unitSpec => { + return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && unitSpec.mark.type === 'rule'; + } + ) ).toBe(true); } else { expect(false).toBe(true); @@ -121,14 +127,20 @@ describe('normalizeErrorBand', () => { const layer = isLayerSpec(outputSpec) && outputSpec.layer; if (layer) { expect( - some(layer, unitSpec => { - return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && unitSpec.mark.type === 'area'; - }) + some( + layer, + unitSpec => { + return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && unitSpec.mark.type === 'area'; + } + ) ).toBe(true); expect( - some(layer, unitSpec => { - return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && unitSpec.mark.type === 'line'; - }) + some( + layer, + unitSpec => { + return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && unitSpec.mark.type === 'line'; + } + ) ).toBe(true); } else { expect(false).toBe(true); @@ -151,9 +163,12 @@ describe('normalizeErrorBand', () => { const layer = isLayerSpec(outputSpec) && outputSpec.layer; if (layer) { expect( - every(layer, unitSpec => { - return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && unitSpec.mark.interpolate === 'monotone'; - }) + every( + layer, + unitSpec => { + return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && unitSpec.mark.interpolate === 'monotone'; + } + ) ).toBe(true); } else { expect(false).toBe(true); @@ -176,9 +191,12 @@ describe('normalizeErrorBand', () => { const layer = isLayerSpec(outputSpec) && outputSpec.layer; expect( - every(layer, unitSpec => { - return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && !unitSpec.mark.interpolate; - }) + every( + layer, + unitSpec => { + return isUnitSpec(unitSpec) && isMarkDef(unitSpec.mark) && !unitSpec.mark.interpolate; + } + ) ).toBe(true); expect(localLogger.warns[0]).toEqual(log.message.errorBand1DNotSupport('interpolate')); }) diff --git ORI/vega-lite/test/compositemark/errorbar.test.ts ALT/vega-lite/test/compositemark/errorbar.test.ts index f9d14a294..8d1a52a64 100644 --- ORI/vega-lite/test/compositemark/errorbar.test.ts +++ ALT/vega-lite/test/compositemark/errorbar.test.ts @@ -228,16 +228,19 @@ describe('normalizeErrorBar with raw data input', () => { const layer = isLayerSpec(outputSpec) && outputSpec.layer; if (layer) { expect( - some(layer, unitSpec => { - return ( - isUnitSpec(unitSpec) && - isMarkDef(unitSpec.mark) && - unitSpec.mark.type === 'tick' && - unitSpec.mark.size === size && - unitSpec.mark.color === color && - unitSpec.mark.opacity === opacity - ); - }) + some( + layer, + unitSpec => { + return ( + isUnitSpec(unitSpec) && + isMarkDef(unitSpec.mark) && + unitSpec.mark.type === 'tick' && + unitSpec.mark.size === size && + unitSpec.mark.color === color && + unitSpec.mark.opacity === opacity + ); + } + ) ).toBe(true); } else { expect(false).toBe(true); @@ -537,54 +540,78 @@ describe('normalizeErrorBar for all possible extents and centers with raw data i if (isAggregate(aggregateTransform)) { if (extent === 'iqr' || (center === 'median' && !extent)) { expect( - some(aggregateTransform.aggregate, aggregateFieldDef => { - return aggregateFieldDef.op === 'median'; - }) + some( + aggregateTransform.aggregate, + aggregateFieldDef => { + return aggregateFieldDef.op === 'median'; + } + ) ).toBe(true); } else if (extent === 'ci') { expect( - some(aggregateTransform.aggregate, aggregateFieldDef => { - return aggregateFieldDef.op === 'mean'; - }) + some( + aggregateTransform.aggregate, + aggregateFieldDef => { + return aggregateFieldDef.op === 'mean'; + } + ) ).toBe(true); } else { if (center) { expect( - some(aggregateTransform.aggregate, aggregateFieldDef => { - return aggregateFieldDef.op === center; - }) + some( + aggregateTransform.aggregate, + aggregateFieldDef => { + return aggregateFieldDef.op === center; + } + ) ).toBe(true); } else { expect( - some(aggregateTransform.aggregate, aggregateFieldDef => { - return aggregateFieldDef.op === 'mean'; - }) + some( + aggregateTransform.aggregate, + aggregateFieldDef => { + return aggregateFieldDef.op === 'mean'; + } + ) ).toBe(true); } if (extent) { expect( - some(aggregateTransform.aggregate, aggregateFieldDef => { - return isPartOfExtent(extent, aggregateFieldDef.op); - }) + some( + aggregateTransform.aggregate, + aggregateFieldDef => { + return isPartOfExtent(extent, aggregateFieldDef.op); + } + ) ).toBe(true); } else if (center === 'median') { expect( - some(aggregateTransform.aggregate, aggregateFieldDef => { - return isPartOfExtent('iqr', aggregateFieldDef.op); - }) + some( + aggregateTransform.aggregate, + aggregateFieldDef => { + return isPartOfExtent('iqr', aggregateFieldDef.op); + } + ) ).toBe(true); expect( - some(aggregateTransform.aggregate, aggregateFieldDef => { - return aggregateFieldDef.op === 'median'; - }) + some( + aggregateTransform.aggregate, + aggregateFieldDef => { + return aggregateFieldDef.op === 'median'; + } + ) ).toBe(false); } else { expect( - some(aggregateTransform.aggregate, aggregateFieldDef => { - return isPartOfExtent('stderr', aggregateFieldDef.op); - }) + some( + aggregateTransform.aggregate, + aggregateFieldDef => { + return isPartOfExtent('stderr', aggregateFieldDef.op); + } + ) ).toBe(true); } } diff --git ORI/vega-lite/test/scale.test.ts ALT/vega-lite/test/scale.test.ts index 7f167e049..28bbfe81b 100644 --- ORI/vega-lite/test/scale.test.ts +++ ALT/vega-lite/test/scale.test.ts @@ -16,9 +16,12 @@ describe('scale', () => { it('should have at least one supported scale types for all scale properties', () => { for (const prop of scale.SCALE_PROPERTIES) { expect( - some(scale.SCALE_TYPES, scaleType => { - return scale.scaleTypeSupportProperty(scaleType, prop); - }) + some( + scale.SCALE_TYPES, + scaleType => { + return scale.scaleTypeSupportProperty(scaleType, prop); + } + ) ).toBeTruthy(); } }); @@ -39,9 +42,12 @@ describe('scale', () => { it('should have at least one supported scale types for all channels with scale', () => { for (const channel of SCALE_CHANNELS) { expect( - some(SCALE_TYPES, scaleType => { - return channelSupportScaleType(channel, scaleType); - }) + some( + SCALE_TYPES, + scaleType => { + return channelSupportScaleType(channel, scaleType); + } + ) ).toBeTruthy(); } }); @@ -50,9 +56,12 @@ describe('scale', () => { it('should have at least one supported channel for all scale types', () => { for (const scaleType of SCALE_TYPES) { expect( - some(SCALE_CHANNELS, channel => { - return channelSupportScaleType(channel, scaleType); - }) + some( + SCALE_CHANNELS, + channel => { + return channelSupportScaleType(channel, scaleType); + } + ) ).toBeTruthy(); } }); ```
sosukesuzuki commented 3 years ago

run sosukesuzuki/prettier#fix-10571

github-actions[bot] commented 3 years ago

sosukesuzuki/prettier@fix-10571 VS prettier/prettier@main

  • babel/babel@2ae19d01b132f5222e1d5bee2c83921e2f107d70
  • vuejs/eslint-plugin-vue@62f577dcfcb859c24c6e0d4615ad880f5e1d4688
  • excalidraw/excalidraw@25fd27515866b5704066d9301dd641c481f6c38c
  • prettier/prettier@5f8bad8275a589ec903bddeacd484123c7db54ab
  • typescript-eslint/typescript-eslint@d0d71862efd7e079694fa9513ea983cc908ec6f6
  • vega/vega-lite@2dff36f971d76292ef3747fc3568e53bf747ef51
Diff (173 lines) ````diff diff --git ORI/excalidraw/src/element/transformHandles.ts ALT/excalidraw/src/element/transformHandles.ts index 579dd53..0c2d03d 100644 --- ORI/excalidraw/src/element/transformHandles.ts +++ ALT/excalidraw/src/element/transformHandles.ts @@ -22,7 +22,9 @@ export type TransformHandles = Partial< >; export type MaybeTransformHandleType = TransformHandleType | false; -const transformHandleSizes: { [k in PointerType]: number } = { +const transformHandleSizes: { + [k in PointerType]: number; +} = { mouse: 8, pen: 16, touch: 28, @@ -221,7 +223,9 @@ export const getTransformHandles = ( zoom: Zoom, pointerType: PointerType = "mouse", ): TransformHandles => { - let omitSides: { [T in TransformHandleType]?: boolean } = {}; + let omitSides: { + [T in TransformHandleType]?: boolean; + } = {}; if ( element.type === "arrow" || element.type === "line" || diff --git ORI/typescript-eslint/packages/eslint-plugin/docs/rules/no-type-alias.md ALT/typescript-eslint/packages/eslint-plugin/docs/rules/no-type-alias.md index 5b720b2..5dc683f 100644 --- ORI/typescript-eslint/packages/eslint-plugin/docs/rules/no-type-alias.md +++ ALT/typescript-eslint/packages/eslint-plugin/docs/rules/no-type-alias.md @@ -41,7 +41,9 @@ person.walk(); - Act like mapping tools between types to allow quick modifications. ```ts -type Immutable = { readonly [P in keyof T]: T[P] }; +type Immutable = { + readonly [P in keyof T]: T[P]; +}; type Person = { name: string; @@ -395,9 +397,13 @@ The setting accepts the following values: Examples of **correct** code for the `{ "allowMappedTypes": "always" }` options: ```ts -type Foo = { readonly [P in keyof T]: T[P] }; +type Foo = { + readonly [P in keyof T]: T[P]; +}; -type Foo = { [P in keyof T]?: T[P] }; +type Foo = { + [P in keyof T]?: T[P]; +}; type Foo = | { readonly [P in keyof T]: T[P] } @@ -414,9 +420,13 @@ type Foo = { [P in keyof T]?: T[P] } & { [P in keyof U]?: U[P] }; Examples of **incorrect** code for the `{ "allowMappedTypes": "in-unions" }` option: ```ts -type Foo = { readonly [P in keyof T]: T[P] }; +type Foo = { + readonly [P in keyof T]: T[P]; +}; -type Foo = { [P in keyof T]?: T[P] }; +type Foo = { + [P in keyof T]?: T[P]; +}; type Foo = { readonly [P in keyof T]: T[P] } & { readonly [P in keyof U]: U[P] }; @@ -437,9 +447,13 @@ type Foo = { [P in keyof T]?: T[P] } | { [P in keyof U]?: U[P] }; Examples of **incorrect** code for the `{ "allowMappedTypes": "in-intersections" }` option: ```ts -type Foo = { readonly [P in keyof T]: T[P] }; +type Foo = { + readonly [P in keyof T]: T[P]; +}; -type Foo = { [P in keyof T]?: T[P] }; +type Foo = { + [P in keyof T]?: T[P]; +}; type Foo = | { readonly [P in keyof T]: T[P] } @@ -460,9 +474,13 @@ type Foo = { [P in keyof T]?: T[P] } & { [P in keyof U]?: U[P] }; Examples of **incorrect** code for the `{ "allowMappedTypes": "in-unions-and-intersections" }` option: ```ts -type Foo = { readonly [P in keyof T]: T[P] }; +type Foo = { + readonly [P in keyof T]: T[P]; +}; -type Foo = { [P in keyof T]?: T[P] }; +type Foo = { + [P in keyof T]?: T[P]; +}; ``` Examples of **correct** code for the `{ "allowMappedTypes": "in-unions-and-intersections" }` option: diff --git ORI/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts ALT/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts index 7664010..fb99451 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts @@ -15,7 +15,9 @@ const enum OptionKeys { VariableDeclarationIgnoreFunction = 'variableDeclarationIgnoreFunction', } -type Options = { [k in OptionKeys]?: boolean }; +type Options = { + [k in OptionKeys]?: boolean; +}; type MessageIds = 'expectedTypedef' | 'expectedTypedefNamed'; diff --git ORI/typescript-eslint/packages/eslint-plugin/src/util/misc.ts ALT/typescript-eslint/packages/eslint-plugin/src/util/misc.ts index e7e0991..0b3b645 100644 --- ORI/typescript-eslint/packages/eslint-plugin/src/util/misc.ts +++ ALT/typescript-eslint/packages/eslint-plugin/src/util/misc.ts @@ -92,7 +92,9 @@ function getNameFromMember( type ExcludeKeys< TObj extends Record, TKeys extends keyof TObj, -> = { [k in Exclude]: TObj[k] }; +> = { + [k in Exclude]: TObj[k]; +}; type RequireKeys< TObj extends Record, TKeys extends keyof TObj, diff --git ORI/typescript-eslint/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts ALT/typescript-eslint/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts index a91c6ae..8d5da6c 100644 --- ORI/typescript-eslint/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts +++ ALT/typescript-eslint/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts @@ -1,2 +1,4 @@ type T = Record; -type A = { [k in string]: T[k] }; +type A = { + [k in string]: T[k]; +}; diff --git ORI/vega-lite/src/util.ts ALT/vega-lite/src/util.ts index cd624dd..0686c6e 100644 --- ORI/vega-lite/src/util.ts +++ ALT/vega-lite/src/util.ts @@ -113,7 +113,9 @@ export function every(arr: readonly T[], f: (d: T, k?: any, i?: any) => boole /** * Like TS Partial but applies recursively to all properties. */ -export type DeepPartial = {[P in keyof T]?: DeepPartial}; +export type DeepPartial = { + [P in keyof T]?: DeepPartial; +}; /** * recursively merges src into dest @@ -225,7 +227,9 @@ export const entries = Object.entries; // Using mapped type to declare a collect of flags for a string literal type S // https://www.typescriptlang.org/docs/handbook/advanced-types.html#mapped-types -export type Flag = {[K in S]: 1}; +export type Flag = { + [K in S]: 1; +}; export function isBoolean(b: any): b is boolean { return b === true || b === false; ````