Comparing version 0.5.6-beta.1 to 0.6.0-beta.1
635
index.d.ts
@@ -0,1 +1,2 @@ | ||
/* eslint-disable no-redeclare */ | ||
/* eslint-disable no-use-before-define */ | ||
@@ -6,3 +7,3 @@ /* eslint-disable object-curly-newline */ | ||
import { Hooks } from './types/hooks'; | ||
import * as Γ from './types/index'; | ||
import { | ||
@@ -16,210 +17,564 @@ LiquidFormat, | ||
import { | ||
Rules, | ||
Definitions, | ||
Language, | ||
Grammars, | ||
Stats, | ||
IParseError, | ||
IConfig, | ||
IConfigInternal, | ||
Data | ||
} from './types/index'; | ||
declare namespace Γsthetic { | ||
export { | ||
Definition, | ||
Definitions, | ||
Rules, | ||
GlobalRules, | ||
LiquidRules, | ||
MarkupRules, | ||
ScriptRules, | ||
StyleRules, | ||
JSONRules, | ||
Language, | ||
LanguageName, | ||
LanguageOfficialName, | ||
LexerName, | ||
Record, | ||
ParseHook, | ||
Data as ParseTable | ||
} from './types/index'; | ||
interface Static { | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Rule Defintions | ||
* | ||
* Rule defintions which describe the different formatting options | ||
* esthetic offers. | ||
*/ | ||
get presets(): { defaults: Rules }; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Rule Defintions | ||
* | ||
* Rule defintions which describe the different formatting options | ||
* esthetic offers. | ||
*/ | ||
get definitions(): Γ.Definitions; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Statistics | ||
* | ||
* Maintains a reference of statistic information about the | ||
* operation, also available in events like `esthetic.on('format')` and | ||
* `esthetic.on('parse')` arguments. | ||
*/ | ||
get stats(): Γ.Stats; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Parse Table | ||
* | ||
* Returns the current Parse Table data~structure. You can only call this | ||
* in a post beautification or parse cycle. | ||
*/ | ||
get table(): Γ.Data; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Parse Error | ||
* | ||
* Returns the the Parse Error or `null` if no error | ||
*/ | ||
get error(): Γ.IParseError; | ||
/** | ||
* #### _Γsthetic Liquid_ | ||
* | ||
* Formatting for the Liquid Template Language. | ||
*/ | ||
liquid: LiquidFormat; | ||
/** | ||
* #### _Γsthetic HTML_ | ||
* | ||
* Formatting for the HTML Language. | ||
*/ | ||
html: HTMLFormat; | ||
/** | ||
* #### _Γsthetic XML_ | ||
* | ||
* Formatting for the XML Language. | ||
*/ | ||
xml: XMLFormat; | ||
/** | ||
* #### _Γsthetic CSS_ | ||
* | ||
* Formatting for the CSS Language. | ||
*/ | ||
css: CSSFormat | ||
/** | ||
* #### _Γsthetic JSON_ | ||
* | ||
* Formatting for the JSON Language. | ||
*/ | ||
json: JSONFormat; | ||
/** | ||
* #### _Γsthetic JavaScript_ | ||
* | ||
* **β οΈ EXPERIMENTAL β οΈ** | ||
* | ||
* Formatting for the JavaScript Language. | ||
*/ | ||
js: LiquidFormat; | ||
/** | ||
* #### _Γsthetic TypeScript_ | ||
* | ||
* **β οΈ EXPERIMENTAL β οΈ** | ||
* | ||
* Formatting for the TypeScript Language. | ||
*/ | ||
ts: LiquidFormat; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Format | ||
* | ||
* Γsthetic supports multiple languages but one should use | ||
* the experimental languages with caution until they are | ||
* out of BETA with full support. | ||
* | ||
* Full Support: | ||
* | ||
* - Liquid | ||
* - HTML | ||
* - XML | ||
* - CSS | ||
* - SCSS | ||
* - JSON | ||
* | ||
* Partial Support: | ||
* | ||
* - JavaScript | ||
* - TypeScript | ||
* - JSX | ||
* - TSX | ||
* --- | ||
* | ||
* @example | ||
* | ||
* import esthetic from 'esthetic'; | ||
* | ||
* const output = esthetic.format('<div id="foo"> Hello World </div>', { | ||
* language: 'html', | ||
* markup: { | ||
* forceAttribute: true | ||
* } | ||
* }); | ||
* | ||
* console.log(output); | ||
* | ||
*/ | ||
format: (source: string | Buffer, rules?: Γ.Rules) => string; | ||
export declare const esthetic: { | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Parse | ||
* | ||
* Executes a parse operation and returns the generate data structure. | ||
* When calling this method, beautification will not be applied, the | ||
* parse table is returned. | ||
* | ||
* The `esthetic.format()` method will execute a parse, so only use this | ||
* method when you are working with the parse table itself, otherwise use | ||
* `esthetic.format()` or one of the language specifics. | ||
* | ||
* --- | ||
* | ||
* **NOTE** | ||
* | ||
* You cannot pass rules, use the `esthetic.rules({})` method instead. | ||
* | ||
* --- | ||
* | ||
* @example | ||
* | ||
* import esthetic from 'esthetic'; | ||
* | ||
* const data = esthetic.parse('<div id="foo"> Hello World </div>'); | ||
* | ||
* // data.begin | ||
* // data.ender | ||
* // data.lexer | ||
* // data.lines | ||
* // data.stack | ||
* // data.token | ||
* // data.types | ||
* | ||
*/ | ||
parse: (source: string | Buffer) => Γ.Data; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Lines | ||
* | ||
* The line numbers according to parse table record indexes. This is an isolated | ||
* reference and is used in logs, reports and parse operations. | ||
* | ||
* @example | ||
* | ||
* // Take the following data structure | ||
* [ | ||
* { begin: -1, ender: 1, lexer: 'markup', }, // etc | ||
* { begin: -1, ender: 1, lexer: 'markup', } // etc | ||
* ] | ||
* | ||
* // The lines reference will be as followed, assuming | ||
* // index 0 and index 1 ae on the same line | ||
* [ | ||
* 1, | ||
* 1 | ||
* ] | ||
*/ | ||
lines: number[] | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Events | ||
* | ||
* Event Listener which invokes on different operations. | ||
*/ | ||
on: Events<Pick<Static, 'on' | 'parse' | 'format'>>; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Hooks | ||
* | ||
* Hook into the parse and beatification operations. Hooks allow you to | ||
* refine output and control different logic during execution cycles. | ||
*/ | ||
hook: Hooks<Pick<Static, 'on' | 'parse' | 'format'>>; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Settings | ||
* | ||
* Control the execution behaviour of Γsthetic. Options exposed in this method | ||
* allow you to refine operations. | ||
* | ||
* To return the configuration settings currently applied along with addition | ||
* reference applied internally, then do no provide a parameter. | ||
*/ | ||
settings: { | ||
/** | ||
* Returns the current configuration options with additional internal references | ||
*/ | ||
(): Γ.IConfigInternal; | ||
/** | ||
* Customise the execution behaviour. Please ensure that you pass this method | ||
* before using `esthetic.format` or `esthetic.parse`, for example: | ||
* | ||
* ```js | ||
* import esthetic from 'esthetic'; | ||
* | ||
* esthetic.config({ | ||
* persistRules: false, | ||
* reportStats: false | ||
* // etc etc | ||
* }) | ||
* | ||
* esthetic.format('...') | ||
* | ||
* // Alternatively, you can chain: | ||
* | ||
* esthetic.settings({}).format('') | ||
* ``` | ||
*/ | ||
(options: Γ.ISettings): Pick<Static, 'on' | 'grammar' | 'rules' | 'hook' | 'parse' | 'format'>; | ||
}; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Rules** | ||
* | ||
* Set format rules to be applied to syntax. Use this method if you are executing | ||
* repeated runs and do not require Γsthetic to validate rules for every cycle. | ||
* | ||
* To return the current beautification rules, then do not provide a parameter. | ||
*/ | ||
rules: { | ||
/** | ||
* Returns the current rulesets Γsthetic is using. | ||
*/ | ||
(): Γ.Rules; | ||
/** | ||
* Update the current rules. | ||
*/ | ||
(rules: Rules): Pick<Static, 'on'| 'parse'| 'format'>; | ||
}; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Grammar** | ||
* | ||
* Extend built-in grammar references. By default, Γsthetics supports all current | ||
* specification standards. | ||
* | ||
* This is helpful when you need to provide additional context and handling | ||
* in languages like Liquid, but you can also extend the core languages like CSS. | ||
* | ||
* To return the current grammar presets, then do not provide a parameter. | ||
*/ | ||
grammar: { | ||
/** | ||
* Returns the current grammar references | ||
*/ | ||
(): Γ.Grammars; | ||
/** | ||
* Extend the current grammar references | ||
*/ | ||
(grammar: Γ.Grammars): Pick<Static, 'on' | 'hook' | 'rules' | 'parse' | 'format'> | ||
}; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Language Detection | ||
* | ||
* Automatic language detection based on the string input. | ||
* Returns lexer, language and official name. | ||
*/ | ||
detect: (sample: string) => Γ.Language; | ||
} | ||
/** | ||
* **Γsthetic Liquid** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Formatting for the Liquid Template Language. | ||
*/ | ||
liquid: LiquidFormat; | ||
/** | ||
* **Γsthetic HTML** | ||
* Settings (Type) | ||
* | ||
* Formatting for the HTML Language. | ||
* Type export of the execution configuration options which is available | ||
* via the `esthetic.config(configuration)` method. | ||
*/ | ||
html: HTMLFormat; | ||
type Settings = Γ.ISettings; | ||
/** | ||
* **Γsthetic XML** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Formatting for the XML Language. | ||
* Stats (Type) | ||
* | ||
* Type export of Statistics return value which is available via | ||
* the `esthetic.stats` getter method. | ||
*/ | ||
xml: XMLFormat; | ||
type Stats = Γ.Stats; | ||
/** | ||
* **Γsthetic CSS** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Formatting for the CSS Language. | ||
* Global Rules (Type) | ||
* | ||
* Type export of Global Formatting Rules. These rules are used | ||
* for every supported language. | ||
* | ||
* --- | ||
* | ||
* [Γsthetic Docs](https://Γ¦sthetic.dev/rules) | ||
*/ | ||
css: CSSFormat | ||
type Rules = Γ.Rules; | ||
/** | ||
* **Γsthetic JSON** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Formatting for the JSON Language. | ||
* Global Rules (Type) | ||
* | ||
* Type export of Global Formatting Rules. These rules are used | ||
* for every supported language. | ||
* | ||
* --- | ||
* | ||
* [Γsthetic Docs](https://Γ¦sthetic.dev/rules#global) | ||
*/ | ||
json: JSONFormat; | ||
type GlobalRules = Γ.GlobalRules; | ||
/** | ||
* **Γsthetic JavaScript (BETA)** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Formatting for the JavaScript Language. | ||
* Liquid Rules (Type) | ||
* | ||
* Type export of Liquid Formatting Rules. These rules are specific | ||
* to the Liquid Language. | ||
* | ||
* --- | ||
* | ||
* [Γsthetic Docs](https://Γ¦sthetic.dev/rules#liquid) | ||
*/ | ||
js: LiquidFormat; | ||
type LiquidRules = Γ.LiquidRules; | ||
/** | ||
* **Γsthetic TypeScript (BETA)** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Formatting for the TypeScript Language. | ||
* Markup Rules (Type) | ||
* | ||
* Type export of Markup Formatting Rules. These rules are specific | ||
* to the HTML, XML, Liquid and other Languages which use Markup. | ||
* | ||
* --- | ||
* | ||
* [Γsthetic Docs](https://Γ¦sthetic.dev/rules#markup) | ||
*/ | ||
ts: LiquidFormat; | ||
type MarkupRules = Γ.MarkupRules; | ||
/** | ||
* **Γsthetic ~ Rule Defintions** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Rule defintions which describe the different formatting options | ||
* esthetic offers. | ||
* Script Rules (Type) | ||
* | ||
* Type export of Script Formatting Rules. These rules are specific | ||
* to the JavaScript, TypeScript, JSX, TSX and other Languages which use Scripts. | ||
* | ||
* --- | ||
* | ||
* [Γsthetic Docs](https://Γ¦sthetic.dev/rules#script) | ||
*/ | ||
get definitions(): Definitions; | ||
type ScriptRules = Γ.ScriptRules; | ||
/** | ||
* **Γsthetic ~ Statistics** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Maintains a reference of statistic information about the | ||
* operation, also available in events like `esthetic.on('format')` and | ||
* `esthetic.on('parse')` arguments. | ||
* Style Rules (Type) | ||
* | ||
* Type export of Style Formatting Rules. These rules are specific | ||
* to the CSS, SCSS and other Languages which use Styles. | ||
* | ||
* --- | ||
* | ||
* [Γsthetic Docs](https://Γ¦sthetic.dev/rules#style) | ||
*/ | ||
get stats(): Stats; | ||
type StyleRules = Γ.StyleRules; | ||
/** | ||
* **Γsthetic ~ Parse Table** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Returns the current Parse Table data~structure. You can only call this | ||
* in a post beautification or parse cycle. | ||
* JSON Rules (Type) | ||
* | ||
* Type export of JSON Formatting Rules. These rules are specific | ||
* to the JSON language. | ||
* | ||
* --- | ||
* | ||
* [Γsthetic Docs](https://Γ¦sthetic.dev/rules#style) | ||
*/ | ||
get table(): Data; | ||
type JSONRules = Γ.JSONRules; | ||
/** | ||
* **Γsthetic ~ Parse Error** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Returns the the Parse Error or `null` if no error | ||
* Language Name (Type) | ||
* | ||
* Type export of lowercase Language names used for determining | ||
* the language Γsthetic is handling. This is the Type used via | ||
* the global rules `language` option. | ||
* | ||
* The type is a Literal Union and leveraged in CLI and reportings. | ||
*/ | ||
get error(): IParseError; | ||
type LanguageName = Γ.LanguageName; | ||
/** | ||
* **Γsthetic ~ Format** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Formatting Support: | ||
* Official Language Names (Type) | ||
* | ||
* - Liquid | ||
* - HTML | ||
* - XML | ||
* - CSS | ||
* - SCSS | ||
* - JSON | ||
* - JavaScript ~ _use with caution_ | ||
* - TypeScript ~ _use with caution_ | ||
* - JSX | ||
* - TSX | ||
* Type export of the official Language names, for example, if the | ||
* the Language name is `liquid` then the official is `Liquid` (with) | ||
* a captial `L`. | ||
* | ||
* The type is a Literal Union and leveraged in CLI and reportings. | ||
* | ||
* --- | ||
* | ||
* [Γsthetic Docs](https://Γ¦sthetic.dev/rules#style) | ||
*/ | ||
format: (source: string | Buffer, rules?: Rules) => string; | ||
type LanguageOfficialName = Γ.LanguageOfficialName; | ||
/** | ||
* **Γsthetic Parse** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Executes a parse operation and returns the generate data structure. | ||
* When calling this method, beautification will not be applied, the | ||
* parse table is returned. | ||
* Lexer Names (Type) | ||
* | ||
* The `esthetic.format()` method will execute a parse, so only use this | ||
* method when you are working with the parse table itself, otherwise use | ||
* `format` or one of the language specifics. | ||
* Type export of the lexer names. This is mostly an internal option but has | ||
* been exposed here for API usage. The **Lexer** name is any one of these 6: | ||
* | ||
* --- | ||
* | ||
* **NOTE** | ||
* `auto` | ||
* | ||
* You cannot pass rules, use the `esthetic.rules({})` method instead. | ||
* _Automatic Detection of Lexer and Language_ | ||
* | ||
* `text` | ||
* | ||
* _Used for Plain Text_ | ||
* | ||
* `markup` | ||
* | ||
* _Used for HTML, XML, Liquid_ | ||
* | ||
* `style` | ||
* | ||
* _Used for CSS and SCSS_ | ||
* | ||
* `script` | ||
* | ||
* _Used for JavaScript, TypeScript, JSON_ | ||
* | ||
* `ignore` | ||
* | ||
* _Used to ignore a language or region_ | ||
* | ||
*/ | ||
parse: (source: string | Buffer) => Data | ||
type LexerName = Γ.LexerName; | ||
/** | ||
* **Γsthetic ~ Events** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Event Listener which invokes on different operations. | ||
* Parse Hook (Type) | ||
* | ||
* Type export of Parse hooks function events. | ||
* | ||
*/ | ||
on: Events<Pick<typeof esthetic, 'on' | 'parse' | 'format'>>; | ||
type ParseHook = Γ.ParseHook; | ||
/** | ||
* **Γsthetic ~ Hooks** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Hook into the parse and beatification operations. Hooks allow you to | ||
* refine output and control different logic during execution cycles. | ||
* Parse Table Record (Type) | ||
* | ||
* Type export of the data structure (parse table) records. | ||
* | ||
*/ | ||
hook: Hooks<Pick<typeof esthetic, 'on' | 'parse' | 'format'>>; | ||
type Record = Γ.Record; | ||
/** | ||
* **Γsthetic ~ Configuration** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Control the execution behaviour of Γsthetic. Options exposed in this method | ||
* allow you to refine operations. | ||
* Parse Table (Type) | ||
* | ||
* To return the configuration settings currently applied along with addition | ||
* reference applied internally, then do no provide a parameter. | ||
* Type export of the data structure Parse Table. | ||
* | ||
*/ | ||
config: { | ||
(options: IConfig): Pick<typeof esthetic, 'on' | 'grammar' | 'rules' | 'hook' | 'parse' | 'format'> | ||
(): IConfigInternal; | ||
} | ||
type ParseTable = Γ.Data; | ||
/** | ||
* **Γsthetic ~ Rules** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Set format rules to be applied to syntax. Use this method if you are executing | ||
* repeated runs and do not require Γsthetic to validate rules for every cycle. | ||
* Γsthetic Grammar (Type) | ||
* | ||
* To return the current beautification rules, then do not provide a parameter. | ||
* Type export of Grammars method parameter. | ||
*/ | ||
rules: { | ||
(rules: Rules): Pick<typeof esthetic, 'on'| 'parse'| 'format'> | ||
(): Rules | ||
} | ||
type Grammar = Γ.Grammars; | ||
/** | ||
* **Γsthetic ~ Grammar** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Extend built-in grammar references. By default, Γsthetics supports all current | ||
* specification standards. | ||
* Parse Error (Type) | ||
* | ||
* This is helpful when you need to provide additional context and handling | ||
* in languages like Liquid, but you can also extend the core languages like CSS. | ||
* | ||
* To return the current grammar presets, then do not provide a parameter. | ||
* Type export of the Parse Error Model which is provided and returned | ||
* by the `esthetic.error` getter. | ||
*/ | ||
grammar: { | ||
(grammar: Grammars): Pick<typeof esthetic, 'on' | 'hook' | 'rules' | 'parse' | 'format'> | ||
(): Grammars; | ||
type ParseError = Γ.IParseError; | ||
} | ||
declare global { | ||
interface Window { | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Syntactical code beautification leveraging the Sparser algorithm. | ||
*/ | ||
get esthetic(): Γsthetic.Static | ||
} | ||
/** | ||
* **Γsthetic ~ Language Detection** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Automatic language detection based on the string input. | ||
* Returns lexer, language and official name. | ||
* Syntactical code beautification leveraging the Sparser algorithm. | ||
*/ | ||
detect: (sample: string) => Language; | ||
export const esthetic: Γsthetic.Static; | ||
}; | ||
} | ||
export default esthetic; | ||
/** | ||
* #### _ΓSTHETIC_ | ||
* | ||
* Syntactical code beautification leveraging the Sparser algorithm. | ||
*/ | ||
declare const Γsthetic: Γsthetic.Static; | ||
export = Γsthetic |
{ | ||
"name": "esthetic", | ||
"version": "0.5.6-beta.1", | ||
"version": "0.6.0-beta.1", | ||
"license": "MIT", | ||
"homepage": "https://Γ¦sthetic.dev", | ||
"author": "ΞΞΞΞΞΞΞ£ Ξ£ΞΞΞΞΞΞΞ£ <n.savvidis@gmx.com>", | ||
@@ -40,21 +41,28 @@ "description": "Γsthetic ~ Language beautification support leveraging the Sparser lexing algorithm.", | ||
"bin": { | ||
"esthetic": "./dist/cli.js" | ||
"esthetic": "./dist/cli/index.js" | ||
}, | ||
"type": "module", | ||
"files": [ | ||
"dist", | ||
"types", | ||
"index.d.ts", | ||
"schema.json", | ||
"ThirdPartyNotices.txt", | ||
"LICENSE" | ||
], | ||
"types": "./index.d.ts", | ||
"main": "./dist/index.mjs", | ||
"module": "./dist/esm/index.js", | ||
"main": "./dist/esthetic.js", | ||
"module": "./dist/esthetic.mjs", | ||
"exports": { | ||
"types": "./index.d.ts", | ||
"require": "./dist/index.js", | ||
"import": "./dist/esm/index.js", | ||
"default": "./dist/iife/index.js" | ||
"require": "./dist/esthetic.cjs", | ||
"import": "./dist/esthetic.mjs", | ||
"default": "./dist/esthetic.js" | ||
}, | ||
"ava": { | ||
"files": [ | ||
"tests/cases/attributes/*.test.mjs", | ||
"tests/cases/liquid/*.test.mjs", | ||
"tests/cases/html/*.test.mjs", | ||
"tests/cases/json/*.test.mjs", | ||
"tests/cases/css/*.test.mjs" | ||
"tests/cases/css/*.test.mjs", | ||
"tests/cases/attributes/*.test.mjs" | ||
], | ||
@@ -71,5 +79,3 @@ "extensions": [ | ||
"ignorePatterns": [ | ||
"index.js", | ||
"index.mjs", | ||
"cli.js", | ||
"**/dist/*", | ||
"**/node_modules/*" | ||
@@ -104,12 +110,12 @@ ], | ||
"devDependencies": { | ||
"@liquify/ava": "^0.0.6", | ||
"@liquify/eslint-config": "^1.1.0", | ||
"@liquify/eslint-config": "^1.2.0", | ||
"@liquify/prettier-config": "^1.2.1", | ||
"@liquify/tsconfig": "^1.0.1", | ||
"@types/benchmark": "^2.1.2", | ||
"ava": "^5.2.0", | ||
"ava": "^5.3.0", | ||
"benchmark": "^2.1.4", | ||
"terser": "^5.16.8", | ||
"terser": "^5.17.7", | ||
"tsup": "^6.7.0", | ||
"type-fest": "^3.7.2" | ||
"type-fest": "^3.11.1", | ||
"@liquify/ava": "^0.0.6" | ||
}, | ||
@@ -121,2 +127,3 @@ "dependencies": { | ||
"fast-glob": "^3.2.12", | ||
"mergerino": "^0.4.0", | ||
"minimist": "^1.2.8" | ||
@@ -126,3 +133,4 @@ }, | ||
"dev": "tsup --watch", | ||
"build": "tsup --minify --env.NODE_ENV production && gzip-size dist/index.js --include-original", | ||
"play": "ava tests/dev.test.mjs --watch", | ||
"build": "tsup --minify --env.NODE_ENV production && gzip-size dist/esthetic.js --include-original", | ||
"pack": "cd versions; pnpm pack ../ && cd ..", | ||
@@ -133,3 +141,2 @@ "release": "pnpm -w release --pkg $npm_package_name", | ||
"test:cli": "cd tests; pnpm esthetic ./cli/*.liquid -w --liquid; cd ..;", | ||
"test:dev": "ava tests/dev.test.mjs --watch", | ||
"test:attributes": "ava tests/cases/attributes/*.test.mjs ---", | ||
@@ -136,0 +143,0 @@ "test:html": "ava tests/cases/html/*.test.mjs ---", |
<br> | ||
<p align="center"> | ||
<img src="https://raw.githubusercontent.com/panoply/esthetic/next/docs/src/assets/svg/esthetic.svg" width="300px"> | ||
<a href="https://Γ¦sthetic.dev"> | ||
<img src="https://raw.githubusercontent.com/panoply/esthetic/next/docs/src/assets/svg/esthetic.svg" width="250px"> | ||
</a> | ||
</p> | ||
@@ -25,4 +27,6 @@ | ||
# Installation | ||
## Installation | ||
Γsthetic is supports both CJS/ESM environments and also provides basic CLI support. | ||
###### PNPM | ||
@@ -52,4 +56,71 @@ | ||
# Acknowledgements | ||
## Usage | ||
Consult the [documentation](https://Γ¦sthetic.dev) for a better understanding. | ||
###### CLI | ||
```bash | ||
$ esthetic <file> --flag | ||
``` | ||
###### ESM | ||
<!--prettier-ignore--> | ||
```js | ||
import esthetic from 'esthetic'; | ||
esthetic.format('...', { /* rules */ }) | ||
``` | ||
###### CJS | ||
<!--prettier-ignore--> | ||
```js | ||
const esthetic = require('esthetic'); | ||
esthetic.format('...', { /* rules */ }) | ||
``` | ||
## Contributing | ||
Looking to contribute? Γsthetic leverages [pnpm](https://pnpm.js.org/) so ensure you're using it as your package manager. Development is intended to be conducted within the [vscode](https://code.visualstudio.com/) text editor. Fork or clone the project and install dependencies. | ||
<details> | ||
<summary> | ||
Pre-requisites | ||
</summary> | ||
<p> | ||
- [Git](https://git-scm.com/) | ||
- [Node v16^](https://nodejs.org/) | ||
- [Pnpm v7^](https://pnpm.js.org/) | ||
- [VSCode](https://code.visualstudio.com/) | ||
</p> | ||
</details> | ||
### Testing / Development | ||
Γsthetic uses the powerful [AVA](https://github.com/avajs/ava) test runner together with a small helper utility that helps alleviate some of the complexities involved with testing tools of its criteria. It's recommended that you develop in a two pane terminal. The [dev.test.mjs](/tests/dev.test.mjs) and [dev.txt](/tests/dev.txt) files are core to testing and working on the module, they will be called when running `pnpm play` | ||
### Commands | ||
The following commands are available as executable scripts. | ||
``` | ||
pnpm dev Bundles module with ESBuild (via tsup) in watch mode | ||
pnpm play Starts up AVA in development mode and runs the dev.txt | ||
pnpm build Generates the distribution bundles | ||
pnpm pack Packages the module up for distribution on NPM registry | ||
pnpm test Runs all the tests | ||
pnpm tests Cherry pick test cases to run | ||
``` | ||
> Consult the [tests](/tests/) readme for more information on `test` prefixed commands | ||
## Acknowledgements | ||
Γsthetic owes its existence to Sparser and PrettyDiff. This project has been adapted from these 2 brilliant tools and while largely refactored + overhauled the original parse architecture remains intact. | ||
@@ -66,7 +137,2 @@ | ||
<a href="https://twitter.com/niksavvidis"> | ||
<img | ||
align="right" | ||
src="https://img.shields.io/badge/-@niksavidis-1DA1F2?logo=twitter&logoColor=fff" | ||
/> | ||
</a> | ||
Follow me on [Twitter](https://twitter.com/niksavvidis) or shoot me an [Email](mailto:n.savvidis@gmx.com). |
@@ -331,3 +331,3 @@ import { LanguageName } from '../shared'; | ||
* ```js | ||
* prettify.grammar({ | ||
* esthetic.grammar({ | ||
* html: { | ||
@@ -334,0 +334,0 @@ * embedded: { |
@@ -18,3 +18,3 @@ import { LiteralUnion } from 'type-fest'; | ||
export interface IConfig { | ||
export interface ISettings { | ||
/** | ||
@@ -31,2 +31,11 @@ * **Use `.editorconfig` File** | ||
/** | ||
* **GlobalThis** | ||
* | ||
* Whether of not Γsthetic should be made available to global scope when used in Browser | ||
* environments. This defaults to `true` resulting in Γsthetic being accessible via `window`. | ||
* | ||
* @default true | ||
*/ | ||
globalThis?: boolean; | ||
/** | ||
* **Report Statistics** | ||
@@ -95,3 +104,3 @@ * | ||
export interface IConfigInternal extends IConfig { | ||
export interface IConfigInternal extends ISettings { | ||
/** | ||
@@ -98,0 +107,0 @@ * **Environment** |
@@ -0,1 +1,2 @@ | ||
import { LiteralUnion } from 'type-fest'; | ||
import { Languages } from 'lexical/enum'; | ||
@@ -223,2 +224,3 @@ import { Types, LanguageOfficialName, LanguageName } from '../shared'; | ||
index?: number; | ||
skip?: boolean; | ||
expect?: string; | ||
@@ -339,8 +341,22 @@ token?: string; | ||
export interface WrapComment { | ||
chars: string[]; | ||
export interface Comments { | ||
/** | ||
* The current index or starting position of comment | ||
*/ | ||
start: number; | ||
/** | ||
* The last known character index | ||
*/ | ||
end: number; | ||
lexer: string; | ||
start: number; | ||
/** | ||
* The lexer mode | ||
*/ | ||
lexer: LiteralUnion< 'markup' |'script' | 'style', string>; | ||
/** | ||
* The opening delimiter token of the comment | ||
*/ | ||
begin: string; | ||
/** | ||
* The closing delimiter token of the comment | ||
*/ | ||
ender: string; | ||
@@ -347,0 +363,0 @@ } |
@@ -6,3 +6,9 @@ | ||
export enum StyleTypes { | ||
/** | ||
* Describes a `:root`selector. This types value exists to uniquely set colon | ||
* characters apart from other types values. | ||
*/ | ||
root = 'root', | ||
/** | ||
* Describes a : character. This types value exists to uniquely set colon | ||
@@ -73,5 +79,4 @@ * characters apart from other types values. | ||
* --- | ||
* @prettify | ||
* | ||
* This infers Liquid code in Prettify | ||
* This infers Liquid code in Γsthetic | ||
*/ | ||
@@ -84,5 +89,4 @@ template = 'template', | ||
* --- | ||
* @prettify | ||
* | ||
* This infers Liquid code in Prettify | ||
* This infers Liquid code in Γsthetic | ||
*/ | ||
@@ -94,5 +98,4 @@ liquid_else = 'liquid_else', | ||
* --- | ||
* @prettify | ||
* | ||
* This infers Liquid code in Prettify | ||
* This infers Liquid code in Γsthetic | ||
*/ | ||
@@ -104,3 +107,2 @@ liquid_end = 'liquid_end', | ||
* --- | ||
* @prettify | ||
* | ||
@@ -129,3 +131,2 @@ * This infers Liquid code in Prettify | ||
* --- | ||
* @prettify | ||
* | ||
@@ -181,5 +182,4 @@ * This infers Liquid `{% comment %}` and `{% endcomment%}` in Prettify | ||
* --- | ||
* @prettify | ||
* | ||
* This infers Liquid code in Prettify | ||
* This infers Liquid code in Γsthetic | ||
*/ | ||
@@ -191,5 +191,4 @@ template = 'template', | ||
* --- | ||
* @prettify | ||
* | ||
* This infers Liquid code in Prettify | ||
* This infers Liquid code in Γsthetic | ||
*/ | ||
@@ -201,5 +200,4 @@ liquid_else = 'liquid_else', | ||
* --- | ||
* @prettify | ||
* | ||
* This infers Liquid code in Prettify | ||
* This infers Liquid code in Γsthetic | ||
*/ | ||
@@ -651,3 +649,3 @@ liquid_end = 'liquid_end', | ||
/** | ||
* A template tag that contains content or other tags not associated with | ||
* A Liquid tag that contains content or other tags not associated with | ||
* the template language and expects a closing tag. This is representative of | ||
@@ -665,2 +663,11 @@ * Liquid tags. | ||
/** | ||
* A Liquid case start tag | ||
* | ||
* --- | ||
* @example | ||
* | ||
* {% case foo %} | ||
*/ | ||
liquid_case_start = 'liquid_case_start', | ||
/** | ||
* A singleton Liquid tag which is used within the `{% case %}` block tag | ||
@@ -678,2 +685,20 @@ * expression. | ||
/** | ||
* A Liquid case else tag | ||
* | ||
* --- | ||
* @example | ||
* | ||
* {% else %} | ||
*/ | ||
liquid_case_else = 'liquid_case_else', | ||
/** | ||
* A Liquid case end tag | ||
* | ||
* --- | ||
* @example | ||
* | ||
* {% case foo %} | ||
*/ | ||
liquid_case_end = 'liquid_case_end', | ||
/** | ||
* A template tag acting as the else block of a condition. This is representative of | ||
@@ -701,2 +726,23 @@ * Liquid tags. | ||
liquid_end = 'liquid_end', | ||
/** | ||
* A Liquid capture tag | ||
* | ||
* --- | ||
* @example | ||
* | ||
* {% capture foo %} | ||
*/ | ||
liquid_capture = 'liquid_capture', | ||
/** | ||
* Ignore next comment | ||
* | ||
* --- | ||
* @example | ||
* | ||
* <!-- esthetic-ignore-next --> | ||
* {% # esthetic-ignore-next %} | ||
*/ | ||
ignore_next = 'ignore_next', | ||
} | ||
@@ -711,3 +757,5 @@ | ||
comment = 'comment', | ||
ignore_start = 'ignore_start', | ||
ignore_end = 'ignore_end', | ||
'content-ignore' = 'content-ignore' | ||
} |
@@ -123,2 +123,3 @@ import { LiteralUnion } from 'type-fest'; | ||
preserveLine?: number; | ||
} |
@@ -17,2 +17,13 @@ import { LiteralUnion } from 'type-fest'; | ||
* | ||
* ππ½ββοΈ Recommended setting is: `true` | ||
* | ||
* Whether or not to format LiquidDoc comment structures. When | ||
* enabled keywords such a `Usage:` and `Accepts:` will apply | ||
* beautification to align with LiquidDoc appropriation. | ||
*/ | ||
commentDoc?: boolean; | ||
/** | ||
* **Default** `true` | ||
* | ||
* This will determine whether comments should always start at position | ||
@@ -27,2 +38,30 @@ * `0` of each line or if comments should be indented according to the code. | ||
/** | ||
* **Default** `true` | ||
* | ||
* ππ½ββοΈ Recommended setting is: `true` | ||
* | ||
* Will force indentation upon all content and tags without regard for the | ||
* text nodes. | ||
* | ||
* --- | ||
* | ||
* #### Example | ||
* | ||
* *Below is an example of how this rule works if it's enabled, ie: `true`* | ||
* | ||
* | ||
* ```liquid | ||
* | ||
* <!-- Before Formatting --> | ||
* {% if foo %}{{ object.prop }}{% endif %} | ||
* | ||
* <!-- After formatting --> | ||
* {% if foo %} | ||
* {{ object.prop }} | ||
* {% endif %} | ||
* ``` | ||
*/ | ||
forceIndent?: boolean; | ||
/** | ||
* **Default** `preserve` | ||
@@ -43,3 +82,2 @@ * | ||
* - `multiline` | ||
* - `linebreak` | ||
* | ||
@@ -205,8 +243,37 @@ * ``` | ||
/** | ||
* **Default** `false` | ||
* **NOT YET AVAILABLE** | ||
* | ||
* Prevent the internals structures of Liquid tokens from being formatted. When enabled, Γsthetic | ||
* will preserve the internal formations of output and tags. | ||
* _This rule is under consideration and is not yet available for usage_ | ||
* | ||
* --- | ||
* | ||
* **Default** `[]` | ||
* | ||
* ππ½ββοΈ Recommended setting is subjective | ||
* | ||
* A list of Liquid tags that should have newlines forced above and | ||
* below. Singleton type Liquid tags are not supported, the rule will | ||
* only apply newlines on start and end types. | ||
* | ||
* > **Note** | ||
* > | ||
* > _This rule will respect the liquid `forceIndent` rule. Only when newline | ||
* > occurances are detected will padding be applied._ | ||
*/ | ||
preserveInternal?: boolean; | ||
paddedTagList?: Array<LiteralUnion< | ||
| 'form' | ||
| 'paginate' | ||
| 'when' | ||
| 'elsif' | ||
| 'else' | ||
| 'for' | ||
| 'if' | ||
| 'raw' | ||
| 'tablerow' | ||
| 'unless' | ||
| 'schema' | ||
| 'style' | ||
| 'script' | ||
| 'stylesheet' | ||
| 'javascript', string>>; | ||
@@ -213,0 +280,0 @@ /** |
export interface MarkupRules { | ||
/** | ||
* **Default** `false` | ||
* **Default** `preserve` | ||
* | ||
* ππ½ββοΈ Recommended setting is: `true` | ||
* | ||
* Controls the formatting style of HTML and/or XML markup comment delimiters. | ||
* This rule will augment delimiter `<!--` and `-->` placements. | ||
* | ||
* --- | ||
* | ||
* ```html | ||
* | ||
* <!-- inline --> | ||
* <!-- inline-align | ||
* inline-align --> | ||
* <!-- | ||
* preserve --> | ||
* <!-- | ||
* force | ||
* --> | ||
* <!-- consistent (before) | ||
* --> | ||
* <!-- consistent (after) --> | ||
* <!-- | ||
* consistent (before) --> | ||
* <!-- | ||
* consistent (after) | ||
* --> | ||
* | ||
* ``` | ||
*/ | ||
commentDelimiters?: | ||
| 'preserve' | ||
| 'consistent' | ||
| 'force' | ||
| 'inline' | ||
| 'inline-align'; | ||
/** | ||
* If a blank new line should be forced above comments. | ||
@@ -238,2 +271,7 @@ */ | ||
/** | ||
* Attribute class list sorting | ||
*/ | ||
classSort?: boolean | string[] | 'tailwind' | ||
/** | ||
* **Default** `false` | ||
@@ -240,0 +278,0 @@ * |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1131634
9203
136
0
6
No
+ Addedmergerino@^0.4.0
+ Addedmergerino@0.4.0(transitive)