openpencil/oxlint.json
Danila Poyarkov f3eac5ac8b Lint all packages: fix 193 errors across core, mcp, acp
Extend lint coverage from src/ to all packages (178 files, 140 rules).

Core (37 files):
- Remove 98 unnecessary conditions (dead ?./?? on non-nullish values)
- Remove 38 unnecessary type assertions (! and as casts)
- Convert 12 patterns to optional chain (a && a.b → a?.b)
- Fix 10 consistent-type-imports (merge duplicates, inline type keyword)
- Add parentheses to 16 nested ternaries
- Convert 4 indexed for-loops to for-of
- Merge 4 duplicate import statements

MCP (3 files):
- Replace typeof undefined check with 'in' operator
- Capture graph in local const to avoid ! assertions

ACP (1 file):
- Fix 5 TypeScript errors (type predicates, object shapes, dead code)
- Remove unnecessary template expression

Vendored kiwi-schema gets broader rule overrides to avoid touching it.
Core complexity stays as warning (24 functions over limit).
2026-03-09 13:18:08 +03:00

129 lines
4.3 KiB
JSON

{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["typescript", "import", "unicorn", "vue"],
"jsPlugins": ["./lint/plugin.js"],
"env": {
"browser": true,
"es2024": true
},
"rules": {
"no-unused-vars": "warn",
"no-console": "off",
"no-restricted-imports": ["error", {
"paths": [
{ "name": "@/types", "message": "Import types directly from @open-pencil/core." }
],
"patterns": [{
"group": ["@/engine/*"],
"message": "Import from @open-pencil/core unless the module adds platform-specific logic.",
"allowImportNames": ["loadFont", "listFamilies", "preloadFonts"]
}]
}],
"no-empty-function": "error",
"max-lines": ["warn", { "max": 600 }],
"complexity": ["error", { "max": 20 }],
"typescript/no-explicit-any": "warn",
"typescript/no-non-null-assertion": "warn",
"typescript/no-floating-promises": "error",
"typescript/no-misused-promises": "error",
"typescript/consistent-type-imports": "error",
"typescript/consistent-return": "error",
"typescript/no-unnecessary-condition": "error",
"typescript/no-unnecessary-type-assertion": "error",
"typescript/no-unnecessary-type-parameters": "error",
"typescript/no-unnecessary-boolean-literal-compare": "error",
"typescript/no-unnecessary-template-expression": "error",
"typescript/no-unnecessary-type-arguments": "error",
"typescript/prefer-optional-chain": "error",
"typescript/prefer-for-of": "error",
"import/no-cycle": "error",
"import/no-self-import": "error",
"import/no-duplicates": "error",
"import/no-mutable-exports": "error",
"unicorn/no-instanceof-array": "error",
"unicorn/no-typeof-undefined": "error",
"unicorn/no-nested-ternary": "error",
"unicorn/no-useless-fallback-in-spread": "error",
"unicorn/no-length-as-slice-end": "error",
"unicorn/no-unnecessary-await": "error",
"unicorn/prefer-string-starts-ends-with": "error",
"unicorn/consistent-existence-index-check": "error",
"vue/no-arrow-functions-in-watch": "error",
"vue/no-deprecated-destroyed-lifecycle": "error",
"vue/no-export-in-script-setup": "error",
"vue/no-lifecycle-after-await": "error",
"vue/no-import-compiler-macros": "error",
"vue/prefer-import-from-vue": "error",
"vue/valid-define-emits": "error",
"vue/valid-define-props": "error",
"vue/no-required-prop-with-default": "error",
"vue/no-multiple-slot-args": "error",
"vue/define-emits-declaration": "error",
"vue/define-props-destructuring": "error",
"vue/require-typed-ref": "error",
"open-pencil/no-inline-named-types": ["error", {
"Vector": "x:number,y:number",
"Color": "a:number,b:number,g:number,r:number",
"GUID": "localID:number,sessionID:number",
"Rect": "height:number,width:number,x:number,y:number",
"Matrix": "m00:number,m01:number,m02:number,m10:number,m11:number,m12:number"
}],
"open-pencil/no-structuredclone-scene-arrays": "error",
"open-pencil/no-math-random": "error",
"open-pencil/no-hand-rolled-color": "error",
"open-pencil/no-raw-console-format": "off"
},
"overrides": [
{
"files": ["**/*.test.ts", "**/*.test.tsx"],
"rules": {
"typescript/no-explicit-any": "off",
"typescript/no-non-null-assertion": "off"
}
},
{
"files": ["**/kiwi/kiwi-schema/**"],
"rules": {
"typescript/no-explicit-any": "off",
"typescript/no-non-null-assertion": "off",
"typescript/prefer-for-of": "off",
"typescript/prefer-optional-chain": "off",
"typescript/consistent-type-imports": "off",
"typescript/no-unnecessary-condition": "off",
"import/no-mutable-exports": "off",
"complexity": "off"
}
},
{
"files": [
"src/stores/editor.ts",
"src/composables/use-canvas-input.ts",
"src/demo.ts"
],
"rules": {
"max-lines": "off"
}
},
{
"files": ["packages/cli/src/commands/**"],
"rules": {
"open-pencil/no-raw-console-format": "error"
}
},
{
"files": ["packages/core/src/**"],
"rules": {
"complexity": "warn"
}
}
],
"ignorePatterns": ["node_modules", "dist", "desktop", "*.config.*"]
}