Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Add prettier
Change eslint config
  • Loading branch information
berkcebi committed Oct 2, 2023
1 parent 5554741 commit a32300f
Show file tree
Hide file tree
Showing 10 changed files with 13,883 additions and 7,147 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.js

This file was deleted.

10 changes: 10 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"env": {
"es6": true
},
"extends": ["eslint:recommended", "eslint-config-prettier"],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
}
}
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tabWidth": 4
}
20,887 changes: 13,806 additions & 7,081 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
"author": {
"name": "Berk Çebi"
},
"dependencies": {
"zem": "^1.0.6"
},
"devDependencies": {
"eslint": "^7.32.0",
"eslint-config-prettier": "^9.0.0",
"prettier": "^3.0.3"
},
"zeplin": {
"displayName": "JSON Design Tokens",
"platforms": [
Expand Down Expand Up @@ -52,10 +60,5 @@
"default": true
}
]
},
"devDependencies": {
"@zeplin/eslint-config": "^1.2.2",
"eslint": "^4.18.2",
"zem": "^0.4.2"
}
}
38 changes: 29 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,52 @@ function textStyles(context) {

let zeplinTextStyles;
if (context.getOption("includeReferencedStyleguides")) {
zeplinTextStyles = getContainerReferencedObjects(container, "textStyles");
zeplinTextStyles = getContainerReferencedObjects(
container,
"textStyles",
);
} else {
zeplinTextStyles = container.textStyles;
}

const extensionTextStyles = TextStyle.fromZeplinTextStyles(zeplinTextStyles, context);
const extensionTextStyles = TextStyle.fromZeplinTextStyles(
zeplinTextStyles,
context,
);

return CodeObject.fromJSONObject(extensionTextStyles);
}

// TODO: Remove after 2020/01/01.
function styleguideTextStyles(context, zeplinTextStyles) {
const extensionTextStyles = TextStyle.fromZeplinTextStyles(zeplinTextStyles, context);
const extensionTextStyles = TextStyle.fromZeplinTextStyles(
zeplinTextStyles,
context,
);

return CodeObject.fromJSONObject(extensionTextStyles);
}

function exportTextStyles(context) {
const textStylesCodeObject = textStyles(context);

return CodeExportObject.fromCodeObject(textStylesCodeObject, TEXT_STYLES_FILENAME);
return CodeExportObject.fromCodeObject(
textStylesCodeObject,
TEXT_STYLES_FILENAME,
);
}

// TODO: Remove after 2020/01/01.
function exportStyleguideTextStyles(context, zeplinTextStyles) {
const textStylesCodeObject = styleguideTextStyles(context, zeplinTextStyles);

return CodeExportObject.fromCodeObject(textStylesCodeObject, TEXT_STYLES_FILENAME);
const textStylesCodeObject = styleguideTextStyles(
context,
zeplinTextStyles,
);

return CodeExportObject.fromCodeObject(
textStylesCodeObject,
TEXT_STYLES_FILENAME,
);
}

// TODO: Remove after 2020/01/01.
Expand All @@ -92,7 +110,9 @@ function getContainerReferencedObjects(container, key) {
return containerObjects;
}

return containerObjects.concat(getContainerReferencedObjects(referencedStyleguide, key));
return containerObjects.concat(
getContainerReferencedObjects(referencedStyleguide, key),
);
}

