Skip to content

Commit

Permalink
fix: 🐛 lint issues over node protocol and switch statement (#18)
Browse files Browse the repository at this point in the history
## Why?

Lint issues over node protocol and switch statement

## How?

- Use node protocol
- Wrap switch cases to enforce scope for declared variables

## Tickets?

- [Ticket 1](the-ticket-url-here)
- [Ticket 2](the-ticket-url-here)
- [Ticket 3](the-ticket-url-here)

## Contribution checklist?

- [ ] The commit messages are detailed
- [ ] The `build` command runs locally
- [ ] Assets or static content are linked and stored in the project
- [ ] You have manually tested
- [ ] You have provided tests

## Security checklist?

- [ ] Sensitive data has been identified and is being protected properly
- [ ] Injection has been prevented (parameterized queries, no eval or
system calls)

## Preview?

Optionally, provide the preview url here

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
heldrida and actions-user authored Aug 15, 2024
1 parent 918f85c commit c131a56
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/commands/functions/utils/getCodeFromPath.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import * as fs from 'node:fs';
import * as os from 'node:os';
import path from 'node:path';

// TODO: These error messages should be revised
// e.g. FleekFunctionPathNotValidError happens regardless of bundling
Expand Down
2 changes: 1 addition & 1 deletion src/commands/sites/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { withGuards } from '../../guards/withGuards';
import { loadConfiguration } from '../../utils/configuration/loadConfiguration';
import { t } from '../../utils/translation';
import { confirmFileOverridePrompt } from './prompts/confirmFileOverridePrompt';
import { initConfiguration } from './utils/initConfiguration';
import { chooseOrCreateSite } from './utils/chooseOrCreateSite';
import { initConfiguration } from './utils/initConfiguration';

const initAction: SdkGuardedFunction = async ({ sdk }) => {
const configLoadingResult = await loadConfiguration({})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { selectPrompt } from '../../../prompts/selectPrompt';
import { t } from '../../../utils/translation';
import { getConfigFileByTypeValue } from '../../../utils/configuration';
import { t } from '../../../utils/translation';

import { FleekSiteConfigFormats } from '../../../utils/configuration/types';

Expand Down
4 changes: 2 additions & 2 deletions src/commands/sites/utils/initConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import type { Site } from '@fleek-platform/sdk';

import { saveConfiguration } from '../../../utils/configuration/saveConfiguration';
import type { FleekRootConfig } from '../../../utils/configuration/types';
import { isValidFleekConfigFormat } from '../../../utils/formats';
import { fileExists } from '../../../utils/fs';
import { t } from '../../../utils/translation';
import { enterDirectoryPathPrompt } from '../prompts/enterDirectoryPathPrompt';
import { selectConfigurationFormatPrompt } from '../prompts/selectConfigurationFormatPrompt';
import { selectBuildCommandOrSkip } from './selectBuildCommandOrSkip';
import { isValidFleekConfigFormat } from '../../../utils/formats';
import { fileExists } from '../../../utils/fs';

type InitConfigurationArgs = {
site: Site;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { join as joinPath } from 'node:path';
import { generateDeploymentWorkflowYaml } from '@fleek-platform/utils-github';

import type { Output } from '../../../output/Output';
import { confirmFileOverridePrompt } from '../prompts/confirmFileOverridePrompt';
import { fileExists } from '../../../utils/fs';
import { confirmFileOverridePrompt } from '../prompts/confirmFileOverridePrompt';
import { getDeploymentWorkflowYamlLocation } from './getDeploymentWorkflowYamlLocation';
import { initializeDeploymentWorkflowDirectory } from './initializeDeploymentWorkflowDirectory';
import { requestDeploymentWorkflowInstallCommand } from './requestDeploymentWorkflowInstallCommand';
Expand Down
2 changes: 1 addition & 1 deletion src/guards/sitesGuard.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { output } from '../cli';
import { chooseOrCreateSite } from '../commands/sites/utils/chooseOrCreateSite';
import { initConfiguration } from '../commands/sites/utils/initConfiguration';
import { loadConfiguration } from '../utils/configuration/loadConfiguration';
import { t } from '../utils/translation';
import { getSdkClient } from './sdkGuard';
import { chooseOrCreateSite } from '../commands/sites/utils/chooseOrCreateSite';

export const sitesGuard = async ({
predefinedConfigPath,
Expand Down
14 changes: 7 additions & 7 deletions src/utils/configuration/saveConfiguration.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { describe, expect, it, beforeEach, afterEach } from 'vitest';
import { type FleekRootConfig, FleekSiteConfigFormats } from './types';
import { saveConfiguration } from './saveConfiguration';
import fs from 'fs/promises';
import path from 'path';
import ts from 'typescript';
import { fileExists } from '../fs';
import fs from 'node:fs/promises';
import path from 'node:path';
import {
ExpectedOneOfValuesError,
InvalidJSONFormat,
} from '@fleek-platform/errors';
import ts from 'typescript';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { fileExists } from '../fs';
import { saveConfiguration } from './saveConfiguration';
import { type FleekRootConfig, FleekSiteConfigFormats } from './types';

const clearConfigFile = async ({
configFilePath,
Expand Down
13 changes: 8 additions & 5 deletions src/utils/configuration/saveConfiguration.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { promises as fs } from 'node:fs';
import path from 'path';
import path from 'node:path';

import {
FLEEK_CONFIG_TMPL_JSON_PLACEHOLDER,
getConfigFileByTypeName,
getConfigTemplateByTypeName,
FLEEK_CONFIG_TMPL_JSON_PLACEHOLDER,
} from '../configuration';

import { type FleekRootConfig, FleekSiteConfigFormats } from './types';
Expand Down Expand Up @@ -57,7 +57,7 @@ export const saveConfiguration = async ({
let configFile: ConfigFilePath;

switch (format) {
case FleekSiteConfigFormats.Typescript:
case FleekSiteConfigFormats.Typescript: {
const contentForTypescriptConfig = (
await fs.readFile(filePathForTypescriptConfig)
).toString();
Expand All @@ -67,7 +67,8 @@ export const saveConfiguration = async ({
);
configFile = getConfigFileByTypeName('Typescript');
break;
case FleekSiteConfigFormats.Javascript:
}
case FleekSiteConfigFormats.Javascript: {
const contentForJavascriptConfig = (
await fs.readFile(filePathForJavascriptConfig)
).toString();
Expand All @@ -77,10 +78,12 @@ export const saveConfiguration = async ({
);
configFile = getConfigFileByTypeName('Javascript');
break;
case FleekSiteConfigFormats.JSON:
}
case FleekSiteConfigFormats.JSON: {
content = formattedOutput;
configFile = getConfigFileByTypeName('JSON');
break;
}
}

try {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/formats.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';

import { isValidFleekConfigFormat } from './formats';
import { FleekSiteConfigFormats } from './configuration';
import { isValidFleekConfigFormat } from './formats';

describe('In the Formats utils', () => {
describe('isValidFleekConfigFormat', () => {
Expand Down

0 comments on commit c131a56

Please sign in to comment.