@prettier/plugin-xml
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -9,2 +9,8 @@ # Changelog | ||
## [2.2.0] - 2022-05-12 | ||
### Added | ||
- Better error messages in the case of a syntax error. | ||
## [2.1.0] - 2022-04-16 | ||
@@ -189,3 +195,4 @@ | ||
[unreleased]: https://github.com/prettier/plugin-xml/compare/v2.1.0...HEAD | ||
[unreleased]: https://github.com/prettier/plugin-xml/compare/v2.2.0...HEAD | ||
[2.2.0]: https://github.com/prettier/plugin-xml/compare/v2.1.0...v2.2.0 | ||
[2.1.0]: https://github.com/prettier/plugin-xml/compare/v2.0.1...v2.1.0 | ||
@@ -192,0 +199,0 @@ [2.0.1]: https://github.com/prettier/plugin-xml/compare/v2.0.0...v2.0.1 |
@@ -7,5 +7,24 @@ "use strict"; | ||
const { lexErrors, parseErrors, cst } = (0, parser_1.parse)(text); | ||
if (lexErrors.length > 0 || parseErrors.length > 0) { | ||
throw Error("Error parsing XML"); | ||
// If there are any lexical errors, throw the first of them as an error. | ||
if (lexErrors.length > 0) { | ||
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; | ||
} | ||
// If there are any parse errors, throw the first of them as an error. | ||
if (parseErrors.length > 0) { | ||
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; | ||
} | ||
// Otherwise return the CST. | ||
return cst; | ||
@@ -12,0 +31,0 @@ }, |
{ | ||
"name": "@prettier/plugin-xml", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "prettier plugin for XML", | ||
@@ -27,3 +27,3 @@ "main": "dist/plugin.js", | ||
"devDependencies": { | ||
"@types/jest": "^27.0.0", | ||
"@types/jest": "^27.5.1", | ||
"@types/node": "^17.0.22", | ||
@@ -35,4 +35,4 @@ "@types/prettier": "^2.3.0", | ||
"eslint-config-prettier": "^8.0.0", | ||
"jest": "^27.0.1", | ||
"ts-jest": "^27.0.2", | ||
"jest": "^28.1.0", | ||
"ts-jest": "^28.0.2", | ||
"ts-node": "^10.0.0", | ||
@@ -39,0 +39,0 @@ "typescript": "^4.3.2" |
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
40499
676
11