Skip to content

Commit

Permalink
Refactor for Prettier (#1673)
Browse files Browse the repository at this point in the history
Apply prettier formatting for JSON.
Adjust line length.
Adjust arrow functions.
Fix grammar.
  • Loading branch information
JimiC authored and robertohuertasm committed Aug 4, 2018
1 parent 61b705f commit 13c8b8f
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .prettierignore
@@ -1,2 +1,2 @@
*.md
*.json
package*.json
2 changes: 0 additions & 2 deletions .prettierrc
@@ -1,6 +1,4 @@
{
"parser": "typescript",
"semi": true,
"singleQuote": true,
"trailingComma": "all"
}
8 changes: 2 additions & 6 deletions .vscode/launch.json
Expand Up @@ -10,14 +10,10 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/src/**/*.js"
],
"outFiles": ["${workspaceFolder}/out/src/**/*.js"],
"preLaunchTask": "npm"
},
{
Expand Down
7 changes: 1 addition & 6 deletions .vscode/tasks.json
Expand Up @@ -15,12 +15,7 @@
"reveal": "silent"
},
// we run the custom script "build" as defined in package.json
"args": [
"run",
"build",
"--loglevel",
"silent"
],
"args": ["run", "build", "--loglevel", "silent"],
// The tsc compiler is running in the background
"isBackground": true,
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
Expand Down
4 changes: 1 addition & 3 deletions src/commands/index.ts
Expand Up @@ -42,9 +42,7 @@ function didChangeConfigurationListener(): void {
doReload = false;
// 'vscode' team still hasn't fixed this: In case the 'user settings' file has just been created
// a delay needs to be introduced in order for the preset change to get persisted on disk.
setTimeout(() => {
executeAndReload(cb, ...argms);
}, 500);
setTimeout(() => executeAndReload(cb, ...argms), 500);
} else if (!customMsgShown) {
manageApplyCustomizations(
initVSIconsConfig,
Expand Down
16 changes: 7 additions & 9 deletions src/icon-manifest/manifestMerger.ts
Expand Up @@ -86,21 +86,21 @@ function mergeSupported(
// check for exentensions in use.
// we'll add a new node
if (file.extends) {
final.filter(x => x.icon === file.extends).forEach(x => {
x.icon = file.icon;
});
final
.filter(x => x.icon === file.extends)
.forEach(x => (x.icon = file.icon));
}
// remove overrides
final = final.filter(x => x.icon !== file.overrides);
// check if file extensions are already in use and remove them
if (!file.extensions) {
file.extensions = [];
}
file.extensions.forEach(ext => {
file.extensions.forEach(ext =>
final
.filter(x => x.extensions.find(y => y === ext))
.forEach(x => _.remove(x.extensions, el => el === ext));
});
.forEach(x => _.remove(x.extensions, el => el === ext)),
);
final.push(file);
});
return final;
Expand Down Expand Up @@ -200,9 +200,7 @@ function togglePreset<
disabled: disable,
});
} else {
existing.forEach(x => {
x.disabled = disable;
});
existing.forEach(x => (x.disabled = disable));
}
});
return workingCopy as T;
Expand Down
2 changes: 1 addition & 1 deletion test/errorHandler.test.ts
Expand Up @@ -39,7 +39,7 @@ describe('ErrorHandler: tests', function() {
expect(error).to.not.haveOwnProperty('stack').to.be.true;
});

it('the error iteslef, when no error stack and message are available', function() {
it('the error itself, when no error stack and message are available', function() {
const error = new Error();
delete error.stack;
delete error.message;
Expand Down
155 changes: 80 additions & 75 deletions test/iconGenerator/iconGeneration-files.test.ts
@@ -1,4 +1,5 @@
// tslint:disable only-arrow-functions
// tslint:disable no-unused-expression
import * as fs from 'fs';
import * as path from 'path';
import { expect } from 'chai';
Expand All @@ -25,12 +26,11 @@ describe('IconGenerator: files icon generation test', function() {
it('filename extension should not have a leading dot', function() {
files.supported
.filter(file => !file.filename && !file.disabled)
.forEach(file => {
file.extensions.forEach(extension => {
// tslint:disable-next-line:no-unused-expression
expect(extension.startsWith('.')).to.be.false;
});
});
.forEach(file =>
file.extensions.forEach(
extension => expect(extension.startsWith('.')).to.be.false,
),
);
});

context('default', function() {
Expand Down Expand Up @@ -61,7 +61,6 @@ describe('IconGenerator: files icon generation test', function() {
`${settings.filePrefix}${file.icon}` +
`${settings.iconSuffix}.${FileFormat[file.format]}`;
const iconFilePath = path.join(iconsFolderPath, filename);
// tslint:disable-next-line:no-unused-expression
expect(fs.existsSync(iconFilePath)).to.be.true;
});
});
Expand All @@ -73,7 +72,6 @@ describe('IconGenerator: files icon generation test', function() {
);
files.supported.filter(file => !file.disabled).forEach(file => {
const definition = `${settings.manifestFilePrefix}${file.icon}`;
// tslint:disable-next-line:no-unused-expression
expect(schema.iconDefinitions[definition]).exist;
});
});
Expand All @@ -97,7 +95,6 @@ describe('IconGenerator: files icon generation test', function() {
settings.iconSuffix
}.${FileFormat[file.format]}`;
const iconFilePath = path.join(iconsFolderPath, filename);
// tslint:disable-next-line:no-unused-expression
expect(fs.existsSync(iconFilePath)).to.be.true;
});
});
Expand All @@ -113,7 +110,6 @@ describe('IconGenerator: files icon generation test', function() {
const definition = `${settings.manifestFileLightPrefix}${
file.icon
}`;
// tslint:disable-next-line:no-unused-expression
expect(schema.iconDefinitions[definition]).exist;
});
});
Expand Down Expand Up @@ -146,9 +142,9 @@ describe('IconGenerator: files icon generation test', function() {
const definition = `${settings.manifestFilePrefix}${
file.icon
}`;
file.extensions.forEach(extension => {
expect(schema.fileExtensions[extension]).equal(definition);
});
file.extensions.forEach(extension =>
expect(schema.fileExtensions[extension]).equal(definition),
);
});
});

Expand All @@ -168,11 +164,11 @@ describe('IconGenerator: files icon generation test', function() {
const definition = `${settings.manifestFileLightPrefix}${
file.icon
}`;
file.extensions.forEach(extension => {
file.extensions.forEach(extension =>
expect(schema.light.fileExtensions[extension]).equal(
definition,
);
});
),
);
});
},
);
Expand All @@ -190,35 +186,40 @@ describe('IconGenerator: files icon generation test', function() {
const definition = `${settings.manifestFilePrefix}${
file.icon
}`;
file.extensions.forEach(extension => {
expect(schema.fileNames[extension]).equal(definition);
});
file.extensions.forEach(extension =>
expect(schema.fileNames[extension]).equal(definition),
);
});
});

// tslint:disable-next-line:max-line-length
it(`that is a filename and has a light theme version, has a file name referencing its 'light' definition`, function() {
const schema = iconGenerator.generateJson(
files,
emptyFolderCollection,
);
files.supported
.filter(
file =>
file.filename &&
!file.languages &&
file.light &&
!file.disabled,
)
.forEach(file => {
const definition = `${settings.manifestFileLightPrefix}${
file.icon
}`;
file.extensions.forEach(extension => {
expect(schema.light.fileNames[extension]).equal(definition);
it(
`that is a filename and has a light theme version, ` +
`has a file name referencing its 'light' definition`,
function() {
const schema = iconGenerator.generateJson(
files,
emptyFolderCollection,
);
files.supported
.filter(
file =>
file.filename &&
!file.languages &&
file.light &&
!file.disabled,
)
.forEach(file => {
const definition = `${settings.manifestFileLightPrefix}${
file.icon
}`;
file.extensions.forEach(extension =>
expect(schema.light.fileNames[extension]).equal(
definition,
),
);
});
});
});
},
);

it('that is supported by language ids, has a language id referencing its definition', function() {
const schema = iconGenerator.generateJson(
Expand Down Expand Up @@ -286,35 +287,40 @@ describe('IconGenerator: files icon generation test', function() {
context('each supported', function() {
context('file extension', function() {
context('that has not a light theme version', function() {
// tslint:disable-next-line:max-line-length
it(`and is supported by language ids, has a 'light' language id referencing its inherited definition`, function() {
const dSchema: IIconSchema = { ...defaultSchema };
dSchema.iconDefinitions._file_light.iconPath = 'light_icon';
const schema = new IconGenerator(vscode, dSchema).generateJson(
files,
emptyFolderCollection,
);
files.supported
.filter(file => file.languages && !file.light && !file.disabled)
.forEach(file => {
const definition = `${settings.manifestFilePrefix}${
file.icon
}`;
const assignLanguagesLight = language => {
expect(schema.light.languageIds[language]).equal(
definition,
);
};
it(
`and is supported by language ids, ` +
`has a 'light' language id referencing its inherited definition`,
function() {
const dSchema: IIconSchema = { ...defaultSchema };
dSchema.iconDefinitions._file_light.iconPath = 'light_icon';
const schema = new IconGenerator(vscode, dSchema).generateJson(
files,
emptyFolderCollection,
);
files.supported
.filter(
file => file.languages && !file.light && !file.disabled,
)
.forEach(file => {
const definition = `${settings.manifestFilePrefix}${
file.icon
}`;
const assignLanguagesLight = language => {
expect(schema.light.languageIds[language]).equal(
definition,
);
};

file.languages.forEach(langIds => {
if (Array.isArray(langIds.ids)) {
langIds.ids.forEach(id => assignLanguagesLight(id));
} else {
assignLanguagesLight(langIds.ids);
}
file.languages.forEach(langIds => {
if (Array.isArray(langIds.ids)) {
langIds.ids.forEach(id => assignLanguagesLight(id));
} else {
assignLanguagesLight(langIds.ids);
}
});
});
});
});
},
);

it('and is not a filename, has a file extension referencing its inherited definition', function() {
const dSchema: IIconSchema = { ...defaultSchema };
Expand All @@ -329,11 +335,11 @@ describe('IconGenerator: files icon generation test', function() {
const definition = `${settings.manifestFilePrefix}${
file.icon
}`;
file.extensions.forEach(extension => {
file.extensions.forEach(extension =>
expect(schema.light.fileExtensions[extension]).equals(
definition,
);
});
),
);
});
});

Expand All @@ -350,7 +356,6 @@ describe('IconGenerator: files icon generation test', function() {
const definition = `${settings.manifestFileLightPrefix}${
file.icon
}`;
// tslint:disable-next-line:no-unused-expression
expect(schema.iconDefinitions[definition]).exist;
});
});
Expand Down Expand Up @@ -378,11 +383,11 @@ describe('IconGenerator: files icon generation test', function() {
const definition = `${settings.manifestFilePrefix}${
file.icon
}`;
file.extensions.forEach(extension => {
file.extensions.forEach(extension =>
expect(schema.light.fileNames[extension]).equals(
definition,
);
});
),
);
});
},
);
Expand Down

0 comments on commit 13c8b8f

Please sign in to comment.