Skip to content

Commit

Permalink
chore: remove old args formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenbroekema committed Dec 15, 2023
1 parent 93dd9b5 commit f939576
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 241 deletions.
3 changes: 2 additions & 1 deletion .changeset/angry-balloons-yell.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
BREAKING:
- `usesReference` util function is now `usesReferences` to be consistent plural form like the other reference util functions.
- `getReferences` first and second parameters have been swapped to be consistent with `resolveReferences`, so value first, then the full token object (instead of the entire dictionary instance).
- `getReferences` accepts a third options parameter which can be used to set reference Regex options as well as an unfilteredTokens object which can be used as a fallback when references are made to tokens that have been filtered out. There will be warnings logged for this.
- `getReferences` accepts a third options parameter which can be used to set reference Regex options as well as an unfilteredTokens object which can be used as a fallback when references are made to tokens that have been filtered out. There will be warnings logged for this.
- `format.formatter` removed old function signature of `(dictionary, platform, file)` in favor of `({ dictionary, platform, options, file })`.
35 changes: 0 additions & 35 deletions __integration__/__snapshots__/customFormats.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,13 +1381,6 @@ snapshots["register custom format with old args should match snapshot"] =
"otherOption": "platform option"
},
"files": [
{
"destination": "registerCustomFormatWithOldArgs.json",
"options": {
"showFileHeader": true,
"otherOption": "Test"
}
},
{
"destination": "registerCustomFormatWithNewArgs.json",
"options": {
Expand All @@ -1413,13 +1406,6 @@ snapshots["register custom format with old args should match snapshot"] =
],
"actions": []
},
"file": {
"options": {
"otherOption": "Test",
"showFileHeader": true
},
"destination": "registerCustomFormatWithOldArgs.json"
},
"options": {
"otherOption": "Test",
"showFileHeader": true
Expand All @@ -1432,13 +1418,6 @@ snapshots["register custom format with old args should match snapshot"] =
"otherOption": "platform option"
},
"files": [
{
"destination": "registerCustomFormatWithOldArgs.json",
"options": {
"showFileHeader": true,
"otherOption": "Test"
}
},
{
"destination": "registerCustomFormatWithNewArgs.json",
"options": {
Expand All @@ -1463,13 +1442,6 @@ snapshots["register custom format with old args should match snapshot"] =
}
],
"actions": []
},
"file": {
"destination": "registerCustomFormatWithOldArgs.json",
"options": {
"showFileHeader": true,
"otherOption": "Test"
}
}
}`;
/* end snapshot register custom format with old args should match snapshot */
Expand Down Expand Up @@ -1887,13 +1859,6 @@ snapshots["register custom format with new args should match snapshot"] =
"otherOption": "platform option"
},
"files": [
{
"destination": "registerCustomFormatWithOldArgs.json",
"options": {
"showFileHeader": true,
"otherOption": "Test"
}
},
{
"destination": "registerCustomFormatWithNewArgs.json",
"options": {
Expand Down
51 changes: 0 additions & 51 deletions __integration__/customFormats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ describe('integration', () => {
otherOption: `platform option`,
},
files: [
{
destination: 'registerCustomFormatWithOldArgs.json',
format: 'registerCustomFormatWithOldArgs',
options: {
showFileHeader: true,
otherOption: 'Test',
},
},
{
destination: 'registerCustomFormatWithNewArgs.json',
format: 'registerCustomFormatWithNewArgs',
Expand All @@ -87,13 +79,6 @@ describe('integration', () => {
},
});

sd.registerFormat({
name: 'registerCustomFormatWithOldArgs',
formatter: (dictionary, platform, file) => {
return JSON.stringify({ dictionary, platform, file }, null, 2);
},
});

sd.registerFormat({
name: 'registerCustomFormatWithNewArgs',
formatter: (opts) => {
Expand All @@ -103,24 +88,6 @@ describe('integration', () => {

await sd.buildAllPlatforms();

describe(`inline custom with old args`, () => {
const output = fs.readFileSync(`${buildPath}inlineCustomFormatWithOldArgs.json`, {
encoding: 'UTF-8',
});

it(`should match snapshot`, async () => {
await expect(output).to.matchSnapshot();
});

it(`should receive proper arguments`, () => {
const { dictionary, platform, file } = JSON.parse(output);
expect(dictionary).to.have.property(`tokens`);
expect(dictionary).to.have.property(`allTokens`);
expect(platform).to.have.nested.property(`options.otherOption`, `platform option`);
expect(file).to.have.nested.property(`options.otherOption`, `Test`);
});
});

describe(`inline custom with new args`, async () => {
const output = fs.readFileSync(`${buildPath}inlineCustomFormatWithNewArgs.json`, {
encoding: 'UTF-8',
Expand All @@ -139,24 +106,6 @@ describe('integration', () => {
});
});

describe(`register custom format with old args`, () => {
const output = fs.readFileSync(`${buildPath}registerCustomFormatWithOldArgs.json`, {
encoding: 'UTF-8',
});

it(`should match snapshot`, async () => {
await expect(output).to.matchSnapshot();
});

it(`should receive proper arguments`, () => {
const { dictionary, platform, file } = JSON.parse(output);
expect(dictionary).to.have.property(`tokens`);
expect(dictionary).to.have.property(`allTokens`);
expect(platform).to.have.nested.property(`options.otherOption`, `platform option`);
expect(file).to.have.nested.property(`options.otherOption`, `Test`);
});
});

describe(`register custom format with new args`, () => {
const output = fs.readFileSync(`${buildPath}registerCustomFormatWithNewArgs.json`, {
encoding: 'UTF-8',
Expand Down
106 changes: 0 additions & 106 deletions __tests__/formats/__snapshots__/all.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,112 +749,6 @@ snapshots["formats all should match css/fonts.css snapshot"] =
``;
/* end snapshot formats all should match css/fonts.css snapshot */

snapshots["formats all should match registerCustomFormatWithOldArgs snapshot"] =
`{
"dictionary": {
"dictionary": {
"tokens": {
"color": {
"red": {
"value": "#FF0000",
"original": {
"value": "#FF0000"
},
"name": "color_red",
"comment": "comment",
"attributes": {
"category": "color",
"type": "red"
},
"path": [
"color",
"red"
]
}
}
},
"allTokens": [
{
"value": "#FF0000",
"original": {
"value": "#FF0000"
},
"name": "color_red",
"comment": "comment",
"attributes": {
"category": "color",
"type": "red"
},
"path": [
"color",
"red"
]
}
]
},
"allTokens": [
{
"value": "#FF0000",
"original": {
"value": "#FF0000"
},
"name": "color_red",
"comment": "comment",
"attributes": {
"category": "color",
"type": "red"
},
"path": [
"color",
"red"
]
}
],
"tokens": {
"color": {
"red": {
"value": "#FF0000",
"original": {
"value": "#FF0000"
},
"name": "color_red",
"comment": "comment",
"attributes": {
"category": "color",
"type": "red"
},
"path": [
"color",
"red"
]
}
}
},
"platform": {},
"file": {
"destination": "__output/",
"format": "javascript/es6",
"filter": {
"attributes": {
"category": "color"
}
}
},
"options": {}
},
"platform": {},
"file": {
"destination": "__output/",
"format": "javascript/es6",
"filter": {
"attributes": {
"category": "color"
}
}
}
}`;
/* end snapshot formats all should match registerCustomFormatWithOldArgs snapshot */

snapshots["formats all should match registerCustomFormatWithNewArgs snapshot"] =
`{
"dictionary": {
Expand Down
8 changes: 0 additions & 8 deletions lib/common/formatHelpers/createPropertyFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ function addComment(to_ret_prop, comment, options) {
* which uses: prefix, indentation, separator, suffix, and commentStyle.
* @memberof module:formatHelpers
* @name createPropertyFormatter
* @param {Object} options
* @param {Boolean} options.outputReferences - Whether or not to output references. You will want to pass this from the `options` object sent to the formatter function.
* @param {Boolean} options.outputReferenceFallbacks - Whether or not to output css variable fallback values when using output references. You will want to pass this from the `options` object sent to the formatter function.
* @param {Dictionary} options.dictionary - The dictionary object sent to the formatter function
* @param {String} options.format - Available formats are: 'css', 'sass', 'less', and 'stylus'. If you want to customize the format and can't use one of those predefined formats, use the `formatting` option
* @param {Object} options.formatting - Custom formatting properties that define parts of a declaration line in code. The configurable strings are: prefix, indentation, separator, suffix, and commentStyle. Those are used to generate a line like this: `${indentation}${prefix}${prop.name}${separator} ${prop.value}${suffix}`
* @param {Boolean} options.themeable [false] - Whether tokens should default to being themeable.
* @returns {Function}
* @example
* ```javascript
* StyleDictionary.registerFormat({
Expand Down
40 changes: 0 additions & 40 deletions lib/register/preprocessor.js

This file was deleted.

0 comments on commit f939576

Please sign in to comment.