-
Notifications
You must be signed in to change notification settings - Fork 0
Add biome config from deepnote/deepnote #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| jlpm exec lint-staged | ||
| yarn exec lint-staged |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @deepnote:registry=https://npm.pkg.github.com | ||
| //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,8 @@ node_modules | |
| !/package.json | ||
| jupyterlab_deepnote | ||
| .venv | ||
| coverage | ||
| **/*.ts | ||
| **/*.tsx | ||
| **/*.js | ||
| **/*.jsx | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| { | ||
| "$schema": "https://biomejs.dev/schemas/2.2.5/schema.json", | ||
| "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true }, | ||
| "files": { "ignoreUnknown": false }, | ||
| "formatter": { | ||
| "enabled": true, | ||
| "formatWithErrors": false, | ||
| "indentStyle": "space", | ||
| "indentWidth": 2, | ||
| "lineEnding": "lf", | ||
| "lineWidth": 120, | ||
| "attributePosition": "auto", | ||
| "bracketSameLine": false, | ||
| "bracketSpacing": true, | ||
| "expand": "auto", | ||
| "useEditorconfig": true, | ||
| "includes": ["**", "!./coverage", "!./dist", "!**/package.json"] | ||
| }, | ||
| "linter": { | ||
| "enabled": true, | ||
| "rules": { | ||
| "recommended": true, | ||
| "a11y": { | ||
| "recommended": true | ||
| }, | ||
| "complexity": { | ||
| "recommended": true, | ||
| "noBannedTypes": "error", | ||
| "noUselessTypeConstraint": "error", | ||
| "noCommaOperator": "error", | ||
| "noStaticOnlyClass": "error", | ||
| "noUselessConstructor": "error", | ||
| "noUselessEmptyExport": "error", | ||
| "noUselessThisAlias": "error", | ||
| "useOptionalChain": "error" | ||
| }, | ||
| "correctness": { | ||
| "recommended": true, | ||
| "noUnusedImports": "error", | ||
| "noUnusedFunctionParameters": "error", | ||
| "noUnusedPrivateClassMembers": "error", | ||
| "useHookAtTopLevel": "error", | ||
| "noConstAssign": "error", | ||
| "noGlobalObjectCalls": "error", | ||
| "noInnerDeclarations": "error", | ||
| "noInvalidUseBeforeDeclaration": "error", | ||
| "noInvalidBuiltinInstantiation": "error", | ||
| "noUnreachableSuper": "error", | ||
| "noUnsafeOptionalChaining": "error", | ||
| "noUnusedLabels": "error" | ||
| }, | ||
| "performance": { | ||
| "recommended": true | ||
| }, | ||
| "security": { | ||
| "recommended": true | ||
| }, | ||
| "style": { | ||
| "recommended": true, | ||
| "noNonNullAssertion": "error", | ||
| "useArrayLiterals": "error", | ||
| "useConst": "error", | ||
| "useForOf": "error", | ||
| "useImportType": "error", | ||
| "useNodejsImportProtocol": "error", | ||
| "useNumberNamespace": "error", | ||
| "noNamespace": "error", | ||
| "noParameterAssign": "error", | ||
| "useAsConstAssertion": "error", | ||
| "useConsistentMemberAccessibility": { | ||
| "level": "error", | ||
| "options": { | ||
| "accessibility": "noPublic" | ||
| } | ||
| }, | ||
| "useShorthandFunctionType": "error", | ||
| "useExportType": "error", | ||
| "useLiteralEnumMembers": "error", | ||
| "useUnifiedTypeSignatures": "error" | ||
| }, | ||
| "suspicious": { | ||
| "recommended": true, | ||
| "noEmptyInterface": "error", | ||
| "noExplicitAny": "error", | ||
| "noConsole": "warn", | ||
| "noDebugger": "error", | ||
| "noConfusingVoidType": "error", | ||
| "noDuplicateClassMembers": "error", | ||
| "noDuplicateObjectKeys": "error", | ||
| "noDuplicateParameters": "error", | ||
| "noExtraNonNullAssertion": "error", | ||
| "noFunctionAssign": "error", | ||
| "noLabelVar": "error", | ||
| "noMisleadingInstantiator": "error", | ||
| "noRedeclare": "error", | ||
| "noUnsafeDeclarationMerging": "error", | ||
| "noUnsafeNegation": "error", | ||
| "useAdjacentOverloadSignatures": "error", | ||
| "useNamespaceKeyword": "error" | ||
| }, | ||
| "nursery": { | ||
| "noFloatingPromises": "error", | ||
| "noMisusedPromises": "error", | ||
| "noNonNullAssertedOptionalChain": "error", | ||
| "useConsistentTypeDefinitions": "error" | ||
| } | ||
| } | ||
| }, | ||
| "javascript": { | ||
| "formatter": { | ||
| "jsxQuoteStyle": "single", | ||
| "quoteProperties": "preserve", | ||
| "trailingCommas": "es5", | ||
| "semicolons": "asNeeded", | ||
| "arrowParentheses": "asNeeded", | ||
| "bracketSameLine": false, | ||
| "quoteStyle": "single", | ||
| "attributePosition": "auto", | ||
| "bracketSpacing": true | ||
| } | ||
| }, | ||
| "overrides": [ | ||
| { | ||
| "includes": ["*.tsx"], | ||
| "linter": { | ||
| "rules": { | ||
| "style": { | ||
| "useImportType": "off" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "html": { "formatter": { "selfCloseVoidElements": "always" } }, | ||
| "assist": { | ||
| "enabled": true, | ||
| "actions": { "source": { "organizeImports": "on" } } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,44 +1,40 @@ | ||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||
| createMarkdown, | ||||||||||||||||||||||||||||||
| createPythonCode, | ||||||||||||||||||||||||||||||
| DeepnoteBlock | ||||||||||||||||||||||||||||||
| } from '@deepnote/blocks'; | ||||||||||||||||||||||||||||||
| import _cloneDeep from 'lodash/cloneDeep'; | ||||||||||||||||||||||||||||||
| import { ICodeCell, IMarkdownCell } from '@jupyterlab/nbformat'; | ||||||||||||||||||||||||||||||
| import { convertDeepnoteBlockTypeToJupyter } from './convert-deepnote-block-type-to-jupyter'; | ||||||||||||||||||||||||||||||
| import { createMarkdown, createPythonCode, type DeepnoteBlock } from '@deepnote/blocks' | ||||||||||||||||||||||||||||||
| import type { ICodeCell, IMarkdownCell } from '@jupyterlab/nbformat' | ||||||||||||||||||||||||||||||
| import _cloneDeep from 'lodash/cloneDeep' | ||||||||||||||||||||||||||||||
| import { convertDeepnoteBlockTypeToJupyter } from './convert-deepnote-block-type-to-jupyter' | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| export function convertDeepnoteBlockToJupyterCell(block: DeepnoteBlock) { | ||||||||||||||||||||||||||||||
| const blockCopy = _cloneDeep(block); | ||||||||||||||||||||||||||||||
| const jupyterCellMetadata = { ...blockCopy.metadata, cell_id: blockCopy.id }; | ||||||||||||||||||||||||||||||
| const jupyterCellType = convertDeepnoteBlockTypeToJupyter(blockCopy.type); | ||||||||||||||||||||||||||||||
| const blockCopy = _cloneDeep(block) | ||||||||||||||||||||||||||||||
| const jupyterCellMetadata = { ...blockCopy.metadata, cell_id: blockCopy.id } | ||||||||||||||||||||||||||||||
| const jupyterCellType = convertDeepnoteBlockTypeToJupyter(blockCopy.type) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (jupyterCellType === 'code') { | ||||||||||||||||||||||||||||||
| const blockOutputs = blockCopy.outputs ?? []; | ||||||||||||||||||||||||||||||
| const blockOutputs = blockCopy.outputs ?? [] | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (Array.isArray(blockOutputs)) { | ||||||||||||||||||||||||||||||
| blockOutputs.forEach(output => { | ||||||||||||||||||||||||||||||
| delete output.truncated; | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| delete output.truncated | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
14
to
18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Comply with Biome style.useForOf. forEach will violate the configured rule. Use for‑of. - if (Array.isArray(blockOutputs)) {
- blockOutputs.forEach(output => {
- delete output.truncated
- })
- }
+ if (Array.isArray(blockOutputs)) {
+ for (const output of blockOutputs) {
+ // Remove Deepnote-only flag
+ // @ts-expect-error property may not exist on Jupyter outputs
+ delete (output as any).truncated
+ }
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const source = createPythonCode(blockCopy); | ||||||||||||||||||||||||||||||
| const source = createPythonCode(blockCopy) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const jupyterCell: ICodeCell = { | ||||||||||||||||||||||||||||||
| cell_type: 'code', | ||||||||||||||||||||||||||||||
| metadata: jupyterCellMetadata, | ||||||||||||||||||||||||||||||
| execution_count: blockCopy.executionCount ?? null, | ||||||||||||||||||||||||||||||
| outputs: blockOutputs, | ||||||||||||||||||||||||||||||
| source | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
| return jupyterCell; | ||||||||||||||||||||||||||||||
| source, | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| return jupyterCell | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| // Markdown cell | ||||||||||||||||||||||||||||||
| const source = createMarkdown(blockCopy); | ||||||||||||||||||||||||||||||
| const source = createMarkdown(blockCopy) | ||||||||||||||||||||||||||||||
| const jupyterCell: IMarkdownCell = { | ||||||||||||||||||||||||||||||
| cell_type: 'markdown', | ||||||||||||||||||||||||||||||
| metadata: {}, | ||||||||||||||||||||||||||||||
| source | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
| return jupyterCell; | ||||||||||||||||||||||||||||||
| source, | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
34
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve metadata (incl. cell_id) for markdown cells. You build jupyterCellMetadata but drop it for markdown. Keep consistency and IDs. - const jupyterCell: IMarkdownCell = {
+ const jupyterCell: IMarkdownCell = {
cell_type: 'markdown',
- metadata: {},
+ metadata: jupyterCellMetadata,
source,
}🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| return jupyterCell | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TSX override glob misses nested files.
"*.tsx" only matches root-level files. Use a recursive glob to apply the rule repo‑wide; otherwise TSX under src/** won’t get the intended useImportType override.
Apply this diff:
🤖 Prompt for AI Agents