@prettier/plugin-xml
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -9,2 +9,13 @@ # Changelog | ||
## [3.2.1] - 2023-09-11 | ||
### Added | ||
- Updated the documentation to reflect that you need to pass the plugin path now. | ||
### Changed | ||
- Error messages thrown by the plugin are now much closer to the error messages thrown by prettier. | ||
- Fixed a bug where self-closing tags that looked like embeds would throw an error. | ||
## [3.2.0] - 2023-08-08 | ||
@@ -232,3 +243,4 @@ | ||
[unreleased]: https://github.com/prettier/plugin-xml/compare/v3.2.0...HEAD | ||
[unreleased]: https://github.com/prettier/plugin-xml/compare/v3.2.1...HEAD | ||
[3.2.1]: https://github.com/prettier/plugin-xml/compare/v3.2.0...v3.2.1 | ||
[3.2.0]: https://github.com/prettier/plugin-xml/compare/v3.1.1...v3.2.0 | ||
@@ -235,0 +247,0 @@ [3.1.1]: https://github.com/prettier/plugin-xml/compare/v3.1.0...v3.1.1 |
{ | ||
"name": "@prettier/plugin-xml", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "prettier plugin for XML", | ||
@@ -35,3 +35,3 @@ "type": "module", | ||
"linguist-languages": "^7.21.0", | ||
"lint-staged": "^13.2.3", | ||
"lint-staged": "^14.0.0", | ||
"prettier": "^3.0.0" | ||
@@ -38,0 +38,0 @@ }, |
@@ -42,3 +42,3 @@ <h1 align="center">Prettier for XML</h1> | ||
```bash | ||
./node_modules/.bin/prettier --write '**/*.xml' | ||
./node_modules/.bin/prettier --plugin=@prettier/plugin-xml --write '**/*.xml' | ||
``` | ||
@@ -73,3 +73,3 @@ | ||
```bash | ||
prettier --tab-width 4 --write '**/*.xml' | ||
prettier --plugin=@prettier/plugin-xml --tab-width 4 --write '**/*.xml' | ||
``` | ||
@@ -76,0 +76,0 @@ |
@@ -127,2 +127,7 @@ import * as doc from "prettier/doc"; | ||
// If the node is self-closing, then skip | ||
if (!node.children.content) { | ||
return; | ||
} | ||
// If the node does not actually contain content, or it contains any content | ||
@@ -129,0 +134,0 @@ // that is not just plain text, then skip |
import { parse as xmlToolsParse } from "@xml-tools/parser"; | ||
function createError(message, options) { | ||
// TODO: Use `Error.prototype.cause` when we drop support for Node.js<18.7.0 | ||
// Construct an error similar to the ones thrown by Prettier. | ||
const error = new SyntaxError( | ||
message + | ||
" (" + | ||
options.loc.start.line + | ||
":" + | ||
options.loc.start.column + | ||
")" | ||
); | ||
return Object.assign(error, options); | ||
} | ||
const parser = { | ||
@@ -10,10 +26,11 @@ parse(text) { | ||
const lexError = lexErrors[0]; | ||
const error = new Error(lexError.message); | ||
error.loc = { | ||
start: { line: lexError.line, column: lexError.column }, | ||
end: { line: lexError.line, column: lexError.column + lexError.length } | ||
}; | ||
throw error; | ||
throw createError(lexError.message, { | ||
loc: { | ||
start: { line: lexError.line, column: lexError.column }, | ||
end: { | ||
line: lexError.line, | ||
column: lexError.column + lexError.length | ||
} | ||
} | ||
}); | ||
} | ||
@@ -24,11 +41,14 @@ | ||
const parseError = parseErrors[0]; | ||
const error = new Error(parseError.message); | ||
const { token } = parseError; | ||
error.loc = { | ||
start: { line: token.startLine, column: token.startColumn }, | ||
end: { line: token.endLine, column: token.endColumn } | ||
}; | ||
throw error; | ||
throw createError(parseError.message, { | ||
loc: { | ||
start: { | ||
line: parseError.token.startLine, | ||
column: parseError.token.startColumn | ||
}, | ||
end: { | ||
line: parseError.token.endLine, | ||
column: parseError.token.endColumn | ||
} | ||
} | ||
}); | ||
} | ||
@@ -35,0 +55,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48589
1063