Skip to content

Commit

Permalink
Improves code quality and adds Discord link (#47)
Browse files Browse the repository at this point in the history
## 🎯 Aim

Refactor code base to include more eslint rules and dependbot and code
QL tips.
Adds Discord link to help section

## ✅ What was done

- [X] adds discord link
- [X] refactor code base

## 🔗 Related issue

Closes: #40
Closes: #24
  • Loading branch information
Adam-it committed May 28, 2023
1 parent 9662aa7 commit 9a3cb4b
Show file tree
Hide file tree
Showing 45 changed files with 538 additions and 494 deletions.
29 changes: 24 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,32 @@
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-const-assign": "error",
"no-debugger": "error",
"no-dupe-args": "error",
"no-dupe-else-if": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-unused-vars": "error",
"curly": "error",
"eqeqeq": "error",
"no-throw-literal": "warn",
"semi": "off",
"no-console": "error"
"semi": "error",
"no-extra-semi": "error",
"no-console": "error",
"no-else-return": "error",
"no-shadow":"error",
"no-var": "error",
"prefer-const": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": "error",
"no-trailing-spaces": "error",
"quotes": ["error", "single"]
},
"ignorePatterns": [
"out",
Expand Down
3 changes: 2 additions & 1 deletion scripts/beta-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const version = packageJson.version.split('.');
packageJson.version = `${version[0]}.${version[1]}.${process.argv[process.argv.length-1].substr(0, 7)}`;
packageJson.preview = true;

// eslint-disable-next-line no-console
console.log(packageJson.version);
core.summary.addHeading(`Version info`).addDetails(`${packageJson.version}`);
core.summary.addHeading('Version info').addDetails(`${packageJson.version}`);

fs.writeFileSync(path.join(path.resolve('.'), 'package.json'), JSON.stringify(packageJson, null, 2));
2 changes: 0 additions & 2 deletions src/constants/AdaptiveCardTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


export const AdaptiveCardTypes = [
{
name: 'Basic Card Template',
Expand Down
4 changes: 2 additions & 2 deletions src/constants/Commands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EXTENSION_NAME } from "./General";
import { EXTENSION_NAME } from './General';


export const Commands = {
Expand Down Expand Up @@ -37,4 +37,4 @@ export const Commands = {

// Serving
serveSolution: `${EXTENSION_NAME}.serveSolution`,
}
};
2 changes: 2 additions & 0 deletions src/constants/ComponentTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-unused-vars */
// eslint-disable-next-line no-shadow
export enum ComponentType {
adaptiveCardExtension = 'adaptiveCardExtension',
webPart = 'webpart',
Expand Down
2 changes: 0 additions & 2 deletions src/constants/ContextKeys.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


export const ContextKeys = {
showWelcome: 'pnp.project.showWelcome',
isSPFxSolution: 'pnp.project.isSPFxSolution',
Expand Down
12 changes: 7 additions & 5 deletions src/constants/ExtensionTypes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* eslint-disable no-unused-vars */
// eslint-disable-next-line no-shadow
export enum ExtensionType {
application = "ApplicationCustomizer",
field = "FieldCustomizer",
listViewCommandSet = "ListViewCommandSet",
formCustomizer = "FormCustomizer",
searchQueryModifier = "SearchQueryModifier"
application = 'ApplicationCustomizer',
field = 'FieldCustomizer',
listViewCommandSet = 'ListViewCommandSet',
formCustomizer = 'FormCustomizer',
searchQueryModifier = 'SearchQueryModifier'
}

export const ExtensionTypes = [
Expand Down
2 changes: 2 additions & 0 deletions src/constants/FrameworkTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-unused-vars */
// eslint-disable-next-line no-shadow
export enum FrameworkType {
none = 'none',
react = 'react',
Expand Down
2 changes: 1 addition & 1 deletion src/constants/General.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const EXTENSION_NAME = `viva-connections-toolkit`;
export const EXTENSION_NAME = 'viva-connections-toolkit';
4 changes: 2 additions & 2 deletions src/constants/ProjectFileContent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@


/* eslint-disable no-unused-vars */
// eslint-disable-next-line no-shadow
export enum ProjectFileContent {
init = 'init',
initScenario = 'init-scenario',
Expand Down
2 changes: 0 additions & 2 deletions src/constants/WebviewCommand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


export const WebviewCommand = {
toWebview: {
viewType: 'view-type'
Expand Down
2 changes: 1 addition & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export * from './ExtensionTypes';
export * from './FrameworkTypes';
export * from './General';
export * from './ProjectFileContent';
export * from './WebviewCommand';
export * from './WebviewCommand';
16 changes: 8 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { PnPWebview } from './webview/PnPWebview';
import { CommandPanel } from './panels/CommandPanel';
import { workspace, window, ThemeIcon, commands } from 'vscode';
import { workspace, window, ThemeIcon, commands, ExtensionContext } from 'vscode';
import { PROJECT_FILE, Scaffolder } from './services/Scaffolder';
import { Extension } from './services/Extension';
import { ExtensionContext } from 'vscode';
import { Dependencies } from './services/Dependencies';
import { unlinkSync, readFileSync } from 'fs';
import { Terminal } from './services/Terminal';
import { AuthProvider } from './providers/AuthProvider';
import { CliActions } from './services/CliActions';
import { ProjectFileContent } from './constants';


export async function activate(context: ExtensionContext) {
Extension.getInstance(context);

Expand All @@ -23,23 +23,23 @@ export async function activate(context: ExtensionContext) {
CliActions.registerCommands();

CommandPanel.register();

PnPWebview.register();

workspace.findFiles(PROJECT_FILE, `**/node_modules/**`).then(async (files) => {
workspace.findFiles(PROJECT_FILE, '**/node_modules/**').then(async (files) => {
if (files.length > 0) {
const fileContents = readFileSync(files[0].fsPath, 'utf8');

if (fileContents && (fileContents === ProjectFileContent.init || fileContents === ProjectFileContent.initScenario)) {
unlinkSync(files[0].fsPath);

const terminal = window.createTerminal({
name: `Installing dependencies`,
name: 'Installing dependencies',
iconPath: new ThemeIcon('cloud-download')
});

if (terminal) {
terminal.sendText(`npm i`);
terminal.sendText('npm i');
terminal.show(true);
}

Expand All @@ -52,4 +52,4 @@ export async function activate(context: ExtensionContext) {
}

// this method is called when your extension is deactivated
export function deactivate() {}
export function deactivate() { }
1 change: 0 additions & 1 deletion src/models/command-result.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export interface CommandResult {
code: number;
cmdOutput: string;
Expand Down
Loading

0 comments on commit 9a3cb4b

Please sign in to comment.