New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’
Socket
Sign inDemoInstall
Socket

esthetic

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esthetic - npm Package Compare versions

Comparing version 0.5.6-beta.1 to 0.6.0-beta.1

./dist/esthetic.js

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';

*
* πŸ’πŸ½β€β™€οΈ &nbsp;&nbsp; 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`
*
* πŸ’πŸ½β€β™€οΈ &nbsp;&nbsp; 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** `[]`
*
* πŸ’πŸ½β€β™€οΈ &nbsp;&nbsp; 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`
*
* πŸ’πŸ½β€β™€οΈ &nbsp;&nbsp; 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 @@ *

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc