@bridge-ds/stylelint-plugin 0.2.11 → 0.2.14

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.
Files changed (2) hide show
  1. package/dist/index.js +15 -4
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -975,7 +975,7 @@ var DEFAULT_GOVERNANCE = {
975
975
  owners: { design: [], tech: [] }
976
976
  };
977
977
  var FLAT_TOKEN_KEYS = ["primitives", "brands", "semantic", "base", "density", "components", "contrastChecks"];
978
- var CANONICAL_TOKEN_KEYS = ["root", "include", "exclude", "tiers", "layers"];
978
+ var CANONICAL_TOKEN_KEYS = ["root", "include", "exclude", "tiers", "layers", "usage"];
979
979
  var FLAT_MODE_KEYS = ["brands", "themes", "densities", "defaults"];
980
980
  var AXIS_OF = { brands: "brand", themes: "theme", densities: "density" };
981
981
  var ConfigError = class extends Error {
@@ -1063,7 +1063,7 @@ function defineConfig(input) {
1063
1063
  const contrastFile = contrastPath ?? [root === "." ? "" : root, paths.contrastChecks].filter(Boolean).join("/");
1064
1064
  return {
1065
1065
  repo: parseRepoInput(input.repo, input.branch),
1066
- tokens: { ...paths, include: input.tokens?.include ?? ["**/*.tokens.json"], exclude: input.tokens?.exclude ?? [], tiers, layers },
1066
+ tokens: { ...paths, include: input.tokens?.include ?? ["**/*.tokens.json"], exclude: input.tokens?.exclude ?? [], tiers, layers, ...t.usage ? { usage: trimSlashes(t.usage) } : {} },
1067
1067
  axes,
1068
1068
  modes,
1069
1069
  contrast: { path: contrastFile, modes: input.contrast?.modes },
@@ -1073,7 +1073,8 @@ function defineConfig(input) {
1073
1073
  styleSuffix: input.components.styleSuffix ?? ".module.css",
1074
1074
  reference: input.components.reference,
1075
1075
  index: input.components.index,
1076
- specs: input.components.specs
1076
+ specs: input.components.specs,
1077
+ ...input.components.styles ? { styles: input.components.styles.map(trimSlashes) } : {}
1077
1078
  } : void 0,
1078
1079
  docs: { ...input.docs },
1079
1080
  changesets: pkg ? { dir: trimSlashes(input.changesets?.dir ?? ".changeset"), package: pkg } : void 0,
@@ -1098,6 +1099,7 @@ function defineConfig(input) {
1098
1099
  products: input.products?.length ? input.products.map((p) => ({ ...p })) : DEFAULT_PRODUCTS.map((p) => ({ ...p })),
1099
1100
  changes: input.changes === "direct" ? "direct" : DEFAULT_CHANGES_MODE,
1100
1101
  ...input.storybook?.url ? { storybook: { url: input.storybook.url.trim().replace(/\/+$/, "") } } : {},
1102
+ ...input.library?.public === true ? { library: { public: true } } : {},
1101
1103
  ...input.audit ? { audit: { ...input.audit } } : {},
1102
1104
  ...input.visualImpact ? { visualImpact: { mode: input.visualImpact.mode === "on-demand" ? "on-demand" : "auto" } } : {},
1103
1105
  ...input.integrations ? { integrations: { ...input.integrations } } : {},
@@ -1142,7 +1144,7 @@ function loadConfig(source) {
1142
1144
  if (!isObj(tokens)) problems.push('"tokens" must be an object');
1143
1145
  else
1144
1146
  for (const [k, v] of Object.entries(tokens)) {
1145
- if (FLAT_TOKEN_KEYS.includes(k) || k === "root") {
1147
+ if (FLAT_TOKEN_KEYS.includes(k) || k === "root" || k === "usage") {
1146
1148
  if (!isStr(v)) problems.push(`"tokens.${k}" must be a non-empty string`);
1147
1149
  } else if (k === "include" || k === "exclude") {
1148
1150
  if (!isStrList(v)) problems.push(`"tokens.${k}" must be a list of globs`);
@@ -1196,6 +1198,7 @@ function loadConfig(source) {
1196
1198
  problems.push('"contrast" must be { "path", "modes"? }');
1197
1199
  const comps = d.components;
1198
1200
  if (comps !== void 0 && (!isObj(comps) || !isStr(comps.dir))) problems.push('"components.dir" must be a non-empty string');
1201
+ if (isObj(comps) && comps.styles !== void 0 && !isStrList(comps.styles)) problems.push('"components.styles" must be a list of globs');
1199
1202
  const cs = d.changeset;
1200
1203
  if (cs !== void 0 && (!isObj(cs) || !isStr(cs.package))) problems.push('"changeset.package" must be a non-empty string');
1201
1204
  const css = d.changesets;
@@ -1228,6 +1231,14 @@ function loadConfig(source) {
1228
1231
  else if (!/^https:\/\/[^\s/]+/.test(sb.url.trim())) problems.push('"storybook.url" must start with https://, for example https://storybook.example.com');
1229
1232
  else for (const k of Object.keys(sb)) if (k !== "url") problems.push(`"storybook.${k}" is not a known key`);
1230
1233
  }
1234
+ const lib = d.library;
1235
+ if (lib !== void 0) {
1236
+ if (!isObj(lib)) problems.push('"library" must be an object, for example { "public": true }');
1237
+ else {
1238
+ if (lib.public !== void 0 && typeof lib.public !== "boolean") problems.push('"library.public" must be true or false');
1239
+ for (const k of Object.keys(lib)) if (k !== "public") problems.push(`"library.${k}" is not a known key`);
1240
+ }
1241
+ }
1231
1242
  problems.push(...productProblems(d.products));
1232
1243
  const audit = d.audit;
1233
1244
  if (audit !== void 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bridge-ds/stylelint-plugin",
3
- "version": "0.2.11",
3
+ "version": "0.2.14",
4
4
  "type": "module",
5
5
  "description": "Stylelint rule bridge/use-tokens: no raw colors, lengths, radii, shadows, durations or z-index in product CSS where a design token exists. Autofixes exact matches. Reads the tokens through @bridge-ds/core and bridge.config.json.",
6
6
  "license": "MIT",
@@ -56,6 +56,6 @@
56
56
  "stylelint": "16.26.1"
57
57
  },
58
58
  "dependencies": {
59
- "@bridge-ds/core": "^0.13.0"
59
+ "@bridge-ds/core": "^0.16.0"
60
60
  }
61
61
  }