vscode-lintlens
vscode-lintlens copied to clipboard
[Bug] Destructuring gives false-positive "options[0] must be object" errors
In my .eslintrc.js
, I have:
const namingConventionRules = [
{ selector: 'default', format: ['camelCase'] },
{ selector: 'variable', format: ['camelCase', 'UPPER_CASE'] },
{ selector: 'variable', types: ['boolean'], prefix: allowedBooleanPrefixes, format: ['UPPER_CASE', 'PascalCase'] },
{ selector: 'parameter', format: ['camelCase'], leadingUnderscore: 'allow' },
{ selector: 'enumMember', format: ['camelCase', 'UPPER_CASE'], leadingUnderscore: 'allow' },
{ selector: 'memberLike', modifiers: ['private'], format: ['camelCase'], leadingUnderscore: 'require' },
{ selector: 'typeLike', format: ['PascalCase'] },
{ selector: ['property', 'parameterProperty'], format: ['camelCase', 'snake_case', 'PascalCase'] },
{ selector: 'objectLiteralProperty', format: ['camelCase', 'snake_case', 'PascalCase', 'UPPER_CASE'] },
{ selector: ['classProperty', 'parameterProperty', 'typeProperty'], types: ['boolean'], prefix: allowedBooleanPrefixes, format: ['snake_case', 'PascalCase'] },
{ selector: 'function', format: ['camelCase'] },
];
This is then used in a rule like so: '@typescript-eslint/naming-convention': ['error', ...namingConventionRules],
This causes an options[0] must be object
error:
I thought, "maybe it's not realizing those are objects, so if I make it explicit, it'll work, so I tried this slight change to my code:
/** @type {object[]} */
const namingConventionRules = [
No dice:
Thank you @kinland. I have been busy on other projects for a while, so I can't remember the details of the module that parses the config... but This may have something to do with the spreading of the array. You can verify this by moving the contents of the array directly into the config options.