Don't trim in html insertPragma (#14441)
This commit is contained in:
1 parent
bed4247180
commit
cb25bd31f5
6 files changed
+159
-1
No files matched your search
@@ -3,7 +3,7 @@ function hasPragma(text) {
|
||||
}
|
||||
|
||||
function insertPragma(text) {
|
||||
return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, "");
|
||||
return "<!-- @format -->\n\n" + text;
|
||||
}
|
||||
|
||||
export { hasPragma, insertPragma };
|
||||
@@ -0,0 +1,138 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`no-pragma.html - {"insertPragma":true} format 1`] = `
|
||||
====================================options=====================================
|
||||
insertPragma: true
|
||||
parsers: ["html"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
|
||||
|
||||
<!-- @not-a-pragma -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
</html>
|
||||
|
||||
=====================================output=====================================
|
||||
<!-- @format -->
|
||||
|
||||
<!-- @not-a-pragma -->
|
||||
<!doctype html>
|
||||
<html></html>
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`no-pragma.html - {"requirePragma":true} format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["html"]
|
||||
printWidth: 80
|
||||
requirePragma: true
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
|
||||
|
||||
<!-- @not-a-pragma -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
</html>
|
||||
|
||||
=====================================output=====================================
|
||||
|
||||
|
||||
<!-- @not-a-pragma -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
</html>
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`with-pragma.html - {"insertPragma":true} format 1`] = `
|
||||
====================================options=====================================
|
||||
insertPragma: true
|
||||
parsers: ["html"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
|
||||
|
||||
<!-- @format -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
</html>
|
||||
|
||||
=====================================output=====================================
|
||||
<!-- @format -->
|
||||
<!doctype html>
|
||||
<html></html>
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`with-pragma.html - {"requirePragma":true} format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["html"]
|
||||
printWidth: 80
|
||||
requirePragma: true
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
|
||||
|
||||
<!-- @format -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
</html>
|
||||
|
||||
=====================================output=====================================
|
||||
<!-- @format -->
|
||||
<!doctype html>
|
||||
<html></html>
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`with-pragma-2.html - {"insertPragma":true} format 1`] = `
|
||||
====================================options=====================================
|
||||
insertPragma: true
|
||||
parsers: ["html"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
|
||||
|
||||
<!-- @prettier -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
</html>
|
||||
|
||||
=====================================output=====================================
|
||||
<!-- @prettier -->
|
||||
<!doctype html>
|
||||
<html></html>
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`with-pragma-2.html - {"requirePragma":true} format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["html"]
|
||||
printWidth: 80
|
||||
requirePragma: true
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
|
||||
|
||||
<!-- @prettier -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
</html>
|
||||
|
||||
=====================================output=====================================
|
||||
<!-- @prettier -->
|
||||
<!doctype html>
|
||||
<html></html>
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1,2 @@
|
||||
run_spec(import.meta, ["html"], { requirePragma: true });
|
||||
run_spec(import.meta, ["html"], { insertPragma: true });
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
<!-- @not-a-pragma -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
<!-- @prettier -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
<!-- @format -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
</html>
|
||||
Reference in new issue
Block a user