|
| 1 | +// ESLint config for the VS Code extension, scoped to this package: the npm |
| 2 | +// package next door is plain CommonJS with its own conventions, so `root` stops |
| 3 | +// this from reaching it. |
| 4 | +// |
| 5 | +// The severities below are not a style opinion - each one is set to the level |
| 6 | +// at which the rule catches a real defect in THIS codebase, so that |
| 7 | +// `npm run lint` failing means something is actually wrong and is worth |
| 8 | +// blocking on. Rules that only fire on deliberate, already-idiomatic code are |
| 9 | +// turned off with the reason recorded rather than silenced case by case. |
| 10 | +{ |
| 11 | + "root": true, |
| 12 | + "parser": "@typescript-eslint/parser", |
| 13 | + "parserOptions": { |
| 14 | + "ecmaVersion": 2022, |
| 15 | + "sourceType": "module" |
| 16 | + }, |
| 17 | + "plugins": ["@typescript-eslint"], |
| 18 | + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], |
| 19 | + "env": { |
| 20 | + "node": true, |
| 21 | + "es2022": true |
| 22 | + }, |
| 23 | + "ignorePatterns": ["out", "dist", "node_modules", "media", "webview"], |
| 24 | + "rules": { |
| 25 | + // The `_`-prefix convention this source already follows: a parameter |
| 26 | + // named `_token` is one the VS Code API hands us and we deliberately do |
| 27 | + // not read, and renaming it would lose which API slot it fills. An |
| 28 | + // unprefixed unused binding is still an error, because that is the case |
| 29 | + // where something was meant to be used and was not. |
| 30 | + "@typescript-eslint/no-unused-vars": [ |
| 31 | + "error", |
| 32 | + { |
| 33 | + "argsIgnorePattern": "^_", |
| 34 | + "varsIgnorePattern": "^_", |
| 35 | + "caughtErrorsIgnorePattern": "^_" |
| 36 | + } |
| 37 | + ], |
| 38 | + // `vscode-languageclient` declares its request types as namespaces |
| 39 | + // (`namespace Foo { export const type = new RequestType(...) }`) and |
| 40 | + // src/views/graphPanel.ts follows that idiom for its own requests. The |
| 41 | + // rule is correct in general and wrong for the one pattern our |
| 42 | + // dependency prescribes. |
| 43 | + "@typescript-eslint/no-namespace": "off", |
| 44 | + // Warn, not error: `any` here is concentrated in the boundary code that |
| 45 | + // talks to the untyped language-server protocol payloads. Each site is |
| 46 | + // a real typing debt worth seeing, but none of them is a defect that |
| 47 | + // should stop a build, and typing them properly is a change to the |
| 48 | + // protocol surface rather than a lint fix. |
| 49 | + "@typescript-eslint/no-explicit-any": "warn" |
| 50 | + }, |
| 51 | + "overrides": [ |
| 52 | + { |
| 53 | + // Test doubles stand in for the `vscode` API, whose shape they must |
| 54 | + // match exactly - including the parameters a given test never |
| 55 | + // reads and the wide types the real API declares. Enforcing either |
| 56 | + // rule here would push the mocks away from the API they imitate. |
| 57 | + "files": ["**/*.test.ts"], |
| 58 | + "rules": { |
| 59 | + "@typescript-eslint/no-explicit-any": "off", |
| 60 | + "@typescript-eslint/no-unsafe-function-type": "off", |
| 61 | + "@typescript-eslint/no-unused-vars": [ |
| 62 | + "error", |
| 63 | + { "args": "none", "varsIgnorePattern": "^_" } |
| 64 | + ] |
| 65 | + } |
| 66 | + } |
| 67 | + ] |
| 68 | +} |
0 commit comments