ghmcadams / vscode-lintlens

Augment your ESLint rules in Visual Studio Code - Adds metadata beside each ESLint rule.
MIT License
42 stars 9 forks source link

[Bug] Destructuring gives false-positive "options[0] must be object" errors #73

Open kinland opened 1 year ago

kinland commented 1 year ago

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: image

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: image

ghmcadams commented 6 months ago

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.