All files / packages/design-tokens/src/style-dictionary/filters config-filter.js

100% Statements 6/6
100% Branches 2/2
100% Functions 3/3
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29            2x             2x 6x               2x 2x   2x      
/**
 * Filters tokens from config.json
 * Config tokens are configuration flags used by components (e.g., --slds-is-v2-enabled)
 * and are built separately from theme tokens since they're theme-independent
 */
 
const CONFIG_FILE_PATH = '/common/config.json';
 
/**
 * Filter function to identify config tokens based on file path
 * @param {Object} token - Style Dictionary token object
 * @returns {boolean} True if token is from config.json
 */
export const configFilterFunction = (token) => {
  return token.filePath && token.filePath.includes(CONFIG_FILE_PATH);
};
 
/**
 * Registers the config filter with Style Dictionary
 * Used in build.js to generate config.css separately from theme files
 * @param {StyleDictionary} StyleDictionary - Style Dictionary instance
 */
export const configFilter = (StyleDictionary) => {
  StyleDictionary.registerFilter({
    name: 'filter/config',
    filter: (token) => configFilterFunction(token),
  });
};