Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: prettier/plugin-xml
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.2.0
Choose a base ref
...
head repository: prettier/plugin-xml
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.0.0
Choose a head ref
Loading
Showing with 896 additions and 883 deletions.
  1. +8 −1 CHANGELOG.md
  2. +5 −5 package.json
  3. +27 −49 src/plugin.ts
  4. +856 −828 yarn.lock
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

## [Unreleased]

## [2.0.0] - 2022-03-22

### Changed

- Require prettier `2.4.0` for the `bracketSameLine` option.

## [1.2.0] - 2021-12-23

### Added
@@ -167,7 +173,8 @@ and it will maintain your formatting.

- Initial release 🎉

[unreleased]: https://github.com/prettier/plugin-xml/compare/v1.2.0...HEAD
[unreleased]: https://github.com/prettier/plugin-xml/compare/v2.0.0...HEAD
[2.0.0]: https://github.com/prettier/plugin-xml/compare/v1.2.0...v2.0.0
[1.2.0]: https://github.com/prettier/plugin-xml/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/prettier/plugin-xml/compare/v1.0.2...v1.1.0
[1.0.2]: https://github.com/prettier/plugin-xml/compare/v1.0.1...v1.0.2
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prettier/plugin-xml",
"version": "1.2.0",
"version": "2.0.0",
"description": "prettier plugin for XML",
"main": "dist/plugin.js",
"scripts": {
@@ -21,14 +21,14 @@
"homepage": "https://github.com/prettier/plugin-xml#readme",
"dependencies": {
"@xml-tools/parser": "^1.0.11",
"prettier": ">=2.3"
"prettier": ">=2.4.0"
},
"devDependencies": {
"@types/jest": "^27.0.0",
"@types/node": "^17.0.4",
"@types/node": "^17.0.22",
"@types/prettier": "^2.3.0",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"eslint": "^8.5.0",
"eslint-config-prettier": "^8.0.0",
"jest": "^27.0.1",
76 changes: 27 additions & 49 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,7 @@
import prettier from "prettier";

import type { Plugin } from "./types";
import parser from "./parser";
import printer from "./printer";

// These are the extra options defined by this plugin.
const options: Plugin["options"] = {
xmlSelfClosingSpace: {
type: "boolean",
category: "XML",
default: true,
description: "Adds a space before self-closing tags.",
since: "1.1.0"
},
xmlWhitespaceSensitivity: {
type: "choice",
category: "XML",
default: "strict",
description: "How to handle whitespaces in XML.",
choices: [
{
value: "strict",
description: "Whitespaces are considered sensitive in all elements."
},
{
value: "ignore",
description: "Whitespaces are considered insensitive in all elements."
}
],
since: "0.6.0"
}
};

// We're going to be using the bracketSameLine option, but since it wasn't
// introduced until prettier 2.4.0, we need to add it to our list of options if
// it's not present so that it gets respected.
if (
!prettier
.getSupportInfo()
.options.some((opt) => opt.name === "bracketSameLine")
) {
options.bracketSameLine = {
type: "boolean",
category: "Global",
default: false,
description:
"Put > of opening tags on the last line instead of on a new line.",
since: "1.0.0"
};
}

const plugin: Plugin = {
languages: [
{
@@ -114,6 +66,7 @@ const plugin: Plugin = {
".rdf",
".resx",
".rss",
".runsettings",
".sch",
".scxml",
".sfproj",
@@ -186,7 +139,32 @@ const plugin: Plugin = {
printers: {
xml: printer
},
options,
options: {
xmlSelfClosingSpace: {
type: "boolean",
category: "XML",
default: true,
description: "Adds a space before self-closing tags.",
since: "1.1.0"
},
xmlWhitespaceSensitivity: {
type: "choice",
category: "XML",
default: "strict",
description: "How to handle whitespaces in XML.",
choices: [
{
value: "strict",
description: "Whitespaces are considered sensitive in all elements."
},
{
value: "ignore",
description: "Whitespaces are considered insensitive in all elements."
}
],
since: "0.6.0"
}
},
defaultOptions: {
printWidth: 80,
tabWidth: 2
1,684 changes: 856 additions & 828 deletions yarn.lock

Large diffs are not rendered by default.