@yummacss/canon
Advanced tools
| #!/usr/bin/env node | ||
| import{readFileSync as e}from"node:fs";import{resolve as t}from"node:path";import{loadConfig as n,suggestClasses as r,validateClasses as i}from"@yummacss/nitro";import{glob as a}from"tinyglobby";const o=[/class(?:Name)?\s*=\s*["']([^"']+)["']/g,/class(?:Name)?=\{["']([^"']+)["']\}/g,/class(?:Name)?=\{`([^`]+)`\}/g,/\b(?:cn|clsx|classnames|cva)\s*\(\s*["'`]([^"'`]+)["'`]/g],s=/^@?[a-z][a-zA-Z0-9@:/.%-]*$/;function c(e){let t=new Set;for(let n of o){n.lastIndex=0;let r=n.exec(e);for(;r!==null;){let i=(r[1]??``).replace(/\$\{[^}]*\}/g,` `);for(let e of i.split(/\s+/))e&&s.test(e)&&t.add(e);r=n.exec(e)}}return t}async function l(o={}){let s=o.cwd??process.cwd(),{config:l}=await n({cwd:s,path:o.configPath,config:o.config}),u=(await a(l.source??[],{cwd:s,absolute:!0})).map(e=>t(e)),d=new Map;for(let t of u){let n;try{n=e(t,`utf-8`)}catch{continue}for(let e of c(n)){let n=d.get(e);n||(n=new Set,d.set(e,n)),n.add(t)}}let f=new Set(o.allowlist??[]),{invalid:p}=i(Array.from(d.keys()).filter(e=>!f.has(e)),l),m=r(p,l);return{files:u.length,classes:d.size,invalid:p.sort().map(e=>({className:e,files:Array.from(d.get(e)??[]).sort(),suggestion:m.get(e)}))}}export{l as n,c as t}; |
+1
-1
| #!/usr/bin/env node | ||
| import{n as e}from"./src-Du8jC-YA.mjs";import{relative as t}from"node:path";function n(e){let t=[],n;for(let r=0;r<e.length;r++){let i=e[r];if(i===`--allow`||i===`-a`){let n=e[++r];n&&t.push(...n.split(`,`).map(e=>e.trim()))}else (i===`--config`||i===`-c`)&&(n=e[++r])}return{allowlist:t,configPath:n}}try{let r=await e(n(process.argv.slice(2)));if(console.info(`Scanned ${r.files} files and found ${r.classes} unique classes.`),r.invalid.length===0)console.info(`All classes are valid.`);else{console.error(`Found ${r.invalid.length} classes Yumma CSS does not recognize:`);for(let{className:e,files:n}of r.invalid){console.error(` "${e}"`);for(let e of n)console.error(` - ${t(process.cwd(),e)}`)}console.error(`Fix the classes above, or pass --allow "class-a,class-b" for custom classes.`),process.exit(1)}}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}export{}; | ||
| import{n as e}from"./src-jyVQWJBr.mjs";import{relative as t}from"node:path";function n(e){let t=[],n;for(let r=0;r<e.length;r++){let i=e[r];if(i===`--allow`||i===`-a`){let n=e[++r];n&&t.push(...n.split(`,`).map(e=>e.trim()))}else (i===`--config`||i===`-c`)&&(n=e[++r])}return{allowlist:t,configPath:n}}try{let r=await e(n(process.argv.slice(2)));if(console.info(`Scanned ${r.files} files and found ${r.classes} unique classes.`),r.invalid.length===0)console.info(`All classes are valid.`);else{console.error(`Found ${r.invalid.length} classes Yumma CSS does not recognize:`);for(let{className:e,files:n,suggestion:i}of r.invalid){console.error(i?` "${e}" - did you mean "${i}"?`:` "${e}"`);for(let e of n)console.error(` - ${t(process.cwd(),e)}`)}console.error(`Fix the classes above, or pass --allow "class-a,class-b" for custom classes.`),process.exit(1)}}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}export{}; |
+4
-0
@@ -33,2 +33,6 @@ | ||
| files: string[]; | ||
| /** | ||
| * The closest valid class, when one exists (e.g. "g-4" for "gap-4"). | ||
| */ | ||
| suggestion?: string; | ||
| } | ||
@@ -35,0 +39,0 @@ interface ValidateResult { |
+1
-1
| #!/usr/bin/env node | ||
| import{n as e,t}from"./src-Du8jC-YA.mjs";export{t as extractClasses,e as validate}; | ||
| import{n as e,t}from"./src-jyVQWJBr.mjs";export{t as extractClasses,e as validate}; |
+2
-2
| { | ||
| "name": "@yummacss/canon", | ||
| "version": "3.27.0", | ||
| "version": "3.28.1", | ||
| "description": "Class validator for Yumma CSS", | ||
@@ -39,3 +39,3 @@ "keywords": [ | ||
| "tinyglobby": "^0.2.15", | ||
| "@yummacss/nitro": "3.27.0" | ||
| "@yummacss/nitro": "3.28.1" | ||
| }, | ||
@@ -42,0 +42,0 @@ "publishConfig": { |
| #!/usr/bin/env node | ||
| import{readFileSync as e}from"node:fs";import{resolve as t}from"node:path";import{loadConfig as n,validateClasses as r}from"@yummacss/nitro";import{glob as i}from"tinyglobby";const a=[/class(?:Name)?\s*=\s*["']([^"']+)["']/g,/class(?:Name)?=\{["']([^"']+)["']\}/g,/class(?:Name)?=\{`([^`]+)`\}/g,/\b(?:cn|clsx|classnames|cva)\s*\(\s*["'`]([^"'`]+)["'`]/g],o=/^@?[a-z][a-zA-Z0-9@:/.%-]*$/;function s(e){let t=new Set;for(let n of a){n.lastIndex=0;let r=n.exec(e);for(;r!==null;){let i=(r[1]??``).replace(/\$\{[^}]*\}/g,` `);for(let e of i.split(/\s+/))e&&o.test(e)&&t.add(e);r=n.exec(e)}}return t}async function c(a={}){let o=a.cwd??process.cwd(),{config:c}=await n({cwd:o,path:a.configPath,config:a.config}),l=(await i(c.source??[],{cwd:o,absolute:!0})).map(e=>t(e)),u=new Map;for(let t of l){let n;try{n=e(t,`utf-8`)}catch{continue}for(let e of s(n)){let n=u.get(e);n||(n=new Set,u.set(e,n)),n.add(t)}}let d=new Set(a.allowlist??[]),{invalid:f}=r(Array.from(u.keys()).filter(e=>!d.has(e)),c);return{files:l.length,classes:u.size,invalid:f.sort().map(e=>({className:e,files:Array.from(u.get(e)??[]).sort()}))}}export{c as n,s as t}; |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
7381
2.84%+ Added
+ Added
- Removed
- Removed
Updated