mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Simplify lint and format configuration
This commit is contained in:
parent
649dfba360
commit
fef24552e9
4 changed files with 56 additions and 28 deletions
12
biome.jsonc
12
biome.jsonc
|
|
@ -60,6 +60,10 @@
|
|||
}
|
||||
},
|
||||
"linter": {
|
||||
"domains": {
|
||||
"react": "recommended",
|
||||
"test": "recommended"
|
||||
},
|
||||
"rules": {
|
||||
"preset": "recommended",
|
||||
"a11y": "info",
|
||||
|
|
@ -69,14 +73,9 @@
|
|||
"options": {
|
||||
"reportUnnecessaryDependencies": false
|
||||
}
|
||||
},
|
||||
"useHookAtTopLevel": "error"
|
||||
}
|
||||
},
|
||||
"nursery": {
|
||||
"noFloatingPromises": "error",
|
||||
"noMisusedPromises": "error",
|
||||
"noUnsafePlusOperands": "error",
|
||||
"useExhaustiveSwitchCases": "error",
|
||||
"noExcessiveSelectorClasses": {
|
||||
"level": "error",
|
||||
"options": {
|
||||
|
|
@ -85,7 +84,6 @@
|
|||
}
|
||||
},
|
||||
"suspicious": {
|
||||
"noArrayIndexKey": "error",
|
||||
"noImportCycles": "error"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ npm run format
|
|||
npm run check
|
||||
```
|
||||
|
||||
Use this as the normal edit loop. `npm run format` applies Biome formatting and import organization; `npm run check` is the local preflight for type checking, tests, lint, format/assist checks, CSS checks, and the production bundle.
|
||||
Use this as the normal edit loop. `npm run format` applies Biome formatting and import organization without lint fixes; `npm run check` is the local preflight for type checking, tests, lint, format/assist checks, CSS checks, and the production bundle.
|
||||
|
||||
Use focused scripts for tight loops: `npm run typecheck`, `npm run test`, `npm run build`, or the targeted `npm run check:*` scripts. CI and release preflight run the same `npm run check` command as local development.
|
||||
|
||||
Biome owns formatting, import organization, general JavaScript/TypeScript/JSON/CSS linting, GritQL source-shape plugins, GritQL import-boundary restrictions, imperative-DOM bridge naming, and GritQL CSS source policy. Biome warnings fail `npm run check`; info diagnostics stay advisory, including accessibility while Obsidian-specific UI semantics are reviewed rule by rule. The CSS usage script still checks dead authored classes. TypeScript owns strict type checking, unused locals and parameters, implicit return coverage, switch fallthrough prevention, and deep-readonly `ChatState` snapshots. ESLint remains for typed strict TypeScript rules that are not compiler options and Obsidian plugin policy. The typed strict preset is used with `@typescript-eslint/require-await` disabled because Obsidian and panel-owned async-shaped boundaries sometimes return already-complete work.
|
||||
Biome owns formatting, import organization, general JavaScript/TypeScript/JSON/CSS linting, Preact-compatible React domain rules, GritQL source-shape plugins, GritQL import-boundary restrictions, imperative-DOM bridge naming, and GritQL CSS source policy. Biome warnings fail `npm run check`; info diagnostics stay advisory, including accessibility while Obsidian-specific UI semantics are reviewed rule by rule. The CSS usage script still checks dead authored classes. TypeScript provides compiler-backed checks such as strict type checking, unused locals and parameters, implicit return coverage, switch fallthrough prevention, and deep-readonly `ChatState` snapshots. ESLint runs the TypeScript ESLint strict type-checked preset over source files, plus Obsidian plugin policy for `manifest.json` and `LICENSE`. Tests are covered by TypeScript, Vitest, and Biome rather than typed ESLint so local preflight stays responsive. Some checks intentionally overlap between Biome, TypeScript, and ESLint so the configuration stays simple.
|
||||
|
||||
## Generated and Loaded Files
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import json from "@eslint/json";
|
||||
import { defineConfig } from "eslint/config";
|
||||
import obsidianmd from "eslint-plugin-obsidianmd";
|
||||
import { PlainTextParser } from "eslint-plugin-obsidianmd/dist/lib/plainTextParser.js";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
const sourceTypeScriptFiles = ["src/**/*.{ts,tsx}"];
|
||||
const strictTypeCheckedTypeScriptRules = Object.assign({}, ...tseslint.configs.strictTypeChecked.map((config) => config.rules ?? {}));
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
|
|
@ -15,14 +16,14 @@ export default defineConfig([
|
|||
obsidianmd,
|
||||
},
|
||||
},
|
||||
...obsidianmd.configs.recommended.map(obsidianRecommendedConfig).filter(Boolean),
|
||||
...obsidianmd.configs.recommended.map(obsidianSourceRecommendedConfig).filter(Boolean),
|
||||
...tseslint.configs.strictTypeChecked.map((config) => ({
|
||||
...config,
|
||||
files: sourceTypeScriptFiles,
|
||||
})),
|
||||
{
|
||||
files: sourceTypeScriptFiles,
|
||||
plugins: {
|
||||
"@typescript-eslint": tseslint.plugin,
|
||||
},
|
||||
languageOptions: {
|
||||
parser: tseslint.parser,
|
||||
ecmaVersion: 2022,
|
||||
sourceType: "module",
|
||||
parserOptions: {
|
||||
|
|
@ -43,29 +44,58 @@ export default defineConfig([
|
|||
},
|
||||
},
|
||||
rules: {
|
||||
...strictTypeCheckedTypeScriptRules,
|
||||
"@typescript-eslint/no-deprecated": "off",
|
||||
"@typescript-eslint/require-await": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: sourceTypeScriptFiles,
|
||||
files: ["manifest.json"],
|
||||
plugins: {
|
||||
json,
|
||||
obsidianmd,
|
||||
},
|
||||
language: "json/json",
|
||||
rules: {
|
||||
"obsidianmd/validate-manifest": "error",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["LICENSE"],
|
||||
plugins: {
|
||||
obsidianmd,
|
||||
},
|
||||
languageOptions: {
|
||||
parser: PlainTextParser,
|
||||
},
|
||||
rules: {
|
||||
"obsidianmd/ui/sentence-case": [
|
||||
"error",
|
||||
{
|
||||
acronyms: ["MCP"],
|
||||
brands: ["Codex", "Codex Panel", "Obsidian"],
|
||||
},
|
||||
],
|
||||
"obsidianmd/validate-license": "error",
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
function obsidianRecommendedConfig(config) {
|
||||
const rules = Object.fromEntries(Object.entries(config.rules ?? {}).filter(([ruleName]) => ruleName.startsWith("obsidianmd/")));
|
||||
function obsidianSourceRecommendedConfig(config) {
|
||||
const rules = Object.fromEntries(
|
||||
Object.entries(config.rules ?? {})
|
||||
.filter(([ruleName]) => {
|
||||
return (
|
||||
ruleName.startsWith("obsidianmd/") && ruleName !== "obsidianmd/validate-manifest" && ruleName !== "obsidianmd/validate-license"
|
||||
);
|
||||
})
|
||||
.map(([ruleName, ruleConfig]) => {
|
||||
if (ruleName !== "obsidianmd/ui/sentence-case") return [ruleName, ruleConfig];
|
||||
return [
|
||||
ruleName,
|
||||
[
|
||||
"error",
|
||||
{
|
||||
enforceCamelCaseLower: true,
|
||||
acronyms: ["MCP"],
|
||||
brands: ["Codex", "Codex Panel", "Obsidian"],
|
||||
},
|
||||
],
|
||||
];
|
||||
}),
|
||||
);
|
||||
if (Object.keys(rules).length === 0) return null;
|
||||
const obsidianConfig = {
|
||||
basePath: "src",
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@
|
|||
"check": "concurrently --group --pad-prefix 'node:check:*' && node --run build",
|
||||
"check:biome": "biome check --diagnostic-level=warn --error-on-warnings",
|
||||
"check:css-usage": "node scripts/lint/check-css-usage.mjs",
|
||||
"check:eslint": "eslint src --max-warnings=0",
|
||||
"check:eslint": "eslint src manifest.json LICENSE --max-warnings=0",
|
||||
"check:test": "node --run test",
|
||||
"check:typecheck": "node --run typecheck",
|
||||
"check:unused": "knip --no-progress",
|
||||
"format": "biome format --write",
|
||||
"format": "biome check --write --linter-enabled=false",
|
||||
"generate:app-server-types": "node scripts/generate-app-server-types.mjs",
|
||||
"release:check": "node scripts/release/check.mjs",
|
||||
"release:preflight": "node scripts/release/preflight.mjs",
|
||||
|
|
|
|||
Loading…
Reference in a new issue