Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html-attribute-sorter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-attribute-sorter - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

dist/types/strategy/code-guide.d.ts

13

CHANGELOG.md
# Changelog
## [0.3.1](https://github.com/shufo/html-attribute-sorter/compare/v0.3.0...v0.3.1) (2022-08-06)
### Fixes
* 🐛 change parameter value from code_guide to code-guide ([f2b49ad](https://github.com/shufo/html-attribute-sorter/commit/f2b49ad5b320da206f239d7a0a86f8d6b8a06650))
### Miscellaneous
* **deps:** update googlecloudplatform/release-please-action action to v3 ([e0a6b9a](https://github.com/shufo/html-attribute-sorter/commit/e0a6b9a8b333add204c7b5530598344cd75e997c))
* **deps:** update jest monorepo to v28 ([8d1a01b](https://github.com/shufo/html-attribute-sorter/commit/8d1a01b99795df41bfc935156c346dd0f1721721))
## [0.3.0](https://www.github.com/shufo/html-attribute-sorter/compare/v0.2.1...v0.3.0) (2022-08-06)

@@ -4,0 +17,0 @@

2

dist/main.js

@@ -1,2 +0,2 @@

"use strict";var u=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var I=(r,t)=>{for(var e in t)u(r,e,{get:t[e],enumerable:!0})},O=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of E(t))!v.call(r,s)&&s!==e&&u(r,s,{get:()=>t[s],enumerable:!(i=_(t,s))||i.enumerable});return r};var x=r=>O(u({},"__esModule",{value:!0}),r);var b={};I(b,{sortAttributes:()=>y});module.exports=x(b);var g=class{constructor(t){this.strategy=t}setStrategy(t){this.strategy=t}sort(t){return this.strategy.sort(t)}};var p=class{sort(t){return t.sort()}};var d=class{constructor(){this.orderedAttrsRegex=["class","id","name","data-.+","ng-.+","src","for","type","href","value","values","title","alt","role","aria-.+","tabindex","style"]}sort(t){let e=[];this.orderedAttrsRegex.forEach(s=>{t.forEach(n=>{new RegExp(`^${s}`).test(n)&&e.push(n)})});let i=t.filter(s=>e.indexOf(s)===-1).sort();return e.concat(i)}};var l=class{constructor(){this.orderedAttrsRegex=["class","id","data-.+"]}sort(t){let e=[];this.orderedAttrsRegex.forEach(s=>{t.forEach(n=>{new RegExp(`^${s}`).test(n)&&e.push(n)})});let i=t.filter(s=>e.indexOf(s)===-1).sort();return e.concat(i)}};var f=class{constructor(){this.DEFINITION=["is","v-is"];this.LIST_RENDERING=["v-for"];this.CONDITIONALS=["v-if","v-else-if","v-else","v-show","v-cloak"];this.RENDER_MODIFIERS=["v-once","v-pre"];this.GLOBAL=["id"];this.UNIQUE=["ref","key"];this.SLOT=["v-slot","slot"];this.TWO_WAY_BINDING=["v-model"];this.OTHER_DIRECTIVES=/v-[-:\w\d]+/g;this.EVENTS=["@click","v-on="];this.CONTENT=["v-text","v-html"];this.headingOrderedAttrsRegex=[...this.DEFINITION,...this.LIST_RENDERING,...this.CONDITIONALS,...this.RENDER_MODIFIERS,...this.GLOBAL,...this.UNIQUE,...this.SLOT,...this.TWO_WAY_BINDING];this.tailOrderedAttrsRegex=[...this.EVENTS,...this.CONTENT]}sort(t){let e=[],i=[];this.headingOrderedAttrsRegex.forEach(o=>{t.forEach(a=>{new RegExp(`^${o}`).test(a)&&e.push(a)})}),this.tailOrderedAttrsRegex.forEach(o=>{t.forEach(a=>{new RegExp(`^${o}`).test(a)&&i.push(a)})});let s=t.filter(o=>e.indexOf(o)===-1).filter(o=>i.indexOf(o)===-1),n=s.filter(o=>this.OTHER_DIRECTIVES.test(o)),c=s.filter(o=>n.indexOf(o)===-1);return e.concat(n).concat(c).concat(i)}};var S=[],m=[];function y(r,t={order:"code_guide"}){let e=r.replace(/<(?!\/)[-:.\w\d@]+\s(?:"[^"]*"|'[^']*'|[^"'])*?>/g,i=>N(i));return w(e,t)}function N(r){let t=S.push(r)-1;return T(t.toString())}function R(r,t){let e=m.push(t)-1;return A(r,e.toString())}function T(r){return"___sort_tags_#___".replace("#",r)}function A(r,t){return`${r}_attrs_#___`.replace("#",t)}function w(r,t){return r.replace(/___sort_tags_(\d+)___/g,(e,i)=>{let n=S[i].replace(/([-:.\w\d]+)=("[^"]*"|'[^']*'|[^"'])/g,(a,h)=>R(h,a));return D(n,t).replace(/[-:.\w\d]+_attrs_(\d+)___/g,(a,h)=>m[h])})}function D(r,t){let e=L(t.order),i=new g(e);return r.replace(/(?<=<[-:.\w\d]+\s)[^>]*?(?=\/?>)/g,s=>{let c=s.split(/\s/).filter(a=>a.length>0);return i.sort(c).join(" ")})}function L(r){switch(r){case"alphabetical":return new p;case"code_guide":return new d;case"idiomatic":return new l;case"vuejs":return new f}throw new Error("You can specify only [alphabetical|code_guide|idiomatic|vuejs] for sorting order")}0&&(module.exports={sortAttributes});
"use strict";var u=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var I=(r,t)=>{for(var e in t)u(r,e,{get:t[e],enumerable:!0})},O=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of _(t))!v.call(r,s)&&s!==e&&u(r,s,{get:()=>t[s],enumerable:!(i=E(t,s))||i.enumerable});return r};var x=r=>O(u({},"__esModule",{value:!0}),r);var b={};I(b,{sortAttributes:()=>y});module.exports=x(b);var g=class{constructor(t){this.strategy=t}setStrategy(t){this.strategy=t}sort(t){return this.strategy.sort(t)}};var p=class{sort(t){return t.sort()}};var d=class{constructor(){this.orderedAttrsRegex=["class","id","name","data-.+","ng-.+","src","for","type","href","value","values","title","alt","role","aria-.+","tabindex","style"]}sort(t){let e=[];this.orderedAttrsRegex.forEach(s=>{t.forEach(n=>{new RegExp(`^${s}`).test(n)&&e.push(n)})});let i=t.filter(s=>e.indexOf(s)===-1).sort();return e.concat(i)}};var l=class{constructor(){this.orderedAttrsRegex=["class","id","data-.+"]}sort(t){let e=[];this.orderedAttrsRegex.forEach(s=>{t.forEach(n=>{new RegExp(`^${s}`).test(n)&&e.push(n)})});let i=t.filter(s=>e.indexOf(s)===-1).sort();return e.concat(i)}};var f=class{constructor(){this.DEFINITION=["is","v-is"];this.LIST_RENDERING=["v-for"];this.CONDITIONALS=["v-if","v-else-if","v-else","v-show","v-cloak"];this.RENDER_MODIFIERS=["v-once","v-pre"];this.GLOBAL=["id"];this.UNIQUE=["ref","key"];this.SLOT=["v-slot","slot"];this.TWO_WAY_BINDING=["v-model"];this.OTHER_DIRECTIVES=/v-[-:\w\d]+/g;this.EVENTS=["@click","v-on="];this.CONTENT=["v-text","v-html"];this.headingOrderedAttrsRegex=[...this.DEFINITION,...this.LIST_RENDERING,...this.CONDITIONALS,...this.RENDER_MODIFIERS,...this.GLOBAL,...this.UNIQUE,...this.SLOT,...this.TWO_WAY_BINDING];this.tailOrderedAttrsRegex=[...this.EVENTS,...this.CONTENT]}sort(t){let e=[],i=[];this.headingOrderedAttrsRegex.forEach(o=>{t.forEach(a=>{new RegExp(`^${o}`).test(a)&&e.push(a)})}),this.tailOrderedAttrsRegex.forEach(o=>{t.forEach(a=>{new RegExp(`^${o}`).test(a)&&i.push(a)})});let s=t.filter(o=>e.indexOf(o)===-1).filter(o=>i.indexOf(o)===-1),n=s.filter(o=>this.OTHER_DIRECTIVES.test(o)),c=s.filter(o=>n.indexOf(o)===-1);return e.concat(n).concat(c).concat(i)}};var S=[],m=[];function y(r,t={order:"code-guide"}){let e=r.replace(/<(?!\/)[-:.\w\d@]+\s(?:"[^"]*"|'[^']*'|[^"'])*?>/g,i=>N(i));return w(e,t)}function N(r){let t=S.push(r)-1;return T(t.toString())}function R(r,t){let e=m.push(t)-1;return A(r,e.toString())}function T(r){return"___sort_tags_#___".replace("#",r)}function A(r,t){return`${r}_attrs_#___`.replace("#",t)}function w(r,t){return r.replace(/___sort_tags_(\d+)___/g,(e,i)=>{let n=S[i].replace(/([-:.\w\d]+)=("[^"]*"|'[^']*'|[^"'])/g,(a,h)=>R(h,a));return D(n,t).replace(/[-:.\w\d]+_attrs_(\d+)___/g,(a,h)=>m[h])})}function D(r,t){let e=L(t.order),i=new g(e);return r.replace(/(?<=<[-:.\w\d]+\s)[^>]*?(?=\/?>)/g,s=>{let c=s.split(/\s/).filter(a=>a.length>0);return i.sort(c).join(" ")})}function L(r){switch(r){case"alphabetical":return new p;case"code-guide":return new d;case"idiomatic":return new l;case"vuejs":return new f}throw new Error("You can specify only [alphabetical|code-guide|idiomatic|vuejs] for sorting order")}0&&(module.exports={sortAttributes});
//# sourceMappingURL=main.js.map

@@ -1,4 +0,4 @@

export declare type Strategy = "alphabetical" | "code_guide" | "idiomatic" | "vuejs";
export declare type Strategy = "alphabetical" | "code-guide" | "idiomatic" | "vuejs";
export interface ISortOption {
order: Strategy;
}
{
"name": "html-attribute-sorter",
"version": "0.3.0",
"version": "0.3.1",
"description": "An html attribute sorter",

@@ -23,3 +23,3 @@ "main": "dist/main.js",

"devDependencies": {
"@types/jest": "^27.4.1",
"@types/jest": "^28.0.0",
"@typescript-eslint/eslint-plugin": "^5.12.1",

@@ -35,7 +35,7 @@ "@typescript-eslint/parser": "^5.12.1",

"husky": "^7.0.4",
"jest": "^27.5.1",
"jest": "^28.0.0",
"lint-staged": "^12.3.4",
"prettier": "^2.5.1",
"prettier-plugin-tailwindcss": "^0.1.7",
"ts-jest": "^27.1.3",
"ts-jest": "^28.0.0",
"ts-node": "^10.5.0",

@@ -42,0 +42,0 @@ "typescript": "^4.5.5"

[![npm](https://img.shields.io/npm/v/html-attribute-sorter)](https://www.npmjs.com/package/html-attribute-sorter)
[![CI](https://github.com/shufo/html-attribute-sorter/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/shufo/html-attribute-sorter/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/shufo/html-attribute-sorter/branch/main/graph/badge.svg?token=U7YzstHupS)](https://codecov.io/gh/shufo/html-attribute-sorter)

@@ -53,3 +54,3 @@ # html-attribute-sorter

{
order: "code_guide",
order: "code-guide",
}

@@ -81,3 +82,3 @@ );

| ----- | ------------------------------------------------------------------------------------------------------------------------ |
| order | An order to sort attributes. You can specify `alphabetical`, `code_guide`, `idiomatic` or `vuejs`. default: `code_guide` |
| order | An order to sort attributes. You can specify `alphabetical`, `code-guide`, `idiomatic` or `vuejs`. default: `code-guide` |

@@ -84,0 +85,0 @@ ## Testing

import { ISortOption, Strategy } from "./options";
import { Sorter } from "./sorter";
import { AlphabeticalStrategy } from "./strategy/alphabetical";
import { CodeGuideStrategy } from "./strategy/code_guide";
import { CodeGuideStrategy } from "./strategy/code-guide";
import { IdiomaticStrategy } from "./strategy/idiomatic";

@@ -13,3 +13,3 @@ import { VuejsStrategy } from "./strategy/vuejs";

html: string,
options: ISortOption = { order: "code_guide" }
options: ISortOption = { order: "code-guide" }
) {

@@ -80,3 +80,3 @@ const replaced = html.replace(

return new AlphabeticalStrategy();
case "code_guide":
case "code-guide":
return new CodeGuideStrategy();

@@ -90,4 +90,4 @@ case "idiomatic":

throw new Error(
`You can specify only [alphabetical|code_guide|idiomatic|vuejs] for sorting order`
`You can specify only [alphabetical|code-guide|idiomatic|vuejs] for sorting order`
);
}

@@ -1,2 +0,2 @@

export type Strategy = "alphabetical" | "code_guide" | "idiomatic" | "vuejs";
export type Strategy = "alphabetical" | "code-guide" | "idiomatic" | "vuejs";

@@ -3,0 +3,0 @@ export interface ISortOption {

Sorry, the diff of this file is not supported yet

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