Skip to content

Commit

Permalink
various
Browse files Browse the repository at this point in the history
  • Loading branch information
panoply committed Jun 27, 2022
1 parent 0f030e4 commit e98ebba
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 10,330 deletions.
10,328 changes: 6 additions & 10,322 deletions index.mjs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"pack": "cd versions; pnpm pack ../ && cd ..",
"play": "ava tests/play.test.mjs --color --watch",
"test": "ava tests/cases/*.test.mjs --serial",
"test:attributes": "ava tests/cases/attributes* ---",
"test:comments": "ava tests/cases/comments* ---",
"test:css": "ava tests/cases/css* ---",
"test:language": "ava tests/cases/language* ---",
Expand All @@ -52,7 +53,8 @@
"splitting": false,
"format": [
"cjs",
"esm"
"esm",
"iife"
]
},
"prettier": "@liquify/prettier-config",
Expand Down
2 changes: 1 addition & 1 deletion src/prettify/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function options (rules: Options) {
} else if (rule === 'style') {
assign(prettify.options.style, rules.style);
} else if (rule === 'json') {
assign(prettify.options.json, rules.json);
assign(prettify.options.script, rules.script);
} else if (rule in prettify.options) {
prettify.options[rule] = rules[rule];
}
Expand Down
2 changes: 1 addition & 1 deletion src/prettify/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ prettify.options.markup = create(null);
prettify.options.markup.attributeGlue = true;
prettify.options.markup.attributeSort = false;
prettify.options.markup.attributeSortList = [];
prettify.options.markup.attributeValueNewlines = 'collapse';
prettify.options.markup.attributeValueNewlines = 'force';
prettify.options.markup.commentNewline = false;
prettify.options.markup.forceAttribute = false;
prettify.options.markup.preserveText = false;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Used for generating repeating characters
* and is merely a wraper around `''.repeat()`
*/
export function repeatChar (count: number, ch: string) {
export function repeatChar (count: number, ch: string = ' ') {

if (count === 0) return ch;

Expand Down
53 changes: 49 additions & 4 deletions tests/cases/attributes.test.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,59 @@
import test from 'ava';
import { samples } from '@liquify/test-utils';
import prettify from '../../index.mjs';
import prettify from '@liquify/prettify';

test.serial('Conditional attributes', async t => {
test.serial.skip('preserveAttributes: true', async t => {

const { source } = await samples.get('markup/preserve-attributes');

const output = await prettify.format(source, {
markup: {
preserveAttributes: true
}
});

t.snapshot(output);

});

test.serial('attributeValueNewlines: "force"', async t => {

const { source } = await samples.get('markup/attribute-value-newlines');

return prettify.format(source, {

markup: {
attributeValueNewlines: 'force'
}
}).then(v => {

return prettify.format(v, {
wrap: 80,
markup: {
attributeValueNewlines: 'force'
}
}).then(v => {

t.log(v);
t.pass();

}).catch(t.log);

}).catch(t.log);

});

test.serial.skip('attributeValueNewlines: "align"', async t => {

const { source } = await samples.get('markup/attribute-value-newlines');

return prettify.format(source).then(v => {
return prettify.format(source, {
markup: {
attributeValueNewlines: 'align'
}
}).then(v => {

t.log((v).split('\n'));
t.log(v);
t.pass();

}).catch(t.log);
Expand Down

0 comments on commit e98ebba

Please sign in to comment.