• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

deriv-com / quill-tokens / 6298939233

25 Sep 2023 11:51AM UTC coverage: 42.697% (-4.1%) from 46.818%
6298939233

Pull #7

github

mohsen-deriv
chore: added new semantic viewport tokens
Pull Request #7: update-raw-token-2023-09-25-08-12-07

21 of 71 branches covered (0.0%)

Branch coverage included in aggregate %.

35 of 35 new or added lines in 4 files covered. (100.0%)

93 of 196 relevant lines covered (47.45%)

162.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

17.86
/src/formatters/token-names.fomatter.ts
1
import { Format, Formatter, Named, TransformedToken } from 'style-dictionary';
2
import { QuillTokenType } from '../types';
3
import fs from 'fs';
4
import { template as LodashTemplate } from 'lodash';
5
import * as prettier from '@prettier/sync';
6

7
const tokenMap: Map<QuillTokenType, TransformedToken[]> = new Map([]);
1✔
8

9
const tokenNamesTemplateFile = fs.readFileSync('src/templates/token-names.template').toString();
1✔
10
const tokenNamesTemplate = LodashTemplate(tokenNamesTemplateFile);
1✔
11

12
const formatter: Formatter = ({ dictionary }) => {
1✔
13
  dictionary.allTokens.forEach((token) => {
×
14
    const tokenType = token.type as QuillTokenType;
×
15
    const currentTokens = tokenMap.get(tokenType) || [];
×
16
    tokenMap.set(tokenType, [...currentTokens, token]);
×
17
  });
18

19
  const tokenMapKeys = Array.from(tokenMap.keys());
×
20

21
  const finalNamesObject = {};
×
22

23
  tokenMapKeys.forEach((keyItem) => {
×
24
    const tempNames = [];
×
25
    const keyItemTokens = tokenMap.get(keyItem);
×
26

27
    keyItemTokens.forEach((keyItemTokensItem) => {
×
28
      if (keyItemTokensItem.attributes.tokenPath) {
×
29
        tempNames.push(keyItemTokensItem.attributes.tokenPath.join('-'));
×
30
      }
31
    });
32

33
    if (tempNames.length > 0) {
×
34
      finalNamesObject[keyItem] = tempNames;
×
35
    }
36
  });
37

38
  finalNamesObject['fontFamilies'] = ['heading', 'sans', 'mono', 'serif'];
×
39

40
  const result = tokenNamesTemplate({
×
41
    names: JSON.stringify(finalNamesObject, null, 2),
42
  });
43

44
  return prettier.format(result, {
×
45
    parser: 'typescript',
46
  });
47
};
48

49
export const TokenNamesFormatter: Named<Format> = {
1✔
50
  name: 'deriv/token-names',
51
  formatter: formatter,
52
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc