Skip to content

Commit

Permalink
Fix tslint 'typedef' errors
Browse files Browse the repository at this point in the history
Fixes #5843

- updated `typedef` tslint warning into an error
- fixed failed `typedef` checks with the rules `call-signature` and `property-declaration`.

Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Aug 5, 2019
1 parent b40a8d5 commit cc51575
Show file tree
Hide file tree
Showing 339 changed files with 984 additions and 916 deletions.
5 changes: 5 additions & 0 deletions configs/errors.tslint.json
Expand Up @@ -131,6 +131,11 @@
true,
"allow-null-check"
],
"typedef": [
true,
"call-signature",
"property-declaration"
],
"typedef-whitespace": [
true,
{
Expand Down
7 changes: 1 addition & 6 deletions configs/warnings.tslint.json
Expand Up @@ -10,11 +10,6 @@
"deprecation": true,
"no-return-await": {
"severity": "warning"
},
"typedef": [
true,
"call-signature",
"property-declaration"
]
}
}
}
Expand Up @@ -62,11 +62,11 @@ export abstract class AbstractGenerator {
return os.EOL + lines.join(os.EOL);
}

protected ifBrowser(value: string, defaultValue: string = '') {
protected ifBrowser(value: string, defaultValue: string = ''): string {
return this.pck.ifBrowser(value, defaultValue);
}

protected ifElectron(value: string, defaultValue: string = '') {
protected ifElectron(value: string, defaultValue: string = ''): string {
return this.pck.ifElectron(value, defaultValue);
}

Expand All @@ -75,7 +75,7 @@ export abstract class AbstractGenerator {
await fs.writeFile(path, content);
}

protected ifMonaco(value: () => string, defaultValue: () => string = () => '') {
protected ifMonaco(value: () => string, defaultValue: () => string = () => ''): string {
return (this.pck.extensionPackages.some(e => e.name === '@theia/monaco') ? value : defaultValue)();
}

Expand Down
2 changes: 1 addition & 1 deletion dev-packages/application-manager/src/rebuild.ts
Expand Up @@ -18,7 +18,7 @@ import fs = require('fs-extra');
import path = require('path');
import cp = require('child_process');

export function rebuild(target: 'electron' | 'browser', modules: string[]) {
export function rebuild(target: 'electron' | 'browser', modules: string[]): void {
const nodeModulesPath = path.join(process.cwd(), 'node_modules');
const browserModulesPath = path.join(process.cwd(), '.browser_modules');
const modulesToProcess = modules || ['@theia/node-pty', 'nsfw', 'native-keymap', 'find-git-repositories'];
Expand Down
Expand Up @@ -30,7 +30,7 @@ const testOutdated = (expectation: (extensionPackage: ExtensionPackage) => boole
assert.equal(await expectation(extensionPackage), outdated);
});

describe('extension-package', function () {
describe('extension-package', function (): void {

this.timeout(10000);
describe('isOutdated', () => {
Expand Down
6 changes: 4 additions & 2 deletions dev-packages/application-package/src/npm-registry.ts
Expand Up @@ -71,7 +71,9 @@ export interface ViewResult {
[key: string]: any
}

export function sortByKey(object: { [key: string]: any }) {
export function sortByKey(object: { [key: string]: any }): {
[key: string]: any;
} {
return Object.keys(object).sort().reduce((sorted, key) => {
sorted[key] = object[key];
return sorted;
Expand Down Expand Up @@ -101,7 +103,7 @@ export class NpmRegistry {
this.resetIndex();
}

updateProps(props?: Partial<NpmRegistryProps>) {
updateProps(props?: Partial<NpmRegistryProps>): void {
const oldRegistry = this.props.registry;
Object.assign(this.props, props);
const newRegistry = this.props.registry;
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/cli/src/theia.ts
Expand Up @@ -52,7 +52,7 @@ function rebuildCommand(command: string, target: ApplicationProps.Target): yargs
};
}

(function () {
(function (): void {
const projectPath = process.cwd();
const appTarget: ApplicationProps.Target = yargs.argv['app-target'];
const manager = new ApplicationPackageManager({ projectPath, appTarget });
Expand Down
12 changes: 6 additions & 6 deletions examples/browser/test/bottom-panel/bottom-panel.ts
Expand Up @@ -30,15 +30,15 @@ export class BottomPanel {
return (tab.$('..').getAttribute('class').split(' ').indexOf('p-mod-current') > -1);
}

openTab(tabName: string) {
openTab(tabName: string): void {
this.driver.element('#theia-bottom-content-panel .p-TabBar .p-TabBar-content').click(`div=${tabName}`);
}

isTerminalVisible(): boolean {
return this.driver.isExisting('.p-Widget div.terminal.xterm');
}

waitForTerminal() {
waitForTerminal(): void {
this.driver.waitForExist('.p-Widget div.terminal.xterm');
// Wait for animations to finish
this.driver.pause(300);
Expand All @@ -48,7 +48,7 @@ export class BottomPanel {
return this.driver.isExisting('.p-Widget div.theia-marker-container');
}

waitForProblemsView() {
waitForProblemsView(): void {
this.driver.waitForExist('.p-Widget div.theia-marker-container');
// Wait for animations to finish
this.driver.pause(300);
Expand All @@ -58,7 +58,7 @@ export class BottomPanel {
return this.driver.isExisting('#callhierarchy');
}

waitForCallHierarchyView() {
waitForCallHierarchyView(): void {
this.driver.waitForExist('#callhierarchy');
// Wait for animations to finish
this.driver.pause(300);
Expand All @@ -68,13 +68,13 @@ export class BottomPanel {
return this.driver.isExisting('.p-Widget div.theia-output');
}

waitForOutputView() {
waitForOutputView(): void {
this.driver.waitForExist('.p-Widget div.theia-output');
// Wait for animations to finish
this.driver.pause(300);
}

closeCurrentView() {
closeCurrentView(): void {
this.driver.click('#theia-bottom-content-panel .p-TabBar-tab.p-mod-current .p-TabBar-tabCloseIcon');
}

Expand Down
8 changes: 4 additions & 4 deletions examples/browser/test/cpp/cpp-change-build-config.ui-spec.ts
Expand Up @@ -83,7 +83,7 @@ int main() {}
/**
* Return whether clangd is available.
*/
function hasClangd() {
function hasClangd(): boolean {
try {
const out = cp.execSync('clangd -version', { encoding: 'utf8' });
// Match 'clangd version' at the start of
Expand All @@ -98,7 +98,7 @@ function hasClangd() {
* Open the build config quick open menu, click on the first config that
* matches `name`.
*/
function changeBuildConfig(name: string, driver: WebdriverIO.Client<void>) {
function changeBuildConfig(name: string, driver: WebdriverIO.Client<void>): void {
const statusBar = driver.element('#theia-statusBar');
const statusBarButton = statusBar.element('div.element*=Build Config');
statusBarButton.click();
Expand All @@ -110,7 +110,7 @@ function changeBuildConfig(name: string, driver: WebdriverIO.Client<void>) {
}

// skip the cpp tests for the moment since they are broken.
describe.skip('cpp extension', function () {
describe.skip('cpp extension', function (): void {

before(() => {
const driver = browser;
Expand All @@ -127,7 +127,7 @@ describe.skip('cpp extension', function () {
mainPage.waitForStartup();
});

it.skip('should be able to change build config', function () {
it.skip('should be able to change build config', function (): void {
if (!hasClangd()) {
this.skip();
return;
Expand Down
8 changes: 4 additions & 4 deletions examples/browser/test/left-panel/left-panel.ts
Expand Up @@ -30,13 +30,13 @@ export class LeftPanel {
return (tab.$('..').getAttribute('class').split(' ').indexOf('p-mod-current') !== -1);
}

openCloseTab(tabName: string) {
openCloseTab(tabName: string): void {
this.driver.element('.p-TabBar.theia-app-left .p-TabBar-content').element(`div*=${tabName}`).click('..');
// Wait for animations to finish
this.driver.pause(300);
}

collapseTab(tabName: string) {
collapseTab(tabName: string): void {
this.driver.element('.p-TabBar.theia-app-left .p-TabBar-content').rightClick(`div*=${tabName}`);
this.driver.element('.p-Widget.p-Menu .p-Menu-content').click('div=Collapse');
}
Expand All @@ -57,7 +57,7 @@ export class LeftPanel {
* collapse it. No check is done to make sure this node actually exists or
* represents a directory.
*/
toggleDirectoryInFilesView(name: string) {
toggleDirectoryInFilesView(name: string): void {
this.waitForFilesViewVisible();
const files = this.driver.element('#files');
const element = files.element('div=' + name);
Expand All @@ -70,7 +70,7 @@ export class LeftPanel {
* it. Not check is done to make sure this node actually exists or
* represents a file.
*/
openFileInFilesView(name: string) {
openFileInFilesView(name: string): void {
this.waitForFilesViewVisible();
const files = this.driver.element('#files');
const element = files.element('div=' + name);
Expand Down
2 changes: 1 addition & 1 deletion examples/browser/test/main-page/main-page.ts
Expand Up @@ -56,7 +56,7 @@ export class MainPage {
return this.driver.waitForExist('div#theia-statusBar');
}

closeAll() {
closeAll(): void {
/* Make sure that all the "docked" layouts are closed */
while (this.driver.isExisting('.p-Widget.p-TabBar .p-TabBar-tab.p-mod-closable')) {
this.driver.rightClick('.p-Widget.p-TabBar .p-TabBar-tab.p-mod-closable');
Expand Down
4 changes: 2 additions & 2 deletions examples/browser/test/right-panel/right-panel.ts
Expand Up @@ -30,13 +30,13 @@ export class RightPanel {
return (tab.$('..').getAttribute('class').split(' ').indexOf('p-mod-current') !== -1);
}

openCloseTab(tabName: string) {
openCloseTab(tabName: string): void {
this.driver.element('.p-TabBar.theia-app-right .p-TabBar-content').element(`div=${tabName}`).click('..');
// Wait for animations to finish
this.driver.pause(300);
}

collapseTab(tabName: string) {
collapseTab(tabName: string): void {
this.driver.element('.p-TabBar.theia-app-right .p-TabBar-content').rightClick(`div=${tabName}`);
this.driver.element('.p-Widget.p-Menu .p-Menu-content').click('div=Collapse');
}
Expand Down
28 changes: 14 additions & 14 deletions examples/browser/test/top-panel/top-panel.ts
Expand Up @@ -24,52 +24,52 @@ export class TopPanel {
return this.driver.isExisting('div#theia-top-panel');
}

openNewTerminal() {
openNewTerminal(): void {
this.clickMenuTab('Terminal');
this.clickSubMenu('New Terminal');
}

toggleCallHierarchyView() {
toggleCallHierarchyView(): void {
this.clickMenuTab('View');
this.clickSubMenu('Call Hierarchy');
}

toggleFilesView() {
toggleFilesView(): void {
this.clickMenuTab('View');
this.clickSubMenu('Explorer');
}

toggleScmView() {
toggleScmView(): void {
this.clickMenuTab('View');
this.clickSubMenu('SCM');
}

toggleGitHistoryView() {
toggleGitHistoryView(): void {
this.clickMenuTab('View');
this.clickSubMenu('Git History');
}

toggleOutlineView() {
toggleOutlineView(): void {
this.clickMenuTab('View');
this.clickSubMenu('Outline');
}

toggleOutputView() {
toggleOutputView(): void {
this.clickMenuTab('View');
this.clickSubMenu('Output');
}

openPluginsView() {
openPluginsView(): void {
this.clickMenuTab('View');
this.clickSubMenu('Plugins');
}

openProblemsView() {
openProblemsView(): void {
this.clickMenuTab('View');
this.clickSubMenu('Problems');
}

toggleSearchView() {
toggleSearchView(): void {
this.clickMenuTab('View');
this.clickSubMenu('Search');
}
Expand All @@ -82,19 +82,19 @@ export class TopPanel {
return this.driver.isExisting('div.p-Widget.p-Menu.p-MenuBar-menu');
}

clickMenuTab(tab: number | string) {
clickMenuTab(tab: number | string): void {
if (typeof tab === 'string') {
this.driver.element('ul.p-MenuBar-content').click(`div=${tab}`);
} else {
this.driver.click(`ul.p-MenuBar-content > .p-MenuBar-item:nth-child(${tab})`);
}
}

clickSubMenu(subMenuItem: string) {
clickSubMenu(subMenuItem: string): void {
this.driver.element('div.p-Widget.p-Menu.p-MenuBar-menu .p-Menu-content').click(`div=${subMenuItem}`);
}

hoverMenuTab(tabNumber: number) {
hoverMenuTab(tabNumber: number): void {
this.driver.moveToObject(`ul.p-MenuBar-content > .p-MenuBar-item:nth-child(${tabNumber})`);
}

Expand All @@ -106,7 +106,7 @@ export class TopPanel {
return this.driver.isExisting('#theia\\:menubar.p-mod-active');
}

getxBarTabPosition(tabNumber: number) {
getxBarTabPosition(tabNumber: number): WebdriverIO.Client<number> & number {
return this.driver.getLocation(`ul.p-MenuBar-content > .p-MenuBar-item:nth-child(${tabNumber}`, 'x');
}

Expand Down
11 changes: 7 additions & 4 deletions packages/bunyan/src/node/bunyan-logger-server.ts
Expand Up @@ -36,7 +36,7 @@ export class BunyanLoggerServer implements ILoggerServer {
protected cli: LogLevelCliContribution;

@postConstruct()
protected init() {
protected init(): void {
/* Create the root logger by default. */
const opts = this.makeLoggerOptions(rootLoggerName);
const rootOpts = Object.assign(opts, { name: 'Theia' });
Expand All @@ -46,14 +46,17 @@ export class BunyanLoggerServer implements ILoggerServer {
this.cli.onLogConfigChanged(() => this.updateLogLevels());
}

protected updateLogLevels() {
protected updateLogLevels(): void {
for (const loggerName of this.loggers.keys()) {
const newLevel = this.cli.logLevelFor(loggerName);
this.setLogLevel(loggerName, newLevel);
}
}

protected makeLoggerOptions(name: string) {
protected makeLoggerOptions(name: string): {
logger: string;
level: number;
} {
return {
logger: name,
level: this.toBunyanLevel(this.cli.logLevelFor(name)),
Expand Down Expand Up @@ -89,7 +92,7 @@ export class BunyanLoggerServer implements ILoggerServer {
}

/* Set the client to receive notifications on. */
setClient(client: ILoggerClient | undefined) {
setClient(client: ILoggerClient | undefined): void {
this.client = client;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/callhierarchy/src/browser/callhierarchy-context.ts
Expand Up @@ -46,6 +46,7 @@ export class CallHierarchyContext implements Disposable {
return symbols;
}

// tslint:disable-next-line:typedef
async getEditorModelReference(uri: string) {
const model = await this.textModelService.createModelReference(new URI(uri));
this.disposables.push(model);
Expand Down Expand Up @@ -96,7 +97,7 @@ export class CallHierarchyContext implements Disposable {
}
}

dispose() {
dispose(): void {
this.disposables.forEach(element => {
element.dispose();
});
Expand Down

0 comments on commit cc51575

Please sign in to comment.