Skip to content

Commit

Permalink
(lint) Fix linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
christianwiedemann committed Mar 31, 2021
1 parent cf1f52e commit d980a0c
Show file tree
Hide file tree
Showing 26 changed files with 87 additions and 77 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const yeoman = require('yeoman-environment');

const Generator = require.resolve('./generators/component');
const env = yeoman.createEnv();
export default function (options) {
export default function(options) {
env.register(Generator, 'ws:component');
env.run('ws:component', () => {});
}
13 changes: 8 additions & 5 deletions packages/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,36 @@ program
.option('-N --use-npm', 'Use npm to install deps')
.option('-S --smoke-test', 'Exit after successful start')
.option('-B --branch <branch>', 'Use a specific branch')
.action((options) => initiate(options));
.action(options => initiate(options));

program
.command('version')
.description('Shows Wingsuit version.')
.action((options) => version(options));
.action(options => version(options));

program
.command('generate-component')
.description('Generate Wingsuit component.')
.option('-N --use-npm', 'Use npm to install deps')
.action((options) => component(options));
.action(options => component(options));

program.command('*', '').action(() => {
const [, , invalidCmd] = process.argv;
logger.error(' Invalid command: %s.\n See --help for a list of available commands.', invalidCmd);
// eslint-disable-next-line
const availableCommands = program.commands.map(cmd => cmd._name);
const suggestion = availableCommands.find((cmd) => leven(cmd, invalidCmd) < 3);
const suggestion = availableCommands.find(cmd => leven(cmd, invalidCmd) < 3);
if (suggestion) {
logger.log(`\n Did you mean ${suggestion}?`);
}

process.exit(1);
});

program.usage('<command> [options]').version('1').parse(process.argv);
program
.usage('<command> [options]')
.version('1')
.parse(process.argv);

if (program.rawArgs.length < 3) {
program.help();
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const fs = require('fs');
const mv = require('mv');
const rimraf = require('rimraf');

export default function (options) {
export default function(options) {
const welcomeMessage = 'ws init - the simplest way to install Wingsuit.';
logger.log(chalk.inverse(`\n ${welcomeMessage} \n`));
const useYarn = Boolean(options.useNpm !== true) && hasYarn();
Expand All @@ -31,7 +31,7 @@ export default function (options) {
const gitOptions = { cwd: npmOptions.gitFolder };

// Removes the \n from the stringified buffer
const extractHash = (buffer) => {
const extractHash = buffer => {
const arr = buffer.toString('utf8').split('\n');
return arr[0];
};
Expand All @@ -58,7 +58,7 @@ export default function (options) {
}
const pkgFile = `${npmOptions.gitFolder}/starter-kits/${npmOptions.starterKit}/package.json`;
const pkg = JSON.parse(fs.readFileSync(pkgFile));
Object.keys(pkg.devDependencies).forEach((key) => {
Object.keys(pkg.devDependencies).forEach(key => {
if (key.indexOf('@wingsuit-designsystem/') === 0) {
pkg.devDependencies[key] = `^${pkg.devDependencies[key]}`;
}
Expand All @@ -76,7 +76,7 @@ export default function (options) {
mv(
`${npmOptions.gitFolder}/starter-kits/${npmOptions.starterKit}`,
npmOptions.targetFolder,
(err) => {
err => {
rimraf.sync(npmOptions.gitFolder);
cmdOptions.cwd = npmOptions.targetFolder;
if (!npmOptions.skipInstall) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const logger = console;
const pkg = require('../package.json');

export default function (options) {
export default function(options) {
logger.log(`Wingsuit Version: ${pkg.version}`);
}
20 changes: 10 additions & 10 deletions packages/core/__tests__/presetManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import { resolveConfig, PresetManager } from '../src/index';

const config = {
webpack: (appConfig) => {
webpack: appConfig => {
return { testWebpack: true };
},
webpackFinal: (appConfig, webpack) => {
Expand Down Expand Up @@ -33,7 +33,7 @@ test('Test parameters in wingsuit.config.', () => {
},
presets: [
{
name: (appConfig) => {
name: appConfig => {
return 'param';
},
webpack: (appConfig, pconfig) => {
Expand Down Expand Up @@ -69,12 +69,12 @@ test('Test defaultConfig.', () => {
{
presets: [
{
defaultConfig: (appConfig) => {
defaultConfig: appConfig => {
return {
param1: true,
};
},
name: (appConfig) => {
name: appConfig => {
return 'param';
},
webpack: (appConfig, pconfig) => {
Expand Down Expand Up @@ -105,12 +105,12 @@ test('Test initial parameters.', () => {
presets: [
[
{
defaultConfig: (appConfig) => {
defaultConfig: appConfig => {
return {
param1: false,
};
},
name: (appConfig) => {
name: appConfig => {
return 'param';
},
webpack: (appConfig, pconfig) => {
Expand Down Expand Up @@ -149,12 +149,12 @@ test('Test parameter overwrite defaultConfig.', () => {
},
presets: [
{
defaultConfig: (appConfig) => {
defaultConfig: appConfig => {
return {
param1: false,
};
},
name: (appConfig) => {
name: appConfig => {
return 'param';
},
webpack: (appConfig, pconfig) => {
Expand Down Expand Up @@ -183,7 +183,7 @@ test('Test generateWebpack.', () => {
'development',
{},
{
webpack: (appConfig) => {
webpack: appConfig => {
return { testWebpack: true };
},
webpackFinal: (appConfig, webpack) => {
Expand Down Expand Up @@ -218,7 +218,7 @@ test('Test support feature.', () => {
{
presets: [
{
supportFeature: (name) => {
supportFeature: name => {
if (name === 'scss') {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function getAppNames(wingsuitConfig: any = null, type = '') {
wingsuitConfig != null ? wingsuitConfig : require(`${process.cwd()}/wingsuit.config`);
const mergedConfig = merge(configStub.wingsuit, projectConfig);
const names: string[] = [];
Object.keys(mergedConfig.apps).forEach((name) => {
Object.keys(mergedConfig.apps).forEach(name => {
if (type === '' || type === mergedConfig.apps[name].type) {
names.push(name);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export function resolveConfig(
appConfig = Object.assign(appConfig, projectConfig[appName]);
}

mergedConfig.presets.forEach((preset) => {
mergedConfig.presets.forEach(preset => {
appConfig.presets.push(preset);
});

appConfig.getParameters = (name) => {
appConfig.getParameters = name => {
return appConfig.parameters[name] != null ? appConfig.parameters[name] : {};
};

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/server/PresetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class PresetManager {

private getPresetDefinitions(appConfig: AppConfig): PresetDefinition[] {
const presets: PresetDefinition[] = [];
appConfig.presets.forEach((item) => {
appConfig.presets.forEach(item => {
if (typeof item === 'string') {
// eslint-disable-next-line global-require,import/no-dynamic-require
const lpreset = require(item);
Expand Down Expand Up @@ -99,7 +99,7 @@ export default class PresetManager {
public supportFeature(name, appConfig: AppConfig) {
const presetDefinitions = this.getPresetDefinitions(appConfig);
let support = false;
Object.keys(presetDefinitions).forEach((key) => {
Object.keys(presetDefinitions).forEach(key => {
const { preset } = presetDefinitions[key];
if (preset != null && preset.supportFeature != null) {
const presetSupport = preset.supportFeature(name);
Expand All @@ -121,7 +121,7 @@ export default class PresetManager {
const presets = this.getPresetDefinitions(appConfig);

const shared: any = [];
Object.keys(presets).forEach((key) => {
Object.keys(presets).forEach(key => {
if (presets[key] != null) {
shared.push(presets[key].preset.webpack(appConfig, presets[key].parameters));
}
Expand Down Expand Up @@ -162,7 +162,7 @@ export default class PresetManager {
]
);

Object.keys(presets).forEach((key) => {
Object.keys(presets).forEach(key => {
if (presets[key].preset.webpackFinal != null) {
config = presets[key].preset.webpackFinal(appConfig, config);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/server/plugins/Svg2JsonPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class Svg2JsonPlugin {
const searchFiles = `${appConfig.absPatternPath}/**/${sourceFolder}/*.svg`;

const files = glob.sync(searchFiles);
files.forEach((file) => {
files.forEach(file => {
svgs.push(path.basename(file, '.svg'));
});
const output = { svgs };
Expand All @@ -39,7 +39,7 @@ export default class Svg2JsonPlugin {
if (readerr) console.error(readerr, `Creating ${path.basename(filename)}!`);
// Only write output if there is a difference or non-existent target file
if (jsondiff.diff(existingJson, output)) {
fs.outputJson(filename, output, (writeerr) => {
fs.outputJson(filename, output, writeerr => {
if (writeerr) console.error(writeerr);
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/server/presets/assetsVideos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function webpack(appConfig: AppConfig) {
export function webpackFinal(appConfig: AppConfig, config: any): {} {
if (appConfig.type === 'storybook') {
// eslint-disable-next-line no-param-reassign
config.module.rules = config.module.rules.map((data) => {
config.module.rules = config.module.rules.map(data => {
if (/mp4\|webm\|wav/.test(String(data.test)))
// eslint-disable-next-line no-param-reassign
data = {};
Expand Down
7 changes: 6 additions & 1 deletion packages/pattern/__int_tests__/PatternStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ describe('PatternStorage', () => {
expect(pattern).toBeInstanceOf(Pattern);
expect(pattern.getDefaultVariant().getFields().length).toBe(0);
expect(Object.keys(pattern.getDefaultVariant().getSettings()).length).toBe(1);
expect(pattern.getDefaultVariant().getSetting('setting').getPreview()).toBe('correct');
expect(
pattern
.getDefaultVariant()
.getSetting('setting')
.getPreview()
).toBe('correct');

const pattern2: Pattern = storage.loadPattern('simple_extend_setting_setting');
expect(pattern2.getDefaultVariant().getFields().length).toBe(0);
Expand Down
2 changes: 1 addition & 1 deletion packages/pattern/__int_tests__/twigRenderEngine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const renderEngine = require('../src/twigRenderEngine');

const renderer = new TwingRenderer();
const loader = new TwingLoaderFilesystem();
Object.keys(namespaces).forEach((namespace) => {
Object.keys(namespaces).forEach(namespace => {
loader.setPaths(namespaces[namespace], namespace);
});

Expand Down
22 changes: 11 additions & 11 deletions packages/pattern/src/PatternStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class PatternStorage implements IPatternStorage {

loadPatternsByNamespace(namespace): Pattern[] {
const foundPatterns: Pattern[] = [];
Object.keys(this.definitions).forEach((key) => {
Object.keys(this.definitions).forEach(key => {
const pattern = this.loadPattern(key);
if (pattern.getNamespace() === namespace) {
foundPatterns.push(pattern);
Expand Down Expand Up @@ -71,7 +71,7 @@ export default class PatternStorage implements IPatternStorage {
basePatternTypes = [basePatternType];
}

Object.keys(basePatternTypes).forEach((key) => {
Object.keys(basePatternTypes).forEach(key => {
const type: string = basePatternTypes[key];
if (basePatternField == null) {
if (basePatternDefinition[type] != null) {
Expand Down Expand Up @@ -120,7 +120,7 @@ export default class PatternStorage implements IPatternStorage {

createDefinitionsFromMultiContext(any): void {
if (Array.isArray(any) === true) {
any.forEach((context) => {
any.forEach(context => {
this.createDefinitionsFromContext(context);
});
} else {
Expand All @@ -129,7 +129,7 @@ export default class PatternStorage implements IPatternStorage {
}

createDefinitionsFromContext(context): void {
context.keys().forEach((key) => {
context.keys().forEach(key => {
if (key.includes('__tests__') === false && key.includes('__int_tests__') === false) {
const data = context(key);
if (data.wingsuit != null && typeof data.wingsuit.patternDefinition === 'object') {
Expand All @@ -150,7 +150,7 @@ export default class PatternStorage implements IPatternStorage {
}
}

Object.keys(patternDefinition).forEach((pattern_key) => {
Object.keys(patternDefinition).forEach(pattern_key => {
if (parameters !== null) {
patternDefinition[pattern_key].parameters = parameters;
}
Expand All @@ -166,7 +166,7 @@ export default class PatternStorage implements IPatternStorage {

findTwigByNamespace(namespace): any | null {
let foundResource = null;
Object.keys(this.twigResources).forEach((key) => {
Object.keys(this.twigResources).forEach(key => {
if (key.trim() === namespace.trim()) {
foundResource = this.twigResources[key];
}
Expand All @@ -180,20 +180,20 @@ export default class PatternStorage implements IPatternStorage {
}

createGlobalsFromContext(context): void {
context.keys().forEach((key) => {
context.keys().forEach(key => {
const data = context(key);
Object.keys(data).forEach((valueKey) => {
Object.keys(data).forEach(valueKey => {
this.addGlobal(valueKey, data[valueKey]);
});
});
}

createTwigStorageFromContext(context): void {
context.keys().forEach((key) => {
context.keys().forEach(key => {
const pathAry = key.replace('./', '').split('/');
const folderName = pathAry[0];
let mappedNamespace = '';
Object.keys(this.namespaces).forEach((namespace) => {
Object.keys(this.namespaces).forEach(namespace => {
const namespaceMap = this.namespaces[namespace].split('/');
if (namespaceMap[namespaceMap.length - 1] === folderName) {
mappedNamespace = namespace;
Expand All @@ -207,7 +207,7 @@ export default class PatternStorage implements IPatternStorage {
getTwigResources(): {} {
const resources = this.twigResources;
const result = {};
Object.keys(resources).forEach((key) => {
Object.keys(resources).forEach(key => {
result[key] = resources[key].default;
});
return result;
Expand Down

0 comments on commit d980a0c

Please sign in to comment.