-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-plugin): add
key-spacing
rule extension for interface &…
… type declarations (#6211) * 🚧 key-spacing for interface on default settings * 🚧 Support type literals as welll * 🚧 Add full typing for the options * 🚧 Add 'mode' param * 🐛 Fix index signatures * ✨ Support classes * 🩹 fixes * ✅ Add tests on mode, multiLine, singleLine * 🏷️ Allow options.multiline.align to be an object * 🎨 Use ast utils to locate last character before token * ✨ Support comments in-between properties * ✅ Add test cases for nested type declarations & multiline type annotations * ✨ Autofix for non-aligned values * ✨ Autofix for aligned values * ✏️ * 🚨 * 🐛 Support optional ? token * ✅ Add tests with class property assignments * 📝 Add documentation on key-spacing * 🎨 Use .at() to access last element of array * ✅ Fix tests * fixup! ✅ Fix tests * ✅ Add some coverage * 🐛 Fix edge case in determining aligned groups In case there is three statements in one line, and one statement in the line after * ⚡️ Use Array.concat instead of .push(...) .push could error if 60k + arguments * 🎨 Improve readability * 🎨 Use tempate literals in tests * ✅ Add test with anonymous types * ✅ Add test with quoted keys * ➕ Add grapheme-splitter to deal with emojis * ✅ Add test case for multiline comments * 🚨 Remove 'in' statements, reduce amount of null-assertions * ✅ Add test case for properties without type annotation or assignments * ✅ Add wacky test cases * ✅ Add coverage * ✅ Add coverage, again * ✅ Add coverage, again * ✅ Add coverage when align is an object, but align.on is missing It defaults to 'colon' in this case * KeyTypeNodeWithTypeAnnotation * Extract to shared helper Co-authored-by: Josh Goldberg <[email protected]>
- Loading branch information
1 parent
09d57ce
commit 67706e7
Showing
11 changed files
with
1,789 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
description: 'Enforce consistent spacing between property names and type annotations in types and interfaces.' | ||
--- | ||
|
||
> 🛑 This file is source code, not the primary documentation location! 🛑 | ||
> | ||
> See **https://typescript-eslint.io/rules/key-spacing** for documentation. | ||
## Examples | ||
|
||
This rule extends the base [`eslint/keyword-spacing`](https://eslint.org/docs/rules/key-spacing) rule. | ||
This version adds support for type annotations on interfaces, classes and type literals properties. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.