Skip to content

Commit

Permalink
chore: add missing linting rules from Podman Desktop (#98)
Browse files Browse the repository at this point in the history
* chore: add missing linting rules from Podman Desktop

fixes issues reported by using the same rules

it also fixes #97
  • Loading branch information
benoitf authored Jan 19, 2024
1 parent 57c27c7 commit bf1ee55
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 24 deletions.
15 changes: 8 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@
}
}
},
"plugins": ["@typescript-eslint", "sonarjs", "etc", "redundant-undefined"],
"ignorePatterns": [
"node_modules/**",
"**/dist/**"
],
"plugins": ["@typescript-eslint", "sonarjs", "etc", "redundant-undefined", "no-null"],
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"eqeqeq": "error",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-explicit-any": "error",
Expand All @@ -51,6 +52,7 @@
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/prefer-optional-chain": "error",
"no-null/no-null": "error",

/**
* Having a semicolon helps the optimizer interpret your code correctly.
Expand All @@ -71,10 +73,8 @@
/**
* Just for beauty
*/
"quotes": [
"warn", "single"
],
"import/no-duplicates" : "error",
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"import/no-duplicates": "error",
"import/no-unresolved": "off",
"import/default": "off",
"import/no-named-as-default-member": "off",
Expand All @@ -85,6 +85,7 @@
"sonarjs/no-small-switch": "off",
"etc/no-commented-out-code": "error",
"etc/no-deprecated": "off",
"redundant-undefined/redundant-undefined": "error"
"redundant-undefined/redundant-undefined": "error",
"import/no-extraneous-dependencies": "error"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"typecheck": "npm run typecheck:shared && npm run typecheck:frontend && npm run typecheck:backend"
},
"devDependencies": {
"@podman-desktop/api": "0.0.202401191125-9c1aea6",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@vitest/coverage-v8": "^1.1.0",
Expand All @@ -37,6 +36,7 @@
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-etc": "^2.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-redundant-undefined": "^1.0.0",
"eslint-plugin-sonarjs": "^0.23.0",
"prettier": "^3.1.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"simple-git": "^3.22.0"
},
"devDependencies": {
"@podman-desktop/api": "0.0.202401191125-9c1aea6",
"@types/js-yaml": "^4.0.9",
"@types/node": "^18"
"@types/node": "^18",
"vitest": "^1.1.0"
}
}
2 changes: 1 addition & 1 deletion packages/backend/src/managers/applicationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export class ApplicationManager {
const dirs = entries.filter(dir => dir.isDirectory());
for (const d of dirs) {
const modelEntries = fs.readdirSync(path.resolve(d.path, d.name));
if (modelEntries.length != 1) {
if (modelEntries.length !== 1) {
// we support models with one file only for now
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/managers/catalogManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class CatalogManager {
try {
this.watchCatalogFile(catalogPath); // do not await, we want to do this async
} catch (err: unknown) {
console.error("unable to watch catalog file, changes to the catalog file won't be reflected to the UI", err);
console.error(`unable to watch catalog file, changes to the catalog file won't be reflected to the UI`, err);
}

try {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/managers/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function findFirstProvider(): ProviderContainerConnection | undefined {
const engines = provider
.getContainerConnections()
.filter(connection => connection.connection.type === 'podman')
.filter(connection => connection.connection.status() == 'started');
.filter(connection => connection.connection.status() === 'started');
return engines.length > 0 ? engines[0] : undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/models/AIConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface AIConfig {
}

export function isString(value: unknown): value is string {
return (value !== undefined && value !== null && typeof value === 'string') || value instanceof String;
return (!!value && typeof value === 'string') || value instanceof String;
}

export function assertString(value: unknown): string {
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"svelte-fa": "^3.0.4",
"svelte-markdown": "^0.4.1",
"svelte-preprocess": "^5.1.3",
"tailwindcss": "^3.4.0"
"tailwindcss": "^3.4.0",
"vitest": "^1.1.0"
}
}
12 changes: 2 additions & 10 deletions packages/shared/src/messages/MessageProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ export interface ISubscribedMessage {
type UnaryRPC = (...args: unknown[]) => Promise<unknown>;

export function isMessageRequest(content: unknown): content is IMessageRequest {
return (
content !== undefined && content !== null && typeof content === 'object' && 'id' in content && 'channel' in content
);
return !!content && typeof content === 'object' && 'id' in content && 'channel' in content;
}

export function isMessageResponse(content: unknown): content is IMessageResponse {
Expand Down Expand Up @@ -208,12 +206,6 @@ export class RpcBrowser {
}

isSubscribedMessage(content: any): content is ISubscribedMessage {
return (
content !== undefined &&
content !== null &&
'id' in content &&
'body' in content &&
this.subscribers.has(content.id)
);
return !!content && 'id' in content && 'body' in content && this.subscribers.has(content.id);
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,11 @@ eslint-plugin-import@^2.29.1:
semver "^6.3.1"
tsconfig-paths "^3.15.0"

eslint-plugin-no-null@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-no-null/-/eslint-plugin-no-null-1.0.2.tgz#1236a812391390a1877ad4007c26e745341c951f"
integrity sha512-uRDiz88zCO/2rzGfgG15DBjNsgwWtWiSo4Ezy7zzajUgpnFIqd1TjepKeRmJZHEfBGu58o2a8S0D7vglvvhkVA==

eslint-plugin-redundant-undefined@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/eslint-plugin-redundant-undefined/-/eslint-plugin-redundant-undefined-1.0.0.tgz"
Expand Down

0 comments on commit bf1ee55

Please sign in to comment.