Skip to content

Commit

Permalink
refactor(formats): fix indents based on editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
klausbayrhammer committed Feb 2, 2021
1 parent f64d5c4 commit 4be242e
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions lib/common/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*/

var fs = require('fs'),
_ = require('lodash'),
GroupMessages = require('../utils/groupMessages');
_ = require('lodash'),
GroupMessages = require('../utils/groupMessages');

var SASS_MAP_FORMAT_DEPRECATION_WARNINGS = GroupMessages.GROUP.SassMapFormatDeprecationWarnings;

Expand All @@ -40,18 +40,18 @@ function fileHeader(options, commentStyle) {

function variablesWithPrefix(prefix, properties, commentStyle) {
return properties.map(function(prop) {
var to_ret_prop = prefix + prop.name + ': ' + (prop.attributes.category==='asset' ? '"'+prop.value+'"' : prop.value) + ';';
var to_ret_prop = prefix + prop.name + ': ' + (prop.attributes.category === 'asset' ? '"' + prop.value + '"' : prop.value) + ';';

if (prop.comment) {
if (commentStyle === 'short') {
to_ret_prop = to_ret_prop.concat(' // ' + prop.comment);
} else {
to_ret_prop = to_ret_prop.concat(' /* ' + prop.comment + ' */');
}
if (prop.comment) {
if (commentStyle === 'short') {
to_ret_prop = to_ret_prop.concat(' // ' + prop.comment);
} else {
to_ret_prop = to_ret_prop.concat(' /* ' + prop.comment + ' */');
}
}

return to_ret_prop;
})
return to_ret_prop;
})
.filter(function(strVal) { return !!strVal })
.join('\n');
}
Expand Down Expand Up @@ -80,14 +80,15 @@ function minifyDictionary(obj) {
if (obj.hasOwnProperty('value')) {
return obj.value;
} else {
for(var name in obj) {
if(obj.hasOwnProperty(name)) {
for (var name in obj) {
if (obj.hasOwnProperty(name)) {
toRet[name] = minifyDictionary(obj[name]);
}
}
}
return toRet;
}

/**
* @namespace Formats
*/
Expand Down Expand Up @@ -259,7 +260,7 @@ module.exports = {
*/
'javascript/module': function(dictionary) {
return fileHeader(this.options) +
'module.exports = ' +
'module.exports = ' +
JSON.stringify(dictionary.properties, null, 2) + ';';
},

Expand All @@ -283,7 +284,7 @@ module.exports = {
* ```
*/
'javascript/object': function(dictionary) {
return fileHeader(this.options) +
return fileHeader(this.options) +
'var ' +
(this.name || '_styleDictionary') +
' = ' +
Expand Down Expand Up @@ -707,8 +708,8 @@ module.exports = {
*/
'json/flat': function(dictionary) {
return '{\n' + dictionary.allProperties.map(function(prop) {
return ` "${prop.name}": ${JSON.stringify(prop.value)}`;
}).join(',\n') + '\n}';
return ` "${prop.name}": ${JSON.stringify(prop.value)}`;
}).join(',\n') + '\n}';
},

/**
Expand All @@ -731,8 +732,8 @@ module.exports = {
*/
'sketch/palette': function(dictionary) {
var to_ret = {
'compatibleVersion':'1.0',
'pluginVersion':'1.1'
'compatibleVersion': '1.0',
'pluginVersion': '1.1'
};
to_ret.colors = _.chain(dictionary.allProperties)
.filter(function(prop) {
Expand Down

0 comments on commit 4be242e

Please sign in to comment.