Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call Indentation Rule breaks on multiline generics #98

Closed
joshuacurtiss opened this issue Feb 9, 2024 · 3 comments
Closed

Call Indentation Rule breaks on multiline generics #98

joshuacurtiss opened this issue Feb 9, 2024 · 3 comments

Comments

@joshuacurtiss
Copy link
Contributor

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.

@joshuacurtiss
Copy link
Contributor Author

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

@pbredenberg
Copy link
Contributor

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

@joshuacurtiss joshuacurtiss changed the title Naming Convention Rule breaks on multiline generics Call Indentation Rule breaks on multiline generics Jun 9, 2024
@joshuacurtiss
Copy link
Contributor Author

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.

@joshuacurtiss joshuacurtiss closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants