html-attribute-sorter
Advanced tools
Comparing version 0.3.1 to 0.3.2
# Changelog | ||
## [0.3.2](https://github.com/shufo/html-attribute-sorter/compare/v0.3.1...v0.3.2) (2022-08-06) | ||
### Fixes | ||
* 🐛 do not sort remaining attributes other than spec ([d46daa1](https://github.com/shufo/html-attribute-sorter/commit/d46daa19ef44f0dc7e690d8d7ea4583e32a44b17)) | ||
### Miscellaneous | ||
* **deps:** update peter-evans/commit-comment action to v2 ([5a00b31](https://github.com/shufo/html-attribute-sorter/commit/5a00b31fe87d6d6fe7fc2829e4a3b7187e246a17)) | ||
## [0.3.1](https://github.com/shufo/html-attribute-sorter/compare/v0.3.0...v0.3.1) (2022-08-06) | ||
@@ -4,0 +16,0 @@ |
@@ -1,2 +0,2 @@ | ||
"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}); | ||
"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);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);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 |
{ | ||
"name": "html-attribute-sorter", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "An html attribute sorter", | ||
@@ -56,3 +56,3 @@ "main": "dist/main.js", | ||
"lint-staged": { | ||
"*.ts": "yarn run fix" | ||
"*.ts": "yarn run fix && yarn run format" | ||
}, | ||
@@ -59,0 +59,0 @@ "keywords": [ |
@@ -39,5 +39,5 @@ import { SortStrategy } from "../sorter"; | ||
const remainings = attributes | ||
.filter((attr) => sorted.indexOf(attr) === -1) | ||
.sort(); | ||
const remainings = attributes.filter( | ||
(attr) => sorted.indexOf(attr) === -1 | ||
); | ||
@@ -44,0 +44,0 @@ return sorted.concat(remainings); |
@@ -21,5 +21,5 @@ import { SortStrategy } from "../sorter"; | ||
const remainings = attributes | ||
.filter((attr) => sorted.indexOf(attr) === -1) | ||
.sort(); | ||
const remainings = attributes.filter( | ||
(attr) => sorted.indexOf(attr) === -1 | ||
); | ||
@@ -26,0 +26,0 @@ return sorted.concat(remainings); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34729