carbon-design-system / stylelint-plugin-carbon-tokens

Apache License 2.0
9 stars 3 forks source link

spurious error for font-weight #103

Closed wkeese closed 4 months ago

wkeese commented 10 months ago

Given the SCSS of

@use "@carbon/type";
...
.keyword,
.function {
  font-weight: type.font-weight("semibold");
}

I'm getting the error that:

✖  Expected carbon type token, mixin or function for "font-weight" found "type.font-weight("semibold")".  carbon/type-token-use

Presumably, that shouldn't be flagged, because type.font-weight() is a carbon mixin.

lee-chase commented 4 months ago

In version 2 this is as expected, set option acceptCarbonFontWeightFunction to true to allow font weight functions.

const defaultOptions = {
  // include standard type properties
  includeProps: ["font", "/^font-*/", "line-height", "letterSpacing"],
  acceptValues: ["/inherit|initial/"],
  acceptsScopes: ["type"],
  acceptCarbonFontWeightFunction: false, // permit use of carbon font weight function
  acceptCarbonTypeScaleFunction: false, // permit use of carbon type scale function
  acceptCarbonFontFamilyFunction: false, // permit use of carbon font family function
  carbonPath: undefined // allows a different path for node_modules (supports monorepo with multiple carbon versions),
   e.g. packages/proj1/node_modules/@carbon
  carbonModulePostfix: undefined, // optional for use in conjunction with `carbonPath` to where a Carbon module has been renamed e.g. `-10` with a carbonPath of `node_modules/@carbon` will use `node_modules/@carbon/type-10`
  enforceScopes: false
};