-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updated the json-swagger plugin to support the 3.x pretter - Switch the plugin to be JS based to avoid the need to compile via TS - Simplified plugin to delegate most work to the base estree plugin - Move swagger plugin source under eng
- Loading branch information
1 parent
ebb636f
commit 7eaa071
Showing
6 changed files
with
41 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const plugins_estree = require("prettier/plugins/estree"); | ||
const plugins_babel = require("prettier/plugins/babel") | ||
|
||
// Customize the standard json-stringify parser from https://github.com/prettier/prettier/blob/50404103ef7d96fb36f8cba1ac7bc40c671fd6cf/src/language-json/parser-json.js | ||
const print = (path, options, print) => { | ||
const node = path.getValue(); | ||
|
||
if (node.type === "NumericLiteral") { | ||
// Keep numeric literal as-is to allow values to have more then one trailing digit after the decimal like 100.00 | ||
return node.extra.raw; | ||
} | ||
|
||
return plugins_estree.printers['estree-json'].print(path, options, print); | ||
}; | ||
|
||
exports.languages = [ | ||
{ | ||
name: 'json-swagger', | ||
extensions: ['.json'], | ||
parsers: ['json-swagger'] | ||
} | ||
]; | ||
exports.parsers = { | ||
'json-swagger': { | ||
...plugins_babel.parsers['json-stringify'], | ||
astFormat: 'estree-swagger-customized' | ||
} | ||
}; | ||
exports.printers = { | ||
'estree-swagger-customized': { | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.