export default {
Expand All @@ -104,5 +124,5 @@ export default {
styleguideTextStyles,
exportTextStyles,
exportStyleguideTextStyles,
comment
comment,
};
10 changes: 3 additions & 7 deletions src/model/codeExportObject.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
export default class CodeExportObject {
constructor({
code,
language,
filename
}) {
constructor({ code, language, filename }) {
Object.assign(this, {
code,
language,
filename
filename,
});
}

static fromCodeObject(codeObject, filename) {
return new CodeExportObject({
code: codeObject.code,
language: codeObject.language,
filename
filename,
});
}
}
9 changes: 3 additions & 6 deletions src/model/codeObject.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
const JSON_STRINGIFY_SPACE = 2;

export default class CodeObject {
constructor({
code,
language
}) {
constructor({ code, language }) {
Object.assign(this, {
code,
language
language,
});
}

static fromJSONObject(object) {
return new CodeObject({
code: JSON.stringify(object, null, JSON_STRINGIFY_SPACE),
language: "json"
language: "json",
});
}
}
24 changes: 9 additions & 15 deletions src/model/color.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
export default class Color {
constructor({
name,
red,
green,
blue,
hex,
hsla,
alpha
}) {
constructor({ name, red, green, blue, hex, hsla, alpha }) {
Object.assign(this, {
name,
red,
green,
blue,
hex,
hsla,
alpha
alpha,
});
}

Expand All @@ -29,7 +21,7 @@ export default class Color {
red: zeplinColor.r,
green: zeplinColor.g,
blue: zeplinColor.b,
alpha: zeplinColor.a
alpha: zeplinColor.a,
});
}
case "hex": {
Expand All @@ -38,7 +30,7 @@ export default class Color {
return new Color({
name: zeplinColor.name,
hex: hex.r + hex.g + hex.b,
alpha: zeplinColor.a
alpha: zeplinColor.a,
});
}
case "hsla": {
Expand All @@ -48,16 +40,18 @@ export default class Color {
zeplinColor.r,
zeplinColor.g,
zeplinColor.b,
zeplinColor.a
)
zeplinColor.a,
),
});
}
default:
}
}

static fromZeplinColors(zeplinColors, context) {
return zeplinColors.map(zeplinColor => Color.fromZeplinColor(zeplinColor, context));
return zeplinColors.map((zeplinColor) =>
Color.fromZeplinColor(zeplinColor, context),
);
}

static rgbaToHsla(red, green, blue, a) {
Expand Down
33 changes: 12 additions & 21 deletions src/model/textStyle.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
import Color from "./color";

class Font {
constructor({
postscriptName,
family,
size,
weight,
stretch
}) {
constructor({ postscriptName, family, size, weight, stretch }) {
Object.assign(this, {
postscriptName,
family,
size,
weight,
stretch
stretch,
});
}
}

export default class TextStyle {
constructor({
name,
letterSpacing,
lineHeight,
alignment,
font,
color
}) {
constructor({ name, letterSpacing, lineHeight, alignment, font, color }) {
Object.assign(this, {
name,
letterSpacing,
lineHeight,
alignment,
font,
color
color,
});
}

Expand All @@ -43,7 +30,9 @@ export default class TextStyle {

let color;
if (zeplinTextStyle.color) {
const zeplinColor = container.findColorEqual(zeplinTextStyle.color) || zeplinTextStyle.color;
const zeplinColor =
container.findColorEqual(zeplinTextStyle.color) ||
zeplinTextStyle.color;

color = Color.fromZeplinColor(zeplinColor, context);
}
Expand All @@ -53,7 +42,7 @@ export default class TextStyle {
family: zeplinTextStyle.fontFamily,
size: zeplinTextStyle.fontSize,
weight: zeplinTextStyle.weightText,
stretch: zeplinTextStyle.fontStretch
stretch: zeplinTextStyle.fontStretch,
});

return new TextStyle({
Expand All @@ -62,11 +51,13 @@ export default class TextStyle {
lineHeight: zeplinTextStyle.lineHeight,
alignment: zeplinTextStyle.textAlign,
font,
color
color,
});
}

static fromZeplinTextStyles(zeplinTextStyles, context) {
return zeplinTextStyles.map(zeplinTextStyle => TextStyle.fromZeplinTextStyle(zeplinTextStyle, context));
return zeplinTextStyles.map((zeplinTextStyle) =>
TextStyle.fromZeplinTextStyle(zeplinTextStyle, context),
);
}
}

0 comments on commit a32300f

Please sign in to comment.