Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ program
.command('sync')
.description('Sync Markdown files to DB')
.argument('<dir>', 'directory')
.action(async (dir) => {
.action(async (dir: string) => {
console.log(`Syncing from "${dir}"...`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using console in code that runs on the browser


It is considered a best practice to avoid the use of any console methods in JavaScript code that will run on the browser.

NOTE: If your repository contains a server side project, you can add "nodejs" to the environment property of analyzer meta in .deepsource.toml.
This will prevent this issue from getting raised.
Documentation for the analyzer meta can be found here.
Alternatively, you can silence this issue for your repository as shown here.

If a specific console call is meant to stay for other reasons, you can add a skipcq comment to that line.
This will inform other developers about the reason behind the log's presence, and prevent DeepSource from flagging it.

if (!fs.existsSync(dir)) {
console.error('Directory not found');
Expand Down Expand Up @@ -57,12 +57,17 @@ program
console.log('Sync complete.');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using console in code that runs on the browser


It is considered a best practice to avoid the use of any console methods in JavaScript code that will run on the browser.

NOTE: If your repository contains a server side project, you can add "nodejs" to the environment property of analyzer meta in .deepsource.toml.
This will prevent this issue from getting raised.
Documentation for the analyzer meta can be found here.
Alternatively, you can silence this issue for your repository as shown here.

If a specific console call is meant to stay for other reasons, you can add a skipcq comment to that line.
This will inform other developers about the reason behind the log's presence, and prevent DeepSource from flagging it.

});

interface ExportOptions {
format: string;
output: string;
}

program
.command('export')
.description('Export data (md, json, site)')
.option('-f, --format <format>', 'format', 'md')
.option('-o, --output <dir>', 'output directory', './export')
.action(async (options) => {
.action(async (options: ExportOptions) => {
const outDir = options.output;
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });

Expand Down Expand Up @@ -194,13 +199,18 @@ async function exportSite(outDir: string) {
fs.writeFileSync(path.join(outDir, 'index.html'), html);
}

interface EntityCreateOptions {
type: string;
description?: string;
}

program
.command('entity-create')
.description('Create entity')
.argument('<name>')
.option('-t, --type <type>', 'type', 'concept')
.option('-d, --description <description>', 'description')
.action(async (name, options) => {
.action(async (name: string, options: EntityCreateOptions) => {
await ensureDb();
try {
const entity = await repository.createEntity({
Expand All @@ -210,7 +220,7 @@ program
});
console.log(`Created: ${entity.name} [${entity.type}] (ID: ${entity.id})`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using console in code that runs on the browser


It is considered a best practice to avoid the use of any console methods in JavaScript code that will run on the browser.

NOTE: If your repository contains a server side project, you can add "nodejs" to the environment property of analyzer meta in .deepsource.toml.
This will prevent this issue from getting raised.
Documentation for the analyzer meta can be found here.
Alternatively, you can silence this issue for your repository as shown here.

If a specific console call is meant to stay for other reasons, you can add a skipcq comment to that line.
This will inform other developers about the reason behind the log's presence, and prevent DeepSource from flagging it.

} catch (err) {
console.error(`Failed to create entity: ${err}`);
console.error(`Failed to create entity: ${String(err)}`);
}
});

Expand All @@ -229,13 +239,17 @@ program
}
});

interface ClaimCreateOptions {
confidence: string;
}

program
.command('claim-create')
.description('Create claim for entity')
.argument('<entity-name>')
.argument('<statement>')
.option('-c, --confidence <confidence>', 'confidence', '1.0')
.action(async (entityName, statement, options) => {
.action(async (entityName: string, statement: string, options: ClaimCreateOptions) => {
await ensureDb();
const entity = await repository.getEntityByName(entityName);
if (!entity || !entity.id) {
Expand All @@ -250,7 +264,7 @@ program
});
console.log(`Claim added to ${entity.name}: ${claim.statement}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using console in code that runs on the browser


It is considered a best practice to avoid the use of any console methods in JavaScript code that will run on the browser.

NOTE: If your repository contains a server side project, you can add "nodejs" to the environment property of analyzer meta in .deepsource.toml.
This will prevent this issue from getting raised.
Documentation for the analyzer meta can be found here.
Alternatively, you can silence this issue for your repository as shown here.

If a specific console call is meant to stay for other reasons, you can add a skipcq comment to that line.
This will inform other developers about the reason behind the log's presence, and prevent DeepSource from flagging it.

} catch (err) {
console.error(`Failed to create claim: ${err}`);
console.error(`Failed to create claim: ${String(err)}`);
}
});

Expand Down
92 changes: 54 additions & 38 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import reactHooks from 'eslint-plugin-react-hooks';
import react from 'eslint-plugin-react';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import reactRefresh from 'eslint-plugin-react-refresh';
import globals from 'globals';

export default tseslint.config(
{
Expand All @@ -17,18 +18,47 @@ export default tseslint.config(
},
js.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
jsxA11y.flatConfigs.recommended,

// App-specific configuration (React)
{
files: ['src/**/*.{ts,tsx}'],
...react.configs.flat.recommended,
...react.configs.flat['jsx-runtime'],
plugins: {
...react.configs.flat.recommended.plugins,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
'jsx-a11y': jsxA11y,
},
languageOptions: {
parserOptions: {
project: ['./tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
...react.configs.flat.recommended.rules,
...react.configs.flat['jsx-runtime'].rules,
...reactHooks.configs.recommended.rules,
...jsxA11y.flatConfigs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/no-static-element-interactions': 'warn',
'jsx-a11y/no-noninteractive-element-interactions': 'warn',
'jsx-a11y/interactive-supports-focus': 'warn',
'jsx-a11y/role-has-required-aria-props': 'warn',
'jsx-a11y/role-supports-aria-props': 'warn',
'jsx-a11y/no-autofocus': 'warn',
'react/no-unescaped-entities': 'warn',
},
settings: {
react: {
version: 'detect',
},
},
},

// Test configuration
{
files: ['tests/**/*.{ts,tsx}', 'src/**/*.test.{ts,tsx}', 'src/**/*.spec.{ts,tsx}', 'src/test/setup.ts'],
languageOptions: {
Expand All @@ -38,59 +68,45 @@ export default tseslint.config(
},
},
},

// CLI and Config Files (Node)
{
files: ['cli/**/*.ts', 'scripts/**/*.ts', '*.config.{ts,js,cjs}', '*.config.*.{ts,js,cjs}', 'eslint.config.js'],
languageOptions: {
globals: {
module: 'readonly',
process: 'readonly',
require: 'readonly',
__dirname: 'readonly',
...globals.node,
},
parserOptions: {
project: ['./tsconfig.node.json'],
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
},
},

{
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-empty-function': 'error',
'no-empty-function': 'off', // Replaced by TS version

// Temporarily downgrade new rules to warn to allow for incremental fixing
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/await-thenable': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/unbound-method': 'warn',
'@typescript-eslint/require-await': 'warn',
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/no-static-element-interactions': 'warn',
'jsx-a11y/no-noninteractive-element-interactions': 'warn',
'jsx-a11y/interactive-supports-focus': 'warn',
'jsx-a11y/role-has-required-aria-props': 'warn',
'jsx-a11y/role-supports-aria-props': 'warn',
'jsx-a11y/no-autofocus': 'warn',
'react/no-unescaped-entities': 'warn',
},
settings: {
react: {
version: 'detect',
},

'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/unbound-method': 'error',
'@typescript-eslint/require-await': 'error',
},
},
);
);
20 changes: 17 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.6",
"globals": "^17.6.0",
"jsdom": "^29.1.1",
"ts-node": "^10.9.2",
"typescript": "^5.2.2",
Expand Down
Loading