Is there a way to configure VSCode to perform syntax checking on .eslintrc.js
and provide autocomplete functionality? I have managed to set up a structure for a JavaScript configuration file with a custom syntax for my application, but the same approach does not seem to work for Linter.BaseConfig
imported from 'eslint'.
/** @typedef {import("eslint").Linter.BaseConfig} BaseConfig */
/** @param {BaseConfig} c */ // does not work
function castBaseConfig(c) {return c}
module.exports = castBaseConfig({
env: {browser: false, es2019: true, node: true},
ignorePatterns: ["dist", "jsdoc", "out", "out2", "public"],
extends: "eslint:recommended",
parserOptions: {ecmaVersion: "latest"},
// etc
})
It is worth noting that
node_modules/@types/eslint/index.d.ts
contains export namespace Linter {interface BaseConfig {...}}
providing field definitions for env, parserOptions, plugins, rules (via HasRules
), and more, suggesting that it should work. However, no type-checking seems to be performed, and specific completions based on types do not work.
In contrast, in another file where I apply a similar technique, the type definition imported with
/** @typedef {import("../lib/config").MultiConfig} MultiConfig */
is correctly enforced. For example, it detects if port
is the wrong type, if a required property is missing, or if an unknown property is present, and it provides appropriate context-based suggestions.
Could the issue be related to discrepancies in the definitions, such as interface
versus type
?