Description
I want to first note that this issue is primarily for the eslint VSCode plugin, where there is one instance of eslint running for the whole monorepo. This issue does not appear for us on the command line since we lint every package/app individually.
The main issue is that the validation for file inclusion only considers the case of one configuration file. Since in our monorepo, we have multiple panda config files, the vscode eslint plugin will only ever recognize the first config file it sees. See below:
Once the first configPath is set, it will never set another configPath again.
This results in the following:
- the first file to be recognized by the eslint plugin as "open" will be properly validated against the
file-not-included
rule. Every file that belongs to the same panda project will also be properly validated. - every subsequent file that is not in the same panda project will be not be properly validated, as the linter will assume the configuration file is the one that was originally used in the first case
I propose the solution should be scoping the configPath
variable to the getContext
function, rather than having a global scope. This would allow multiple config files to exist, while also allowing the context cache to remain in use.
Example Change
// line 14
let configPath: string | undefined // delete this line
export async function getContext(opts: Opts) {
if (process.env.NODE_ENV === 'test') {
const configPath = opts.configPath // const declaration here
const ctx = createContext({ importMap: './panda' }) as unknown as PandaContext
ctx.getFiles = () => ['App.tsx']
return ctx
} else {
const configPath = findConfig({ cwd: opts.configPath ?? opts.currentFile }) // const declaration, no short circuiting
// cache still works below
// Ensure that the context is refreshed when the configPath changes.
if (!contextCache[configPath]) {
contextCache[configPath] = _getContext(configPath)
}
return await contextCache[configPath]
}
}