@razorwind/eslint 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/runtime.d.cts +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/{types-BskEdv2u.d.mts → types-0Ihh2dhy.d.mts} +4 -3
- package/dist/types-0Ihh2dhy.d.mts.map +1 -0
- package/dist/{types-cqb0r3sP.d.cts → types-DbTyD7of.d.cts} +4 -3
- package/dist/types-DbTyD7of.d.cts.map +1 -0
- package/package.json +5 -5
- package/dist/types-BskEdv2u.d.mts.map +0 -1
- package/dist/types-cqb0r3sP.d.cts.map +0 -1
package/README.md
CHANGED
|
@@ -106,7 +106,8 @@ export default defineConfig({
|
|
|
106
106
|
|
|
107
107
|
Generating writes `eslint/design-system/index.mjs` (the plugin, with the
|
|
108
108
|
design-system manifest inlined) and an `INSTALL.md` listing every rule and its
|
|
109
|
-
default severity.
|
|
109
|
+
default severity. Multi-theme token sets generate one shared plugin and guide,
|
|
110
|
+
not separate files per theme. Wire the plugin into `eslint.config.mjs`:
|
|
110
111
|
|
|
111
112
|
```js
|
|
112
113
|
import designSystem from "./eslint/design-system/index.mjs";
|
|
@@ -128,7 +129,7 @@ export default [
|
|
|
128
129
|
|
|
129
130
|
| Option | Default | Description |
|
|
130
131
|
| --------------- | ---------------------------------- | ------------------------------------------------------------------------------------ |
|
|
131
|
-
| `eslintPath` | `"eslint/design-system/index.mjs"` | Output
|
|
132
|
+
| `eslintPath` | `"eslint/design-system/index.mjs"` | Output filename of the generated plugin module, not a directory. |
|
|
132
133
|
| `prefix` | `"design-system"` | Rule namespace used in `eslint.config.*`. |
|
|
133
134
|
| `runtimeImport` | `"@razorwind/eslint/runtime"` | Module the generated file imports the runtime from. |
|
|
134
135
|
| `cssVarPrefix` | initials of the schema name | Prefix of the token CSS variables, matching `@razorwind/css`. `false` for none. |
|
|
@@ -136,6 +137,10 @@ export default [
|
|
|
136
137
|
| `tamagui` | `false` | Include the `@razorwind/tamagui` v3 guardrails as `tamagui-*` rules. |
|
|
137
138
|
| `installGuide` | generated | Override the generated `INSTALL.md`. |
|
|
138
139
|
|
|
140
|
+
Relative `eslintPath` values resolve against the generation cwd. Include a full
|
|
141
|
+
filename when placing the module in a directory, for example
|
|
142
|
+
`eslint({ eslintPath: "eslint/design-system/index.ts" })`.
|
|
143
|
+
|
|
139
144
|
### Rules
|
|
140
145
|
|
|
141
146
|
Every rule reads its allowlist, suggestions and examples from the design
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./runtime-BsIMYTOg.cjs");let t=require("@razorwind/core/plugin"),n=require("@razorwind/core/utils"),r=require("node:
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./runtime-BsIMYTOg.cjs");let t=require("@razorwind/core/plugin"),n=require("@razorwind/core/utils"),r=require("node:fs/promises"),i=require("node:path"),a=require("@razorwind/tailwindcss/eslint"),o=require("@razorwind/tailwindcss/generate"),s=require("@razorwind/tamagui"),c=require("@razorwind/tamagui/eslint");const l=[`light`,`default`,`base`],u=/^\{([^}]+)\}$/,d=/\{([^}]+)\}/,f={color:`color`,shadow:`shadow`,typography:`typography`,fontFamily:`fontFamily`,fontWeight:`fontWeight`,duration:`duration`,cubicBezier:`easing`},p={color:`color`,space:`space`,size:`size`,radius:`radius`,zIndex:`zIndex`,fontSize:`fontSize`,fontWeight:`fontWeight`,shadow:`shadow`,insetShadow:`shadow`,dropShadow:`shadow`,textShadow:`shadow`,boxShadow:`shadow`},m={button:[`button`],"icon-button":[`iconbutton`],link:[`link`,`anchor`,`textlink`],checkbox:[`checkbox`],code:[`code`,`inlinecode`,`codeblock`],heading:[`heading`],image:[`image`,`img`],radio:[`radio`,`radiogroup`],range:[`slider`,`range`],select:[`select`,`nativeselect`],"text-input":[`input`,`textinput`,`textfield`],textarea:[`textarea`],text:[`text`,`typography`],"visually-hidden":[`visuallyhidden`,`sronly`,`screenreaderonly`],icon:[`icon`],primitive:[`box`,`stack`,`hstack`,`vstack`,`xstack`,`ystack`,`inline`,`flex`,`grid`,`center`]};function h(e){return e.replaceAll(/([\p{Ll}\d])(\p{Lu})/gu,`$1 $2`).replaceAll(/(\p{Lu})(\p{Lu}\p{Ll})/gu,`$1 $2`).split(/[^\p{L}\d]+/u).filter(Boolean).join(`-`).toLowerCase()}function g(e){return e.split(/[^a-z0-9]+/i).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function _(e){return e.toLowerCase().replaceAll(/[^a-z0-9]/g,``)}function v(e,t){let n=e.split(`.`).map(e=>e.toLowerCase()),r=(...e)=>e.some(e=>n.includes(e)),i=(e,t)=>n.some((r,i)=>r===e&&n[i+1]===t),a=t?f[t]:void 0;if(a)return a;if(r(`font-size`,`fontsize`)||i(`font`,`size`)||i(`text`,`size`))return`fontSize`;if(r(`font-weight`,`fontweight`)||i(`font`,`weight`))return`fontWeight`;if(r(`font-family`,`fontfamily`)||i(`font`,`family`))return`fontFamily`;if(r(`line-height`,`lineheight`,`leading`)||i(`line`,`height`))return`lineHeight`;if(r(`letter-spacing`,`letterspacing`,`tracking`)||i(`letter`,`spacing`))return`letterSpacing`;if(r(`border-width`,`borderwidth`,`stroke-width`,`strokewidth`,`outline-width`)||r(`border`,`stroke`,`outline`)&&r(`width`))return`borderWidth`;if(r(`duration`,`durations`,`delay`))return`duration`;if(r(`easing`,`ease`,`timing`,`cubic-bezier`))return`easing`;if(r(`opacity`,`opacities`))return`opacity`;let o=(0,s.resolveTokenCategory)(e,t);return o?p[o]:void 0}function y(e){let t=/* @__PURE__ */ new Map,r=(e,i,a)=>{if(!(0,n.isObject)(e))return;let o=e.$deprecated,s=o===!0||typeof o==`string`&&o.length>0?o:o===!1?void 0:a;if((0,n.isTokenLeaf)(e)){s&&!t.has(i.join(`.`))&&t.set(i.join(`.`),s);return}for(let[t,n]of Object.entries(e))t.startsWith(`$`)||r(n,[...i,t],s)};for(let t of(0,n.resolveTokenSets)(e))r(t.tokens,[],void 0);return t}function b(e){if(e===void 0)return-1;let t=l.indexOf(e.toLowerCase());return t<0?l.length:t}function x(e,t){let r=(0,n.flattenTokens)(e),i=y(e),a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map;for(let e of r){o.set(`${e.theme??``}:${e.path}`,e);let t=a.get(e.path);(!t||b(e.theme)<b(t.theme))&&a.set(e.path,e)}let s=(e,t=0)=>{let n=typeof e.value==`string`?u.exec(e.value)?.[1]:void 0;if(!n||t>10)return e;let r=o.get(`${e.theme??``}:${n}`)??a.get(n);return r?s(r,t+1):e};return[...a.values()].map(e=>{let r=s(e),o=e.type??r.type,c=(0,n.formatTokenValue)(r.value,o),l=i.get(e.path),u=typeof l==`string`?d.exec(l)?.[1]:void 0,f=v(e.path,o),p={path:e.path,cssVar:`--${h([t??``,...e.path.split(`.`)].join(` `))}`};return o&&(p.type=o),f&&(p.category=f),c&&!/^[[{]/.test(c)&&!c.includes(`var(`)&&(p.value=c),r!==e&&(p.alias=!0),l&&(p.deprecated=l),u&&a.has(u)&&(p.replacement=u),p}).sort((e,t)=>e.path.localeCompare(t.path,void 0,{numeric:!0}))}function S(e){let t=Object.values(e??{}),n=e=>[...new Set([e.title,e.name].map(g).filter(Boolean))];return t.map(e=>{let r=/* @__PURE__ */ new Set([_(e.name),_(e.title)]),i=Object.keys(m).filter(e=>m[e].some(e=>r.has(e))),a=e.tags?.some(e=>e.toLowerCase()===`deprecated`),o=(e.related??[]).flatMap(e=>{let r=t.find(t=>t.name===e);return r?[n(r)[0]]:[]}),s={name:e.name,jsx:n(e),roles:i};return a&&(s.deprecated=!0,o.length>0&&(s.replacements=o)),s}).sort((e,t)=>e.name.localeCompare(t.name))}function C(e){return[...new Set(Object.values(e??{}).flatMap(e=>[e.name,...e.aliases??[]].map(e=>g(e).replace(/Icon$/,``)).filter(Boolean).map(e=>`${e}Icon`)))].sort()}function w(e){return Object.values(e??{}).map(e=>({family:e.family??e.title??e.name,...e.role?{role:e.role}:{}}))}function T(e){return!!e&&(0,n.resolveTokenSets)(e).length>0}function E(e,t={}){let r=e.name??`design-system`,i=t.prefix??`design-system`,a=t.cssVarPrefix===!1?void 0:t.cssVarPrefix??(0,n.cssVarPrefixFromName)(e.name),o=T(e.tokens)?x(e.tokens,a):[],s={name:r,version:`0.0.0`,prefix:i,...a?{cssVarPrefix:a}:{},themes:T(e.tokens)?(0,n.resolveTokenSets)(e.tokens).map(e=>e.id).filter(e=>e!=="default"):[],tokens:o,components:S(e.components),icons:C(e.icons),fonts:w(e.fonts)},c=t.tailwind===!1?void 0:D(e,i);c&&(s.tailwind=c);let l=t.tamagui?O(e,i,t):void 0;return l&&(s.tamagui=l),s}function D(e,t){let n=(0,a.buildGuardrailTheme)(T(e.tokens)?(0,o.flattenThemeTokens)(e.tokens):[],{fonts:e.fonts,name:e.name,prefix:t});return Object.keys(n.namespaces).length>0?n:void 0}function O(e,t,n){let r=typeof n.tamagui==`object`?n.tamagui:{},i=(0,c.buildGuardrailTheme)((0,s.collectTamaguiVocabulary)(e,T(e.tokens)?(0,s.flattenTokens)(e.tokens,{includeTypes:r.includeTypes}):[]),{name:e.name,prefix:t,shorthands:r.shorthands});return Object.keys(i.tokens).length>0?i:void 0}function k(e,t={}){let n=t.runtimeImport??`@razorwind/eslint/runtime`;return`// Generated by @razorwind/eslint. Do not edit by hand: re-run
|
|
2
2
|
// Razorwind generate when design tokens change.
|
|
3
3
|
//
|
|
4
4
|
// import designSystem from "./<path-to-this-file>";
|
|
@@ -19,7 +19,7 @@ export const configs = designSystem.configs;
|
|
|
19
19
|
export const defaultSeverity = designSystem.defaultSeverity;
|
|
20
20
|
|
|
21
21
|
export default designSystem.config;
|
|
22
|
-
`}function
|
|
22
|
+
`}function A(t){let{eslintPath:n,manifest:r}=t,{rules:i,defaultSeverity:a}=e.t(r),o=Object.keys(i).map(e=>{let t=i[e];return`| \`${r.prefix}/${e}\` | ${a[e]??`off`} | ${t.meta.docs.description} |`}).join(`
|
|
23
23
|
`);return`# Installing the ESLint Design-System Plugin
|
|
24
24
|
|
|
25
25
|
Generated by \`@razorwind/eslint\` from ${[`${r.tokens.length} tokens`,`${r.components.length} components`,`${r.icons.length} icons`,`${r.fonts.length} fonts`].join(`, `)}.
|
|
@@ -72,4 +72,4 @@ ${o}
|
|
|
72
72
|
## Regenerate
|
|
73
73
|
|
|
74
74
|
Re-run Razorwind generate when the design system changes so \`${n}\` stays in sync.
|
|
75
|
-
`}async function
|
|
75
|
+
`}async function j(e,t={},a=process.cwd()){let o=E(e,t);if(o.tokens.length===0&&o.components.length===0&&o.icons.length===0)return{};let s=t.eslintPath??`eslint/design-system/index.mjs`;if((await(0,r.stat)((0,i.resolve)(a,s)).catch(e=>{if(e.code!==`ENOENT`)throw e}))?.isDirectory())throw Error(`eslintPath must be a filename, not an existing directory: "${s}". Set eslintPath to "${(0,i.join)(s,`index.mjs`)}" instead.`);let c=(0,i.join)((0,i.dirname)(s),`INSTALL.md`),l={name:`razorwind-eslint`};return{[s]:(0,n.createDocument)(s,k(o,t),l,void 0,`javascript`),[c]:(0,n.createDocument)(c,t.installGuide??A({eslintPath:s,manifest:o}),l,void 0,`markdown`)}}var M=(0,t.definePlugin)(e=>({name:`eslint`,themeGeneration:`combined`,generate:async(t,n)=>j(t,e??{},n.cwd)}));exports.DEFAULT_PREFIX=`design-system`,exports.buildManifest=E,exports.collectManifestComponents=S,exports.collectManifestIcons=C,exports.collectManifestTokens=x,exports.default=M,exports.generateEslintPlugin=j,exports.kebabCase=h,exports.pascalCase=g,exports.renderEslintInstallMd=A,exports.renderEslintPlugin=k,exports.resolveCategory=v;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DesignSystemRuleId, c as EslintPluginOptions, d as ManifestToken, f as TokenCategory, i as DesignSystemOptions, l as ManifestComponent, n as CoreRuleId, o as DesignSystemSettings, p as TokenReferenceStyle, r as DesignSystemManifest, s as DesignSystemSeverity, t as ComponentRole, u as ManifestFont } from "./types-
|
|
1
|
+
import { a as DesignSystemRuleId, c as EslintPluginOptions, d as ManifestToken, f as TokenCategory, i as DesignSystemOptions, l as ManifestComponent, n as CoreRuleId, o as DesignSystemSettings, p as TokenReferenceStyle, r as DesignSystemManifest, s as DesignSystemSeverity, t as ComponentRole, u as ManifestFont } from "./types-DbTyD7of.cjs";
|
|
2
2
|
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
3
3
|
import { Schema, Tokens } from "@razorwind/core/schema";
|
|
4
4
|
//#region src/manifest.d.ts
|
|
@@ -50,7 +50,7 @@ declare function renderEslintInstallMd(options: {
|
|
|
50
50
|
* Generate an ESLint plugin whose rules are derived from the schema's design
|
|
51
51
|
* tokens, components, icons and fonts.
|
|
52
52
|
*/
|
|
53
|
-
declare function generateEslintPlugin(spec: Schema, options?: EslintPluginOptions): Promise<GeneratorFunctionResult<Schema, EslintPluginOptions>>;
|
|
53
|
+
declare function generateEslintPlugin(spec: Schema, options?: EslintPluginOptions, cwd?: string): Promise<GeneratorFunctionResult<Schema, EslintPluginOptions>>;
|
|
54
54
|
/**
|
|
55
55
|
* Razorwind plugin: generate an ESLint plugin that keeps code aligned with
|
|
56
56
|
* the design system. It ports the `@atlaskit/eslint-plugin-design-system`
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/manifest.ts","../src/index.ts"],"mappings":";;;;cAiDa;;;;;;iBA2EG,UAAU;;iBAWV,WAAW;;;;;iBAgBX,gBACd,cACA,gBACC;;;;;iBAoHa,sBACd,QAAQ,SAAS,eAAe,SAChC,wBACC;;iBAsEa,0BACd,YAAY,uBACX;;iBA4Ca,qBAAqB,OAAO;;;;;;iBA6B5B,cACd,MAAM,QACN,UAAS,sBACR;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/manifest.ts","../src/index.ts"],"mappings":";;;;cAiDa;;;;;;iBA2EG,UAAU;;iBAWV,WAAW;;;;;iBAgBX,gBACd,cACA,gBACC;;;;;iBAoHa,sBACd,QAAQ,SAAS,eAAe,SAChC,wBACC;;iBAsEa,0BACd,YAAY,uBACX;;iBA4Ca,qBAAqB,OAAO;;;;;;iBA6B5B,cACd,MAAM,QACN,UAAS,sBACR;;;;;;;iBCpWa,mBACd,UAAU,sBACV,UAAS,KAAK;;;;;iBAgCA,sBAAsB;EACpC;EACA,UAAU;;;;;;iBA6EU,qBACpB,MAAM,QACN,UAAS,qBACT,eACC,QAAQ,wBAAwB,QAAQ"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DesignSystemRuleId, c as EslintPluginOptions, d as ManifestToken, f as TokenCategory, i as DesignSystemOptions, l as ManifestComponent, n as CoreRuleId, o as DesignSystemSettings, p as TokenReferenceStyle, r as DesignSystemManifest, s as DesignSystemSeverity, t as ComponentRole, u as ManifestFont } from "./types-
|
|
1
|
+
import { a as DesignSystemRuleId, c as EslintPluginOptions, d as ManifestToken, f as TokenCategory, i as DesignSystemOptions, l as ManifestComponent, n as CoreRuleId, o as DesignSystemSettings, p as TokenReferenceStyle, r as DesignSystemManifest, s as DesignSystemSeverity, t as ComponentRole, u as ManifestFont } from "./types-0Ihh2dhy.mjs";
|
|
2
2
|
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
3
3
|
import { Schema, Tokens } from "@razorwind/core/schema";
|
|
4
4
|
//#region src/manifest.d.ts
|
|
@@ -50,7 +50,7 @@ declare function renderEslintInstallMd(options: {
|
|
|
50
50
|
* Generate an ESLint plugin whose rules are derived from the schema's design
|
|
51
51
|
* tokens, components, icons and fonts.
|
|
52
52
|
*/
|
|
53
|
-
declare function generateEslintPlugin(spec: Schema, options?: EslintPluginOptions): Promise<GeneratorFunctionResult<Schema, EslintPluginOptions>>;
|
|
53
|
+
declare function generateEslintPlugin(spec: Schema, options?: EslintPluginOptions, cwd?: string): Promise<GeneratorFunctionResult<Schema, EslintPluginOptions>>;
|
|
54
54
|
/**
|
|
55
55
|
* Razorwind plugin: generate an ESLint plugin that keeps code aligned with
|
|
56
56
|
* the design system. It ports the `@atlaskit/eslint-plugin-design-system`
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./runtime-gmz9xNDY.mjs";import{definePlugin as t}from"@razorwind/core/plugin";import{createDocument as n,cssVarPrefixFromName as r,flattenTokens as i,formatTokenValue as a,isObject as o,isTokenLeaf as s,resolveTokenSets as c}from"@razorwind/core/utils";import{dirname as
|
|
1
|
+
import{t as e}from"./runtime-gmz9xNDY.mjs";import{definePlugin as t}from"@razorwind/core/plugin";import{createDocument as n,cssVarPrefixFromName as r,flattenTokens as i,formatTokenValue as a,isObject as o,isTokenLeaf as s,resolveTokenSets as c}from"@razorwind/core/utils";import{stat as l}from"node:fs/promises";import{dirname as u,join as d,resolve as f}from"node:path";import{buildGuardrailTheme as p}from"@razorwind/tailwindcss/eslint";import{flattenThemeTokens as m}from"@razorwind/tailwindcss/generate";import{collectTamaguiVocabulary as h,flattenTokens as g,resolveTokenCategory as _}from"@razorwind/tamagui";import{buildGuardrailTheme as v}from"@razorwind/tamagui/eslint";const y=`design-system`,b=[`light`,`default`,`base`],x=/^\{([^}]+)\}$/,S=/\{([^}]+)\}/,C={color:`color`,shadow:`shadow`,typography:`typography`,fontFamily:`fontFamily`,fontWeight:`fontWeight`,duration:`duration`,cubicBezier:`easing`},w={color:`color`,space:`space`,size:`size`,radius:`radius`,zIndex:`zIndex`,fontSize:`fontSize`,fontWeight:`fontWeight`,shadow:`shadow`,insetShadow:`shadow`,dropShadow:`shadow`,textShadow:`shadow`,boxShadow:`shadow`},T={button:[`button`],"icon-button":[`iconbutton`],link:[`link`,`anchor`,`textlink`],checkbox:[`checkbox`],code:[`code`,`inlinecode`,`codeblock`],heading:[`heading`],image:[`image`,`img`],radio:[`radio`,`radiogroup`],range:[`slider`,`range`],select:[`select`,`nativeselect`],"text-input":[`input`,`textinput`,`textfield`],textarea:[`textarea`],text:[`text`,`typography`],"visually-hidden":[`visuallyhidden`,`sronly`,`screenreaderonly`],icon:[`icon`],primitive:[`box`,`stack`,`hstack`,`vstack`,`xstack`,`ystack`,`inline`,`flex`,`grid`,`center`]};function E(e){return e.replaceAll(/([\p{Ll}\d])(\p{Lu})/gu,`$1 $2`).replaceAll(/(\p{Lu})(\p{Lu}\p{Ll})/gu,`$1 $2`).split(/[^\p{L}\d]+/u).filter(Boolean).join(`-`).toLowerCase()}function D(e){return e.split(/[^a-z0-9]+/i).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function O(e){return e.toLowerCase().replaceAll(/[^a-z0-9]/g,``)}function k(e,t){let n=e.split(`.`).map(e=>e.toLowerCase()),r=(...e)=>e.some(e=>n.includes(e)),i=(e,t)=>n.some((r,i)=>r===e&&n[i+1]===t),a=t?C[t]:void 0;if(a)return a;if(r(`font-size`,`fontsize`)||i(`font`,`size`)||i(`text`,`size`))return`fontSize`;if(r(`font-weight`,`fontweight`)||i(`font`,`weight`))return`fontWeight`;if(r(`font-family`,`fontfamily`)||i(`font`,`family`))return`fontFamily`;if(r(`line-height`,`lineheight`,`leading`)||i(`line`,`height`))return`lineHeight`;if(r(`letter-spacing`,`letterspacing`,`tracking`)||i(`letter`,`spacing`))return`letterSpacing`;if(r(`border-width`,`borderwidth`,`stroke-width`,`strokewidth`,`outline-width`)||r(`border`,`stroke`,`outline`)&&r(`width`))return`borderWidth`;if(r(`duration`,`durations`,`delay`))return`duration`;if(r(`easing`,`ease`,`timing`,`cubic-bezier`))return`easing`;if(r(`opacity`,`opacities`))return`opacity`;let o=_(e,t);return o?w[o]:void 0}function A(e){let t=/* @__PURE__ */ new Map,n=(e,r,i)=>{if(!o(e))return;let a=e.$deprecated,c=a===!0||typeof a==`string`&&a.length>0?a:a===!1?void 0:i;if(s(e)){c&&!t.has(r.join(`.`))&&t.set(r.join(`.`),c);return}for(let[t,i]of Object.entries(e))t.startsWith(`$`)||n(i,[...r,t],c)};for(let t of c(e))n(t.tokens,[],void 0);return t}function j(e){if(e===void 0)return-1;let t=b.indexOf(e.toLowerCase());return t<0?b.length:t}function M(e,t){let n=i(e),r=A(e),o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let e of n){s.set(`${e.theme??``}:${e.path}`,e);let t=o.get(e.path);(!t||j(e.theme)<j(t.theme))&&o.set(e.path,e)}let c=(e,t=0)=>{let n=typeof e.value==`string`?x.exec(e.value)?.[1]:void 0;if(!n||t>10)return e;let r=s.get(`${e.theme??``}:${n}`)??o.get(n);return r?c(r,t+1):e};return[...o.values()].map(e=>{let n=c(e),i=e.type??n.type,s=a(n.value,i),l=r.get(e.path),u=typeof l==`string`?S.exec(l)?.[1]:void 0,d=k(e.path,i),f={path:e.path,cssVar:`--${E([t??``,...e.path.split(`.`)].join(` `))}`};return i&&(f.type=i),d&&(f.category=d),s&&!/^[[{]/.test(s)&&!s.includes(`var(`)&&(f.value=s),n!==e&&(f.alias=!0),l&&(f.deprecated=l),u&&o.has(u)&&(f.replacement=u),f}).sort((e,t)=>e.path.localeCompare(t.path,void 0,{numeric:!0}))}function N(e){let t=Object.values(e??{}),n=e=>[...new Set([e.title,e.name].map(D).filter(Boolean))];return t.map(e=>{let r=/* @__PURE__ */ new Set([O(e.name),O(e.title)]),i=Object.keys(T).filter(e=>T[e].some(e=>r.has(e))),a=e.tags?.some(e=>e.toLowerCase()===`deprecated`),o=(e.related??[]).flatMap(e=>{let r=t.find(t=>t.name===e);return r?[n(r)[0]]:[]}),s={name:e.name,jsx:n(e),roles:i};return a&&(s.deprecated=!0,o.length>0&&(s.replacements=o)),s}).sort((e,t)=>e.name.localeCompare(t.name))}function P(e){return[...new Set(Object.values(e??{}).flatMap(e=>[e.name,...e.aliases??[]].map(e=>D(e).replace(/Icon$/,``)).filter(Boolean).map(e=>`${e}Icon`)))].sort()}function F(e){return Object.values(e??{}).map(e=>({family:e.family??e.title??e.name,...e.role?{role:e.role}:{}}))}function I(e){return!!e&&c(e).length>0}function L(e,t={}){let n=e.name??`design-system`,i=t.prefix??`design-system`,a=t.cssVarPrefix===!1?void 0:t.cssVarPrefix??r(e.name),o=I(e.tokens)?M(e.tokens,a):[],s={name:n,version:`0.0.0`,prefix:i,...a?{cssVarPrefix:a}:{},themes:I(e.tokens)?c(e.tokens).map(e=>e.id).filter(e=>e!=="default"):[],tokens:o,components:N(e.components),icons:P(e.icons),fonts:F(e.fonts)},l=t.tailwind===!1?void 0:R(e,i);l&&(s.tailwind=l);let u=t.tamagui?z(e,i,t):void 0;return u&&(s.tamagui=u),s}function R(e,t){let n=p(I(e.tokens)?m(e.tokens):[],{fonts:e.fonts,name:e.name,prefix:t});return Object.keys(n.namespaces).length>0?n:void 0}function z(e,t,n){let r=typeof n.tamagui==`object`?n.tamagui:{},i=v(h(e,I(e.tokens)?g(e.tokens,{includeTypes:r.includeTypes}):[]),{name:e.name,prefix:t,shorthands:r.shorthands});return Object.keys(i.tokens).length>0?i:void 0}function B(e,t={}){let n=t.runtimeImport??`@razorwind/eslint/runtime`;return`// Generated by @razorwind/eslint. Do not edit by hand: re-run
|
|
2
2
|
// Razorwind generate when design tokens change.
|
|
3
3
|
//
|
|
4
4
|
// import designSystem from "./<path-to-this-file>";
|
|
@@ -19,7 +19,7 @@ export const configs = designSystem.configs;
|
|
|
19
19
|
export const defaultSeverity = designSystem.defaultSeverity;
|
|
20
20
|
|
|
21
21
|
export default designSystem.config;
|
|
22
|
-
`}function
|
|
22
|
+
`}function V(t){let{eslintPath:n,manifest:r}=t,{rules:i,defaultSeverity:a}=e(r),o=Object.keys(i).map(e=>{let t=i[e];return`| \`${r.prefix}/${e}\` | ${a[e]??`off`} | ${t.meta.docs.description} |`}).join(`
|
|
23
23
|
`);return`# Installing the ESLint Design-System Plugin
|
|
24
24
|
|
|
25
25
|
Generated by \`@razorwind/eslint\` from ${[`${r.tokens.length} tokens`,`${r.components.length} components`,`${r.icons.length} icons`,`${r.fonts.length} fonts`].join(`, `)}.
|
|
@@ -72,5 +72,5 @@ ${o}
|
|
|
72
72
|
## Regenerate
|
|
73
73
|
|
|
74
74
|
Re-run Razorwind generate when the design system changes so \`${n}\` stays in sync.
|
|
75
|
-
`}async function
|
|
75
|
+
`}async function H(e,t={},r=process.cwd()){let i=L(e,t);if(i.tokens.length===0&&i.components.length===0&&i.icons.length===0)return{};let a=t.eslintPath??`eslint/design-system/index.mjs`;if((await l(f(r,a)).catch(e=>{if(e.code!==`ENOENT`)throw e}))?.isDirectory())throw Error(`eslintPath must be a filename, not an existing directory: "${a}". Set eslintPath to "${d(a,`index.mjs`)}" instead.`);let o=d(u(a),`INSTALL.md`),s={name:`razorwind-eslint`};return{[a]:n(a,B(i,t),s,void 0,`javascript`),[o]:n(o,t.installGuide??V({eslintPath:a,manifest:i}),s,void 0,`markdown`)}}var U=t(e=>({name:`eslint`,themeGeneration:`combined`,generate:async(t,n)=>H(t,e??{},n.cwd)}));export{y as DEFAULT_PREFIX,L as buildManifest,N as collectManifestComponents,P as collectManifestIcons,M as collectManifestTokens,U as default,H as generateEslintPlugin,E as kebabCase,D as pascalCase,V as renderEslintInstallMd,B as renderEslintPlugin,k as resolveCategory};
|
|
76
76
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["buildTailwindTheme","buildTamaguiTheme","flattenTamaguiTokens","createDesignSystemPlugin","flattenTokens$1","buildGuardrailTheme$1","DEFAULT_PREFIX","PRIMARY_THEME_IDS","DTCG_ALIAS","DTCG_REFERENCE","TYPE_CATEGORIES","TAMAGUI_CATEGORIES","ROLE_NAMES","kebabCase","value","pascalCase","part","compact","resolveCategory","segments","path","segment","has","names","name","pair","first","index","second","byType","type","category","resolveTokenCategory","collectDeprecations","deprecated","walk","isObject","node","own","current","inherited","isTokenLeaf","key","child","set","resolveTokenSets","tokens","themeRank","theme","collectManifestTokens","rows","flattenTokens","deprecations","primary","byTheme","row","resolve","alias","depth","target","resolved","formatTokenValue","replacement","token","cssVarPrefix","a","b","collectManifestComponents","all","components","jsxNames","component","words","roles","role","tag","replacements","related","item","entry","collectManifestIcons","icons","icon","collectManifestFonts","fonts","font","hasTokens","buildManifest","spec","prefix","options","cssVarPrefixFromName","manifest","id","tailwind","buildTailwind","tamagui","buildTamagui","buildGuardrailTheme","flattenThemeTokens","collectTamaguiVocabulary","renderEslintPlugin","runtimeImport","renderEslintInstallMd","rules","rule","defaultSeverity","eslintPath","generateEslintPlugin","
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["buildTailwindTheme","buildTamaguiTheme","flattenTamaguiTokens","createDesignSystemPlugin","flattenTokens$1","buildGuardrailTheme$1","DEFAULT_PREFIX","PRIMARY_THEME_IDS","DTCG_ALIAS","DTCG_REFERENCE","TYPE_CATEGORIES","TAMAGUI_CATEGORIES","ROLE_NAMES","kebabCase","value","pascalCase","part","compact","resolveCategory","segments","path","segment","has","names","name","pair","first","index","second","byType","type","category","resolveTokenCategory","collectDeprecations","deprecated","walk","isObject","node","own","current","inherited","isTokenLeaf","key","child","set","resolveTokenSets","tokens","themeRank","theme","collectManifestTokens","rows","flattenTokens","deprecations","primary","byTheme","row","resolve","alias","depth","target","resolved","formatTokenValue","replacement","token","cssVarPrefix","a","b","collectManifestComponents","all","components","jsxNames","component","words","roles","role","tag","replacements","related","item","entry","collectManifestIcons","icons","icon","collectManifestFonts","fonts","font","hasTokens","buildManifest","spec","prefix","options","cssVarPrefixFromName","manifest","id","tailwind","buildTailwind","tamagui","buildTamagui","buildGuardrailTheme","flattenThemeTokens","collectTamaguiVocabulary","renderEslintPlugin","runtimeImport","renderEslintInstallMd","rules","rule","defaultSeverity","eslintPath","generateEslintPlugin","stat","cwd","error","join","installPath","dirname","meta","createDocument","src_default","definePlugin","config"],"sources":[],"mappings":""}
|
package/dist/runtime.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DesignSystemRuleId, d as ManifestToken, f as TokenCategory, i as DesignSystemOptions, l as ManifestComponent, n as CoreRuleId, o as DesignSystemSettings, p as TokenReferenceStyle, r as DesignSystemManifest, s as DesignSystemSeverity, t as ComponentRole, u as ManifestFont } from "./types-
|
|
1
|
+
import { a as DesignSystemRuleId, d as ManifestToken, f as TokenCategory, i as DesignSystemOptions, l as ManifestComponent, n as CoreRuleId, o as DesignSystemSettings, p as TokenReferenceStyle, r as DesignSystemManifest, s as DesignSystemSeverity, t as ComponentRole, u as ManifestFont } from "./types-DbTyD7of.cjs";
|
|
2
2
|
import { GuardrailRuleModule } from "@razorwind/tailwindcss/eslint-runtime";
|
|
3
3
|
import { GuardrailRuleModule as GuardrailRuleModule$1 } from "@razorwind/tamagui/eslint-runtime";
|
|
4
4
|
//#region src/runtime/ast.d.ts
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DesignSystemRuleId, d as ManifestToken, f as TokenCategory, i as DesignSystemOptions, l as ManifestComponent, n as CoreRuleId, o as DesignSystemSettings, p as TokenReferenceStyle, r as DesignSystemManifest, s as DesignSystemSeverity, t as ComponentRole, u as ManifestFont } from "./types-
|
|
1
|
+
import { a as DesignSystemRuleId, d as ManifestToken, f as TokenCategory, i as DesignSystemOptions, l as ManifestComponent, n as CoreRuleId, o as DesignSystemSettings, p as TokenReferenceStyle, r as DesignSystemManifest, s as DesignSystemSeverity, t as ComponentRole, u as ManifestFont } from "./types-0Ihh2dhy.mjs";
|
|
2
2
|
import { GuardrailRuleModule } from "@razorwind/tailwindcss/eslint-runtime";
|
|
3
3
|
import { GuardrailRuleModule as GuardrailRuleModule$1 } from "@razorwind/tamagui/eslint-runtime";
|
|
4
4
|
//#region src/runtime/ast.d.ts
|
|
@@ -7,8 +7,9 @@ import { TokenType } from "@power-plant/dtcg-schema";
|
|
|
7
7
|
*/
|
|
8
8
|
interface EslintPluginOptions {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* the
|
|
10
|
+
* Filename of the generated ESLint plugin module, not an output directory.
|
|
11
|
+
* Relative paths are resolved against the generation cwd. For a module in
|
|
12
|
+
* a directory, include the filename (for example, `eslint/design-system/index.mjs`).
|
|
12
13
|
*
|
|
13
14
|
* @defaultValue "eslint/design-system/index.mjs"
|
|
14
15
|
*/
|
|
@@ -204,4 +205,4 @@ interface DesignSystemOptions extends DesignSystemSettings {
|
|
|
204
205
|
}
|
|
205
206
|
//#endregion
|
|
206
207
|
export { DesignSystemRuleId as a, EslintPluginOptions as c, ManifestToken as d, TokenCategory as f, DesignSystemOptions as i, ManifestComponent as l, CoreRuleId as n, DesignSystemSettings as o, TokenReferenceStyle as p, DesignSystemManifest as r, DesignSystemSeverity as s, ComponentRole as t, ManifestFont as u };
|
|
207
|
-
//# sourceMappingURL=types-
|
|
208
|
+
//# sourceMappingURL=types-0Ihh2dhy.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-0Ihh2dhy.d.mts","names":[],"sources":["../src/types.ts"],"mappings":""}
|
|
@@ -7,8 +7,9 @@ import { GuardrailRuleId as TamaguiGuardrailRuleId, GuardrailSettings as Tamagui
|
|
|
7
7
|
*/
|
|
8
8
|
interface EslintPluginOptions {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* the
|
|
10
|
+
* Filename of the generated ESLint plugin module, not an output directory.
|
|
11
|
+
* Relative paths are resolved against the generation cwd. For a module in
|
|
12
|
+
* a directory, include the filename (for example, `eslint/design-system/index.mjs`).
|
|
12
13
|
*
|
|
13
14
|
* @defaultValue "eslint/design-system/index.mjs"
|
|
14
15
|
*/
|
|
@@ -204,4 +205,4 @@ interface DesignSystemOptions extends DesignSystemSettings {
|
|
|
204
205
|
}
|
|
205
206
|
//#endregion
|
|
206
207
|
export { DesignSystemRuleId as a, EslintPluginOptions as c, ManifestToken as d, TokenCategory as f, DesignSystemOptions as i, ManifestComponent as l, CoreRuleId as n, DesignSystemSettings as o, TokenReferenceStyle as p, DesignSystemManifest as r, DesignSystemSeverity as s, ComponentRole as t, ManifestFont as u };
|
|
207
|
-
//# sourceMappingURL=types-
|
|
208
|
+
//# sourceMappingURL=types-DbTyD7of.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DbTyD7of.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;UA0CiB;;;;;;;;EAQf;;;;;;;EAQA;;;;;;EAOA;;;;;;;;EASA;;;;;;;EAQA;;;;;;;;EASA;IAGM,aAAa;IACb,eAAe;;;;;;EAOrB;;;;;;KAOU;;;;;KAsBA;;UAmBK;;EAEf;;EAEA;;EAEA,WAAW;;EAEX;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;EAEA,OAAO;;EAEP;;EAEA;;;UAIe;;EAEf;;EAEA;;;;;;UAOe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;EACA,QAAQ;EACR,YAAY;;EAEZ;EACA,OAAO;;EAEP,WAAW;;EAEX,UAAU;;;KAIA;;KAcA,quBA4BR;KAEQ,6BAA6B;KAC7B,2BAA2B;;KAG3B,qBAAqB,aAAa,iBAAiB;KAEnD;;KAGA;;UAGK;;;;;;EAMf;;;;;;;EAOA,iBAAiB;;;;;;;EAOjB;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;EAKA,gBAAgB;;;UAID,4BAA4B;;EAE3C;;EAEA;;EAEA,WAAW,QAAQ,OAAO,oBAAoB;;EAE9C,WAAW;;EAEX,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/eslint",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Razorwind ESLint plugin generator to create eslint rules that can be used as design system guidelines.",
|
|
6
6
|
"repository": {
|
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@power-plant/core": "^0.0.93",
|
|
83
83
|
"@power-plant/dtcg-schema": "^0.0.1",
|
|
84
|
-
"@razorwind/core": "^0.0.
|
|
85
|
-
"@razorwind/tailwindcss": "^0.0.
|
|
86
|
-
"@razorwind/tamagui": "^0.0.
|
|
84
|
+
"@razorwind/core": "^0.0.86",
|
|
85
|
+
"@razorwind/tailwindcss": "^0.0.84",
|
|
86
|
+
"@razorwind/tamagui": "^0.0.89"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": { "eslint": ">=9.0.0" },
|
|
89
89
|
"peerDependenciesMeta": { "eslint": { "optional": true } },
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"typescript": "^6.0.3"
|
|
94
94
|
},
|
|
95
95
|
"publishConfig": { "access": "public" },
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "9d4e4b72eaf0b91c50891bad43ae6ec5d231952a"
|
|
97
97
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-BskEdv2u.d.mts","names":[],"sources":["../src/types.ts"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-cqb0r3sP.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;UA0CiB;;;;;;;EAOf;;;;;;;EAQA;;;;;;EAOA;;;;;;;;EASA;;;;;;;EAQA;;;;;;;;EASA;IAGM,aAAa;IACb,eAAe;;;;;;EAOrB;;;;;;KAOU;;;;;KAsBA;;UAmBK;;EAEf;;EAEA;;EAEA,WAAW;;EAEX;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;EAEA,OAAO;;EAEP;;EAEA;;;UAIe;;EAEf;;EAEA;;;;;;UAOe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;EACA,QAAQ;EACR,YAAY;;EAEZ;EACA,OAAO;;EAEP,WAAW;;EAEX,UAAU;;;KAIA;;KAcA,quBA4BR;KAEQ,6BAA6B;KAC7B,2BAA2B;;KAG3B,qBAAqB,aAAa,iBAAiB;KAEnD;;KAGA;;UAGK;;;;;;EAMf;;;;;;;EAOA,iBAAiB;;;;;;;EAOjB;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;EAKA,gBAAgB;;;UAID,4BAA4B;;EAE3C;;EAEA;;EAEA,WAAW,QAAQ,OAAO,oBAAoB;;EAE9C,WAAW;;EAEX,UAAU"}
|