silvermine/eslint-config-silvermine

Call Indentation Rule breaks on multiline generics

joshuacurtiss opened this issue · 3 comments

In the event that there is a generic defined with angle brackets that are multiline, an error is thrown, in the sense that the linting rule crashes:

TypeError: Cannot read properties of undefined (reading 'loc')
Rule: "@silvermine/silvermine/call-indentation"
    at validateCallIndentation (/path/to/proj/node_modules/@silvermine/eslint-plugin-silvermine/lib/rules/call-indentation.js:34:51)
    at CallExpression (/path/to/proj/node_modules/@silvermine/eslint-plugin-silvermine/lib/rules/call-indentation.js:140:13)
    ...

This may occur in Vue 3 with TypeScript when defining component properties, for example:

// Crashes the rule:
defineProps<{
   id: number,
   name: string,
}>();

However, if it is a single line, it will not crash:

// This works:
defineProps<{ id: number, name: string }>();

// So does this:
defineProps<MyType>();

For now, I've been working around it by always keeping generics to one line, creating a type/interface if necessary.

See silvermine/eslint-plugin-silvermine#63; I accidentally submitted the error here.

hey @joshuacurtiss so do I understand correctly that this issue is related to our ESLint plugin, and not to the naming convention rule?

Hi @pbredenberg sorry for the delay! Yes, it appears to be related to the call indentation rule, sorry I don't recall why I thought to use "Naming Convention" at the time. 🤦‍♂️ So, silvermine/eslint-plugin-silvermine#63 and this issue are both reporting the same bug. But I suggest marking this one as the dupe since it's the wrong repo.